/*
  Task Manager theme system.
  Two explicit themes: data-theme="light" (default) and data-theme="dark".
  No prefers-color-scheme auto-switching — user controls it via toggle.
  All color combinations hit WCAG AA minimum (4.5:1) for body text.
*/
:root, :root[data-theme="light"] {
  /* Surfaces — subtle blue-tinted whites for a calm look */
  --bg:        #f5f8fd;   /* page background */
  --surface:   #ffffff;   /* cards */
  --surface-2: #eaf0f8;   /* buttons, chips */
  --surface-3: #dde5f0;   /* hover surfaces */
  --line:      #b8c3d4;   /* borders — deliberately visible */
  --line-soft: #d3dbe8;   /* subtle dividers */

  /* Text hierarchy — all pass WCAG AA against --bg (contrast in comment) */
  --ink:   #0b1530;  /* 17.5:1 — primary text, headings */
  --ink-2: #1d2a4b;  /* 12.3:1 — strong secondary */
  --ink-3: #394773;  /*  7.4:1 — labels, meta */
  --ink-4: #5a6a92;  /*  4.6:1 — hints, disabled */

  /* Accent — deep blue so white text passes on buttons */
  --accent:       #1e40af;   /* 8.6:1 — white on this passes AAA */
  --accent-ink:   #1e3a8a;   /* on accent-soft: strong contrast */
  --accent-soft:  #dbeafe;   /* soft chip backgrounds */

  /* Semantic — white text on saturated, dark text on soft */
  --sage:       #15803d;   /* success button bg — white passes 5.1:1 */
  --sage-ink:   #166534;
  --sage-soft:  #dcfce7;
  --rose:       #b91c1c;   /* danger — white passes 6.1:1 */
  --rose-ink:   #991b1b;
  --rose-soft:  #fee2e2;
  --amber:      #b45309;   /* warning — white passes 5.4:1 */
  --amber-ink:  #92400e;
  --amber-soft: #fef3c7;
  --slate:      #475569;
  --slate-soft: #e2e8f0;
  --purple:     #6b21a8;
  --purple-soft:#f3e8ff;

  --r-sm: 6px; --r: 8px; --r-lg: 8px;
  --shadow-sm: 0 1px 2px rgba(11,21,48,.05);
  --shadow:    0 1px 2px rgba(11,21,48,.05), 0 4px 12px rgba(11,21,48,.06);
  --shadow-lg: 0 2px 4px rgba(11,21,48,.06), 0 20px 40px rgba(11,21,48,.08);
  --display: "Instrument Serif", Georgia, serif;
  --ui: "Fira Sans", -apple-system, system-ui, sans-serif;
  --mono: "Fira Code", ui-monospace, Menlo, monospace;
  --motion-instant: 90ms;
  --motion-fast: 150ms;
  --motion-ui: 220ms;
  --motion-page: 420ms;
  --motion-route: 520ms;
  --ease-standard: cubic-bezier(.2,.8,.2,1);
  --ease-spring: cubic-bezier(.16,1,.3,1);
  --ease-emphasized: cubic-bezier(.22,1,.36,1);
  --ease-exit: cubic-bezier(.4,0,1,1);
  --shadow-float: 0 2px 3px rgba(11,21,48,.06), 0 14px 28px rgba(11,21,48,.10);

  /* Legacy aliases — keep existing templates rendering */
  --primary: var(--accent);
  --primary-light: var(--accent);
  --primary-dark: var(--accent-ink);
  --success: var(--sage);
  --danger: var(--rose);
  --warning: var(--amber);
  --card: var(--surface);
  --text: var(--ink);
  --text-light: var(--ink-3);
  --border: var(--line-soft);
  --radius: var(--r-lg);
  --nav-hover: var(--surface-2);
  --nav-dropdown: var(--surface-3);
}

:root[data-theme="dark"] {
  --bg:        #0b1220;
  --surface:   #121b2e;
  --surface-2: #1c2740;
  --surface-3: #263355;
  --line:      #3e4a6c;
  --line-soft: #2a3558;

  --ink:   #f1f5fa;  /* 17.1:1 on --bg */
  --ink-2: #d1d8e8;  /* 12.8:1 */
  --ink-3: #9aa6c2;  /*  6.6:1 — labels in dark */
  --ink-4: #6e7d9e;  /*  3.8:1 — hints (AA-large only) */

  --accent:       #60a5fa;
  --accent-ink:   #93c5fd;
  --accent-soft:  #1e3a8a;

  --sage:       #4ade80;
  --sage-ink:   #86efac;
  --sage-soft:  #14532d;
  --rose:       #f87171;
  --rose-ink:   #fca5a5;
  --rose-soft:  #7f1d1d;
  --amber:      #fbbf24;
  --amber-ink:  #fde68a;
  --amber-soft: #78350f;
  --slate:      #94a3b8;
  --slate-soft: #334155;
  --purple:     #c084fc;
  --purple-soft:#581c87;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow:    0 1px 2px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.4);
  --shadow-lg: 0 2px 4px rgba(0,0,0,.4), 0 20px 40px rgba(0,0,0,.6);
  --shadow-float: 0 2px 4px rgba(0,0,0,.42), 0 18px 34px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); overflow-x: hidden; }
body {
  font-family: var(--ui); color: var(--ink);
  font-size: 14px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility; position: relative;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(color-mix(in srgb, var(--accent) 5%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--accent) 5%, transparent) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.7), transparent 72%);
  opacity: .56;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.skip-link {
  position: fixed; top: 10px; left: 12px; z-index: 1000;
  padding: 9px 12px; border-radius: var(--r); background: var(--ink); color: var(--bg);
  font-size: 13px; font-weight: 700; transform: translateY(-160%);
  transition: transform .16s ease-out; box-shadow: var(--shadow);
}
.skip-link:focus { transform: translateY(0); }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 8px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
  ::view-transition-old(root),
  ::view-transition-new(root) { animation-duration: .01ms !important; }
  body::before { display: none; }
}

