/* Kokosend component layer — plain CSS built from tokens.css variables.
   Used by the Payroll screens; existing Leave screens keep their Tailwind
   markup and only borrow the .tag/.btn primitives where a template opts in. */

*, *::before, *::after { box-sizing: border-box; }

.text-muted { color: color-mix(in srgb, var(--color-text) 62%, transparent); }
::selection { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }

/* `.blueprint` is a standard filled, rounded, softly-shadowed card. The name
   is kept because templates already reference it; the wireframe corner-mark
   treatment it used to draw is retired — the corner marks below stay in the
   DOM (harmless) but render as nothing. */
.blueprint {
  position: relative;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.blueprint > .corner { display: none; }

/* — buttons — */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none;
  font-family: var(--font-body); font-weight: 600;
  font-size: var(--text-sm); line-height: 1.2; color: var(--color-text);
  background: var(--color-surface); border: 1px solid var(--color-divider);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }
.btn-primary:hover { background: var(--color-accent-600); border-color: var(--color-accent-600); }
.btn-primary:active { background: var(--color-accent-700); }
.btn-secondary { background: var(--color-surface); border-color: var(--color-divider); }
.btn-secondary:hover { background: var(--color-neutral-100); }
.btn-ghost { background: transparent; color: var(--color-accent); border-color: transparent; padding-inline: var(--space-2); }
.btn-ghost:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.btn-danger { background: var(--k-danger); color: #fff; border-color: var(--k-danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--k-danger) 85%, #000); border-color: color-mix(in srgb, var(--k-danger) 85%, #000); }
.btn-block { width: 100%; margin-top: var(--space-2); }
.btn-sm { padding: 6px 12px; font-size: var(--text-xs); }

/* — link — */
.link { color: var(--color-accent); text-decoration: none; font-weight: 600; }
.link:hover { text-decoration: underline; }

/* — forms — */
.field > label {
  display: block; font-size: var(--text-xs); font-weight: 600; margin-bottom: 6px;
  color: color-mix(in srgb, var(--color-text) 75%, transparent);
}
.input {
  width: 100%; min-height: 42px; padding: 8px 12px; font: inherit;
  font-size: var(--text-sm); color: var(--color-text); caret-color: var(--color-accent);
  background: var(--color-bg);
  border: 1px solid var(--color-divider); border-radius: var(--radius-md);
}
.input:hover { border-color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.input:focus-visible { border-color: var(--color-accent); outline: 2px solid color-mix(in srgb, var(--color-accent) 35%, transparent); outline-offset: 0; }
textarea.input { min-height: 90px; resize: vertical; }
select.input { cursor: pointer; }
.checkbox { width: 16px; height: 16px; accent-color: var(--color-accent); cursor: pointer; }

.seg {
  display: inline-flex; overflow: hidden;
  border: 1px solid var(--color-divider); border-radius: var(--radius-md);
}
.seg-opt {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; font-size: var(--text-sm); font-weight: 600; cursor: pointer;
}
.seg-opt + .seg-opt { border-left: 1px solid var(--color-divider); }
.seg-opt:has(input:checked) { background: var(--color-accent); color: #fff; }
.seg-opt:not(:has(input:checked)):hover { background: var(--color-neutral-100); }

/* — cards — */
.card {
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-4); border-radius: var(--radius-lg);
  background: var(--color-surface-raised); border: 1px solid var(--color-divider);
  box-shadow: var(--shadow-sm);
}
.card-kicker { font-size: var(--text-xs); letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-accent); font-weight: 700; }
.card-title { font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: 19px; line-height: 1.25; }
.card-body { margin: 0; font-size: var(--text-sm); opacity: 0.85; flex: 1; }
.card-meta { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: color-mix(in srgb, var(--color-text) 58%, transparent); }
.elev-sm { box-shadow: var(--shadow-sm); }
.elev-md { box-shadow: var(--shadow-md); }
.elev-lg { box-shadow: var(--shadow-lg); }

/* — tags — */
.tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: var(--text-xs); font-weight: 600;
  letter-spacing: 0.02em; padding: 4px 11px; border-radius: 999px;
}
.tag-accent { background: var(--color-accent-100); color: var(--color-accent-800); }
.tag-neutral { background: var(--color-neutral-100); color: var(--color-neutral-800); }
.tag-outline { border: 1px solid var(--color-accent); color: var(--color-accent); }
.tag-warn { background: var(--k-warn-bg); color: var(--k-warn); }
.tag-danger { background: var(--k-danger-bg); color: var(--k-danger); }

