/* ==========================================================================
   Anderson Drive Club — Component library
   Buttons · Cards · Badges · Tables · Forms · Tabs · Modals · Toasts ·
   Avatars · Progress · Timeline · Empty states · Chart chrome
   ========================================================================== */

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  --btn-h: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: var(--btn-h);
  padding-inline: var(--sp-4);
  border-radius: var(--r-sm);
  font-size: var(--t-md);
  font-weight: 560;
  letter-spacing: -.008em;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease),
              color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease),
              box-shadow var(--dur-2) var(--ease);
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.btn .ic { flex-shrink: 0; }

.btn-primary {
  background: var(--brand);
  color: var(--brand-ink);
  box-shadow: var(--sh-1);
}
.btn-primary:hover { background: var(--brand-strong); box-shadow: var(--sh-brand); }

.btn-dark {
  background: var(--surface-inv);
  color: var(--ink-inv);
}
.btn-dark:hover { opacity: .88; }

.btn-outline {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}
.btn-outline:hover { border-color: var(--ink-3); background: var(--surface-2); }

.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); }

.btn-soft { background: var(--surface-3); color: var(--ink); }
.btn-soft:hover { background: var(--line); }

.btn-danger { background: var(--critical); color: #fff; }
.btn-danger:hover { filter: brightness(1.06); }

.btn-sm { --btn-h: 32px; padding-inline: var(--sp-3); font-size: var(--t-sm); border-radius: var(--r-xs); }
.btn-xs { --btn-h: 26px; padding-inline: 10px; font-size: var(--t-xs); border-radius: var(--r-xs); gap: 5px; }
.btn-lg { --btn-h: 50px; padding-inline: var(--sp-6); font-size: var(--t-lg); border-radius: var(--r-md); }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
  position: relative;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn.sm { width: 30px; height: 30px; border-radius: var(--r-xs); }
.icon-btn.active { background: var(--brand-soft); color: var(--brand-strong); }

.btn-group {
  display: inline-flex;
  background: var(--surface-3);
  padding: 3px;
  border-radius: var(--r-sm);
  gap: 2px;
}
.btn-group button {
  height: 30px; padding-inline: 12px;
  border-radius: 6px;
  font-size: var(--t-sm); font-weight: 540;
  color: var(--ink-3);
  transition: all var(--dur-1) var(--ease);
}
.btn-group button:hover { color: var(--ink); }
.btn-group button[aria-pressed="true"] {
  background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); font-weight: 580;
}

/* --------------------------------------------------------------------------
   Cards & panels
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  position: relative;
}
.card-pad { padding: var(--sp-5); }
.card-hover { transition: transform var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease); }
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--sh-3); border-color: var(--line-strong); }
.card-flat { box-shadow: none; }
.card-inset { background: var(--surface-2); }

.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--line-soft);
}
.card-head h3, .card-head .card-title {
  font-family: var(--font-display);
  font-size: var(--t-lg); font-weight: 600; letter-spacing: -.012em;
}
.card-head .sub { font-size: var(--t-xs); color: var(--ink-3); margin-top: 2px; font-family: var(--font-ui); font-weight: 400; letter-spacing: 0; }
.card-body { padding: var(--sp-5); }
.card-foot {
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

/* --------------------------------------------------------------------------
   Badges, chips, pills
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding-inline: 8px;
  border-radius: var(--r-xs);
  font-size: var(--t-2xs); font-weight: 620;
  letter-spacing: .015em;
  background: var(--surface-3); color: var(--ink-2);
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge svg { width: 12px; height: 12px; }

.badge-good     { background: var(--good-soft);     color: var(--good-ink); }
.badge-warning  { background: var(--warning-soft);  color: var(--warning-ink); }
.badge-serious  { background: var(--serious-soft);  color: var(--serious-ink); }
.badge-critical { background: var(--critical-soft); color: var(--critical-ink); }
.badge-info     { background: var(--info-soft);     color: var(--info-ink); }
.badge-brand    { background: var(--brand-soft);    color: var(--brand-strong); }
.badge-solid    { background: var(--surface-inv);   color: var(--ink-inv); }
.badge-lg { height: 26px; padding-inline: 10px; font-size: var(--t-xs); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding-inline: 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: var(--t-sm); font-weight: 500; color: var(--ink-2);
  transition: all var(--dur-1) var(--ease);
}
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip[aria-pressed="true"] {
  background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand-strong); font-weight: 580;
}

.tier-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding-inline: 9px;
  border-radius: var(--r-xs);
  font-size: var(--t-2xs); font-weight: 650; letter-spacing: .04em; text-transform: uppercase;
}
.tier-drive     { background: var(--info-soft);  color: var(--info-ink); }
.tier-signature { background: var(--brand-soft); color: var(--brand-strong); }
.tier-blackkey  { background: var(--surface-inv); color: var(--ink-inv); }

/* --------------------------------------------------------------------------
   Vehicle photography
   Studio shots ship on a white sweep, so the tile keeps a near-white plate in
   BOTH themes — otherwise the cut-out reads as a white box on a dark card.
   -------------------------------------------------------------------------- */
