/* Business Intelligence app styles. Brand tokens come from /assets/brand.css (Codex); these are fallbacks only. */
:root {
  --brand-teal: #70ABB2;          /* accents only: fails contrast as text */
  --brand-teal-dark: #2F6E75;
  --ink: #1C2B33;
  --sand: #F6F1E8;
  --ko-olina-gold: #C99700;
  --ko-olina-gold-dark: #7A5C00;
  --princeville-copper: #C2723C;
  --princeville-copper-dark: #8A4A20;
  --font-heading: Georgia, "Times New Roman", serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --font-variant-numeric: tabular-nums;
  --logo-reverse-filter: brightness(0) invert(1);

  --paper: #FFFFFF;
  --line: #E4DCCB;
  --muted: #4A5A62;
  --accent: var(--brand-teal);
  --accent-dark: var(--brand-teal-dark);
  --radius: 10px;
  --shadow: 0 1px 2px rgba(28, 43, 51, .06), 0 4px 16px rgba(28, 43, 51, .06);
}
body[data-property="ko-olina"] { --accent: var(--ko-olina-gold); --accent-dark: var(--ko-olina-gold-dark); }
body[data-property="princeville"] { --accent: var(--princeville-copper); --accent-dark: var(--princeville-copper-dark); }

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--sand); color: var(--ink); font: 15px/1.55 var(--font-ui); -webkit-font-smoothing: antialiased; }
h1, h2, h3, .serif { font-family: var(--font-heading); font-weight: 500; letter-spacing: -.01em; }
a { color: var(--brand-teal-dark); }
.num, td.num, .tabular { font-variant-numeric: var(--font-variant-numeric); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--brand-teal); outline-offset: 2px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); font: 500 14px/1.2 var(--font-ui);
  cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--brand-teal); }