/* ── App shell ─────────────────────────────────────── */
.app {
  display: grid; grid-template-columns: 240px 1fr; min-height: 100vh;
  max-width: 1640px; width: 100%; min-width: 0; margin: 0 auto;
  position: relative; z-index: 1;
}
.app.no-nav { grid-template-columns: 1fr; }
.app.no-nav .main { max-width: 100%; padding: 40px 20px; }
.side {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 72%, var(--bg)), var(--bg));
  border-right: 1px solid var(--line-soft);
  padding: 22px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; overflow-y: auto;
  box-shadow: inset -1px 0 rgba(255,255,255,.42);
  backdrop-filter: blur(18px) saturate(120%);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; text-decoration: none; color: inherit; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; background: var(--ink); color: var(--bg);
  display: grid; place-items: center; font-family: var(--display); font-size: 20px; line-height: 1;
  flex-shrink: 0; overflow: hidden; position: relative;
  transition: transform var(--motion-ui) var(--ease-spring), box-shadow var(--motion-ui) ease;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 1px; border: 1px solid rgba(255,255,255,.2);
  border-radius: 7px; pointer-events: none;
}
.brand:hover .brand-mark { transform: translateY(-1px) rotate(-2deg); box-shadow: var(--shadow); }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.brand-name { font-family: var(--display); font-size: 20px; letter-spacing: 0; color: var(--ink); }
.brand-sub { font-size: 10.5px; color: var(--ink-3); margin-top: -2px; font-weight: 500; }

.side-section { margin-top: 18px; }
.side-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0; color: var(--ink-3); padding: 0 10px 6px; font-weight: 700; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  font-size: 13.5px; color: var(--ink); font-weight: 500; cursor: pointer;
  transition:
    background var(--motion-fast) ease,
    color var(--motion-fast) ease,
    transform var(--motion-ui) var(--ease-spring);
  margin-bottom: 1px; text-decoration: none; position: relative; isolation: isolate;
}
.nav-item::before {
  content: ""; position: absolute; left: 3px; top: 9px; bottom: 9px; width: 2px;
  border-radius: 999px; background: var(--accent); opacity: 0;
  transform: scaleY(.25); transition: opacity var(--motion-fast) ease, transform var(--motion-ui) var(--ease-spring);
}
.nav-item:hover { background: var(--surface-2); transform: translateX(2px); }
.nav-item.active { background: var(--ink); color: var(--bg); }
.nav-item.active::before { opacity: 1; transform: scaleY(1); background: var(--bg); }
.nav-icon {
  width: 16px; height: 16px; flex-shrink: 0; opacity: .75;
  transition: opacity var(--motion-fast) ease, transform var(--motion-ui) var(--ease-spring);
}
.nav-item:hover .nav-icon { opacity: 1; transform: scale(1.08); }
.nav-item.active .nav-icon { opacity: 1; }
.nav-count { margin-left: auto; font-size: 11px; color: var(--ink-2); background: var(--surface-2); padding: 1px 7px; border-radius: 10px; font-variant-numeric: tabular-nums; font-weight: 600; }
.nav-item.active .nav-count { background: rgba(255,255,255,.18); color: var(--bg); }
.side-footer {
  margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 12px; flex-shrink: 0; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.side-user-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.side-user-role { font-size: 11px; color: var(--ink-3); text-transform: capitalize; font-weight: 500; }

/* Theme toggle button in sidebar */
.theme-toggle {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--surface-2); color: var(--ink-2);
  display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--line-soft);
  transition: background var(--motion-fast) ease, color var(--motion-fast) ease, transform var(--motion-ui) var(--ease-spring);
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--surface-3); color: var(--ink); transform: rotate(8deg) scale(1.04); }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.main {
  padding: 32px 48px 80px; max-width: 1320px; width: 100%; min-width: 0;
  position: relative;
}
.container { max-width: none; padding: 0; margin: 0; }

/* ── Typography ────────────────────────────────────── */
h1 {
  font-family: var(--display); font-size: 40px; line-height: 1.06;
  letter-spacing: 0; margin: 0 0 16px; font-weight: 400; color: var(--ink);
}
h1 em { font-style: italic; color: var(--accent); font-weight: 400; }
h2 { font-family: var(--ui); font-size: 15px; margin: 0 0 12px; color: var(--ink); font-weight: 600; }
h3 { font-family: var(--ui); font-size: 13px; margin: 0 0 8px; color: var(--ink); font-weight: 600; }
.page-head { margin-bottom: 28px; }
.page-eyebrow { font-size: 12px; color: var(--ink-3); letter-spacing: 0; font-weight: 500; }
.page-title { font-family: var(--display); font-size: 44px; line-height: 1.05; letter-spacing: 0; margin: 2px 0 4px; font-weight: 400; color: var(--ink); }
.page-sub { color: var(--ink-3); font-size: 14px; }

