/* Alara HQ - design tokens + components. Light first, dark via prefers-color-scheme. */
:root {
  --paper: #F8F7F4;
  --surface: #FFFFFF;
  --surface-2: #EFEDE8;
  --line: #E0DDD5;
  --ink: #131A23;
  --ink-2: #57606D;
  --ink-3: #828C9B;
  --accent: #2F664B;
  --accent-soft: #DFEDE5;
  --accent-ink: #FFFFFF;
  --accent-hover: #26543D;
  --tom: #2F3A8F;
  --tom-bg: #EEF0FA;
  --good: #1F7A4D;
  --good-bg: #DDF2E6;
  --warn: #B8720A;
  --warn-bg: #FBEDD2;
  --bad: #B3261E;
  --bad-bg: #F9DEDC;
  --head: "Bricolage Grotesque", "Helvetica Neue", Arial, sans-serif;
  --body: "Source Sans 3", "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(28, 23, 32, .06), 0 8px 24px -12px rgba(28, 23, 32, .18);
  --focus: 0 0 0 3px rgba(47, 102, 75, .25);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0E131A;
    --surface: #141A22;
    --surface-2: #1A222C;
    --line: #263039;
    --ink: #EFF2F5;
    --ink-2: #A7B1BF;
    --ink-3: #75808E;
    --accent: #55B084;
    --accent-soft: #1B3529;
    --accent-ink: #08100B;
    --accent-hover: #6FC29A;
    --tom: #B7C0F7;
    --tom-bg: #252B55;
    --good: #6CCB98;
    --good-bg: #173426;
    --warn: #E8AD55;
    --warn-bg: #3A2B12;
    --bad: #F29189;
    --bad-bg: #43201E;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
    --focus: 0 0 0 3px rgba(85, 176, 132, .35);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--paper); }
body {
  margin: 0; background: var(--paper); color: var(--ink); font-family: var(--body);
  font-size: 16px; line-height: 1.5; overflow-x: hidden; overflow-wrap: anywhere;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--head); margin: 0; line-height: 1.15; letter-spacing: -.01em; }
