/* ==========================================================================
   Safeharbor — hand-written design system (no build step, Milepost-style)
   Brand palette from brand/tokens.json. Two themes (dark / light / system)
   via semantic tokens — components only ever reference the semantic layer.
   ========================================================================== */

/* ---- brand palette constants (theme-independent) ---- */
:root {
  --p-navy-950: #031022;
  --p-navy-900: #061936;
  --p-navy-800: #0B2448;
  --p-navy-700: #12345F;
  --p-blue-500: #2D8CFF;
  --p-blue-400: #54A8FF;
  --p-cyan-300: #7DDCFF;
  --p-gold-400: #F6C95B;
  --p-mint-300: #62F6B0;
  --p-rose-400: #FF7A85;

  --radius-sm: 14px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---- dark theme (default) — lifted one notch brighter than the original
       abyss-navy, per feedback; still unmistakably 8 West ---- */
:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #081F45;
  --bg-panel: rgba(11, 36, 72, 0.65);
  --bg-topbar: rgba(11, 36, 72, 0.45);
  --bg-solid: #0B2448;
  --bg-raised: #12345F;
  --card: rgba(255, 255, 255, 0.075);
  --card-strong: rgba(255, 255, 255, 0.12);
  --line: rgba(255, 255, 255, 0.16);
  --line-soft: rgba(255, 255, 255, 0.08);

  --text: #EAF3FF;
  --text-strong: #FFFFFF;
  --muted: #AEBED4;
  --muted-strong: #D5E2F5;
  --dim: rgba(174, 190, 212, 0.7);
  --faint: rgba(174, 190, 212, 0.5);

  --accent: #2D8CFF;
  --accent-2: #54A8FF;
  --cyan: #7DDCFF;
  --gold: #F6C95B;
  --mint: #62F6B0;
  --rose: #FF7A85;

  --hover: rgba(255, 255, 255, 0.04);
  --sel: rgba(45, 140, 255, 0.15);
  --sel-ring: rgba(45, 140, 255, 0.4);
  --chip-bg: rgba(255, 255, 255, 0.05);
  --input-bg: rgba(6, 25, 54, 0.7);
  --overlay: rgba(3, 16, 34, 0.7);
  --shadow-card: 0 24px 70px rgba(0, 0, 0, 0.32);
  --bar-off: rgba(255, 255, 255, 0.15);
  --scroll-thumb: #12345F;
  --scroll-track: transparent;

  --msg-tech-bg: rgba(45, 140, 255, 0.07);
  --msg-tech-border: rgba(45, 140, 255, 0.25);
  --note-bg: rgba(246, 201, 91, 0.07);
  --gold-soft-bg: rgba(246, 201, 91, 0.1);
  --gold-soft-border: rgba(246, 201, 91, 0.4);
  --mint-soft-bg: rgba(98, 246, 176, 0.1);
  --accent-soft-bg: rgba(45, 140, 255, 0.2);
  --error-bg: rgba(255, 122, 133, 0.1);
  --error-border: rgba(255, 122, 133, 0.3);
  --scroll-base: #081F45;
}

/* ---- light theme — same bones, daylight surface ---- */
[data-theme="light"] {
  color-scheme: light;
  --bg: #EAF0F9;
  --bg-panel: #FFFFFF;
  --bg-topbar: #FFFFFF;
  --bg-solid: #FFFFFF;
  --bg-raised: #F3F7FD;
  --card: #FFFFFF;
  --card-strong: #F3F7FD;
  --line: rgba(11, 36, 72, 0.14);
  --line-soft: rgba(11, 36, 72, 0.08);

  --text: #0B2448;
  --text-strong: #061936;
  --muted: #51627C;
  --muted-strong: #2A3F5F;
  --dim: rgba(81, 98, 124, 0.8);
  --faint: rgba(81, 98, 124, 0.55);

  --accent: #2D8CFF;
  --accent-2: #1B6FE0;
  --cyan: #0B7BC0;
  --gold: #A66A0B;
  --mint: #0E7A45;
  --rose: #D9303E;

  --hover: rgba(11, 36, 72, 0.05);
  --sel: rgba(45, 140, 255, 0.12);
  --sel-ring: rgba(45, 140, 255, 0.45);
  --chip-bg: rgba(11, 36, 72, 0.04);
  --input-bg: #FFFFFF;
  --overlay: rgba(11, 36, 72, 0.35);
  --shadow-card: 0 18px 50px rgba(11, 36, 72, 0.16);
  --bar-off: rgba(11, 36, 72, 0.15);
  --scroll-thumb: #C3D2EA;
  --scroll-track: transparent;

  --msg-tech-bg: rgba(45, 140, 255, 0.08);
  --msg-tech-border: rgba(45, 140, 255, 0.3);
  --note-bg: rgba(246, 201, 91, 0.16);
  --gold-soft-bg: rgba(246, 201, 91, 0.18);
  --gold-soft-border: rgba(166, 106, 11, 0.4);
  --mint-soft-bg: rgba(14, 122, 69, 0.1);
  --accent-soft-bg: rgba(45, 140, 255, 0.15);
  --error-bg: rgba(217, 48, 62, 0.08);
  --error-border: rgba(217, 48, 62, 0.3);
  --scroll-base: #EAF0F9;
}