/* ── Cards ─────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r); padding: 20px; margin-bottom: 18px;
  box-shadow: var(--shadow-sm); overflow-x: auto;
  transition:
    border-color var(--motion-ui) ease,
    box-shadow var(--motion-ui) ease,
    transform var(--motion-ui) var(--ease-spring);
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.card-meta { font-size: 12px; color: var(--ink-3); }
.card > h2:first-child,
.card-head h2 { margin-bottom: 10px; }

/* ── Buttons ───────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 7px 14px; border-radius: var(--r); font-size: 13px; font-weight: 700;
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--line);
  transition:
    background var(--motion-fast) ease,
    border-color var(--motion-fast) ease,
    color var(--motion-fast) ease,
    transform var(--motion-ui) var(--ease-spring),
    box-shadow var(--motion-ui) ease,
    opacity var(--motion-fast) ease;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-3); box-shadow: var(--shadow-sm); }
.btn:active:not(:disabled) { transform: scale(.98); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { transform: translateY(-1px); }
}
.btn:disabled, button:disabled {
  opacity: .58;
  cursor: wait;
  transform: none;
}
.btn.is-submitting {
  cursor: wait; width: var(--submit-width, auto); min-width: var(--submit-width, auto);
  max-width: var(--submit-width, none); justify-content: center; font-size: 0; overflow: hidden;
}
.btn.is-submitting > * { opacity: 0; }
.btn.is-submitting::after {
  content: ""; width: 12px; height: 12px; flex: 0 0 12px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: busy-spin .65s linear infinite;
}
.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-primary:hover { opacity: .9; }
.btn-accent, .btn-purple { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover, .btn-purple:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-success { background: var(--sage); color: #fff; border-color: var(--sage); }
.btn-success:hover { opacity: .9; }
.btn-danger { background: var(--rose); color: #fff; border-color: var(--rose); }
.btn-danger:hover { opacity: .9; }
.btn-ghost, .btn-outline { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover, .btn-outline:hover { background: var(--surface-2); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 12px; }
.btn-icon { width: 32px; height: 32px; padding: 0; justify-content: center; border-radius: 8px; }

/* ── Forms ─────────────────────────────────────────── */
input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="time"], input[type="email"], input[type="url"], input[type="tel"],
input[type="search"], input[type="file"], textarea, select,
.input, .select {
  min-height: 38px; padding: 8px 12px; border-radius: var(--r); background: var(--surface);
  border: 1px solid var(--line); color: var(--ink);
  font-size: 13.5px; outline: none; transition: border-color .15s, box-shadow .15s;
  width: 100%; font-family: inherit;
}
input:focus, textarea:focus, select:focus, .input:focus, .select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--ink-4); opacity: 1; }
input:disabled, textarea:disabled, select:disabled {
  background: var(--surface-2); color: var(--ink-3); cursor: not-allowed; opacity: .72;
}
input[type="color"] { padding: 2px; height: 38px; }
input[type="file"] { padding: 6px 12px; }
textarea { resize: vertical; min-height: 60px; line-height: 1.5; }
.label, .form-group label {
  font-size: 12px; color: var(--ink-2); font-weight: 600;
  margin-bottom: 5px; display: block;
}
.form-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-group { display: flex; flex-direction: column; margin-bottom: 12px; }
.form-group.grow { flex: 1; min-width: 150px; }
.form-group > label { margin-bottom: 5px; }
.inline-form { display: inline; }
.help-text, .field-hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.required::after { content: " *"; color: var(--rose); }

/* ── Tables ────────────────────────────────────────── */
table, .table {
  width: 100%; min-width: 720px; border-collapse: separate; border-spacing: 0; font-size: 13.5px;
}
th { text-align: left; font-weight: 700; font-size: 11px; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: 0; padding: 10px 12px;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
td { padding: 13px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; font-size: 13.5px; color: var(--ink); }
tbody tr { transition: background .15s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr td:first-child { box-shadow: inset 2px 0 transparent; transition: box-shadow var(--motion-fast) ease; }
tbody tr:hover td:first-child { box-shadow: inset 2px 0 var(--accent); }
tbody tr:last-child td { border-bottom: 0; }

/* ── Badges / pills ────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line-soft);
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); }
.badge.accent { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.badge.sage, .badge-done, .badge-paid, .badge-active, .badge-success {
  background: var(--sage-soft); color: var(--sage-ink); border-color: transparent;
}
.badge.amber, .badge-pending, .badge-warning {
  background: var(--amber-soft); color: var(--amber-ink); border-color: transparent;
}
.badge.rose, .badge-deleted, .badge-overdue, .badge-danger {
  background: var(--rose-soft); color: var(--rose-ink); border-color: transparent;
}
.badge.slate, .badge-draft, .badge-completed, .badge-on-hold {
  background: var(--slate-soft); color: var(--slate); border-color: transparent;
}
.badge-recurring, .badge-sent { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.badge-oneoff, .badge-subadmin { background: var(--purple-soft); color: var(--purple); border-color: transparent; }
.badge-sales { background: var(--sage-soft); color: var(--sage-ink); border-color: transparent; }
.badge-admin { background: var(--amber-soft); color: var(--amber-ink); border-color: transparent; }
.badge-superadmin { background: var(--purple-soft); color: var(--purple); border-color: transparent; }

/* ── Stats ─────────────────────────────────────────── */
.stat, .stat-card {
  padding: 16px 18px; border: 1px solid var(--line-soft);
  border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
  transition:
    border-color var(--motion-ui) ease,
    box-shadow var(--motion-ui) ease,
    transform var(--motion-ui) var(--ease-spring);
}
.stats-grid .stat-card::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 2px;
  background: var(--stat-accent, var(--accent)); opacity: .76;
  transform: scaleX(.22); transform-origin: left;
  transition: transform var(--motion-page) var(--ease-emphasized), opacity var(--motion-fast) ease;
}
.stats-grid .stat-card:nth-child(2) { --stat-accent: var(--sage); }
.stats-grid .stat-card:nth-child(3) { --stat-accent: var(--amber); }
.stats-grid .stat-card:nth-child(4) { --stat-accent: var(--purple); }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0; color: var(--ink-2); font-weight: 700; }
.stat-value {
  font-family: var(--display); font-size: 40px; line-height: 1; margin-top: 8px;
  letter-spacing: 0; font-weight: 400; color: var(--ink);
}
.stat-sub { font-size: 12px; color: var(--ink-3); margin-top: 6px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }

/* ── Task items ────────────────────────────────────── */
.task-item, .task-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 6px; border-bottom: 1px solid var(--line-soft);
  transition: background .12s, border-color .12s;
}
.task-item:hover, .task-row:hover { background: var(--surface-2); border-radius: var(--r-sm); }
.task-item:last-child, .task-row:last-child { border-bottom: 0; }
.task-item.done, .task-row.done { opacity: .65; }
.task-item.done .task-title { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--ink-4); }
.task-title { font-weight: 600; font-size: 14px; color: var(--ink); }
.task-content { flex: 1; min-width: 0; }
.task-desc {
  font-size: 13px; color: var(--ink-2); margin-top: 4px; line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.task-comment-list { margin-top: 6px; font-size: 12px; }
.task-comment-entry {
  padding: 4px 0; border-top: 1px solid var(--line-soft);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.task-comment-meta { color: var(--ink-3); }
.task-comment-form {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  align-items: end; gap: 6px; margin-top: 8px;
}
.task-comment-form input[type="text"] {
  min-width: 0; padding: 6px 9px; font-size: 12px;
}
.task-comment-form .btn { min-height: 38px; }
.task-projects { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.check, .check-circle {
  width: 24px; height: 24px; border-radius: 50%;
  border: 1.5px solid var(--ink-4); flex-shrink: 0; margin-top: 1px;
  display: grid; place-items: center; cursor: pointer;
  transition:
    background var(--motion-fast) ease,
    border-color var(--motion-fast) ease,
    color var(--motion-fast) ease,
    transform var(--motion-ui) var(--ease-spring),
    box-shadow var(--motion-ui) ease;
  background: transparent; color: transparent;
}
.check:hover, .check-circle:hover { border-color: var(--ink-2); transform: scale(1.08); }
.check.done, .check-circle.checked {
  background: var(--sage); border-color: var(--sage); color: #fff;
  animation: check-set var(--motion-page) var(--ease-spring) both;
}

/* ── Grid ──────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }

/* ── Tabs ──────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.tab { padding: 10px 14px; font-size: 13px; color: var(--ink-3); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; font-weight: 500; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }

/* ── Calendar ──────────────────────────────────────── */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-header { text-align: center; font-weight: 700; font-size: 11px; padding: 10px 4px; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0; }
.cal-day {
  min-height: 92px; padding: 8px 10px;
  border: 1px solid var(--line-soft); border-radius: var(--r-sm);
  font-size: 12px; background: var(--surface); cursor: pointer;
  transition: border-color .15s;
}
.cal-day:hover { border-color: var(--ink-4); }
.cal-day.today { border-color: var(--accent); border-width: 2px; }
.cal-day.empty { background: transparent; border-color: transparent; cursor: default; }
.cal-day .day-num { font-weight: 700; font-size: 13px; margin-bottom: 4px; color: var(--ink); }
.cal-day .day-info { color: var(--ink-3); font-size: 11px; }
.cal-day .day-bar { height: 4px; border-radius: 2px; background: var(--sage); margin-top: 4px; }

/* ── Layout helpers ────────────────────────────────── */
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 14px; }
.main > .flex-between:first-child {
  padding: 20px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  background:
    linear-gradient(135deg, rgba(37,99,235,.08), rgba(249,115,22,.06) 46%, transparent 72%),
    var(--surface);
  margin-bottom: 18px !important;
  box-shadow: var(--shadow-sm);
}
.main > .flex-between:first-child h1 { margin-bottom: 6px; }
.main > .flex-between:first-child > div:last-child {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.action-row, .table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.muted { color: var(--ink-3); }
.soft-divider { border-top: 1px solid var(--line-soft); margin: 16px 0; }

/* ── Modal ─────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(11,21,48,.55); z-index: 500;
  align-items: center; justify-content: center;
  padding: 16px; overscroll-behavior: contain;
}
.modal-overlay.active { display: flex; animation: modal-overlay-in var(--motion-fast) ease-out both; }
.modal {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r-lg); padding: 24px;
  width: min(100%, 500px); max-height: calc(100dvh - 32px); overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: var(--shadow-lg); color: var(--ink);
}
.modal-overlay.active .modal { animation: modal-panel-in var(--motion-ui) var(--ease-spring) both; }
body.modal-open { overflow: hidden; }
@keyframes modal-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modal-panel-in {
  from { opacity: 0; transform: translateY(12px) scale(.975); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal h3 { font-family: var(--display); font-size: 22px; font-weight: 400; margin-bottom: 16px; color: var(--ink); }
.modal .form-group { margin-bottom: 14px; }
.modal .btn-row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── Flash messages ────────────────────────────────── */
.flash {
  padding: 12px 16px; border-radius: var(--r); margin-bottom: 16px; font-size: 13.5px;
  border: 1px solid var(--line-soft); background: var(--surface);
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.flash::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent); }
.flash-error::before { background: var(--rose); }
.flash-success::before { background: var(--sage); }
.flash-warning::before { background: var(--amber); }
.flash-error { background: var(--rose-soft); color: var(--rose-ink); border-color: transparent; font-weight: 500; }
.flash-success { background: var(--sage-soft); color: var(--sage-ink); border-color: transparent; font-weight: 500; }
.flash-warning { background: var(--amber-soft); color: var(--amber-ink); border-color: transparent; font-weight: 500; }

/* ── Empty / misc ──────────────────────────────────── */
.empty { padding: 48px 24px; text-align: center; color: var(--ink-3); font-size: 13.5px; }
.empty-title { color: var(--ink); font-family: var(--display); font-size: 22px; margin-bottom: 4px; font-weight: 400; }
.empty, .empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--r);
  background: color-mix(in srgb, var(--surface) 76%, var(--surface-2));
}
.employee-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border: 1px solid var(--line-soft); border-radius: var(--r);
  transition: all .15s; text-decoration: none; color: var(--ink); background: var(--surface);
}
.employee-card:hover { border-color: var(--ink-4); box-shadow: var(--shadow-sm); }
.celebration-card {
  background: linear-gradient(135deg, var(--amber-soft), rgba(255,255,255,.55));
  border-color: color-mix(in srgb, var(--amber) 36%, var(--line-soft));
}
.celebration-content {
  display: grid;
  justify-items: center;
  gap: 6px;
  text-align: center;
  padding: 10px;
}
.celebration-content h2 { margin: 4px 0 0; }
.celebration-content p { margin: 0; color: var(--ink-2); }
.celebration-mark {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--amber-ink);
  border: 1px solid var(--line-soft);
  font-size: 12px;
  font-weight: 800;
}
code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); padding: 1px 6px; border-radius: 4px; color: var(--ink); }
hr { border: none; border-top: 1px solid var(--line-soft); margin: 20px 0; }
details {
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  background: var(--surface);
}
details > summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 800;
}
details[open] > summary { border-bottom: 1px solid var(--line-soft); }
details > summary::marker { color: var(--ink-3); }