.h1 { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem); font-weight: 800; }
.h2 { font-size: 1.15rem; font-weight: 700; }
.h3 { font-size: 1rem; font-weight: 700; margin: .9rem 0 .3rem; }
p { margin: .35rem 0; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.muted-inline { color: var(--ink-2); font-family: var(--body); font-weight: 400; font-size: .95rem; margin-left: .6rem; }
.small { font-size: .85rem; }
.bad { color: var(--bad); }
.good { color: var(--good); }
.warn-ink { color: var(--warn); }
.tom-ink { color: var(--tom); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: .92em; }
.nowrap { white-space: nowrap; }
.wrap { white-space: normal; min-width: 14rem; }
.wrap-full { white-space: normal; min-width: 0; }
.wrap-lg { min-width: 24rem; max-width: 60ch; overflow-wrap: anywhere; }
.stack-page { display: grid; gap: 14px; }
.stack-page > div { min-width: 0; }
@media (max-width: 600px) { .wrap { min-width: 10rem; } }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > label { flex: 1 1 10rem; min-width: 0; }
.inline { display: inline; }
.list { margin: .3rem 0; padding-left: 1.1rem; }
.list li { margin: .25rem 0; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 10px; }
.section-title .h2 { margin: 0; }
.eyebrow { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 700; }

/* ---------- shell ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 10px clamp(14px, 3vw, 32px); display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-family: var(--head); font-weight: 800; font-size: 1.05rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: #fff; display: inline-grid; place-items: center; font-family: var(--head); font-weight: 800; font-size: 1.05rem; flex: none; }
.brand-sub { color: var(--ink-3); font-weight: 600; font-family: var(--body); font-size: .85rem; margin-left: 2px; }
.nav { display: flex; gap: 2px; flex-wrap: nowrap; flex: 0 0 auto; min-width: 0; }
.nav a { color: var(--ink-2); padding: 8px 11px; border-radius: 8px; font-weight: 600; font-size: .93rem; line-height: 1.2; min-height: 40px; display: inline-flex; align-items: center; gap: 6px; }
.nav a.active { color: var(--ink); background: var(--surface-2); }
.nav a:hover { text-decoration: none; color: var(--ink); }
.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: 1 1 auto; min-width: 0; flex-wrap: wrap; justify-content: flex-end; }
.topbar-right .chip { min-width: 0; }
.topbar-right .chip-text, .topbar-right .chip-tom-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
@media (max-width: 1300px) { .chip-working { max-width: 12rem; } .chip-tom-text .long { display: none; } }
.logout { display: flex; align-items: center; gap: 8px; margin: 0; }
.who { color: var(--ink-2); font-size: .9rem; font-weight: 600; }
.badge { display: inline-block; min-width: 1.25rem; padding: 0 .4rem; border-radius: 999px; background: var(--accent); color: #fff; font-family: var(--mono); font-size: .7rem; text-align: center; line-height: 1.25rem; }
.page { max-width: 1180px; margin: 0 auto; padding: 20px clamp(14px, 3vw, 32px) 80px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { color: var(--ink-2); font-size: .93rem; margin: 4px 0 0; }
.page-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.today-date { color: var(--ink-2); font-weight: 600; font-size: .92rem; }
@media (max-width: 600px) {
  .nav { order: 3; width: 100%; flex: none; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; padding: 8px 10px; }
  .who { display: none; }
  .page { padding-top: 14px; }
  .page-head { margin-bottom: 14px; }
}

/* ---------- chips / pills ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; line-height: 1.3; max-width: 100%; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.chip-good { background: var(--good-bg); color: var(--good); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-bad { background: var(--bad-bg); color: var(--bad); }
.chip-tom { background: var(--tom-bg); color: var(--tom); }
.chip-accent { background: var(--accent-soft); color: var(--accent); }
.chip .num { font-size: .8rem; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; vertical-align: middle; line-height: 1.4; }
.pill-p1 { background: var(--accent-soft); color: var(--accent); }
.pill-p2 { background: var(--warn-bg); color: var(--warn); }
.pill-p3 { background: var(--surface-2); color: var(--ink-2); }
.pill-good { background: var(--good-bg); color: var(--good); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-tom { background: var(--tom-bg); color: var(--tom); }
.pill-open { background: var(--surface-2); color: var(--ink-2); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.grade-chip { display: inline-flex; align-items: baseline; gap: 1px; padding: 3px 9px; border-radius: 999px; font-family: var(--mono); font-weight: 600; font-size: .85rem; line-height: 1.3; }
.grade-chip small { font-size: .7em; opacity: .75; }
.grade-5, .grade-4 { background: var(--good-bg); color: var(--good); }
.grade-3 { background: var(--warn-bg); color: var(--warn); }
.grade-2, .grade-1, .grade-0 { background: var(--bad-bg); color: var(--bad); }
.grade-none { background: var(--surface-2); color: var(--ink-3); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; min-width: 0; }
.card > .h2 { margin-bottom: 10px; }
.card-tom { background: var(--tom-bg); border-color: transparent; border-left: 4px solid var(--tom); color: var(--ink); }
.card-tom .h2, .card-tom .eyebrow { color: var(--tom); }
.card-flat { box-shadow: none; }
.card-muted { color: var(--ink-2); }

/* ---------- forms ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: var(--ink-2); font-weight: 700; min-width: 0; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); cursor: pointer; min-height: 40px; }
input, textarea, select {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 12px; width: 100%; max-width: 100%; min-height: 42px; line-height: 1.35;
}
textarea { resize: vertical; min-height: 84px; }
select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
input[type="checkbox"] { width: 24px; height: 24px; min-height: 0; padding: 0; accent-color: var(--good); border-radius: 6px; flex: none; cursor: pointer; }
input[type="date"], input[type="time"], input[type="number"] { font-family: var(--mono); font-size: .92rem; }
input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-btn { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.file-btn .file-name { color: var(--ink-3); font-size: .82rem; font-weight: 600; max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin: 0; min-width: 0; }
legend { padding: 0 6px; }
.btn {
  font: inherit; font-weight: 700; font-size: .92rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: var(--radius-sm); padding: 9px 14px; min-height: 40px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px; line-height: 1.2; text-decoration: none; max-width: 100%;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn-sm { padding: 7px 12px; font-size: .86rem; min-height: 36px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; }
.btn-warn { border-color: var(--warn); color: var(--warn); background: var(--warn-bg); }
.btn-warn:hover { background: var(--warn-bg); filter: brightness(.97); }
.btn-good { border-color: var(--good); color: var(--good); background: var(--good-bg); }
.btn-tom { background: var(--tom); border-color: var(--tom); color: #fff; }
.btn-tom:hover { background: #27317a; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn-icon { width: 40px; padding: 0; }
@media (max-width: 600px) { .btn { min-height: 42px; } .btn-sm { min-height: 40px; } }

/* ---------- flashes ---------- */
.flash { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 12px; font-weight: 600; border: 1px solid var(--line); background: var(--surface); }
.flash-good { background: var(--good-bg); color: var(--good); border-color: transparent; }
.flash-bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.flash-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.flash-info { background: var(--tom-bg); color: var(--tom); border-color: transparent; }

/* ---------- layout: two columns ---------- */
.cols { display: grid; grid-template-columns: 1.25fr .9fr; gap: 14px 18px; align-items: start; }
.cols > * { min-width: 0; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }

/* ---------- day / dashboard ---------- */
.date-switch { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.date-switch input[type="date"] { width: auto; min-height: 40px; padding: 6px 10px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; display: flex; flex-direction: column; gap: 3px; box-shadow: var(--shadow); min-width: 0; }
.stat .num { font-size: 1.25rem; font-weight: 600; }
.stat-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 700; }

/* briefing box */
.briefing-box .eyebrow { margin-bottom: 6px; }
.briefing-text { white-space: pre-wrap; font-size: 1.02rem; margin: 0 0 12px; }
.briefing-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.briefing-reply { margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(47, 58, 143, .18); }
.briefing-reply textarea { background: var(--surface); }
.briefing-reply-sent { background: var(--surface); border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 10px; }

/* clock row */
.clock-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.clock-row form { display: flex; gap: 8px; flex-wrap: wrap; flex: 1 1 16rem; min-width: 0; align-items: center; }
.clock-row form input { flex: 1 1 12rem; min-width: 0; }
.clock-note { color: var(--ink-2); font-size: .9rem; }

/* attention strip */
.attention { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.attention a, .attention span.chip { text-decoration: none; }
.attention a.chip:hover { filter: brightness(.96); }

/* task list */
.tasks-card { padding: 0; overflow: hidden; }
.tasks-card .tasks-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tasks-wrap { position: relative; }
.tasks-wrap.gated .task-list { opacity: .38; pointer-events: none; filter: saturate(.4); user-select: none; }
.gate-overlay { position: absolute; inset: 0; display: flex; align-items: flex-start; justify-content: center; padding-top: 56px; pointer-events: none; z-index: 2; }
.gate-overlay span { background: var(--tom); color: #fff; font-weight: 700; padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow); font-family: var(--head); }
.task-list { list-style: none; margin: 0; padding: 0; }
.task { display: grid; grid-template-columns: 32px 1fr; gap: 4px 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task-running { background: color-mix(in srgb, var(--tom-bg) 45%, var(--surface)); }
.task-check { grid-row: 1 / span 3; padding-top: 2px; }
.task-check form { margin: 0; }
.check-btn { width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--ink-3); background: transparent; cursor: pointer; padding: 0; display: grid; place-items: center; color: transparent; flex: none; position: relative; }
.check-btn::before { content: ""; position: absolute; inset: -8px; }
.check-btn.is-done { background: var(--good); border-color: var(--good); color: #fff; }
.check-btn svg { width: 14px; height: 14px; }
.check-btn[disabled] { cursor: default; opacity: .7; }
.task-main { min-width: 0; }
.task-top { display: flex; justify-content: space-between; gap: 8px 12px; align-items: flex-start; flex-wrap: wrap; }
.task-title { font-family: var(--head); font-size: 1.08rem; font-weight: 700; margin: 0; line-height: 1.25; flex: 1 1 14rem; min-width: 0; }
.task-done .task-title { color: var(--ink-3); text-decoration: line-through; text-decoration-thickness: 1px; }
.task-side { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
.task-why { color: var(--ink-2); font-size: .95rem; margin: 4px 0 0; }
.task-dll { font-size: .95rem; margin: 4px 0 0; }
.task-dll strong { font-weight: 700; color: var(--ink); }
.task-meta { display: flex; gap: 8px 14px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.task-meta form { margin: 0; }
.elapsed { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: .92rem; color: var(--ink-2); }
.elapsed.is-running { color: var(--tom); font-weight: 600; }
.elapsed .est { color: var(--ink-3); }
.grade-line { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; margin-top: 10px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: .93rem; }
.grade-line .note { flex: 1 1 12rem; color: var(--ink-2); }

details > summary { cursor: pointer; font-weight: 700; color: var(--ink-2); list-style: none; padding: 6px 0; min-height: 36px; display: flex; align-items: center; gap: 6px; font-size: .9rem; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "+"; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: var(--surface-2); font-family: var(--mono); font-size: .85rem; }
details[open] > summary::before { content: "\2013"; }
details > form, details > .note-item { margin-top: 10px; }
.note-box, .edit-box { margin-top: 8px; }
.note-item { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 8px; }
.note-item p { margin: 4px 0; }
.tom-reply { color: var(--tom); font-weight: 600; }

/* comment threads */
.thread { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.comment { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; border: 1px solid transparent; }
.comment p { margin: 4px 0 0; white-space: pre-wrap; }
.comment-tom { background: var(--tom-bg); color: var(--ink); border-left: 4px solid var(--tom); }
.comment-tom .comment-meta strong { color: var(--tom); }
.comment-new { box-shadow: 0 0 0 2px var(--accent); }
.comment-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .88rem; }
.comment-meta strong { font-weight: 700; }
.attachments { margin: 6px 0 0; padding-left: 1rem; font-size: .9rem; }
.compose { margin-top: 4px; }
.compose textarea { min-height: 64px; margin-bottom: 8px; }
.compose-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.compose-row .file-btn { flex: 0 1 auto; min-width: 0; margin-right: auto; }
.report { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 10px; border-left: 4px solid var(--good); }
.report-late { border-left-color: var(--bad); }
.countdown { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 600; }

/* coming up */
.upcoming { list-style: none; margin: 0; padding: 0; }
.upcoming li { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
.upcoming li:last-child { border-bottom: 0; }

/* ratings */
.score-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.score-chip { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 8px; border-radius: var(--radius-sm); min-width: 44px; background: var(--surface-2); }
.score-chip .d { font-size: .65rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700; }
.score-chip .v { font-family: var(--mono); font-weight: 600; font-size: .92rem; }
.score-chip.s-good { background: var(--good-bg); color: var(--good); }
.score-chip.s-warn { background: var(--warn-bg); color: var(--warn); }
.score-chip.s-bad { background: var(--bad-bg); color: var(--bad); }
.score-chip.s-good .d, .score-chip.s-warn .d, .score-chip.s-bad .d { color: inherit; opacity: .75; }
.spark { display: block; max-width: 100%; height: auto; }
.spark-axis { stroke: var(--line); stroke-width: 1; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linejoin: round; }
.spark-dot { fill: var(--accent); }
.spark-wide { width: 100%; max-width: 360px; height: auto; }

/* messages */
.messages-card .thread { max-height: 32rem; overflow-y: auto; padding-right: 2px; }

/* ---------- team ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 14px; }
.person { color: var(--ink); display: block; }
.person:hover { text-decoration: none; border-color: var(--accent); }
.person-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.person-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.person-stats > div { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; margin-top: 12px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--good); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.card.table-wrap, .card > .table-wrap { margin-left: -16px; margin-right: -16px; width: calc(100% + 32px); padding: 0 16px; }
.card.table-wrap { margin: 0 0 14px; width: auto; padding: 4px 16px; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
th { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 700; }
th.num, td.num { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
td .inline { margin-right: 4px; }

/* ---------- briefing page ---------- */
.briefing .comment-meta { justify-content: space-between; margin-bottom: 6px; }
.prose { overflow-wrap: anywhere; }
.prose h1, .prose h2, .prose h3 { margin: .9rem 0 .3rem; font-size: 1.05rem; }
.prose table { margin: .5rem 0; display: block; overflow-x: auto; max-width: 100%; }
.prose pre { overflow-x: auto; background: var(--surface-2); padding: 10px; border-radius: var(--radius-sm); }
.prose code { font-family: var(--mono); font-size: .85em; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.run-tom { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.run-tom select { width: auto; min-width: 10rem; flex: 1 1 10rem; }

/* ---------- login ---------- */
.login-wrap { max-width: 24rem; margin: clamp(1.5rem, 8vh, 5rem) auto 0; }
.login-wrap .brand { margin-bottom: 18px; }
.login-wrap .h1 { margin-bottom: 4px; }
.login-wrap .card { padding: 20px; margin-top: 16px; }

/* ---------- settings ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 14px; }

/* ---------- top bar: working-on chip ---------- */
.chip-working { max-width: 16rem; }
.chip-working .chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chip-working:hover { text-decoration: none; }
@media (max-width: 600px) { .chip-working { max-width: 11rem; } }

/* ---------- team chat ---------- */
.layout { display: flex; align-items: flex-start; max-width: 1540px; margin: 0 auto; }
.layout > .page { flex: 1 1 auto; min-width: 0; max-width: 1180px; }
.chat-toggle { position: relative; gap: 6px; }
.chat-toggle .badge { position: absolute; top: -6px; right: -6px; }
.chat {
  display: flex; flex-direction: column; flex: 0 0 340px; width: 340px; position: sticky; top: var(--topbar-h, 61px);
  height: calc(100vh - var(--topbar-h, 61px)); background: var(--surface); border-left: 1px solid var(--line); min-width: 0;
}
body.chat-closed .chat { display: none; }
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.chat-body { flex: 1 1 auto; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; scroll-behavior: smooth; }
.chat-msg { max-width: 88%; align-self: flex-start; background: var(--surface-2); border-radius: 10px; padding: 8px 11px; font-size: .93rem; }
.chat-msg.is-tom { background: var(--tom-bg); border-left: 4px solid var(--tom); }
.chat-msg.is-tom .chat-meta strong { color: var(--tom); }
.chat-msg.is-mine { align-self: flex-end; background: var(--accent-soft); }
.chat-msg.is-new { box-shadow: 0 0 0 2px var(--accent); }
.chat-meta { display: flex; gap: 8px; align-items: baseline; font-size: .8rem; }
.chat-meta time { color: var(--ink-3); font-family: var(--mono); font-size: .72rem; }
.chat-text { margin: 2px 0 0; white-space: pre-wrap; }
.mention { color: var(--accent); font-weight: 700; background: var(--accent-soft); border-radius: 4px; padding: 0 3px; }
.chat-msg.is-mine .mention { background: var(--surface); }
.chat-compose { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); align-items: flex-end; }
.chat-compose textarea { min-height: 44px; flex: 1 1 auto; }
.chat-toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px; font-weight: 700; font-size: .9rem; box-shadow: var(--shadow); z-index: 40; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
@media (max-width: 860px) {
  .chat { position: fixed; inset: 0; width: auto; height: 100%; height: 100dvh; flex: none; z-index: 30; border-left: 0; }
  body.chat-open { overflow: hidden; }
  .chat-toggle-label { display: none; }
  .chat-toggle { width: 40px; padding: 0; }
}
@media (min-width: 861px) { .chat-close { display: none; } }

/* ---------- v3: branding ---------- */
.logo-pill { display: inline-flex; align-items: center; }
.logo { height: 28px; width: auto; max-width: 220px; display: block; image-rendering: auto; }
.logo-fallback { font-family: var(--head); font-weight: 800; color: #fff; font-size: 1.05rem; letter-spacing: -.01em; white-space: nowrap; }
.logo-fallback em { color: var(--accent); font-style: normal; }
.hq-chip { font-family: var(--head); font-weight: 800; padding: 3px 8px; font-size: .75rem; }
.brand-mark { display: none; }


/* ---------- v3: login front door ---------- */
body.is-front { background: #0A0E14; }
body.is-front .topbar { display: none; }
body.is-front .layout { max-width: none; }
body.is-front .page { max-width: none; padding: 0; }
.front { display: grid; grid-template-columns: 58fr 42fr; min-height: 100vh; min-height: 100dvh; background: #0A0E14; }
.front-brand { background: #0A0E14; color: #fff; padding: clamp(28px, 6vw, 96px); display: flex; flex-direction: column; gap: 36px; justify-content: space-between; font-family: "Sora", var(--head); }
.front-eyebrow { font-family: "Sora", var(--head); font-weight: 700; font-size: .8rem; letter-spacing: .18em; text-transform: uppercase; color: #828C9B; margin-bottom: 14px; }
.front-hq { display: flex; align-items: center; gap: clamp(12px, 1.5vw, 22px); flex-wrap: wrap; margin: 0; }
.front-logo { height: clamp(80px, 12vw, 150px); width: auto; display: block; }
/* text -> logo morph: the words show first, then dissolve into the real wordmark */
.morph { position: relative; display: inline-grid; align-items: center; }
.morph > * { grid-area: 1 / 1; }
.morph-text { font-family: "Sora", var(--head); font-weight: 800; font-size: clamp(2.6rem, 1.2rem + 5vw, 5.4rem); line-height: .98; letter-spacing: -.035em; color: #fff; white-space: nowrap; animation: morph-out 1.1s cubic-bezier(.6,0,.2,1) 1.4s forwards; }
.morph-logo { opacity: 0; transform: scale(.92); filter: blur(10px); animation: morph-in 1.1s cubic-bezier(.6,0,.2,1) 1.55s forwards; }
@keyframes morph-out { 0% { opacity: 1; transform: none; filter: blur(0); letter-spacing: -.035em; } 100% { opacity: 0; transform: scale(1.06); filter: blur(14px); letter-spacing: .08em; } }
@keyframes morph-in { 0% { opacity: 0; transform: scale(.92); filter: blur(10px); } 100% { opacity: 1; transform: none; filter: blur(0); } }
@media (prefers-reduced-motion: reduce) { .morph-text { display: none; } .morph-logo { opacity: 1; transform: none; filter: none; animation: none; } }
.front-hq-chip { font-family: "Sora", var(--head); font-weight: 800; font-size: clamp(2rem, 1rem + 3.5vw, 4.2rem); line-height: .9; color: #55B084; letter-spacing: -.03em; }
.front-hq span { color: #55B084; }
.front-tag { color: #C8D0DA; font-weight: 700; font-family: "Sora", var(--head); font-size: clamp(1.15rem, .8rem + 1.3vw, 1.7rem); letter-spacing: -.01em; margin: 18px 0 0; }
.collage { display: grid; grid-template-columns: 1.4fr 1fr; grid-auto-rows: clamp(150px, 16vw, 240px); gap: 12px; max-width: 900px; }
.collage img { width: 100%; height: 100%; object-fit: cover; border-radius: 14px; display: block; background: #141A22; }
.collage .collage-a { grid-row: 1 / span 2; }
.front-quote { margin: 0; }
.front-quote p { font-family: "Sora", var(--head); font-weight: 800; font-size: clamp(1.5rem, 1rem + 1.8vw, 2.5rem); line-height: 1.12; margin: 0 0 12px; letter-spacing: -.025em; color: #fff; }
.front-quote footer { color: #55B084; font-weight: 700; font-size: 1.05rem; }
.front-form { display: flex; align-items: center; justify-content: center; padding: clamp(20px, 5vw, 80px); background: #0A0E14; border-left: 1px solid #1C2530; }
.front-form .login-wrap { width: 100%; max-width: 26rem; margin: 0; }
.front-form .login-wrap .muted, .front-form .login-wrap .faint { color: #828C9B; }
.front-form-title { font-family: "Sora", var(--head); font-weight: 800; font-size: 2.2rem; letter-spacing: -.03em; color: #fff; }
.front-form .card { background: #141A22; border-color: #28323E; box-shadow: 0 20px 60px -20px rgba(0,0,0,.8); padding: 24px; }
.front-form label { color: #B9B0B8; }
.front-form input { background: #0A0E14; border-color: #33404E; color: #fff; min-height: 46px; font-size: 1rem; }
.front-form input:focus { border-color: #55B084; outline-color: #55B084; }
.front-form .btn-primary { min-height: 48px; font-size: 1.02rem; font-family: "Sora", var(--head); font-weight: 700; }
@media (max-width: 860px) {
  .front { grid-template-columns: 1fr; min-height: 0; }
  .front-brand { gap: 22px; padding: 32px 22px 30px; }
  .collage { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 120px; gap: 8px; }
  .collage .collage-a { grid-column: 1 / span 2; grid-row: 1; }
  .front-logo { height: 72px; width: auto; }
  .morph-text { font-size: 2.3rem; }
  .front-hq-chip { font-size: 2.2rem; }
  .front-tag { font-size: 1.15rem; }
  .front-quote p { font-size: 1.4rem; }
  .front-form { padding: 8px 22px 44px; }
}

/* ---------- v3: quote bar ---------- */
.quote-bar { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; padding: 8px 14px; margin: -2px 0 14px; border-left: 3px solid var(--accent); color: var(--ink-2); font-size: .93rem; background: var(--surface); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.quote-bar .quote-mark { font-family: var(--head); font-weight: 800; color: var(--accent); font-size: 1.3rem; line-height: 0; }
.quote-card { background: var(--ink); color: var(--paper); border-color: transparent; }
.quote-card .quote-text { font-family: var(--head); font-weight: 800; font-size: 1.15rem; line-height: 1.2; margin: 0 0 6px; }
.quote-card .muted { color: var(--accent); }

/* ---------- v3: ratings ---------- */
.big-num { font-family: var(--mono); font-weight: 600; font-size: 1.55rem; line-height: 1; font-variant-numeric: tabular-nums; }
.big-num.sm { font-size: 1.15rem; }
.rb-good { color: var(--good); } .rb-warn { color: var(--warn); } .rb-bad { color: var(--bad); } .rb-none { color: var(--ink-3); }
.rate-key { display: inline-flex; gap: 6px; margin-left: 6px; vertical-align: middle; }
.rate-key .rb { font-family: var(--mono); font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.rate-key .rb-good { background: var(--good-bg); } .rate-key .rb-warn { background: var(--warn-bg); } .rate-key .rb-bad { background: var(--bad-bg); }
.rating-table td { vertical-align: middle; }
.rating-big { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.rating-big > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rating-items { margin: 8px 0 0; padding-left: 0; list-style: none; font-size: .85rem; color: var(--ink-2); }
.rating-items li { display: flex; gap: 8px; padding: 2px 0; }
.spark-guide { stroke: var(--good); stroke-width: 1; stroke-dasharray: 3 3; opacity: .7; }

/* ---------- v3: briefing compact ---------- */
.rows-card { padding: 12px 16px; }
.row-item > summary { justify-content: space-between; }
.row-item > summary .row-title { flex: 1 1 auto; color: var(--ink); }
details.more > summary { display: inline; padding: 0; min-height: 0; font-weight: 400; color: inherit; }
details.more > summary::before { display: none; }
details.more[open] > summary { display: none; }
.more-link { color: var(--accent); font-weight: 700; }

/* ---------- v3: overview ---------- */
.glance-grid { display: grid; gap: 0; }
.glance-row { display: grid; grid-template-columns: 7rem 1fr; gap: 4px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.glance-row:last-child { border-bottom: 0; }
.glance-row:hover { text-decoration: none; background: var(--surface-2); margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.glance-running { grid-column: 2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 600px) { .glance-row { grid-template-columns: 1fr; } .glance-running { grid-column: 1; } }
.tip { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); margin-top: 8px; border-left: 4px solid var(--ink-3); }
.tip p { margin: 4px 0 8px; }
.tip-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tip-actions { display: flex; gap: 6px; }
.tip-actions form { margin: 0; }
.tip-productivity { border-left-color: var(--tom); } .tip-revenue { border-left-color: var(--good); } .tip-stop-loss { border-left-color: var(--bad); } .tip-blind-spot { border-left-color: var(--warn); }
.pill-productivity { background: var(--tom-bg); color: var(--tom); } .pill-revenue { background: var(--good-bg); color: var(--good); }
.pill-stop-loss { background: var(--bad-bg); color: var(--bad); } .pill-blind-spot { background: var(--warn-bg); color: var(--warn); }
.feed { list-style: none; margin: 0; padding: 0; max-height: 34rem; overflow-y: auto; }
.feed-item { padding: 8px 0 8px 12px; border-left: 3px solid var(--line); border-bottom: 1px solid var(--line); font-size: .9rem; }
.feed-item:last-child { border-bottom: 0; }
.feed-tom { border-left-color: var(--tom); }
.feed-bad { border-left-color: var(--bad); }
.feed-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; }
.feed-meta time { margin-left: auto; font-size: .75rem; }
.feed-text { margin: 2px 0 0; color: var(--ink-2); white-space: pre-wrap; }
.person-tom { border-color: var(--tom); }
div.person-tom:hover { border-color: var(--tom); }

/* ---------- v4: personal overview ---------- */
.me-head { display: flex; gap: 18px 28px; align-items: center; flex-wrap: wrap; }
.me-today { display: flex; flex-direction: column; gap: 2px; padding-right: 24px; border-right: 1px solid var(--line); }
.big-num.xl { font-size: 2.6rem; }
.me-stats { display: grid; grid-template-columns: repeat(4, minmax(6rem, 1fr)); gap: 10px 18px; flex: 1 1 20rem; }
.me-stats > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.delta { font-size: .8rem; font-weight: 700; }
@media (max-width: 600px) { .me-today { border-right: 0; padding-right: 0; width: 100%; } .me-stats { grid-template-columns: 1fr 1fr; } }
.week-table th { white-space: nowrap; }
.week-table tbody th { text-align: left; font-size: .75rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.week-table td { padding: 6px 8px; }
.chip-xs { padding: 2px 8px; font-size: .72rem; }
.rules { margin: 6px 0 0; padding-left: 1.2rem; font-size: .95rem; }
.rules li { margin: 6px 0; }
.tip-closed { opacity: .6; }
.card-tom .tip { background: var(--surface); }