/* ---- system theme: follow the OS ---- */
@media (prefers-color-scheme: light) {
  [data-theme="system"] {
    color-scheme: light;
    --bg: #EAF0F9;
    --bg-panel: #FFFFFF;
    --bg-topbar: #FFFFFF;
    --bg-solid: #FFFFFF;
    --bg-raised: #F3F7FD;
    --card: #FFFFFF;
    --card-strong: #F3F7FD;
    --line: rgba(11, 36, 72, 0.14);
    --line-soft: rgba(11, 36, 72, 0.08);
    --text: #0B2448;
    --text-strong: #061936;
    --muted: #51627C;
    --muted-strong: #2A3F5F;
    --dim: rgba(81, 98, 124, 0.8);
    --faint: rgba(81, 98, 124, 0.55);
    --accent: #2D8CFF;
    --accent-2: #1B6FE0;
    --cyan: #0B7BC0;
    --gold: #A66A0B;
    --mint: #0E7A45;
    --rose: #D9303E;
    --hover: rgba(11, 36, 72, 0.05);
    --sel: rgba(45, 140, 255, 0.12);
    --sel-ring: rgba(45, 140, 255, 0.45);
    --chip-bg: rgba(11, 36, 72, 0.04);
    --input-bg: #FFFFFF;
    --overlay: rgba(11, 36, 72, 0.35);
    --shadow-card: 0 18px 50px rgba(11, 36, 72, 0.16);
    --bar-off: rgba(11, 36, 72, 0.15);
    --scroll-thumb: #C3D2EA;
    --scroll-track: transparent;
    --msg-tech-bg: rgba(45, 140, 255, 0.08);
    --msg-tech-border: rgba(45, 140, 255, 0.3);
    --note-bg: rgba(246, 201, 91, 0.16);
    --gold-soft-bg: rgba(246, 201, 91, 0.18);
    --gold-soft-border: rgba(166, 106, 11, 0.4);
    --mint-soft-bg: rgba(14, 122, 69, 0.1);
    --accent-soft-bg: rgba(45, 140, 255, 0.15);
    --error-bg: rgba(217, 48, 62, 0.08);
    --error-border: rgba(217, 48, 62, 0.3);
    --scroll-base: #EAF0F9;
  }
}

/* ==========================================================================
   Base
   ========================================================================== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  transition: background-color 160ms ease, color 160ms ease;
}

::selection { background: rgba(45, 140, 255, 0.35); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 8px; border: 2px solid var(--scroll-base); }
::-webkit-scrollbar-track { background: var(--scroll-track); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; text-align: left; }
img { display: block; }

.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.35rem; height: 1.35rem; padding: 0 .35rem;
  border-radius: 6px; border: 1px solid var(--line);
  background: var(--chip-bg); color: var(--muted); font-size: 11px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
[data-theme="light"] .card { box-shadow: 0 1px 3px rgba(11, 36, 72, 0.06); }
@media (prefers-color-scheme: light) {
  [data-theme="system"] .card { box-shadow: 0 1px 3px rgba(11, 36, 72, 0.06); }
}

.link { color: var(--accent-2); }
.link:hover { color: var(--cyan); }

@keyframes pulse-soft { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.pulse { animation: pulse-soft 1.6s ease-in-out infinite; }

@keyframes row-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   Chrome — shell, sidebar, topbar
   ========================================================================== */
.shell { display: flex; height: 100%; }

.sidebar {
  width: 240px; flex: none; display: flex; flex-direction: column;
  background: var(--bg-panel);
  border-right: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 20px; }