/* Leave-type chips + legend dots — hue driven by --lt (set via .lt-* modifier). */
.lt-ann { --lt: var(--lt-annual); }
.lt-sck { --lt: var(--lt-sick); }
.lt-cmp { --lt: var(--lt-compassionate); }
.lt-mat { --lt: var(--lt-maternity); }
.lt-pat { --lt: var(--lt-paternity); }
.lt-other { --lt: var(--lt-other); }
.tag-lt {
  background: color-mix(in srgb, var(--lt, var(--lt-other)) 16%, transparent);
  color: var(--lt, var(--lt-other));
  border: 1px solid color-mix(in srgb, var(--lt, var(--lt-other)) 32%, transparent);
}
.lt-dot { width: 10px; height: 10px; border-radius: 999px; display: inline-block; background: var(--lt, var(--lt-other)); }

/* — callout: tinted note box — */
.callout {
  border: 1px solid var(--color-divider); border-left: 3px solid var(--color-neutral-400);
  border-radius: var(--radius-md); padding: var(--space-3) var(--space-4);
  background: var(--color-surface); font-size: var(--text-sm);
}
.callout-accent { border-left-color: var(--color-accent); background: var(--color-accent-50); }
.callout-warn { border-left-color: var(--k-warn); background: var(--k-warn-bg); }
.callout-danger { border-left-color: var(--k-danger); background: var(--k-danger-bg); }

/* — stat: big-number KPI tile (dashboards, reports) — */
.stat {
  display: flex; flex-direction: column; gap: var(--space-1);
  padding: var(--space-4) var(--space-6);
  background: var(--color-surface-raised); border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.stat-accent { border-left: 3px solid var(--color-accent); }
.stat-label {
  font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: color-mix(in srgb, var(--color-text) 60%, transparent);
}
.stat-value { font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: 30px; line-height: 1.1; }
.stat-value.is-accent { color: var(--color-accent-700); }
.stat-value.is-warn { color: var(--k-warn); }
.stat-value.is-danger { color: var(--k-danger); }
.stat-value.is-muted { color: color-mix(in srgb, var(--color-text) 55%, transparent); }

/* — tables — */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th {
  text-align: left; font-size: var(--text-xs); letter-spacing: 0.05em; text-transform: uppercase;
  font-weight: 700;
  color: color-mix(in srgb, var(--color-text) 65%, transparent);
  padding: 12px var(--space-3); border-bottom: 1px solid var(--color-divider);
}
.table td { padding: 12px var(--space-3); border-bottom: 1px solid var(--color-divider); }
.table tbody tr:hover { background: var(--color-surface); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* — tabs: underline nav for in-page sections — */
.tabbar { display: flex; gap: 2px; border-bottom: 1px solid var(--color-divider); overflow-x: auto; }
.tab {
  padding: 10px 16px; font-size: var(--text-sm); font-weight: 600; white-space: nowrap; cursor: pointer;
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  color: color-mix(in srgb, var(--color-text) 55%, transparent);
  font-family: var(--font-body);
}
.tab:hover { color: var(--color-text); }
.tab.is-active { color: var(--color-accent-700); border-bottom-color: var(--color-accent); }

/* — pilltabs: compact segmented toggle (chart views etc.) — */
.pilltabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--color-surface); border: 1px solid var(--color-divider); border-radius: var(--radius-md); }
.pilltab {
  padding: 6px 14px; font-size: var(--text-sm); font-weight: 600; cursor: pointer;
  border: 0; background: transparent; border-radius: calc(var(--radius-md) - 2px);
  color: color-mix(in srgb, var(--color-text) 55%, transparent); font-family: var(--font-body);
}
.pilltab:hover { color: var(--color-text); }
.pilltab.is-active { background: var(--color-surface-raised); color: var(--color-accent-700); box-shadow: var(--shadow-sm); }