/* ── Sales leads workflow ──────────────────────────── */
.leads-workspace {
  --lead-blue: #2563eb;
  --lead-orange: #f97316;
  --lead-cyan: #0891b2;
  --lead-green: #15803d;
  --lead-violet: #7c3aed;
  --lead-red: #b91c1c;
}
.lead-hero,
.lead-detail-hero,
.lead-toolbar,
.lead-create-panel,
.lead-pipeline-card,
.lead-panel,
.lead-stage-rail {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
}
.lead-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, .9fr);
  gap: 18px;
  padding: 24px;
  margin-bottom: 16px;
  background:
    linear-gradient(135deg, rgba(37,99,235,.10), rgba(249,115,22,.08) 48%, transparent 76%),
    var(--surface);
}
.lead-hero h1,
.lead-detail-title-row h1 { margin-bottom: 8px; }
.lead-hero-copy { min-width: 0; }
.lead-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.lead-alert-pill {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(255,255,255,.54);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  transition: border-color .15s, transform .15s, background .15s;
}
.lead-alert-pill.active {
  border-color: var(--lead-orange);
  background: var(--amber-soft);
  color: var(--amber-ink);
}
@media (hover: hover) and (pointer: fine) {
  .lead-alert-pill:hover {
    border-color: var(--lead-orange);
    background: var(--amber-soft);
    color: var(--amber-ink);
    transform: translateY(-1px);
  }
  .lead-alert-pill.muted:hover { border-color: var(--line); background: var(--surface-2); color: var(--ink); }
}
.lead-alert-count {
  min-width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 12px;
}
.lead-metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.lead-metric {
  min-height: 112px;
  padding: 15px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  background: rgba(255,255,255,.62);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.lead-metric-label,
.lead-summary-meta,
.lead-muted,
.lead-contact-line,
.lead-metric-sub,
.lead-followup-meta,
.lead-history-meta {
  color: var(--ink-3);
}
.lead-metric-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 800;
}
.lead-metric strong {
  font-family: var(--mono);
  font-size: 26px;
  line-height: 1.05;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.lead-metric-sub { font-size: 12px; }
.stage-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.stage-chip {
  position: relative;
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  background: var(--surface);
  overflow: hidden;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.stage-chip::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: var(--slate);
}
.stage-chip.active {
  border-color: var(--ink-4);
  box-shadow: var(--shadow-sm);
}
@media (hover: hover) and (pointer: fine) {
  .stage-chip:hover {
    transform: translateY(-1px);
    border-color: var(--ink-4);
    box-shadow: var(--shadow-sm);
  }
}
.stage-chip[data-stage="enquiry"]::before { background: var(--lead-orange); }
.stage-chip[data-stage="discussion"]::before { background: var(--lead-blue); }
.stage-chip[data-stage="confirmation"]::before { background: var(--lead-green); }
.stage-chip[data-stage="on_hold"]::before { background: var(--slate); }
.stage-chip[data-stage="converted"]::before { background: var(--lead-violet); }
.stage-chip.active { background: var(--surface-2); }
.stage-chip-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink);
  font-weight: 800;
}
.stage-chip-top strong {
  font-family: var(--mono);
  font-size: 18px;
}
.stage-chip-sub {
  display: block;
  margin-top: 10px;
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 12px;
}
.lead-toolbar,
.lead-create-panel,
.lead-pipeline-card,
.lead-panel { margin-bottom: 16px; }
.lead-toolbar { padding: 16px; }
.lead-filter-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) minmax(140px, .8fr) minmax(140px, .8fr) minmax(140px, .8fr) auto;
  gap: 10px;
  align-items: end;
}
.lead-filter-grid .form-group { margin-bottom: 0; }
.lead-filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.lead-create-panel {
  overflow: hidden;
}
.lead-create-panel summary {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
}
.lead-create-panel summary::-webkit-details-marker { display: none; }
.lead-create-panel[open] summary { border-bottom: 1px solid var(--line-soft); }
.lead-summary-title {
  display: block;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
}
.lead-summary-meta {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 500;
}
.lead-create-form,
.lead-edit-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}
.lead-form-section {
  padding-top: 2px;
  border-top: 1px solid var(--line-soft);
}
.lead-form-section:first-of-type { border-top: 0; }
.lead-followup-section .form-row { align-items: end; }
.lead-submit { min-height: 38px; }
.lead-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.lead-section-head h2,
.lead-panel h2 { margin-bottom: 2px; text-transform: none; letter-spacing: 0; }
.lead-pipeline-card,
.lead-panel { padding: 18px; }
.lead-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
}
.lead-table th { position: sticky; top: 0; z-index: 1; }
.lead-main-cell { min-width: 320px; }
.lead-title-link {
  display: inline-block;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}