.brand-mark { width: 32px; height: 32px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.brand-sub { font-size: 10.5px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--muted);
  transition: background .1s, color .1s;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.nav-on { background: var(--sel); color: var(--cyan); }
.nav-label { flex: 1; }
.nav-kbd { opacity: 0; transition: opacity .1s; }
.nav-item:hover .nav-kbd { opacity: 1; }

.suite-label {
  padding: 24px 16px 4px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; color: var(--dim);
}
.suite { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }
.suite-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--faint); cursor: not-allowed;
}
.suite-box { width: 14px; height: 14px; border: 1px solid var(--line); border-radius: 4px; }
.suite-name { flex: 1; }
.suite-tag { font-size: 10px; }

.sidebar-foot {
  margin-top: auto; display: flex; align-items: center; gap: 10px;
  padding: 12px; border-top: 1px solid var(--line);
}
.foot-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.foot-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.foot-tenant { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.foot-out { font-size: 11px; color: var(--muted); padding: 4px 8px; border-radius: var(--radius-sm); }
.foot-out:hover { color: var(--text); }

/* theme switcher */
.theme-switch {
  display: flex; gap: 2px; margin: 10px 12px 0; padding: 3px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--chip-bg);
}
.theme-btn {
  flex: 1; display: flex; align-items: center; justify-content: center;
  height: 26px; border-radius: 999px; color: var(--muted);
  transition: background .1s, color .1s;
}
.theme-btn:hover { color: var(--text); }
.theme-btn.theme-on { background: var(--sel); color: var(--cyan); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--line);
  background: var(--bg-topbar);
}
.topbar-flex { flex: 1; }
.search-trigger {
  display: flex; align-items: center; gap: 10px; width: 288px;
  padding: 6px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--chip-bg);
  color: var(--muted); font-size: 13px; transition: border-color .1s, color .1s;
}
.search-trigger:hover { border-color: var(--sel-ring); color: var(--text); }
.search-label { flex: 1; text-align: left; }

.timer-widget {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px; font-size: 12px;
  border: 1px solid var(--line); color: var(--muted); transition: color .1s;
}
.timer-widget:hover { color: var(--text); }
.timer-widget.timer-on {
  border-color: var(--gold-soft-border); background: var(--gold-soft-bg); color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.timer-widget .tw-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }

.content { flex: 1; min-height: 0; overflow-y: auto; }

/* ==========================================================================
   Pages — shared
   ========================================================================== */