.veh-photo {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--photo-tile);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .07);
  flex-shrink: 0;
}
/* Source shots run 4:3 → 2:1, so `contain` keeps every bumper and roofline in
   frame; the white plate matches the photos' own sweep, so there is no seam. */
.veh-photo img {
  width: 100%; height: 100%;
  object-fit: contain;
  object-position: center 52%;
  padding: 3%;
  transition: transform var(--dur-4) var(--ease-out);
}
.veh-photo .vp-fallback { color: #94A3B8; display: grid; place-items: center; }
.card-hover:hover .veh-photo img,
.fleet-card:hover .veh-photo img { transform: scale(1.04); }

/* thumbnail variant used inside dense table rows */
.veh-photo.thumb { width: 58px; height: 40px; border-radius: 7px; }
.veh-photo.thumb img { padding: 2px; object-position: center 50%; }

/* the brand logotype */
.brand-mark { display: block; flex-shrink: 0; }

/* --------------------------------------------------------------------------
   Avatars
   -------------------------------------------------------------------------- */
.avatar {
  --sz: 36px;
  width: var(--sz); height: var(--sz);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: calc(var(--sz) * .36);
  font-weight: 620;
  letter-spacing: .01em;
  color: var(--ink);
  background: var(--surface-3);
  flex-shrink: 0;
  overflow: hidden;
  user-select: none;
}
.avatar.xs { --sz: 26px; } .avatar.sm { --sz: 30px; }
.avatar.lg { --sz: 46px; } .avatar.xl { --sz: 64px; }
.avatar-brand { background: var(--brand); color: var(--brand-ink); }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -9px; box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--r-lg);
  overscroll-behavior-x: contain;
}
table.tbl { width: 100%; font-size: var(--t-sm); }
table.tbl thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2);
  text-align: left;
  font-size: var(--t-2xs);
  font-weight: 620;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 10px var(--sp-4);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.tbl thead th.sortable { cursor: pointer; user-select: none; }
table.tbl thead th.sortable:hover { color: var(--ink); }
table.tbl thead th .sort-ind { opacity: .35; margin-left: 4px; display: inline-block; }
table.tbl thead th[aria-sort] .sort-ind { opacity: 1; color: var(--brand-strong); }
table.tbl tbody td {
  padding: 11px var(--sp-4);
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  color: var(--ink-2);
}
table.tbl tbody tr { transition: background var(--dur-1) var(--ease); }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl .cell-primary { color: var(--ink); font-weight: 560; }
table.tbl .cell-actions { width: 1%; white-space: nowrap; text-align: right; }
table.tbl tbody tr.row-link { cursor: pointer; }

.tbl-compact tbody td { padding: 8px var(--sp-3); }
.tbl-compact thead th { padding: 8px var(--sp-3); }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label {
  font-size: var(--t-xs); font-weight: 580; color: var(--ink-2); letter-spacing: -.002em;
}
.hint { font-size: var(--t-xs); color: var(--ink-muted); }
.err  { font-size: var(--t-xs); color: var(--critical-ink); }

.input, .select, .textarea {
  width: 100%;
  height: 40px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--t-md);
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.textarea { height: auto; padding: 10px var(--sp-3); resize: vertical; min-height: 92px; line-height: 1.55; }
.input::placeholder, .textarea::placeholder { color: var(--ink-muted); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-muted); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--ring);
}
.input.sm, .select.sm { height: 34px; font-size: var(--t-sm); }

.select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238A92A1' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  cursor: pointer;
}

.input-icon { position: relative; display: flex; align-items: center; }
.input-icon > svg, .input-icon > .ic {
  position: absolute; left: 11px; width: 16px; height: 16px;
  color: var(--ink-muted); pointer-events: none;
}
.input-icon .input { padding-left: 35px; }

