/* =============================================================================
   Tasic-Test-1 CRM : design system + components
   One file, three layers: tokens, base, components. No framework.
   ============================================================================= */

/* ---------- 1. tokens ----------------------------------------------------- */
:root {
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --bg:            #F5F7FA;
  --surface:       #FFFFFF;
  --surface-2:     #F8FAFC;
  --surface-3:     #F1F5F9;
  --border:        #E2E8F0;
  --border-strong: #CBD5E1;

  --text:          #0F172A;
  --text-2:        #475569;
  --text-3:        #64748B;
  --text-disabled: #94A3B8;

  /* brand (from the tier1 logo): navy ground, mint accent, teal support */
  --brand-navy:        #111A2C;
  --brand-navy-2:      #18243A;
  --brand-navy-line:   #243352;
  --brand-mint:        #81E2B9;
  --brand-mint-hover:  #6EDBAD;
  --brand-mint-active: #5CD3A0;
  --brand-teal:        #43746B;

  /* primary = deep green that passes AA on white; buttons use the mint itself */
  --primary:       #2F7D63;
  --primary-hover: #26694F;
  --primary-soft:  #E9F8F1;
  --primary-ring:  rgba(67, 116, 107, .32);
  --on-primary:    #FFFFFF;

  --danger:        #DC2626;
  --danger-hover:  #B91C1C;
  --danger-soft:   #FEF2F2;
  --success:       #059669;
  --success-soft:  #ECFDF5;
  --warning:       #D97706;
  --warning-soft:  #FFFBEB;

  /* status badges: text / background */
  --tone-slate-fg: #334155; --tone-slate-bg: #F1F5F9; --tone-slate-dot: #64748B;
  --tone-green-fg: #065F46; --tone-green-bg: #D1FAE5; --tone-green-dot: #059669;
  --tone-rose-fg:  #9F1239; --tone-rose-bg:  #FFE4E6; --tone-rose-dot:  #E11D48;
  --tone-amber-fg: #92400E; --tone-amber-bg: #FEF3C7; --tone-amber-dot: #D97706;
  --tone-blue-fg:  #1E40AF; --tone-blue-bg:  #DBEAFE; --tone-blue-dot:  #2563EB;

  --radius-sm: 4px;
  --radius:    6px;
  --radius-lg: 10px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .08), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, .16), 0 2px 6px rgba(15, 23, 42, .08);

  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px; --space-12: 48px;

  --text-xs: 12px; --text-sm: 13px; --text-base: 14px; --text-md: 15px;
  --text-lg: 17px; --text-xl: 20px; --text-2xl: 24px; --text-3xl: 30px;

  --control-h: 36px;
  --row-h: 44px;
  --topbar-h: 56px;
  --drawer-w: 440px;

  --dur-fast: 120ms; --dur: 180ms; --dur-slow: 260ms;
  --ease: cubic-bezier(.2, 0, 0, 1);

  --z-sticky: 10; --z-drawer: 40; --z-modal: 50; --z-toast: 60; --z-menu: 70;
}