.page { max-width: 1152px; margin: 0 auto; padding: 20px; }
.page-narrow { max-width: 720px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.page-title { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.page-sub { margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.page-actions { display: flex; align-items: center; gap: 8px; }
.page-note { margin-top: 12px; padding: 0 4px; font-size: 11.5px; color: var(--dim); }
.backlink { font-size: 12px; color: var(--muted); display: inline-block; margin-bottom: 6px; }
.backlink:hover { color: var(--text); }

.filters { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.filter-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px; font-size: 12px; color: var(--muted);
  transition: background .1s, color .1s;
}
.filter-pill:hover { color: var(--text); }
.filter-pill.pill-on { background: var(--accent-soft-bg); color: var(--cyan); }
.pill-count { color: var(--dim); }
.pill-kbd { margin-left: 2px; }
@media (max-width: 760px) { .pill-kbd { display: none; } }

.empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 56px 16px; text-align: center; font-size: 13px; color: var(--muted);
}
.empty-mark { width: 56px; height: 56px; opacity: .6; }
.accent { color: var(--cyan); }

.keyhints { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 0 4px; font-size: 11.5px; color: var(--dim); flex-wrap: wrap; }
.keyhints-right { margin-left: auto; }

/* ==========================================================================
   Ticket rows (queue + client)
   ========================================================================== */
.list { overflow: hidden; }

.trow {
  display: grid;
  grid-template-columns: 22px 64px 1fr auto auto 110px 52px;
  align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
  transition: background .1s;
  animation: row-in 160ms ease-out;
}
.trow:last-child { border-bottom: 0; }
.trow:not(.trow-head):hover { background: var(--hover); }
.trow.trow-sel { background: var(--sel); box-shadow: inset 0 0 0 1px var(--sel-ring); }
.trow-head {
  padding: 8px 16px; background: var(--chip-bg);
  font-size: 10.5px; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; color: var(--dim);
  animation: none;
}
.trow-num { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.trow-main { min-width: 0; display: flex; flex-direction: column; }
.trow-subject { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trow-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trow-age { text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* status chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--chip-bg); font-size: 12px;
}
.chip-dot { width: 6px; height: 6px; border-radius: 50%; }
.dot-blue { background: var(--accent); }
.dot-cyan { background: var(--cyan); }
.dot-gold { background: var(--gold); }
.dot-mint { background: var(--mint); }
.chip-text-blue { color: var(--accent-2); }
.chip-text-cyan { color: var(--cyan); }
.chip-text-gold { color: var(--gold); }
.chip-text-mint { color: var(--mint); }

/* priority glyph */
.pri { display: inline-flex; align-items: center; gap: 6px; }
.pri-bars { display: inline-flex; align-items: flex-end; gap: 2px; }
.pri-bar { width: 3px; border-radius: 2px; display: inline-block; }
.bar-muted { background: var(--muted); }
.bar-blue { background: var(--accent-2); }
.bar-gold { background: var(--gold); }
.bar-rose { background: var(--rose); }
.bar-off { background: var(--bar-off); }
.pri-label { font-size: 12px; color: var(--muted); }

/* SLA lamp */
.sla { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-variant-numeric: tabular-nums; }
.sla-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.sla-healthy { color: var(--mint); }
.sla-at_risk { color: var(--gold); }
.sla-breached { color: var(--rose); }
.sla-met { color: var(--mint); opacity: .7; }

/* avatar */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 10px; font-weight: 600; color: #0B2448;
  flex: none;
}
.avatar-none { border: 1px dashed var(--line); color: var(--muted); background: transparent; }

/* ==========================================================================
   Ticket detail
   ========================================================================== */
.ticket-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ticket-num { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ticket-subject { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.ticket-sub { margin-top: 4px; font-size: 12.5px; color: var(--muted); }

.ticket-grid { display: grid; grid-template-columns: 1fr 290px; gap: 20px; margin-top: 16px; }
@media (max-width: 900px) { .ticket-grid { grid-template-columns: 1fr; } }

.thread { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.msg { max-width: 85%; padding: 10px 14px; }
.msg-tech { margin-left: auto; border-color: var(--msg-tech-border); background: var(--msg-tech-bg); }
.msg-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 11.5px; }
.msg-author { font-weight: 500; color: var(--text); }
.msg-author-tech { font-weight: 500; color: var(--cyan); }
.msg-author-note { font-weight: 500; color: var(--gold); }
.msg-when { color: var(--dim); }
.msg-body { font-size: 13px; line-height: 1.55; color: var(--muted-strong); white-space: pre-wrap; }
.msg-note {
  padding: 10px 14px; border-left: 2px solid var(--gold);
  background: var(--note-bg); border-radius: 8px;
}
.msg-system { padding: 4px 0; text-align: center; font-size: 11.5px; font-style: italic; color: var(--dim); }

.reply { padding: 12px; margin-top: 4px; }
.reply textarea {
  width: 100%; resize: none; background: transparent; border: 0;
  color: var(--text); font: inherit; font-size: 13.5px; line-height: 1.55;
}
.reply textarea:focus { outline: none; }
.reply textarea::placeholder { color: var(--dim); }
.reply-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.reply-hint { font-size: 11px; color: var(--dim); }

/* right rail */
.rail { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.rail-label {
  padding: 0 4px; font-size: 11px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
.rail-label:not(:first-child) { margin-top: 8px; }
.rail-stack { display: flex; flex-direction: column; gap: 8px; }
.rail-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--chip-bg);
  transition: border-color .1s;
}
.rail-btn:hover { border-color: var(--sel-ring); }
.rail-btn .kbd { opacity: 0; transition: opacity .1s; }
.rail-btn:hover .kbd { opacity: 1; }
.rail-k { display: block; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.rail-v { display: block; margin-top: 2px; }
.rail-card { padding: 10px 14px; font-size: 13px; }
.rail-note { display: block; margin-top: 2px; font-size: 11.5px; color: var(--muted); }
.rail-suite { font-size: 12px; line-height: 1.6; color: var(--muted); }
.rail-suite p { display: flex; align-items: center; gap: 8px; }
.rail-suite p + p { margin-top: 6px; }
.suite-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }
.assignee-cell { display: inline-flex; align-items: center; gap: 8px; }
.assignee-name { font-size: 13px; }
.team-row { display: flex; gap: 6px; padding: 0 4px; }
.timer-btn { justify-content: center; font-size: 13px; }
.timer-btn.timer-on { border-color: var(--gold-soft-border); background: var(--gold-soft-bg); color: var(--gold); }

/* ==========================================================================
   Clients
   ========================================================================== */
.crow {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 16px; border-bottom: 1px solid var(--line-soft);
  transition: background .1s;
}
.crow:last-child { border-bottom: 0; }
.crow:hover { background: var(--hover); }
.crow.crow-sel { background: var(--sel); box-shadow: inset 0 0 0 1px var(--sel-ring); }
.health-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.health-dot.big { width: 10px; height: 10px; }
.crow-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.crow-name { font-size: 13.5px; }
.crow-sub { font-size: 12px; color: var(--muted); }
.tier {
  padding: 2px 10px; border-radius: 999px; font-size: 11px;
  background: var(--chip-bg); color: var(--muted);
}
.tier-premium { background: var(--gold-soft-bg); color: var(--gold); }
.crow-open { width: 80px; text-align: right; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* client stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0 20px; }
@media (max-width: 900px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { padding: 12px 16px; }
.stat-k { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.stat-v { margin-top: 4px; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-warn { color: var(--gold); }
.stat-good { color: var(--mint); }
.stat-dim { color: var(--muted); }
.stat-hint { font-size: 10.5px; color: var(--faint); }

.rail-list { overflow: hidden; }
.rail-list-item { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); }
.rail-list-item:last-child { border-bottom: 0; }
.rail-list-name { font-size: 13px; }
.rail-list-sub { font-size: 11.5px; color: var(--muted); }

/* ==========================================================================
   Time page
   ========================================================================== */
.page-time { max-width: 896px; }
.timer-card {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 20px; margin-bottom: 20px;
}
.timer-card[data-state="on"] { border-color: var(--gold-soft-border); }
.timer-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--faint); flex: none; }
.timer-card[data-state="on"] .timer-dot { background: var(--gold); animation: pulse-soft 1.6s ease-in-out infinite; }
.timer-info { flex: 1; min-width: 0; }
.timer-title { font-size: 13.5px; }
.timer-sub { font-size: 11.5px; color: var(--muted); }
.timer-clock { font-size: 24px; font-weight: 600; color: var(--gold); font-variant-numeric: tabular-nums; }
.timer-clock:empty { display: none; }

.sugg-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
}
.sugg-row:last-child { border-bottom: 0; }
.sugg-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); flex: none; }
.sugg-main { flex: 1; min-width: 0; }
.sugg-title { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sugg-reason { font-size: 11.5px; color: var(--muted); }

.entry-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--line-soft);
}
.entry-row:last-child { border-bottom: 0; }
.entry-min { width: 56px; text-align: right; font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
.entry-main { flex: 1; min-width: 0; }
.entry-note { font-size: 13px; color: var(--muted-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-ticket { font-size: 11.5px; }
.entry-badge {
  padding: 2px 8px; border-radius: 999px; font-size: 10.5px;
  background: var(--chip-bg); color: var(--muted);
}
.badge-billable { background: var(--mint-soft-bg); color: var(--mint); }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff; font-size: 13.5px; font-weight: 500;
  text-align: center; transition: background .1s;
}
.btn-primary:hover { background: var(--accent-2); color: #fff; }
.btn-primary:disabled { opacity: .4; cursor: default; }
.btn-sm { padding: 6px 16px; font-size: 13px; }
.btn-gold {
  padding: 6px 16px; border-radius: var(--radius-sm);
  background: var(--gold); color: #0B2448;
  font-size: 13px; font-weight: 500; transition: filter .1s;
}
.btn-gold:hover { filter: brightness(1.05); }
.btn-chip {
  padding: 4px 12px; border-radius: var(--radius-sm);
  background: var(--accent-soft-bg); color: var(--cyan); font-size: 12px;
  transition: background .1s;
}
.btn-chip:hover { background: var(--sel); }
.btn-link { padding: 4px 8px; font-size: 12px; color: var(--muted); }
.btn-link:hover { color: var(--text); }
.btn-ghost {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--chip-bg);
  font-size: 13.5px; transition: background .1s;
}
.btn-ghost:hover { background: var(--hover); }
.btn-ghost:disabled { opacity: .6; cursor: not-allowed; }
.btn-danger {
  padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--error-border); background: var(--error-bg);
  color: var(--rose); font-size: 13px; transition: background .1s;
}
.btn-danger:hover { background: var(--error-border); }
.sso-mark { width: 16px; height: 16px; }

/* ==========================================================================
   Forms
   ========================================================================== */
.form-card { padding: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span-2 { grid-column: span 1; } }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.field input,
.field select,
.field textarea {
  padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--input-bg);
  color: var(--text); font: inherit; font-size: 13.5px;
}
.field input:focus,
.field select:focus,
.field textarea:focus { outline: none; border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 90px; }
.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.form-error {
  margin-bottom: 12px; padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--error-bg); border: 1px solid var(--error-border);
  color: var(--rose); font-size: 12.5px;
}
.form-ok {
  margin-bottom: 12px; padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--mint-soft-bg); border: 1px solid var(--mint);
  color: var(--mint); font-size: 12.5px;
}
.swatches { display: flex; gap: 8px; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: border-color .1s, transform .1s;
}
.swatch:hover { transform: scale(1.1); }
.swatch.swatch-on { border-color: var(--text); }