.search-box {
  display: flex; align-items: center; gap: var(--sp-2);
  height: 38px; padding: 0 var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink-3);
  transition: all var(--dur-1) var(--ease);
  min-width: 0;
}
.search-box:focus-within { background: var(--surface); border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.search-box input {
  border: 0; background: none; outline: none; flex: 1; min-width: 0;
  font-size: var(--t-sm); color: var(--ink);
}
.search-box input::placeholder { color: var(--ink-muted); }

.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding-inline: 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  font-family: var(--font-ui);
  font-size: 10.5px; font-weight: 600;
  color: var(--ink-3);
}

.switch {
  --w: 40px; --h: 23px;
  position: relative; display: inline-block; width: var(--w); height: var(--h); flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .track {
  position: absolute; inset: 0;
  background: var(--line-strong);
  border-radius: var(--r-pill);
  transition: background var(--dur-2) var(--ease);
  cursor: pointer;
}
.switch .track::after {
  content: ""; position: absolute;
  left: 3px; top: 3px;
  width: calc(var(--h) - 6px); height: calc(var(--h) - 6px);
  background: #fff; border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.28);
  transition: transform var(--dur-2) var(--ease-spring);
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(calc(var(--w) - var(--h))); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--ring); }

.check {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-size: var(--t-sm); color: var(--ink-2); cursor: pointer;
}
.check input { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }

/* --------------------------------------------------------------------------
   Tabs & segmented nav
   -------------------------------------------------------------------------- */
.tabs {
  display: flex; gap: var(--sp-1);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tabs button {
  position: relative;
  padding: 10px var(--sp-3) 12px;
  font-size: var(--t-sm); font-weight: 540;
  color: var(--ink-3);
  white-space: nowrap;
  transition: color var(--dur-1) var(--ease);
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); font-weight: 600; }
.tabs button[aria-selected="true"]::after {
  content: ""; position: absolute; left: var(--sp-3); right: var(--sp-3); bottom: -1px;
  height: 2px; background: var(--brand); border-radius: 2px 2px 0 0;
}
.tabs .count {
  display: inline-block; margin-left: 6px; padding: 1px 6px;
  border-radius: var(--r-pill); background: var(--surface-3);
  font-size: 10.5px; font-weight: 620; color: var(--ink-3);
}

/* --------------------------------------------------------------------------
   Progress, meters, rings
   -------------------------------------------------------------------------- */
