/* Vira HQ: the Vira console look (IBM Plex, amber/spruce). Tokens match VisionGuard's console. */

:root {
  --bg: #fbfaf8; --panel: #ffffff; --ink: #1d1a15; --muted: #5f5a51; --faint: #8f887c;
  --line: #e7e3da; --line2: #efece5; --field: #fdfcfa; --fieldline: #ddd7cb;
  --amber: #a76a15; --amber-soft: #fbf1e0; --amber-line: #e7cfa2;
  --spruce: #2c7c62; --spruce-soft: #e7f1ec; --spruce-line: #b6d6c9;
  --crit: #b5432f; --crit-soft: #fbeae6; --crit-line: #e6c3ba;
  --shadow: 0 8px 30px rgba(29, 26, 21, .06);
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'IBM Plex Sans', ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --serif: 'IBM Plex Serif', Georgia, 'Times New Roman', serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16140f; --panel: #1e1b15; --ink: #efe9dd; --muted: #b3aa9a; --faint: #8a8172;
    --line: #332e25; --line2: #2a2620; --field: #1a1813; --fieldline: #3d372c;
    --amber: #e2a24c; --amber-soft: #241c11; --amber-line: #5c451f;
    --spruce: #5fb596; --spruce-soft: #132a22; --spruce-line: #265445;
    --crit: #e07a63; --crit-soft: #2a1713; --crit-line: #5c332a;
    --shadow: 0 10px 34px rgba(0, 0, 0, .4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16140f; --panel: #1e1b15; --ink: #efe9dd; --muted: #b3aa9a; --faint: #8a8172;
  --line: #332e25; --line2: #2a2620; --field: #1a1813; --fieldline: #3d372c;
  --amber: #e2a24c; --amber-soft: #241c11; --amber-line: #5c451f;
  --spruce: #5fb596; --spruce-soft: #132a22; --spruce-line: #265445;
  --crit: #e07a63; --crit-soft: #2a1713; --crit-line: #5c332a;
  --shadow: 0 10px 34px rgba(0, 0, 0, .4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--sans);
  font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
a { color: var(--amber); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0 0 .4em; }
h1 { font-size: clamp(26px, 4vw, 34px); }
h2 { font-size: 21px; }
p { margin: 0 0 .7em; }
.muted { color: var(--muted); }
.mark rect { stroke: var(--amber); }
.mark circle { fill: var(--spruce); }

/* Top bar */
.bar {
  position: sticky; top: 0; z-index: 5; padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.bar .in { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; }
.brand .word { font-family: var(--mono); font-weight: 600; letter-spacing: .32em; text-transform: uppercase; font-size: 13px; }
.brand .gs { font-family: var(--mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--spruce); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a {
  font-size: 14px; font-weight: 500; color: var(--muted); text-decoration: none;
  padding: 5px 10px; border-radius: 7px;
}
.nav a:hover { color: var(--ink); background: var(--line2); }
.nav a.on { color: var(--ink); background: var(--amber-soft); box-shadow: inset 0 0 0 1px var(--amber-line); }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.who .email { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); text-decoration: none; padding: 5px 8px; border-radius: 7px; }
.who .email:hover, .who .email.on { color: var(--ink); background: var(--line2); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 32px 16px 90px; }

/* Shared pieces */
.card { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 16px 18px; }
.banner { border: 1px solid var(--crit-line); background: var(--crit-soft); color: var(--ink); border-radius: 12px; padding: 12px 16px; font-size: 14.5px; margin: 14px 0; }
.eyebrow { font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--faint); }
.k { font-family: var(--mono); font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--amber); font-weight: 600; }
.pill { display: inline-block; font-family: var(--mono); font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; border-radius: 5px; padding: 2px 7px; border: 1px solid; }
.pill.ok { color: var(--spruce); background: var(--spruce-soft); border-color: var(--spruce-line); }
.pill.open { color: var(--amber); background: var(--amber-soft); border-color: var(--amber-line); }
.pill.bad { color: var(--crit); background: var(--crit-soft); border-color: var(--crit-line); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 6px; align-items: center; }
.soon { max-width: 640px; margin-top: 18px; }

button, .btnlike {
  font: inherit; font-weight: 600; font-size: 14px; border-radius: 8px; padding: 7px 12px; cursor: pointer;
  border: 1px solid var(--fieldline); background: var(--panel); color: var(--ink); text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
}
button.primary { background: var(--amber); border-color: var(--amber); color: #fff; }
button.ghost, .btnlike.ghost { background: transparent; border-color: transparent; color: var(--muted); font-weight: 500; padding: 5px 8px; }
button.ghost:hover, .btnlike.ghost:hover { color: var(--ink); background: var(--line2); }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible, a:focus-visible, textarea:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
textarea {
  width: 100%; font: inherit; font-size: 15px; color: var(--ink); background: var(--field);
  border: 1px solid var(--fieldline); border-radius: 9px; padding: 10px 12px; resize: none;
}
textarea:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }

table { border-collapse: collapse; width: 100%; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line2); text-align: left; vertical-align: top; font-size: 14px; }
th { font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
tr:last-child td { border-bottom: none; }

.toc { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: hidden; }
.toc li + li { border-top: 1px solid var(--line2); }
.toc a { display: block; padding: 9px 12px; color: var(--ink); text-decoration: none; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc a:hover, .toc a:focus-visible { background: var(--amber-soft); outline: none; }
.toc a.on { background: var(--amber-soft); box-shadow: inset 3px 0 0 var(--amber); }
.toc .empty { padding: 10px 12px; color: var(--faint); font-size: 13.5px; }

/* Login */
.page-login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login { width: 100%; max-width: 420px; }
.login .brand { margin-bottom: 26px; }
.login h1 { font-size: 30px; }
.signin {
  display: flex; width: 100%; align-items: center; justify-content: center; gap: 10px; margin-top: 22px;
  font-size: 15px; color: #fff; background: var(--amber); border: 1px solid var(--amber); border-radius: 9px; padding: 11px 16px;
}
.signin:hover { box-shadow: 0 0 0 3px var(--amber-soft); }
.signin[hidden] { display: none; }
.fine { font-size: 13px; margin-top: 12px; }
.banner[hidden] { display: none; }
footer { margin-top: 30px; padding-top: 14px; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 11px; color: var(--faint); display: flex; justify-content: space-between; }

/* Assistant page */
.assistant-layout { display: grid; grid-template-columns: 250px 1fr; gap: 18px; height: calc(100vh - 150px); min-height: 460px; }
.history { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.history-head { display: flex; justify-content: space-between; align-items: center; }
.history .toc { overflow-y: auto; }
@media (max-width: 760px) {
  .assistant-layout { grid-template-columns: 1fr; height: auto; }
  .history .toc { max-height: 160px; }
  .chat-full { height: 70vh; }
  .who .email { display: none; }
}

/* Chat (shared by the full page and the panel) */
.chat { display: flex; flex-direction: column; min-height: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.chat .log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat .intro { color: var(--muted); font-size: 14px; }
.chat .intro .eyebrow { display: block; margin-bottom: 6px; }
.chat .suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chat .suggest button { font-weight: 500; font-size: 13px; padding: 5px 10px; color: var(--muted); }
.msg { max-width: 88%; font-size: 14.5px; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--amber-soft); border: 1px solid var(--amber-line); border-radius: 12px 12px 3px 12px; padding: 8px 12px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; }
.msg.assistant p:last-child { margin-bottom: 0; }
.msg.assistant ul, .msg.assistant ol { margin: 0 0 .7em; padding-left: 1.3em; }
.msg.assistant code { font-family: var(--mono); font-size: 13px; background: var(--line2); border-radius: 4px; padding: 1px 4px; }
.msg.assistant pre { background: var(--line2); border-radius: 8px; padding: 10px 12px; overflow-x: auto; }
.msg.assistant pre code { background: none; padding: 0; }
.msg.assistant .tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 9px; margin: 0 0 .7em; }
.msg.error { align-self: stretch; max-width: none; }
.msg .tools { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.msg.pending::after { content: "▍"; color: var(--amber); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.chat form { border-top: 1px solid var(--line); padding: 10px; display: flex; gap: 8px; align-items: flex-end; }
.chat form textarea { min-height: 42px; max-height: 180px; }

/* Floating panel on other pages */
.chat-fab {
  position: fixed; right: 18px; bottom: 18px; z-index: 20; border-radius: 999px; padding: 10px 16px;
  background: var(--amber); border-color: var(--amber); color: #fff; box-shadow: var(--shadow);
}
.chat-panel {
  position: fixed; right: 18px; bottom: 18px; z-index: 30; width: min(420px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 90px)); display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.chat-panel[hidden] { display: none; }
.chat-panel-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--line); }
.chat-panel .chat { flex: 1; border: none; border-radius: 0 0 14px 14px; }
@media (max-width: 520px) {
  .chat-panel { right: 0; bottom: 0; width: 100vw; height: 100vh; border-radius: 0; }
}

/* Account */
.account-section { margin-top: 28px; max-width: 820px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.section-head h2 { margin: 0; }
.list { margin-top: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow-x: auto; }
.list td .ghost { padding: 3px 8px; font-size: 13px; }

/* Operations */
.small { font-size: 12.5px; }
.r { text-align: right; }
.ops.loading .kpis, .ops.loading .panel { opacity: .6; transition: opacity .2s; }
.ops-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.ops-head h1 { margin: 0; }
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--fieldline); border-radius: 8px; overflow: hidden; }
.seg button { border: none; border-radius: 0; background: var(--panel); color: var(--muted); font-weight: 500; padding: 6px 12px; }
.seg button + button { border-left: 1px solid var(--fieldline); }
.seg button[aria-checked="true"] { background: var(--amber-soft); color: var(--ink); font-weight: 600; }
.note { border: 1px solid var(--amber-line); background: var(--amber-soft); border-radius: 12px; padding: 12px 16px; font-size: 14.5px; margin: 14px 0; }
.note[hidden] { display: none; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 8px 0 18px; }
.kpi { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 12px 14px; position: relative; }
.kpi.bad { border-color: var(--crit-line); box-shadow: inset 3px 0 0 var(--crit); }
.kpi.warn { border-color: var(--amber-line); box-shadow: inset 3px 0 0 var(--amber); }
.kpi-label { font-size: 13px; color: var(--muted); }
.kpi-value { font-size: 26px; font-weight: 600; line-height: 1.25; margin-top: 2px; }
.kpi-sub { font-size: 12.5px; color: var(--muted); }

.ops-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 14px; margin-bottom: 14px; }
.panel { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.panel-head h2 { margin: 0; font-size: 18px; }
.panel .list { margin-top: 0; border: none; border-radius: 0; }
.empty { color: var(--faint); font-size: 13.5px; list-style: none; }

.feed { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; }
.feed li { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 8px 0; border-top: 1px solid var(--line2); font-size: 14px; }
.feed li:first-child { border-top: none; }
.feed .pill { grid-row: span 2; align-self: start; margin-top: 2px; }
.feed-time { font-size: 12.5px; }

.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.timeline { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow-y: auto; }
.tl-row, .axis { display: grid; grid-template-columns: 140px 1fr 96px; gap: 10px; align-items: center; }
.tl-name { display: flex; flex-direction: column; font-size: 13.5px; line-height: 1.25; min-width: 0; }
.tl-name span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-cells { display: flex; gap: 1px; height: 18px; }
.tl-cells { min-width: 0; }
.tl-cells .cell { flex: 1 1 0; width: auto; min-width: 0; height: 100%; border-radius: 1px; }
.tl-down { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }
.cell { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.cell.up { background: var(--spruce); }
.cell.down { background: var(--crit); }
.cell.mixed { background: var(--amber); }
.cell.none { background: var(--line); }
.axis { margin-top: 6px; font-family: var(--mono); font-size: 10.5px; }
.axis-span { display: flex; justify-content: space-between; }

.trends { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 14px; margin-bottom: 14px; }
.chart-card { margin: 0; }
.chart-card figcaption { font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.chart { height: 150px; position: relative; }
.chart[data-empty]::after { content: attr(data-empty); position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); font-size: 13px; }

.meters { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.meter-head { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; font-size: 14px; margin-bottom: 4px; }
.track { height: 6px; border-radius: 3px; background: var(--spruce-soft); overflow: hidden; }
.fill { height: 100%; background: var(--spruce); }
.stale { white-space: nowrap; }
@media (max-width: 620px) {
  .tl-row, .axis { grid-template-columns: 90px 1fr; }
  .tl-down, .axis > :last-child { display: none; }
}

/* Pipeline */
.search { font: inherit; font-size: 14px; color: var(--ink); background: var(--field); border: 1px solid var(--fieldline); border-radius: 8px; padding: 7px 10px; width: min(300px, 100%); }
.search:focus, .field input:focus, .field select:focus, .field textarea:focus, .note-form input:focus, .note-form select:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.error-text { color: var(--crit); }
.linklike { background: none; border: none; padding: 0; font: inherit; font-weight: 500; color: var(--ink); text-align: left; cursor: pointer; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.linklike:hover { text-decoration-color: var(--amber); }
.search-results { margin-bottom: 14px; display: flex; gap: 28px; flex-wrap: wrap; }
.search-results[hidden] { display: none; }
.result-group { display: flex; flex-direction: column; gap: 6px; min-width: 200px; }

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 16px; align-items: start; }
.stage { background: var(--line2); border: 1px solid var(--line); border-radius: 12px; padding: 8px; min-height: 160px; display: flex; flex-direction: column; }
.stage.closed { background: transparent; }
.stage.over { border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.stage-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 2px 4px 8px; }
.stage-name { font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
.stage-list { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 60px; }
.stage-empty { padding: 10px 4px; }
.deal { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; cursor: grab; display: flex; flex-direction: column; gap: 3px; }
.deal:hover, .deal:focus-visible { border-color: var(--amber-line); outline: none; box-shadow: 0 0 0 3px var(--amber-soft); }
.deal.dragging { opacity: .45; }
.deal-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.deal-title { font-weight: 600; font-size: 14px; line-height: 1.3; }
.deal-value { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.deal-next { color: var(--ink); }
.deal-next.overdue { color: var(--crit); }
.feed li.fu { grid-template-columns: auto 1fr; }

.sheet { width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 40px); border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--ink); padding: 0; box-shadow: var(--shadow); }
.sheet::backdrop { background: rgba(20, 18, 14, .45); }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 16px 18px 6px; position: sticky; top: 0; background: var(--panel); z-index: 1; }
.sheet-head h2 { margin: 2px 0 0; font-size: 22px; }
.sheet .banner { margin: 6px 18px; }
.sheet-body { padding: 4px 18px 20px; display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.sheet-body > * { max-width: 100%; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; width: 100%; }
.form-grid.compact { margin-top: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field-label { font-size: 12.5px; color: var(--muted); }
.field input, .field select, .field textarea, .note-form input, .note-form select {
  font: inherit; font-size: 14.5px; color: var(--ink); background: var(--field); border: 1px solid var(--fieldline); border-radius: 8px; padding: 7px 9px; width: 100%; resize: vertical;
}
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
.history { width: 100%; border-top: 1px solid var(--line); padding-top: 12px; }
.history h3 { font-size: 16px; margin-bottom: 8px; }
.history > button { margin-bottom: 8px; }
.note-form { display: grid; grid-template-columns: 110px 1fr auto; gap: 8px; margin-bottom: 6px; }
@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .note-form { grid-template-columns: 1fr; }
}

/* Projects */
.repo-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 14px; margin-bottom: 14px; }
.repo-name { font-family: var(--serif); font-weight: 600; font-size: 18px; color: var(--ink); text-decoration: none; }
.repo-name:hover { text-decoration: underline; text-decoration-color: var(--amber); }
.repo-stats { display: flex; gap: 22px; margin: 2px 0 14px; }
.repo-stat .kpi-value { font-size: 22px; }
.meter-head .linklike { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.due-group + .due-group { margin-top: 12px; }
.issues-panel { margin-top: 14px; }
.small-filters select, .inline-select { font: inherit; font-size: 13.5px; color: var(--ink); background: var(--field); border: 1px solid var(--fieldline); border-radius: 8px; padding: 5px 8px; }
.small-filters .search { width: 180px; }
.checks { border: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.check { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; }
.check input { accent-color: var(--spruce); }
.form-grid > .wide { grid-column: 1 / -1; }