.btn-primary { background: var(--brand-teal-dark); border-color: var(--brand-teal-dark); color: #fff; }
.btn-primary:hover { background: #255A60; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn[disabled] { opacity: .55; cursor: default; }
input, select, textarea { font: inherit; color: inherit; }
input[type=email], input[type=text], input[type=date], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #CFC5B1; border-radius: 8px; background: #fff; }
label { font-weight: 600; font-size: 13px; }
.stack { display: grid; gap: 10px; }
.notice { background: #FFF7E0; border: 1px solid #EAD9A6; padding: 10px 12px; border-radius: 8px; }
.error { background: #FBEAEA; border: 1px solid #E5B9B9; padding: 10px 12px; border-radius: 8px; }

/* ---------- sign-in */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(280px, 44%) 1fr; }
.auth-brand { background: var(--brand-teal-dark) url("/assets/topo.svg") center / cover; color: #fff; display: flex; align-items: flex-end; padding: 48px; }
.auth-brand-inner { max-width: 420px; }
.auth-mark { filter: var(--logo-reverse-filter); display: block; margin-bottom: 18px; }
.auth-name { font: 500 34px/1.15 var(--font-heading); margin: 0 0 10px; }
.auth-tag { margin: 0; font-size: 17px; opacity: .92; }
.auth-panel { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 32px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 0 0 6px; font-size: 28px; }
.auth-foot { color: var(--muted); font-size: 13px; margin-top: 18px; text-align: center; }
@media (max-width: 760px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-brand { padding: 28px 20px; min-height: 180px; }
  .auth-name { font-size: 26px; }
}

/* ---------- app shell */
.shell { display: grid; grid-template-columns: 280px 1fr; height: 100vh; }
.side { background: var(--brand-teal-dark); color: #fff; display: flex; flex-direction: column; min-height: 0; }
.side-top { padding: 18px 16px 10px; display: flex; align-items: center; gap: 10px; }
.side-top img { width: 34px; height: 34px; filter: var(--logo-reverse-filter); }
.side-top .name { font: 500 19px/1.1 var(--font-heading); }
.side label { color: rgba(255,255,255,.85); font-weight: 500; font-size: 12px; text-transform: none; letter-spacing: .02em; }
.side .prop { padding: 6px 16px 12px; }
.side select { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.3); }
.side select option { color: var(--ink); }
.side .new { margin: 0 16px 10px; background: #fff; color: var(--brand-teal-dark); border-color: #fff; }
.side nav { padding: 0 8px; }
.side nav a, .side .conv a { display: block; color: #fff; text-decoration: none; padding: 8px 10px; border-radius: 8px; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side nav a:hover, .side .conv a:hover { background: rgba(255,255,255,.1); }
.side nav a[aria-current="page"], .side .conv a[aria-current="true"] { background: rgba(255,255,255,.18); }
.side nav .count { float: right; background: var(--accent); color: var(--ink); border-radius: 999px; padding: 0 7px; font-size: 12px; }
.side h2 { font: 600 11px/1 var(--font-ui); letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.7); margin: 16px 18px 6px; }
.side .conv { flex: 1; overflow-y: auto; padding: 0 8px 8px; min-height: 0; }
.side-foot { border-top: 1px solid rgba(255,255,255,.18); padding: 12px 16px; font-size: 13px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-foot button { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; font: inherit; padding: 4px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--sand); }
.topbar .accent { width: 6px; height: 28px; border-radius: 3px; background: var(--accent); }
.topbar .where { font: 500 18px/1.2 var(--font-heading); }
.topbar .clock { margin-left: auto; color: var(--muted); font-size: 13px; text-align: right; }
.topbar .menu { display: none; }
.view { flex: 1; overflow-y: auto; min-height: 0; }

/* ---------- chat */
.thread { max-width: 780px; margin: 0 auto; padding: 24px 20px 12px; }
.hello h1 { font-size: 34px; margin: 28px 0 6px; }
.hello p { margin: 0 0 18px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 26px; }
.chip { border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 8px 14px; font-size: 14px; cursor: pointer; color: var(--ink); text-align: left; }
.chip:hover { border-color: var(--accent); }
.strip h2 { font-size: 20px; margin: 8px 0 10px; }
.strip .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.empty { border: 1px dashed #CFC5B1; border-radius: var(--radius); padding: 16px; color: var(--muted); background: rgba(255,255,255,.5); }

.msg { margin: 0 0 22px; }
.msg.user .bubble { margin-left: auto; max-width: 85%; width: fit-content; background: #fff; border: 1px solid var(--line); border-radius: 14px 14px 4px 14px; padding: 10px 14px; white-space: pre-wrap; }
.msg.assistant .answer { padding: 2px 0; }
.answer p { margin: 0 0 10px; }
.answer ul, .answer ol { margin: 0 0 10px; padding-left: 22px; }
.answer h4 { font: 600 15px/1.3 var(--font-ui); margin: 14px 0 6px; }
.cite a { text-decoration: none; font-size: 11px; font-weight: 600; color: var(--accent-dark); padding: 0 1px; }
.sources { margin: 10px 0 0; padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); font-size: 13px; }
.sources ol { margin: 4px 0 0; padding-left: 20px; }
.sources li { margin: 2px 0; }
.kind { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .02em; padding: 1px 6px; border-radius: 4px; margin-right: 4px;
  background: #EEF5F6; color: var(--brand-teal-dark); }
.kind.public { background: #F3EEE2; color: #5C4B1F; }
.kind.decision { background: #EAF1EA; color: #2D5A31; }
.offer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.offer .q { font-size: 14px; color: var(--muted); margin-right: 4px; }
.offer .done { font-size: 13px; color: var(--muted); }
.offer .link { background: none; border: 0; color: var(--brand-teal-dark); text-decoration: underline; cursor: pointer; font: inherit; font-size: 13px; padding: 0; }
.thinking { color: var(--muted); font-style: italic; }
.answer.live { white-space: pre-wrap; }

.composer { border-top: 1px solid var(--line); background: var(--sand); padding: 12px 20px 16px; }
.composer form { max-width: 780px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end;
  background: #fff; border: 1px solid #CFC5B1; border-radius: 14px; padding: 8px 8px 8px 14px; box-shadow: var(--shadow); }
.composer textarea { border: 0; padding: 6px 0; resize: none; max-height: 200px; min-height: 24px; line-height: 1.5; background: transparent; }
.composer textarea:focus { outline: none; }
.composer .scope { max-width: 780px; margin: 6px auto 0; font-size: 12px; color: var(--muted); }

.mic { min-width: 40px; padding: 8px 10px; color: var(--brand-teal-dark); }
.mic.recording { background: #7A2E2E; border-color: #7A2E2E; color: #fff; }
.mic.working { opacity: .6; }
.mic-time { font-size: 13px; }
.think { font-size: 13px; padding: 8px 10px; color: var(--muted); }
.think.on { background: #EEF5F6; border-color: var(--brand-teal-dark); color: var(--brand-teal-dark); }

.fb { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.fb-btn { background: none; border: 1px solid transparent; border-radius: 6px; padding: 3px 8px; font: 13px var(--font-ui); color: var(--muted); cursor: pointer; }
.fb-btn:hover { border-color: var(--line); }
.fb-btn.on { border-color: var(--brand-teal-dark); color: var(--brand-teal-dark); background: #EEF5F6; }
.fb-form { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; margin-top: 4px; }
.fb-form select { width: auto; }
.fb-form input { flex: 1 1 220px; width: auto; }

/* ---------- review page */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin: 12px 0 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font: 500 24px/1.2 var(--font-heading); font-variant-numeric: var(--font-variant-numeric); }
.stat span { font-size: 12px; color: var(--muted); }
table.log { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table.log th, table.log td { text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.log tr[data-mid] { cursor: pointer; }
table.log tr[data-mid]:hover { background: #F7F3EA; }
.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: #EEF5F6; color: var(--brand-teal-dark); }
.pill.cannot_confirm, .pill.citation_enforced, .pill.no_hits { background: #FFF3D6; color: #6B4E00; }
.pill.ai_error, .pill.budget { background: #F6E6E6; color: #7A2E2E; }
pre.raw { white-space: pre-wrap; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 13px; }

/* ---------- Decision Register */
.register { max-width: 1100px; margin: 0 auto; padding: 22px 20px 40px; }
.register-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.register-head h1 { margin: 0; font-size: 28px; flex: 1 1 240px; }
.register-head select { width: auto; }
.deal { background: var(--paper); border: 1px solid var(--line); border-left: 5px solid var(--deal-accent, var(--brand-teal)); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); cursor: pointer; text-align: left; width: 100%; font: inherit; color: inherit; }
.deal:hover { border-color: var(--brand-teal); }
.deal .row1 { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.deal h3 { font-size: 17px; margin: 6px 0 8px; line-height: 1.3; }
.deal dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; font-size: 13px; }
.deal dt { color: var(--muted); }
.deal dd { margin: 0; }
.deals { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.status { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #EEF5F6; color: var(--brand-teal-dark); }
.status.proposed { background: #FFF3D6; color: #6B4E00; }
.status.reversed, .status.rejected { background: #F6E6E6; color: #7A2E2E; }
.status.superseded { background: #EDEDED; color: #444; }

dialog { border: 0; border-radius: 14px; padding: 0; overflow: auto; width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(28, 43, 51, .45); }
.dlg { padding: 22px 24px; }
.dlg h2 { margin: 0 0 12px; font-size: 22px; }
.dlg .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.dlg .full { grid-column: 1 / -1; }
.dlg .actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.dlg .field-view { margin: 0 0 10px; }
.dlg .field-view b { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.dlg iframe { width: 100%; height: 420px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

/* ---------- source viewer and upload */
.page { max-width: 860px; margin: 0 auto; padding: 24px 20px 48px; }
.page h1 { font-size: 26px; margin: 8px 0 6px; }
.chunk { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 10px; white-space: pre-wrap; }
.chunk:target { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(112, 171, 178, .35); }
.drop { border: 2px dashed #B9AE96; border-radius: 14px; background: #fff; padding: 36px 20px; text-align: center; }
.drop.over { border-color: var(--brand-teal-dark); background: #F1F7F7; }
.bar { height: 8px; background: #EAE3D3; border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--brand-teal-dark); }
table.files { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 14px; }
table.files td, table.files th { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }

/* ---------- small screens */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 86vw; max-width: 320px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .shell.open .side { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .topbar .menu { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .thread, .composer { padding-left: 16px; padding-right: 16px; }
  .dlg .grid2 { grid-template-columns: 1fr; }
  .hello h1 { font-size: 28px; }
}