.meter {
  height: 6px; border-radius: var(--r-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.meter > i {
  display: block; height: 100%;
  border-radius: var(--r-pill);
  background: var(--s1);
  transition: width var(--dur-4) var(--ease-out);
}
.meter.thick { height: 9px; }
.meter i.good { background: var(--good); }
.meter i.warning { background: var(--warning); }
.meter i.serious { background: var(--serious); }
.meter i.critical { background: var(--critical); }
.meter i.brand { background: var(--brand); }

.ring-wrap { position: relative; display: inline-grid; place-items: center; }
.ring-wrap .ring-val {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 640; letter-spacing: -.02em;
}

/* --------------------------------------------------------------------------
   Stat tiles
   -------------------------------------------------------------------------- */
.stat {
  display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5) var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  position: relative;
  overflow: hidden;
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.stat:hover { border-color: var(--line-strong); box-shadow: var(--sh-2); }
.stat .stat-label {
  font-size: var(--t-xs); font-weight: 540; color: var(--ink-3);
  display: flex; align-items: center; gap: 6px;
}
.stat .stat-value {
  font-family: var(--font-display);
  font-size: var(--t-3xl); font-weight: 650; letter-spacing: -.03em;
  line-height: 1.05; color: var(--ink);
}
.stat .stat-foot { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.stat .stat-spark { margin-top: auto; }

.delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: var(--t-xs); font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.delta svg { width: 13px; height: 13px; }
.delta.up   { color: var(--good-ink); }
.delta.down { color: var(--critical-ink); }
.delta.flat { color: var(--ink-3); }
.delta-note { font-size: var(--t-xs); color: var(--ink-muted); }

.hero-figure {
  font-family: var(--font-display);
  font-size: clamp(40px, 5vw, 56px);
  font-weight: 700; letter-spacing: -.04em; line-height: 1;
}

/* --------------------------------------------------------------------------
   Chart chrome
   -------------------------------------------------------------------------- */
.chart-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-4);
}
.chart-title { font-family: var(--font-display); font-size: var(--t-lg); font-weight: 600; letter-spacing: -.012em; }
.chart-sub { font-size: var(--t-xs); color: var(--ink-3); margin-top: 2px; }
.chart-box { position: relative; width: 100%; }
.chart-box svg { display: block; width: 100%; height: auto; overflow: visible; }

.legend { display: flex; flex-wrap: wrap; gap: var(--sp-4) var(--sp-5); align-items: center; }
.legend-item {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: var(--t-xs); color: var(--ink-2); font-weight: 500;
  cursor: default;
}
.legend-key { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-key.line { width: 14px; height: 3px; border-radius: 2px; }
.legend-item .legend-val { color: var(--ink); font-weight: 620; font-variant-numeric: tabular-nums; }

.viz-tip {
  position: absolute;
  z-index: 40;
  pointer-events: none;
  min-width: 132px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--sh-3);
  font-size: var(--t-xs);
  opacity: 0;
  transform: translate(-50%, -114%);
  transition: opacity var(--dur-1) var(--ease);
}
.viz-tip.on { opacity: 1; }
.viz-tip .tip-head {
  font-weight: 620; color: var(--ink); margin-bottom: 6px;
  padding-bottom: 6px; border-bottom: 1px solid var(--line-soft);
}
.viz-tip .tip-row {
  display: flex; align-items: center; gap: 7px;
  color: var(--ink-2); line-height: 1.7; white-space: nowrap;
}
.viz-tip .tip-row b { margin-left: auto; color: var(--ink); font-variant-numeric: tabular-nums; }

.table-view-toggle { font-size: var(--t-xs); color: var(--ink-3); }

/* --------------------------------------------------------------------------
   Timeline
   -------------------------------------------------------------------------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before {
  content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px;
  width: 2px; background: var(--line);
}
.tl-item { position: relative; padding-bottom: var(--sp-5); }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ""; position: absolute; left: -23px; top: 5px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--line-strong);
}
.tl-item.accent::before { border-color: var(--brand); background: var(--brand); }
.tl-item.good::before { border-color: var(--good); background: var(--good); }
.tl-item.critical::before { border-color: var(--critical); background: var(--critical); }
.tl-time { font-size: var(--t-2xs); color: var(--ink-muted); font-weight: 500; }
.tl-title { font-size: var(--t-sm); font-weight: 580; color: var(--ink); margin-top: 1px; }
.tl-desc { font-size: var(--t-xs); color: var(--ink-3); margin-top: 2px; }

/* --------------------------------------------------------------------------
   List rows
   -------------------------------------------------------------------------- */
.list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--line-soft);
  transition: background var(--dur-1) var(--ease);
}
.list-row:last-child { border-bottom: 0; }
.list-row.clickable { cursor: pointer; }
.list-row.clickable:hover { background: var(--surface-2); }
.list-row .row-title { font-size: var(--t-sm); font-weight: 560; color: var(--ink); }
.list-row .row-sub { font-size: var(--t-xs); color: var(--ink-3); }

/* --------------------------------------------------------------------------
   Modal / drawer / toast
   -------------------------------------------------------------------------- */
.scrim {
  position: fixed; inset: 0; z-index: 200;
  background: var(--overlay);
  backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-2) var(--ease);
}
.scrim.on { opacity: 1; pointer-events: auto; }

.modal {
  position: fixed; z-index: 210;
  left: 50%; top: 50%;
  width: min(560px, calc(100vw - 32px));
  max-height: min(84vh, 760px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-4);
  transform: translate(-50%, -46%) scale(.97);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-2) var(--ease), transform var(--dur-3) var(--ease-out);
}
.modal.on { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.modal.wide { width: min(880px, calc(100vw - 32px)); }
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--line-soft);
}
.modal-body { padding: var(--sp-5); overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}

.drawer {
  position: fixed; z-index: 210; top: 0; right: 0; bottom: 0;
  width: min(560px, 100vw);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--sh-4);
  transform: translateX(102%);
  transition: transform var(--dur-3) var(--ease-out);
}
.drawer.on { transform: none; }
.drawer-head { padding: var(--sp-5); border-bottom: 1px solid var(--line-soft); }
.drawer-body { padding: var(--sp-5); overflow-y: auto; flex: 1; }