/* — action tiles: minimalist cubes for dashboard shortcuts, standing in for
   a row of differently-colored full-width buttons — */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: var(--space-3); }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 28px 14px; text-align: center; text-decoration: none; color: var(--color-text);
  background: var(--color-surface-raised); border: 1px solid var(--color-divider); border-radius: var(--radius-lg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.tile:hover { border-color: var(--color-accent); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.tile-label { font-size: var(--text-sm); font-weight: 600; line-height: 1.3; }
.tile-sub { font-size: var(--text-2xs); color: color-mix(in srgb, var(--color-text) 55%, transparent); }

/* — nav (used inside the sidebar shell) — */
.nav-group-label {
  font-size: var(--text-xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: color-mix(in srgb, var(--color-text) 50%, transparent);
}
.nav-link {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  border: 0; cursor: pointer; font-family: var(--font-body); font-size: var(--text-sm);
  padding: 9px 10px; border-radius: var(--radius-sm); border-left: 2px solid transparent; background: transparent;
  color: var(--color-text); text-decoration: none;
}
.nav-link:hover { background: var(--color-surface); }
.nav-link.active {
  border-left-color: var(--color-accent);
  background: var(--color-accent-100);
  color: var(--color-accent-700);
  font-weight: 600;
}
.nav-badge { font-size: var(--text-2xs); font-weight: 700; padding: 1px 7px; border-radius: 999px; background: color-mix(in srgb, var(--color-text) 10%, transparent); color: color-mix(in srgb, var(--color-text) 70%, transparent); }
/* Separates the links that administer a module from the viewer's own ones. */
.nav-divider { height: 1px; margin: 6px 10px; background: var(--color-divider); }

/* — collapsible nav categories — */
.nav-group-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; border: 0; background: transparent; cursor: pointer;
  padding: 8px 10px; border-radius: var(--radius-sm); text-align: left;
}
.nav-group-toggle:hover { background: var(--color-surface); }
.nav-group-toggle:hover .nav-group-label { color: var(--color-text); }
.nav-chevron {
  width: 14px; height: 14px; flex-shrink: 0;
  color: color-mix(in srgb, var(--color-text) 40%, transparent);
  transition: transform 0.18s ease;
}
.nav-group.open > .nav-group-toggle .nav-chevron { transform: rotate(90deg); }

.nav-group-items {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows 0.2s ease;
}
.nav-group.open .nav-group-items { grid-template-rows: 1fr; }
.nav-group-items-inner {
  overflow: hidden; min-height: 0;
  display: flex; flex-direction: column; gap: 2px;
  margin: 2px 0 4px 20px; padding-left: 10px;
  border-left: 1px solid var(--color-divider);
}

/* — sidebar shell: header/footer pinned, only the menu scrolls behind them — */
.sidebar-scroll {
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--color-divider) transparent;
}
.sidebar-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--color-divider); border-radius: 999px; }

/* — dark mode toggle — */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: 1px solid var(--color-divider); background: transparent; cursor: pointer;
  color: var(--color-text);
}
.theme-toggle:hover { background: var(--color-surface); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
}

/* — dialog — */
.dialog-backdrop {
  position: fixed; inset: 0; display: grid; place-items: center;
  padding: var(--space-4); background: color-mix(in srgb, var(--color-neutral-900) 55%, transparent);
}
/* A native <dialog> is display:none until opened via .showModal(); only lay
   out its contents once the browser marks it [open], or it renders inline
   on the page instead of as a modal. */
dialog.dialog { width: min(440px, 100%); flex-direction: column; gap: var(--space-3); padding: var(--space-6); border-radius: var(--radius-lg); background: var(--color-surface-raised); box-shadow: var(--shadow-lg); border: none; }
dialog.dialog[open] { display: flex; }
dialog.dialog::backdrop { background: color-mix(in srgb, var(--color-neutral-900) 55%, transparent); }
.dialog-title { font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: 22px; }
.dialog-body { font-size: var(--text-sm); opacity: 0.9; }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-2); }