.lead-title-link:hover { color: var(--accent); }
.lead-contact-line {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 3px;
  font-size: 12px;
}
.lead-contact-line span + span::before {
  content: "";
  width: 4px;
  height: 4px;
  display: inline-block;
  margin: 0 8px 2px 0;
  border-radius: 50%;
  background: var(--line);
}
.lead-requirement {
  display: block;
  margin-top: 6px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.45;
}
.lead-due-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line-soft);
  white-space: nowrap;
}
.lead-due-pill.overdue { background: var(--rose-soft); color: var(--rose-ink); border-color: transparent; }
.lead-due-pill.today { background: var(--amber-soft); color: var(--amber-ink); border-color: transparent; }
.lead-due-pill.scheduled { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.lead-value {
  font-family: var(--mono);
  font-weight: 700;
  white-space: nowrap;
}
.lead-action-cell { text-align: right; }
.lead-card-list {
  display: none;
  gap: 10px;
}
.lead-mobile-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  background: var(--surface);
}
.lead-mobile-top,
.lead-mobile-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.lead-empty { border: 1px dashed var(--line); border-radius: var(--r-sm); }

.lead-detail-hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 22px;
  margin-bottom: 14px;
  background:
    linear-gradient(135deg, rgba(8,145,178,.11), rgba(21,128,61,.08) 48%, transparent 76%),
    var(--surface);
}
.lead-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}
.lead-back-link:hover { color: var(--ink); }
.lead-detail-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.lead-contact-pills,
.lead-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.lead-contact-pills span,
.lead-contact-pills a {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(255,255,255,.48);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 700;
}
.lead-detail-actions { align-items: flex-start; justify-content: flex-end; }
.lead-stage-rail {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  margin-bottom: 16px;
  overflow: hidden;
}
.lead-stage-step {
  position: relative;
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  color: var(--ink-3);
  font-weight: 800;
  border-right: 1px solid var(--line-soft);
}
.lead-stage-step:last-child { border-right: 0; }
.lead-stage-step::after {
  content: "";
  position: absolute;
  left: 28px;
  right: -1px;
  bottom: 12px;
  height: 2px;
  background: var(--line-soft);
}
.lead-stage-step:last-child::after { display: none; }
.lead-stage-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--surface);
  z-index: 1;
}
.lead-stage-step.done,
.lead-stage-step.active { color: var(--ink); }
.lead-stage-step.done .lead-stage-dot {
  background: var(--sage);
  border-color: var(--sage);
}
.lead-stage-step.active .lead-stage-dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.lead-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, .75fr);
  gap: 18px;
  align-items: start;
}
.lead-detail-side {
  position: sticky;
  top: 18px;
}
.lead-form-actions {
  display: flex;
  justify-content: flex-end;
}
.lead-followup-add {
  display: grid;
  grid-template-columns: 150px 130px minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
}
.lead-followup-add .form-group { margin-bottom: 0; }
.lead-followup-list,
.lead-history-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}
.lead-followup-item {
  display: grid;
  grid-template-columns: 175px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-left: 4px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
}
.lead-followup-item.overdue { border-left-color: var(--rose); }
.lead-followup-item.today { border-left-color: var(--amber); }
.lead-followup-date strong {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
}
.lead-followup-date span,
.lead-followup-meta,
.lead-history-meta { font-size: 12px; }
.lead-followup-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.lead-followup-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.lead-snapshot-grid,
.lead-readonly-grid {
  display: grid;
  gap: 12px;
}
.lead-snapshot-grid strong,
.lead-readonly-grid strong {
  display: block;
  color: var(--ink);
  font-weight: 800;
  overflow-wrap: anywhere;
}
.lead-convert-panel {
  border-color: rgba(21,128,61,.32);
  background: linear-gradient(135deg, rgba(21,128,61,.10), transparent 54%), var(--surface);
}
.lead-convert-panel .btn { width: 100%; justify-content: center; }
.lead-history-item {
  position: relative;
  padding: 0 0 12px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.lead-history-item:last-child { border-bottom: 0; padding-bottom: 0; }
.lead-history-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.lead-history-title {
  font-weight: 800;
  color: var(--ink);
}

:root[data-theme="dark"] .lead-hero,
:root[data-theme="dark"] .lead-detail-hero {
  background:
    linear-gradient(135deg, rgba(96,165,250,.16), rgba(249,115,22,.10) 46%, transparent 78%),
    var(--surface);
}
:root[data-theme="dark"] .lead-metric,
:root[data-theme="dark"] .lead-alert-pill,
:root[data-theme="dark"] .lead-contact-pills span,
:root[data-theme="dark"] .lead-contact-pills a {
  background: rgba(28,39,64,.66);
}
:root[data-theme="dark"] .main > .flex-between:first-child {
  background:
    linear-gradient(135deg, rgba(96,165,250,.12), rgba(249,115,22,.08) 46%, transparent 74%),
    var(--surface);
}
:root[data-theme="dark"] .side { box-shadow: inset -1px 0 rgba(255,255,255,.04); }

/* ── Premium interaction layer ─────────────────────── */
.route-progress {
  position: fixed; inset: 0 0 auto; z-index: 1200; height: 3px;
  pointer-events: none; opacity: 0; overflow: hidden;
  transition: opacity var(--motion-fast) ease;
}
.route-progress-bar {
  display: block; width: 100%; height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--sage), var(--amber));
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 55%, transparent);
  transform: scaleX(0); transform-origin: left;
}
.route-progress.is-active { opacity: 1; }
.route-progress.is-active .route-progress-bar {
  animation: route-progress-run 8s var(--ease-emphasized) forwards;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--motion-route);
  animation-timing-function: var(--ease-emphasized);
}