/* ---------- 2. base ------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
  margin: 0; min-height: 100%;
  font-family: var(--font-sans); font-size: var(--text-base); line-height: 1.5;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01", "tnum";
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
h1 { font-size: var(--text-2xl); line-height: 1.25; }
h2 { font-size: var(--text-lg);  line-height: 1.3; }
h3 { font-size: var(--text-md);  line-height: 1.35; }
p  { margin: 0; }
a  { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--radius-sm); }
::selection { background: #C9F3E2; }

.muted   { color: var(--text-3); }
.subtle  { color: var(--text-2); }
.small   { font-size: var(--text-sm); }
.xs      { font-size: var(--text-xs); }
.mono    { font-family: var(--font-mono); font-size: var(--text-sm); }
.tnum    { font-variant-numeric: tabular-nums; }
.truncate{ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap  { white-space: nowrap; }
.right   { text-align: right; }
.center  { text-align: center; }
.flex    { display: flex; align-items: center; gap: var(--space-2); }
.flex-1  { flex: 1 1 auto; min-width: 0; }
.stack   { display: flex; flex-direction: column; gap: var(--space-3); }
.row     { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.spacer  { flex: 1; }
.mt-2 { margin-top: var(--space-2); } .mt-4 { margin-top: var(--space-4); } .mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); } .mb-4 { margin-bottom: var(--space-4); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- 3. app shell -------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  height: var(--topbar-h); display: flex; align-items: center; gap: var(--space-6);
  padding: 0 var(--space-6); background: var(--brand-navy); border-bottom: 1px solid var(--brand-navy-line);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: var(--space-3); color: #fff; font-weight: 600; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 28px; width: auto; display: block; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px; background: var(--brand-mint); color: var(--brand-navy);
  display: grid; place-items: center; font-size: 13px; font-weight: 700; letter-spacing: 0;
}
.nav { display: flex; align-items: center; gap: var(--space-1); }
.nav a {
  display: inline-flex; align-items: center; height: 32px; padding: 0 var(--space-3);
  border-radius: var(--radius); color: rgba(255, 255, 255, .72); font-weight: 500; font-size: var(--text-base);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.nav a[aria-current="page"] { background: rgba(255, 255, 255, .12); color: #fff; }
.nav a:focus-visible { outline-color: var(--brand-mint); }
.topbar .user { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); }
.topbar .user-name { color: rgba(255, 255, 255, .88); }
.topbar .user-name .muted { color: rgba(255, 255, 255, .55); }
.topbar .btn-ghost { color: rgba(255, 255, 255, .78); }
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.topbar .btn-ghost:focus-visible { outline-color: var(--brand-mint); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand-mint); color: var(--brand-navy);
  display: grid; place-items: center; font-size: 12px; font-weight: 600; letter-spacing: .02em;
}

.page { padding: var(--space-6); max-width: 1480px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); flex-wrap: wrap; }
.page-head p { color: var(--text-3); margin-top: 2px; }
.page-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

/* ---------- 4. buttons ---------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--control-h); padding: 0 var(--space-4); border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 500; font-size: var(--text-base); line-height: 1; white-space: nowrap;
  box-shadow: var(--shadow-sm); cursor: pointer; user-select: none;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), opacity var(--dur-fast);
}
.btn:hover { background: var(--surface-2); border-color: #B6C2D1; }
.btn:active { background: var(--surface-3); box-shadow: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn svg { width: 16px; height: 16px; flex: none; }

.btn-primary { background: var(--brand-mint); border-color: var(--brand-mint); color: var(--brand-navy); }
.btn-primary:hover { background: var(--brand-mint-hover); border-color: var(--brand-mint-hover); color: var(--brand-navy); }
.btn-primary:active { background: var(--brand-mint-active); border-color: var(--brand-mint-active); }
.btn-primary:focus-visible { outline-color: var(--brand-teal); }

.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: #FCA5A5; }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: var(--danger-hover); border-color: var(--danger-hover); }

.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); border-color: transparent; }
.btn-ghost.btn-danger { color: var(--danger); }
.btn-ghost.btn-danger:hover { background: var(--danger-soft); color: var(--danger-hover); border-color: transparent; }

.btn-sm { height: 30px; padding: 0 var(--space-3); font-size: var(--text-sm); }
.btn-icon { width: var(--control-h); padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn-block { width: 100%; }

.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; color: var(--text-2);
  animation: spin .7s linear infinite;
}
.btn-primary.is-loading::after { color: var(--brand-navy); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 5. forms ------------------------------------------------------ */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: var(--text-sm); font-weight: 500; color: var(--text-2); }
.field .hint { font-size: var(--text-xs); color: var(--text-3); }
.field .error { font-size: var(--text-xs); color: var(--danger); }
.req::after { content: " *"; color: var(--danger); }

.input, .select, .textarea {
  width: 100%; height: var(--control-h); padding: 0 var(--space-3);
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
  color: var(--text); font-size: var(--text-base); box-shadow: var(--shadow-sm);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-disabled); }
.input:hover, .select:hover, .textarea:hover { border-color: #B6C2D1; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--danger); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-3); color: var(--text-3); cursor: not-allowed; }
.textarea { height: auto; min-height: 88px; padding: var(--space-2) var(--space-3); resize: vertical; line-height: 1.5; }
.select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center;
}
.input-sm, .select-sm { height: 30px; font-size: var(--text-sm); }
.input-group { position: relative; }
.input-group > svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.input-group > .input { padding-left: 34px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.form-grid .span-2 { grid-column: span 2; }
.checkbox { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; font-size: var(--text-base); }
.checkbox input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); cursor: pointer; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 44px; }
.pw-wrap .pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); height: 28px; width: 36px; border: 0; background: transparent; color: var(--text-3); border-radius: var(--radius-sm); }
.pw-wrap .pw-toggle:hover { background: var(--surface-3); color: var(--text); }
.pw-wrap .pw-toggle svg { width: 16px; height: 16px; margin: 0 auto; }