/* user rows (Team page) */
.urow {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
}
.urow:last-child { border-bottom: 0; }
.urow-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.urow-name { font-size: 13.5px; }
.urow-sub { font-size: 12px; color: var(--muted); }
.role-badge {
  padding: 2px 10px; border-radius: 999px; font-size: 11px;
  background: var(--chip-bg); color: var(--muted);
}
.role-owner, .role-admin { background: var(--accent-soft-bg); color: var(--cyan); }
.urow-inactive { opacity: .5; }

/* demo cleanup card */
.demo-card {
  margin-top: 20px; padding: 14px 16px;
  border: 1px dashed var(--gold-soft-border); border-radius: var(--radius-md);
  background: var(--gold-soft-bg);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.demo-text { flex: 1; min-width: 220px; font-size: 12.5px; color: var(--muted-strong); line-height: 1.5; }

/* ==========================================================================
   Login
   ========================================================================== */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100%; padding: 16px; }
.login-wrap { width: 100%; max-width: 384px; }
.login-head { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 32px; }
.login-mark { width: 64px; height: 64px; margin-bottom: 16px; }
.login-name { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.login-tag { margin-top: 4px; font-size: 13px; color: var(--muted); }
.login-card { padding: 20px; }
.login-error {
  margin-bottom: 12px; padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--error-bg); border: 1px solid var(--error-border);
  color: var(--rose); font-size: 12.5px;
}
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.login-form input {
  padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--input-bg);
  color: var(--text); font: inherit; font-size: 13.5px;
}
.login-form input:focus { outline: none; border-color: var(--accent); }
.login-form .btn-primary { margin-top: 4px; justify-content: center; }
.login-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0; font-size: 11px; color: var(--dim);
}
.login-divider span { flex: 1; height: 1px; background: var(--line); }
.login-foot { margin-top: 20px; text-align: center; font-size: 11.5px; line-height: 1.6; color: var(--dim); }
.login-foot code { padding: 1px 6px; border-radius: 4px; background: var(--chip-bg); color: var(--gold); }
.login-theme { position: fixed; top: 14px; right: 14px; width: auto; margin: 0; }

