/* Phase 0 palette (from phase0-kpi-rollout-overview.pptx): Cambria titles, Calibri body. */
:root {
  --ink: #1d2b3a;
  --muted: #5a6b7c;
  --navy: #1a2350;
  --band: #065a82;
  --teal: #0e8fa8;
  --teal-text: #1c7293;
  --purple: #5a52a0;
  --green: #1d7a4f;
  --amber: #9a6a00;
  --amber-bg: #fdf5e0;
  --red: #a32024;
  --red-bg: #fbecec;
  --rule: #dde5ec;
  --rule-strong: #9fb0c0;
  --panel: #f1f5f8;
  --surface: #ffffff;
  --serif: Cambria, Georgia, "Times New Roman", serif;
  --sans: Calibri, "Segoe UI", Candara, Arial, sans-serif;
  --mono: Consolas, "Cascadia Mono", "Courier New", monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* component display rules must not override the hidden attribute */
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--panel);
  color: var(--ink);
  font: 15px/1.45 var(--sans);
  display: flex;
  flex-direction: column;
}
button { font: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* Header */
.top {
  background: var(--band);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
}
.eyebrow { margin: 0; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.85; }
.top h1 { margin: 2px 0 0; font: 600 21px/1.2 var(--serif); }
.top-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.status { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: rgba(255, 255, 255, 0.16);
  color: #fff; border: 1px solid transparent; }
button.status:hover { border-color: rgba(255, 255, 255, 0.7); }
button.status::after { content: " \25BE"; }

/* Model picker (6 Oct 2026) */
.model-pick { position: relative; }
.model-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30;
  width: min(380px, calc(100vw - 32px)); max-height: 72vh; overflow: auto;
  background: var(--surface); color: var(--ink); border: 1px solid var(--rule-strong); border-radius: 8px;
  box-shadow: 0 10px 28px rgba(26, 35, 80, 0.22);
}
.model-menu-head { padding: 10px 14px 8px; border-bottom: 1px solid var(--rule); }
.model-menu-head strong { font: 600 15px/1.2 var(--serif); color: var(--navy); }
.model-note { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.model-list { list-style: none; margin: 0; padding: 4px 0; }
.model-opt {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: none; border: 0; padding: 7px 14px; color: var(--ink);
}
.model-opt:hover:not(:disabled), .model-opt:focus-visible { background: var(--panel); }
.model-opt .tick { width: 14px; color: var(--green); font-weight: 700; flex-shrink: 0; }
.model-opt .name { font-family: var(--mono); font-size: 13px; flex: 1; overflow-wrap: anywhere; }
.model-opt .meta { font-size: 11px; color: var(--muted); white-space: nowrap; }
.model-opt:disabled { opacity: 1; color: var(--rule-strong); }
.model-opt:disabled .name { text-decoration: line-through; }
.badge { font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase; padding: 1px 6px; border-radius: 99px;
  background: var(--panel); color: var(--teal-text); border: 1px solid var(--rule); white-space: nowrap; }
.badge.warn { background: var(--amber-bg); color: var(--amber); border-color: #ecd9a6; }
.model-sep { padding: 8px 14px 2px; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.model-menu-foot { padding: 8px 14px 10px; border-top: 1px solid var(--rule); }
.link { background: none; border: 0; padding: 0; color: var(--teal-text); text-decoration: underline; font-size: 13px; }
.turn-stats .model-tag { font-family: var(--mono); color: var(--teal-text); }
.status.ok { background: rgba(29, 122, 79, 0.9); }
.status.bad { background: rgba(163, 32, 36, 0.92); }
.ghost { background: transparent; color: inherit; border: 1px solid rgba(255, 255, 255, 0.55); border-radius: 6px; padding: 5px 11px; }
.trace .ghost { color: var(--teal-text); border-color: var(--rule-strong); }
.small { padding: 2px 9px; font-size: 13px; }

/* Layout */
.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
}
.chat { display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.messages { flex: 1; overflow-y: auto; padding: 20px 24px 8px; }
.trace { border-left: 1px solid var(--rule); display: flex; flex-direction: column; min-height: 0; background: var(--panel); }

/* Empty state */
.empty { max-width: 640px; margin: 8vh auto 0; text-align: center; color: var(--muted); }
.empty h2 { color: var(--navy); font: 600 20px/1.3 var(--serif); margin: 0 0 8px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.chip { border: 1px solid var(--rule-strong); background: var(--surface); color: var(--teal-text); border-radius: 99px; padding: 6px 13px; }
.chip:hover { border-color: var(--teal); background: #e9f5f8; }

/* Messages */
.msg { display: flex; margin: 0 0 16px; }
.msg.user { justify-content: flex-end; }
.bubble { max-width: min(760px, 92%); padding: 10px 14px; border-radius: 12px; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--navy); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant .bubble { background: var(--panel); border: 1px solid var(--rule); border-bottom-left-radius: 4px; width: 100%; }
.msg.error .bubble { background: var(--red-bg); border: 1px solid #e3b5b6; color: var(--red); }
.user-photo { display: block; max-width: 220px; max-height: 160px; border-radius: 8px; margin-bottom: 6px; }
.working { color: var(--muted); font-style: italic; }
.working::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--teal); animation: pulse 1s infinite ease-in-out; }
@keyframes pulse { 50% { opacity: 0.25; } }
.answer p { margin: 0 0 8px; }
.answer p:last-child { margin-bottom: 0; }
.answer ul, .answer ol { margin: 4px 0 8px; padding-left: 22px; }
.answer code { font: 13px var(--mono); background: #e6edf2; padding: 0 4px; border-radius: 3px; }
.answer table { border-collapse: collapse; margin: 6px 0 10px; font-size: 13px; display: block; overflow-x: auto; }
.answer th, .answer td { border: 1px solid var(--rule); padding: 4px 8px; text-align: left; }
.answer th { background: #e6edf2; }
.turn-stats { margin-top: 8px; font-size: 12px; color: var(--muted); }
.turn-stats .slow { color: var(--amber); background: var(--amber-bg); padding: 0 6px; border-radius: 4px; font-weight: 600; }

/* Candidate cards */
.cards-head { font: 600 14px var(--serif); color: var(--navy); margin: 2px 0 6px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 10px; }
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.card-img { aspect-ratio: 4 / 3; background: #e6edf2; display: flex; align-items: center; justify-content: center; }
.card-img img { width: 100%; height: 100%; object-fit: contain; }
.card-img .noimg { font-size: 12px; color: var(--muted); }
.card-body { padding: 7px 9px 9px; font-size: 12.5px; }
.card-rank { display: inline-block; background: var(--teal); color: #fff; border-radius: 99px; padding: 0 7px; font-size: 11px; font-weight: 700; margin-right: 4px; }
.card-name { font-weight: 600; word-break: break-all; }
.card-id { font: 11px var(--mono); color: var(--muted); margin-top: 3px; word-break: break-all; }
.card-label { margin-top: 5px; font-size: 11px; color: var(--amber); }
.caveat { font-size: 12px; color: var(--amber); background: var(--amber-bg); border-radius: 6px; padding: 5px 8px; margin: 0 0 10px; }

/* Parts table */
.parts-head { font: 600 14px var(--serif); color: var(--navy); margin: 2px 0 6px; }
.parts-wrap { overflow-x: auto; margin-bottom: 4px; }
.parts { border-collapse: collapse; width: 100%; font-size: 13px; background: var(--surface); }
.parts th, .parts td { border-bottom: 1px solid var(--rule); padding: 5px 8px; text-align: left; white-space: nowrap; }
.parts th { background: var(--band); color: #fff; font-weight: 600; }
.parts td.desc { white-space: normal; min-width: 160px; }
.parts td.code-wrap { white-space: normal; overflow-wrap: anywhere; font-family: var(--mono); font-size: 12px; min-width: 220px; }
.parts .flag { color: var(--amber); font-weight: 600; }
.parts-foot { font-size: 12px; color: var(--muted); margin: 0 0 10px; }

/* Composer */
.composer { border-top: 1px solid var(--rule); padding: 10px 16px 14px; background: var(--surface); }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea {
  flex: 1; resize: none; min-height: 44px; max-height: 160px; padding: 10px 12px;
  border: 1px solid var(--rule-strong); border-radius: 8px; font: inherit; color: var(--ink);
}
.composer textarea:focus { border-color: var(--teal); outline: none; box-shadow: 0 0 0 2px rgba(14, 143, 168, 0.18); }
.attach { position: relative; border: 1px solid var(--rule-strong); border-radius: 8px; padding: 10px 12px; color: var(--teal-text); background: var(--surface); cursor: pointer; }
.attach input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.attach:focus-within { outline: 2px solid var(--teal); outline-offset: 2px; }
#send { background: var(--teal); color: #fff; border: 0; border-radius: 8px; padding: 10px 18px; font-weight: 600; }
.attachment { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.attachment img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--rule); }
.icon { border: 0; background: var(--panel); color: var(--muted); width: 26px; height: 26px; border-radius: 50%; font-size: 16px; line-height: 1; }

/* Trace panel */
.trace-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 0; }
.trace-head h2 { margin: 0; font: 600 17px var(--serif); color: var(--navy); }
.trace-note { margin: 4px 16px 10px; font-size: 12px; color: var(--muted); }
.trace-list { list-style: none; margin: 0; padding: 0 12px 16px; overflow-y: auto; flex: 1; }
.trace-turn { margin: 12px 4px 6px; font-size: 12px; font-weight: 700; color: var(--teal-text); letter-spacing: 0.04em; text-transform: uppercase; border-top: 1px solid var(--rule); padding-top: 10px; }
.trace-turn:first-child { border-top: 0; margin-top: 4px; padding-top: 0; }
.ev { background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--rule-strong); border-radius: 6px; padding: 6px 9px; margin: 0 0 6px; font-size: 12.5px; }
.ev-top { display: flex; justify-content: space-between; gap: 8px; }
.ev-tag { font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.ev-time { font: 11px var(--mono); color: var(--muted); }
.ev-body { margin-top: 2px; overflow-wrap: anywhere; }
.ev-body code { font: 11.5px var(--mono); color: var(--ink); }
.ev-reason { color: var(--red); }
.ev.fixed { border-left-color: var(--purple); } .ev.fixed .ev-tag { color: var(--purple); }
.ev.photo { border-left-color: var(--purple); } .ev.photo .ev-tag { color: var(--purple); }
.ev.propose { border-left-color: var(--teal); } .ev.propose .ev-tag { color: var(--teal-text); }
.ev.pass { border-left-color: var(--green); } .ev.pass .ev-tag { color: var(--green); }
.ev.block { border-left-color: var(--red); background: var(--red-bg); } .ev.block .ev-tag { color: var(--red); }
.ev.tool { border-left-color: var(--navy); } .ev.tool .ev-tag { color: var(--navy); }
.ev.ans { border-left-color: var(--band); } .ev.ans .ev-tag { color: var(--band); }
.ev.usage { border-left-color: var(--rule); color: var(--muted); }
.ev.slow { border-left-color: var(--amber); background: var(--amber-bg); } .ev.slow .ev-tag { color: var(--amber); }
.ev.error { border-left-color: var(--red); } .ev.error .ev-tag { color: var(--red); }

/* Phone width: trace panel stacks under the chat and can be collapsed */
@media (max-width: 860px) {
  body { height: auto; min-height: 100%; }
  .layout { grid-template-columns: 1fr; }
  .chat { min-height: 70vh; }
  .messages { padding: 14px 16px 6px; }
  .trace { border-left: 0; border-top: 1px solid var(--rule); max-height: none; }
  .trace-list { max-height: 60vh; }
  .top { padding: 10px 16px; flex-wrap: wrap; }
  .top h1 { font-size: 18px; }
  .composer { padding: 8px 12px 12px; }
  .bubble { max-width: 100%; }
}
.trace.collapsed .trace-note, .trace.collapsed .trace-list { display: none; }

/* Stage 4: location choice under a where-used answer */
.choices { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }

/* Sign-in page */
.signin { max-width: 380px; width: calc(100% - 32px); margin: 48px auto; padding: 24px; background: var(--surface);
  border: 1px solid var(--rule); border-radius: 12px; box-sizing: border-box; }
.signin h1 { font: 600 21px/1.2 var(--serif); color: var(--navy); margin: 0 0 6px; }
.signin p { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.signin label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.signin input { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--rule-strong);
  border-radius: 8px; font: inherit; color: var(--ink); background: var(--surface); }
.signin input:focus { border-color: var(--teal); outline: none; box-shadow: 0 0 0 2px rgba(14, 143, 168, 0.18); }
.signin button { margin-top: 12px; width: 100%; background: var(--teal); color: #fff; border: 0; border-radius: 8px;
  padding: 10px 18px; font-weight: 600; }
.signin .error { color: #b3261e; font-size: 14px; margin: 10px 0 0; min-height: 1.3em; }