/* ---------- 6. cards / panels -------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); }
.card-body { padding: var(--space-5); }
.card-foot { padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); display: flex; align-items: center; gap: var(--space-2); }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-5); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); cursor: pointer; transition: border-color var(--dur-fast); text-align: left; }
.stat:hover { border-color: var(--border-strong); }
.stat[aria-pressed="true"] { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.stat .stat-label { font-size: var(--text-xs); font-weight: 500; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; display: flex; align-items: center; gap: 6px; }
.stat .stat-value { font-size: var(--text-2xl); font-weight: 600; letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ---------- 7. toolbar / filters ----------------------------------------- */
.toolbar { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.toolbar .input-group { width: 280px; max-width: 100%; }
.toolbar .select { width: auto; min-width: 150px; }
.toolbar .count { color: var(--text-3); font-size: var(--text-sm); white-space: nowrap; }
.bulkbar { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); padding: var(--space-2) var(--space-4); background: var(--primary-soft); border-bottom: 1px solid #BFEBD8; font-size: var(--text-sm); color: var(--text); }
.bulkbar .select { width: auto; min-width: 180px; }

/* ---------- 8. table ------------------------------------------------------ */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
.table-scroll { overflow: auto; max-height: calc(100vh - 290px); min-height: 200px; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-base); }
.table th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2);
  text-align: left; font-size: var(--text-xs); font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .04em; padding: 0 var(--space-3); height: 38px;
  border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none;
}
.table th.sortable { cursor: pointer; }
.table th.sortable:hover { color: var(--text); }
.table th .sort { display: inline-flex; align-items: center; gap: 4px; }
.table th .sort svg { width: 12px; height: 12px; opacity: .5; }
.table th[aria-sort] .sort svg { opacity: 1; color: var(--primary); }
.table td { padding: 0 var(--space-3); height: var(--row-h); border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.table tbody tr { transition: background var(--dur-fast); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.is-selected { background: var(--primary-soft); }
.table tbody tr.is-clickable { cursor: pointer; }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.cell-check, .table th.cell-check { width: 40px; padding-right: 0; }
.table td.cell-check input, .table th.cell-check input { width: 15px; height: 15px; margin: 0; accent-color: var(--primary); cursor: pointer; display: block; }
.table .cell-name { font-weight: 500; color: var(--text); }
.table .cell-name .sub { display: block; font-weight: 400; font-size: var(--text-xs); color: var(--text-3); }
.table .cell-muted { color: var(--text-3); }
.table .cell-actions { text-align: right; }
.table .select-sm { min-width: 140px; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) var(--space-4); border-top: 1px solid var(--border); background: var(--surface-2); font-size: var(--text-sm); color: var(--text-3); }
.pager { display: flex; align-items: center; gap: var(--space-1); }

/* ---------- 9. badges ----------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px 0 7px;
  border-radius: 999px; font-size: var(--text-xs); font-weight: 500; white-space: nowrap; line-height: 1;
  color: var(--tone-slate-fg); background: var(--tone-slate-bg);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--tone-slate-dot); flex: none; }
.badge-green { color: var(--tone-green-fg); background: var(--tone-green-bg); } .badge-green::before { background: var(--tone-green-dot); }
.badge-rose  { color: var(--tone-rose-fg);  background: var(--tone-rose-bg);  } .badge-rose::before  { background: var(--tone-rose-dot); }
.badge-amber { color: var(--tone-amber-fg); background: var(--tone-amber-bg); } .badge-amber::before { background: var(--tone-amber-dot); }
.badge-blue  { color: var(--tone-blue-fg);  background: var(--tone-blue-bg);  } .badge-blue::before  { background: var(--tone-blue-dot); }
.badge-plain::before { display: none; }
.pill { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 4px; background: var(--surface-3); color: var(--text-2); font-size: var(--text-xs); font-weight: 500; }

/* status select tinted to match the badge */
.status-select { font-weight: 500; }
.status-select[data-tone="slate"] { color: var(--tone-slate-fg); }
.status-select[data-tone="green"] { color: var(--tone-green-fg); border-color: #A7F3D0; background-color: var(--tone-green-bg); }
.status-select[data-tone="rose"]  { color: var(--tone-rose-fg);  border-color: #FECDD3; background-color: var(--tone-rose-bg); }
.status-select[data-tone="amber"] { color: var(--tone-amber-fg); border-color: #FDE68A; background-color: var(--tone-amber-bg); }
.status-select[data-tone="blue"]  { color: var(--tone-blue-fg);  border-color: #BFDBFE; background-color: var(--tone-blue-bg); }

/* ---------- 10. tabs ------------------------------------------------------ */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); margin-bottom: var(--space-5); overflow-x: auto; }
.tab {
  position: relative; height: 40px; padding: 0 var(--space-3); border: 0; background: transparent;
  color: var(--text-2); font-weight: 500; white-space: nowrap; border-radius: var(--radius) var(--radius) 0 0;
}
.tab:hover { color: var(--text); background: var(--surface-3); }
.tab[aria-selected="true"] { color: var(--text); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: var(--space-2); right: var(--space-2); bottom: -1px; height: 2px; background: var(--primary); border-radius: 2px 2px 0 0; }
.tab .pill { margin-left: 6px; }

/* ---------- 11. drawer / modal / menu ------------------------------------ */
.scrim { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: var(--z-drawer); opacity: 0; transition: opacity var(--dur) var(--ease); }
.scrim.is-open { opacity: 1; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--drawer-w); max-width: 100vw; z-index: calc(var(--z-drawer) + 1);
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; transform: translateX(100%);
  /* keep the closed drawer out of the tab order: hide it once the slide-out finishes */
  visibility: hidden; transition: transform var(--dur-slow) var(--ease), visibility 0s linear var(--dur-slow);
}
.drawer.is-open { transform: translateX(0); visibility: visible; transition: transform var(--dur-slow) var(--ease); }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); padding: var(--space-5) var(--space-5) var(--space-4); border-bottom: 1px solid var(--border); }
.drawer-body { flex: 1; overflow: auto; padding: var(--space-5); }
.drawer-foot { padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border); background: var(--surface-2); display: flex; gap: var(--space-2); align-items: center; }