/* ==========================================================================
   Palette + toasts
   ========================================================================== */
.palette-overlay {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 14vh;
  background: var(--overlay); backdrop-filter: blur(4px);
}
.palette {
  position: relative; width: 580px; max-width: 92vw; overflow: hidden;
  background: var(--bg-solid); box-shadow: var(--shadow-card);
  border: 1px solid var(--line); border-radius: var(--radius-md);
}
.palette-input-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  color: var(--cyan);
}
.palette-input {
  flex: 1; background: transparent; border: 0; color: var(--text);
  font: inherit; font-size: 14px;
}
.palette-input:focus { outline: none; }
.palette-input::placeholder { color: var(--dim); }
.palette-list { max-height: 46vh; overflow-y: auto; padding: 6px 0; }
.palette-group {
  padding: 10px 16px 4px; font-size: 10.5px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--dim);
}
.palette-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 8px 16px; font-size: 13px; color: var(--muted-strong);
}
.palette-item.sel { background: var(--sel); color: var(--text); }
.palette-item-main { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item-hint { font-size: 12px; color: var(--dim); max-width: 40%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.palette-foot {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; border-top: 1px solid var(--line);
  font-size: 11px; color: var(--dim); flex-wrap: wrap;
}
.palette-foot .right { margin-left: auto; }
.palette-empty { padding: 32px 16px; text-align: center; font-size: 13px; color: var(--muted); }

.toasts {
  position: fixed; bottom: 16px; right: 16px; z-index: 50;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 8px 14px; font-size: 13px; color: var(--text);
  background: var(--bg-solid); border: 1px solid var(--sel-ring);
  border-radius: var(--radius-md); box-shadow: var(--shadow-card);
  animation: row-in 160ms ease-out;
}