html[data-theme-transition="active"]::view-transition-old(root) {
  animation: none;
  z-index: 1;
}
html[data-theme-transition="active"]::view-transition-new(root) {
  animation: theme-reveal var(--motion-route) var(--ease-emphasized) both;
  z-index: 2;
}

.command-trigger {
  width: 32px; height: 32px; flex: 0 0 32px; padding: 0;
}
.command-overlay {
  display: none; position: fixed; inset: 0; z-index: 650;
  align-items: flex-start; justify-content: center;
  padding: min(18vh, 160px) 18px 24px;
  background: color-mix(in srgb, var(--ink) 46%, transparent);
  backdrop-filter: blur(12px) saturate(90%);
}
.command-overlay.active {
  display: flex;
  animation: command-overlay-in var(--motion-fast) ease-out both;
}
.command-dialog {
  width: min(100%, 620px); max-height: min(70vh, 640px);
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--line-soft));
  border-radius: var(--r); background: var(--surface);
  box-shadow: 0 28px 90px rgba(11,21,48,.24), var(--shadow-lg);
  transform-origin: 50% 0;
}
.command-overlay.active .command-dialog {
  animation: command-dialog-in var(--motion-ui) var(--ease-spring) both;
}
.command-search-row {
  min-height: 60px; display: grid; grid-template-columns: 22px minmax(0, 1fr) 36px;
  gap: 10px; align-items: center; padding: 10px 12px 10px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.command-search-icon { color: var(--ink-3); }
.command-search-row input[type="search"] {
  min-height: 40px; padding: 8px 0; border: 0; border-radius: 0;
  background: transparent; box-shadow: none; font-size: 16px;
}
.command-search-row input[type="search"]::-webkit-search-cancel-button { display: none; }
.command-search-row input[type="search"]:focus { border: 0; box-shadow: none; }
.command-close { color: var(--ink-3); }
.command-results {
  overflow-y: auto; padding: 8px; overscroll-behavior: contain;
}
.command-group-label {
  padding: 8px 10px 5px; color: var(--ink-3); font-size: 10px;
  font-weight: 800; text-transform: uppercase; letter-spacing: 0;
}
.command-result {
  width: 100%; min-height: 46px; display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 18px; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink);
  text-align: left; cursor: pointer;
  transition:
    background var(--motion-fast) ease,
    color var(--motion-fast) ease,
    transform var(--motion-ui) var(--ease-spring);
}
.command-result:hover,
.command-result.is-active { background: var(--surface-2); }
.command-result.is-active { transform: translateX(2px); }
.command-result-icon {
  width: 18px; height: 18px; display: grid; place-items: center;
  color: var(--ink-3);
}
.command-result-icon svg { width: 16px; height: 16px; }
.command-result-label { min-width: 0; font-size: 13.5px; font-weight: 700; }
.command-result-arrow { color: var(--ink-4); opacity: 0; transform: translateX(-3px); }
.command-result.is-active .command-result-arrow,
.command-result:hover .command-result-arrow {
  opacity: 1; transform: translateX(0);
  transition: opacity var(--motion-fast) ease, transform var(--motion-ui) var(--ease-spring);
}
.command-empty {
  padding: 34px 20px; text-align: center; color: var(--ink-3); font-size: 13px;
}
.command-empty[hidden] { display: none; }
body.command-open { overflow: hidden; }

@media (hover: hover) and (pointer: fine) {
  .card:hover,
  .stat:hover,
  .stat-card:hover,
  .employee-card:hover,
  .kanban-card:hover {
    border-color: color-mix(in srgb, var(--accent) 30%, var(--line-soft));
    box-shadow: var(--shadow-float);
    transform: translateY(-2px);
  }
  .stats-grid .stat-card:hover::before { transform: scaleX(1); opacity: 1; }
  .btn-primary:hover,
  .btn-accent:hover,
  .btn-success:hover,
  .btn-danger:hover { box-shadow: 0 7px 16px rgba(11,21,48,.16); }
}