.modal-scrim { z-index: var(--z-modal); display: grid; place-items: center; padding: var(--space-4); }
.modal { width: 100%; max-width: 480px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); transform: translateY(8px) scale(.98); transition: transform var(--dur) var(--ease); }
.scrim.is-open .modal { transform: none; }
.modal-lg { max-width: 760px; }
.modal-head { padding: var(--space-5) var(--space-5) 0; }
.modal-head p { color: var(--text-3); margin-top: 4px; }
.modal-body { padding: var(--space-5); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.menu { position: absolute; z-index: var(--z-menu); min-width: 180px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 4px; }
.menu button { display: flex; width: 100%; align-items: center; gap: var(--space-2); height: 32px; padding: 0 var(--space-3); border: 0; background: transparent; border-radius: var(--radius-sm); text-align: left; font-size: var(--text-base); color: var(--text); }
.menu button:hover { background: var(--surface-3); }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

/* ---------- 12. description lists, timeline ------------------------------ */
.dl { display: grid; grid-template-columns: 120px 1fr; gap: var(--space-2) var(--space-4); font-size: var(--text-base); }
.dl dt { color: var(--text-3); font-size: var(--text-sm); padding-top: 1px; }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.section-title { font-size: var(--text-xs); font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; margin: var(--space-6) 0 var(--space-3); }
.section-title:first-child { margin-top: 0; }

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.timeline li { display: grid; grid-template-columns: 18px 1fr; gap: var(--space-3); font-size: var(--text-sm); }
.timeline .dot { width: 18px; height: 18px; border-radius: 50%; background: var(--surface-3); color: var(--text-3); display: grid; place-items: center; margin-top: 1px; }
.timeline .dot svg { width: 11px; height: 11px; }
.timeline .when { color: var(--text-3); font-size: var(--text-xs); }
.timeline .body { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- 13. toast ----------------------------------------------------- */
.toasts { position: fixed; right: var(--space-5); bottom: var(--space-5); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--space-2); max-width: 380px; }
.toast {
  display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4);
  background: var(--text); color: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg); font-size: var(--text-sm);
  animation: toast-in var(--dur) var(--ease);
}
.toast svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.toast.error { background: var(--danger); }
.toast.success svg { color: #6EE7B7; }
.toast .toast-action { margin-left: auto; color: #fff; text-decoration: underline; background: none; border: 0; padding: 0; font: inherit; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 14. empty / loading states ----------------------------------- */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2); padding: var(--space-12) var(--space-6); text-align: center; color: var(--text-3); }
.empty svg { width: 32px; height: 32px; color: var(--text-disabled); margin-bottom: var(--space-2); }
.empty h3 { color: var(--text); }
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, #E9EEF4 37%, var(--surface-3) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--radius-sm); height: 14px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.progress { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); border-radius: 999px; transition: width var(--dur) var(--ease); }

/* ---------- 15. notices --------------------------------------------------- */
.notice { display: flex; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); font-size: var(--text-sm); color: var(--text-2); }
.notice svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.notice.info { background: var(--primary-soft); border-color: #BFEBD8; color: #1B4D3C; }
.notice.warn { background: var(--warning-soft); border-color: #FDE68A; color: #78350F; }
.notice.danger { background: var(--danger-soft); border-color: #FECACA; color: #7F1D1D; }
.notice.success { background: var(--success-soft); border-color: #A7F3D0; color: #064E3B; }

/* ---------- 16. dropzone -------------------------------------------------- */
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg); padding: var(--space-10) var(--space-6); text-align: center; background: var(--surface); transition: border-color var(--dur-fast), background var(--dur-fast); cursor: pointer; }
.dropzone:hover, .dropzone.is-over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone svg { width: 28px; height: 28px; color: var(--text-3); margin: 0 auto var(--space-3); }
.dropzone strong { color: var(--text); }
.dropzone p { color: var(--text-3); font-size: var(--text-sm); margin-top: 4px; }

/* ---------- 17. login ----------------------------------------------------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: var(--space-6); background: var(--brand-navy); }
.login-wrap { width: 100%; max-width: 400px; }
.login-logo { display: block; width: 132px; height: auto; margin: 0 auto var(--space-6); }
.login-card { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: var(--space-8); }
.login-card h1 { font-size: var(--text-xl); margin-bottom: 4px; }
.login-card .lede { color: var(--text-3); margin-bottom: var(--space-6); }
.login-card .input:focus { border-color: var(--brand-teal); }
.login-foot { margin-top: var(--space-6); text-align: center; font-size: var(--text-xs); color: rgba(255, 255, 255, .6); }
.login-card .login-foot { color: var(--text-3); }
.login-page .login-foot { margin-top: var(--space-5); }

/* ---------- 18. responsive ------------------------------------------------ */
@media (max-width: 900px) {
  .page { padding: var(--space-4); }
  .topbar { padding: 0 var(--space-4); gap: var(--space-4); }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .table-scroll { max-height: none; }
  .toolbar .input-group { width: 100%; }
  .drawer { width: 100vw; }
  .dl { grid-template-columns: 100px 1fr; }
}
@media (max-width: 640px) {
  .topbar .user .user-name { display: none; }
  .nav a { padding: 0 var(--space-2); }
  .table th:not(.keep), .table td:not(.keep) { display: none; }
  .table th.keep, .table td.keep { display: table-cell; }
  .toasts { left: var(--space-4); right: var(--space-4); max-width: none; }
  /* phones: one scrollable strip of tiles instead of four stacked rows */
  .stat-row { display: flex; overflow-x: auto; gap: var(--space-2); margin: 0 calc(-1 * var(--space-4)) var(--space-4); padding: 0 var(--space-4) var(--space-1); scroll-snap-type: x proximity; }
  .stat { flex: 0 0 132px; scroll-snap-align: start; }
}

/* ---------- 19. print ----------------------------------------------------- */
@media print {
  .topbar, .toolbar, .bulkbar, .table-foot, .btn, .toasts { display: none !important; }
  .table-scroll { max-height: none; overflow: visible; }
  body { background: #fff; }
}