.toast-host {
  position: fixed; z-index: 300; right: var(--sp-5); bottom: var(--sp-5);
  display: flex; flex-direction: column; gap: var(--sp-2);
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  min-width: 280px; max-width: 400px;
  padding: 12px var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--sh-3);
  font-size: var(--t-sm);
  pointer-events: auto;
  animation: toast-in var(--dur-3) var(--ease-out);
}
.toast.out { animation: toast-out var(--dur-2) var(--ease) forwards; }
.toast .t-icon { flex-shrink: 0; margin-top: 1px; }
.toast .t-title { font-weight: 600; color: var(--ink); }
.toast .t-desc { color: var(--ink-3); font-size: var(--t-xs); margin-top: 1px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

/* --------------------------------------------------------------------------
   Command palette
   -------------------------------------------------------------------------- */
.cmdk {
  position: fixed; z-index: 260;
  left: 50%; top: 15vh; transform: translateX(-50%) translateY(-12px);
  width: min(620px, calc(100vw - 32px));
  max-height: 60vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-4);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-2) var(--ease), transform var(--dur-3) var(--ease-out);
  overflow: hidden;
}
.cmdk.on { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.cmdk-input {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4);
  border-bottom: 1px solid var(--line-soft);
}
.cmdk-input input {
  flex: 1; border: 0; background: none; outline: none;
  font-size: var(--t-lg); color: var(--ink);
}
.cmdk-list { overflow-y: auto; padding: var(--sp-2); }
.cmdk-group { font-size: var(--t-2xs); font-weight: 620; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); padding: var(--sp-3) var(--sp-3) 6px; }
.cmdk-item {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; padding: 9px var(--sp-3);
  border-radius: var(--r-sm);
  font-size: var(--t-sm); color: var(--ink-2);
  text-align: left;
}
.cmdk-item .ci-icon { color: var(--ink-muted); flex-shrink: 0; }
.cmdk-item[data-active="true"] { background: var(--brand-soft); color: var(--brand-strong); }
.cmdk-item[data-active="true"] .ci-icon { color: var(--brand-strong); }
.cmdk-item .ci-tag { margin-left: auto; font-size: var(--t-2xs); color: var(--ink-muted); }

/* --------------------------------------------------------------------------
   Dropdown menu
   -------------------------------------------------------------------------- */
.menu {
  position: absolute; z-index: 120;
  min-width: 200px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--sh-3);
  opacity: 0; pointer-events: none;
  transform: translateY(-6px) scale(.98);
  transform-origin: top right;
  transition: opacity var(--dur-1) var(--ease), transform var(--dur-2) var(--ease-out);
}
.menu.on { opacity: 1; pointer-events: auto; transform: none; }
.menu-item {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; padding: 8px 10px;
  border-radius: var(--r-xs);
  font-size: var(--t-sm); color: var(--ink-2); text-align: left;
}
.menu-item:hover { background: var(--surface-2); color: var(--ink); }
.menu-item.danger { color: var(--critical-ink); }
.menu-item.danger:hover { background: var(--critical-soft); }
.menu-sep { height: 1px; margin: 5px 0; background: var(--line-soft); }
.menu-label { padding: 8px 10px 4px; font-size: var(--t-2xs); font-weight: 620; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-muted); }

/* --------------------------------------------------------------------------
   Empty state
   -------------------------------------------------------------------------- */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: var(--sp-9) var(--sp-5);
  color: var(--ink-3);
}
.empty .e-icon {
  display: grid; place-items: center;
  width: 52px; height: 52px; margin-bottom: var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface-3); color: var(--ink-muted);
}
.empty .e-title { font-size: var(--t-md); font-weight: 600; color: var(--ink); }
.empty .e-desc { font-size: var(--t-sm); margin-top: 4px; max-width: 340px; }

/* --------------------------------------------------------------------------
   Skeleton
   -------------------------------------------------------------------------- */
.skel {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%;
  animation: skel 1.4s ease infinite;
  border-radius: var(--r-xs);
}
@keyframes skel { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* --------------------------------------------------------------------------
   Misc
   -------------------------------------------------------------------------- */
.dot-status {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent);
}
.pulse-dot { position: relative; }
.pulse-dot::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: currentColor; animation: pulse-ring 2s var(--ease-out) infinite;
}
@keyframes pulse-ring {
  0% { transform: scale(1); opacity: .6; }
  80%, 100% { transform: scale(2.6); opacity: 0; }
}

.notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--critical);
  box-shadow: 0 0 0 2px var(--surface);
}

.gold-rule {
  height: 3px; width: 44px; border-radius: 2px;
  background: linear-gradient(90deg, var(--brand), transparent);
}

.stack-sep > * + * { border-top: 1px solid var(--line-soft); }

@media (max-width: 640px) {
  .modal { border-radius: var(--r-lg); }
  .toast-host { left: var(--sp-4); right: var(--sp-4); bottom: var(--sp-4); }
  .toast { max-width: none; min-width: 0; }
}