@keyframes route-progress-run {
  0% { transform: scaleX(.04); }
  14% { transform: scaleX(.26); }
  58% { transform: scaleX(.72); }
  100% { transform: scaleX(.9); }
}
@keyframes theme-reveal {
  from { clip-path: circle(0 at var(--theme-x, 50%) var(--theme-y, 50%)); }
  to { clip-path: circle(150vmax at var(--theme-x, 50%) var(--theme-y, 50%)); }
}
@keyframes command-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes command-dialog-in {
  from { opacity: 0; transform: translateY(-10px) scale(.975); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes busy-spin {
  to { transform: rotate(360deg); }
}
@keyframes check-set {
  0% { transform: scale(.82); box-shadow: 0 0 0 0 color-mix(in srgb, var(--sage) 40%, transparent); }
  58% { transform: scale(1.08); box-shadow: 0 0 0 6px transparent; }
  100% { transform: scale(1); box-shadow: 0 0 0 0 transparent; }
}

/* ── Scrollbar ─────────────────────────────────────── */
.side::-webkit-scrollbar { width: 6px; }
.side::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ── Mobile nav toggle ─────────────────────────────── */
.mobile-nav-btn {
  display: none; position: fixed; top: 16px; left: 16px; z-index: 400;
  width: 44px; height: 44px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  align-items: center; justify-content: center; box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, transform .2s cubic-bezier(.2,.8,.2,1);
}
.mobile-nav-btn .icon-close { display: none; }
.mobile-nav-btn[aria-expanded="true"] .icon-menu { display: none; }
.mobile-nav-btn[aria-expanded="true"] .icon-close { display: block; }
.nav-scrim { display: none; }

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: fixed; top: 0; left: 0; width: 280px; z-index: 350;
    height: 100dvh; padding-top: max(22px, env(safe-area-inset-top));
    padding-bottom: max(22px, env(safe-area-inset-bottom));
    overscroll-behavior: contain;
    transform: translateX(-100%); transition: transform .2s cubic-bezier(.2,.8,.2,1);
    box-shadow: var(--shadow-lg);
  }
  .side .brand { padding-right: 52px; align-items: flex-start; }
  .side .brand > div:last-child { min-width: 0; }
  .side .brand-name {
    font-size: 18px; line-height: 1.15; overflow-wrap: anywhere;
  }
  .side.open, body.nav-open .side { transform: translateX(0); }
  body.nav-open { overflow: hidden; }
  .nav-scrim {
    display: block; position: fixed; inset: 0; z-index: 340;
    background: rgba(11,21,48,.5); opacity: 0; visibility: hidden;
    transition: opacity .18s ease-out, visibility 0s linear .18s;
  }
  body.nav-open .nav-scrim {
    opacity: 1; visibility: visible; transition-delay: 0s;
  }
  body.nav-open .mobile-nav-btn { transform: translateX(204px); }
  .main { padding: 72px 20px 40px; }
  .mobile-nav-btn { display: flex; top: max(16px, env(safe-area-inset-top)); }
  .side .nav-item { min-height: 44px; }
  .side .theme-toggle,
  .side .command-trigger { width: 44px; height: 44px; flex-basis: 44px; }
  .command-overlay {
    align-items: flex-end; padding: 12px;
  }
  .command-dialog {
    max-height: min(78dvh, 680px);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .command-search-row { min-height: 64px; }
  .command-result { min-height: 52px; }
  .grid-2, .grid-3, .grid-4, .grid-2-1 { grid-template-columns: 1fr; }
  h1, .page-title { font-size: 32px; }
  body { font-size: 15px; }
  .form-row { flex-direction: column; align-items: stretch; }
  input[type="text"], input[type="password"], input[type="number"], input[type="date"],
  input[type="time"], input[type="email"], input[type="url"], input[type="tel"],
  input[type="search"], input[type="file"], textarea, select,
  .input, .select { min-height: 44px; font-size: 16px; }
  .btn { min-height: 44px; justify-content: center; }
  .btn-sm { min-height: 38px; }
  .main > .flex-between:first-child {
    align-items: stretch;
    flex-direction: column;
    padding: 18px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  .main > .flex-between:first-child > * {
    min-width: 0;
    max-width: 100%;
  }
  .main > .flex-between:first-child > div:last-child,
  .action-row,
  .table-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
    justify-content: stretch;
  }
  .main > .flex-between:first-child .btn,
  .main > .flex-between:first-child form,
  .action-row .btn,
  .table-actions .btn {
    width: 100%;
    min-width: 0;
    white-space: normal;
  }
  .main > .flex-between:first-child form.form-row {
    align-items: stretch;
  }
  .card { padding: 16px; }
  table, .table { min-width: 680px; }
  .lead-hero,
  .lead-detail-grid,
  .lead-filter-grid,
  .lead-followup-add { grid-template-columns: 1fr; }
  .lead-detail-hero { flex-direction: column; }
  .lead-detail-actions { justify-content: flex-start; }
  .lead-detail-side { position: static; }
  .stage-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lead-stage-rail {
    grid-template-columns: 1fr;
  }
  .lead-stage-step {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .lead-stage-step:last-child { border-bottom: 0; }
  .lead-stage-step::after { display: none; }
  .lead-filter-actions { align-items: stretch; }
  .lead-followup-item { grid-template-columns: 1fr; }
  .lead-followup-actions { justify-content: flex-start; }
}
@media (max-width: 760px) {
  .lead-hero,
  .lead-detail-hero,
  .lead-toolbar,
  .lead-create-panel,
  .lead-pipeline-card,
  .lead-panel { border-radius: var(--r-sm); }
  .lead-hero { padding: 16px; }
  .lead-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lead-metric { min-height: 94px; padding: 12px; }
  .lead-metric strong { font-size: 22px; }
  .stage-strip {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(138px, 44vw);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    padding-bottom: 6px;
  }
  .stage-chip { min-height: 72px; scroll-snap-align: start; }
  .lead-table-wrap { display: none; }
  .lead-card-list { display: grid; }
  .lead-mobile-top,
  .lead-mobile-meta {
    align-items: flex-start;
    flex-direction: column;
  }
  .lead-section-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .lead-create-panel summary { align-items: center; flex-direction: row; }
  .lead-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lead-search,
  .lead-filter-actions { grid-column: 1 / -1; }
  .lead-filter-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lead-filter-actions,
  .lead-filter-actions .btn,
  .lead-detail-actions,
  .lead-detail-actions .btn,
  .lead-detail-actions form,
  .lead-submit {
    width: 100%;
  }
}
