/* ═══════════════════════════════════════════════════════════════════════════
   Harbor & Pine — theoretical SMB visual data room
   Deep navy + amber, matching the d2d-demos house visual language.
   Light and dark are both first-class: the page is meant to be shared.
   ═══════════════════════════════════════════════════════════════════════════
*/

:root {
  --navy: #0c1f2e;
  --navy-deep: #061018;
  --navy-light: #163a4f;
  --amber: #e8a317;
  --amber-light: #fde68a;
  --amber-dark: #b45309;
  --green: #10b981;
  --red: #dc2626;
  --orange: #f97316;
  --blue: #2563eb;
  --purple: #8b5cf6;
  --teal: #14b8a6;

  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --accent-text: #92400e;
  --shadow-sm: 0 1px 3px rgba(12, 31, 46, 0.08);
  --shadow-md: 0 4px 12px rgba(12, 31, 46, 0.1);

  --radius: 10px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

:root:not([data-theme='light']) {
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0a141d;
    --surface: #10202d;
    --surface-alt: #162c3c;
    --border: #1f3a4d;
    --border-strong: #2c5065;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-faint: #64748b;
    --accent-text: #f5c451;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --bg: #0a141d;
  --surface: #10202d;
  --surface-alt: #162c3c;
  --border: #1f3a4d;
  --border-strong: #2c5065;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --accent-text: #f5c451;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--blue); }

/* ─── Synthetic-data banner ─────────────────────────────────────────────── */
.banner {
  background: repeating-linear-gradient(135deg, var(--amber-dark), var(--amber-dark) 12px, #a1490a 12px, #a1490a 24px);
  color: #fff;
  padding: 0.45rem 1.5rem;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
}
.banner strong { font-weight: 800; }

/* ─── Header ────────────────────────────────────────────────────────────── */
.app-header .btn.ghost {
  border-color: rgba(255, 255, 255, 0.32);
  color: rgba(255, 255, 255, 0.86);
}
.app-header .btn.ghost:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }

.app-header {
  background: linear-gradient(135deg, var(--navy-deep) 0%, var(--navy-light) 100%);
  color: #fff;
  padding: 1.1rem 1.5rem 0;
  position: relative;
  overflow: hidden;
}
.app-header::before {
  content: '';
  position: absolute;
  top: -60%; right: -6%;
  width: 340px; height: 340px;
  background: radial-gradient(circle, rgba(232, 163, 23, 0.2) 0%, transparent 65%);
  border-radius: 50%;
  pointer-events: none;
}
.header-inner {
  max-width: 1360px; margin: 0 auto;
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1.5rem; flex-wrap: wrap; position: relative;
}
.brand { display: flex; align-items: center; gap: 0.8rem; }
.brand svg { width: 40px; height: 40px; flex: none; }
.brand-text h1 { font-size: 1.16rem; font-weight: 700; letter-spacing: -0.01em; }
.brand-text p { font-size: 0.78rem; color: rgba(255,255,255,0.68); margin-top: 0.1rem; }
.header-meta { display: flex; gap: 1.6rem; flex-wrap: wrap; }
.header-meta div { font-size: 0.72rem; color: rgba(255,255,255,0.6); }
.header-meta strong { display: block; font-size: 0.9rem; color: #fff; font-weight: 600; margin-top: 0.1rem; }
.header-meta .accent { color: var(--amber-light); }

.tabs {
  max-width: 1360px; margin: 0.9rem auto 0;
  display: flex; gap: 0.15rem; overflow-x: auto; position: relative;
  scrollbar-width: thin;
}
.tabs button {
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  color: rgba(255,255,255,0.62); padding: 0.6rem 0.9rem; cursor: pointer;
  font-size: 0.82rem; font-weight: 500; white-space: nowrap; transition: color .15s, border-color .15s;
}
.tabs button:hover { color: #fff; }
.tabs button[aria-selected='true'] { color: #fff; border-bottom-color: var(--amber); font-weight: 600; }

/* ─── Layout ────────────────────────────────────────────────────────────── */
main { max-width: 1360px; margin: 0 auto; padding: 1.4rem 1.5rem 4rem; }
.page-head { margin-bottom: 1.1rem; }
.page-head h2 { font-size: 1.24rem; font-weight: 700; letter-spacing: -0.01em; }
.page-head p { color: var(--text-muted); font-size: 0.86rem; margin-top: 0.2rem; max-width: 78ch; }

.grid { display: grid; gap: 1rem; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); align-items: start; }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
.stack { display: grid; gap: 1rem; margin-top: 1rem; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow-sm);
}
.card.pad-0 { padding: 0; overflow: hidden; }
.card-title {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: 0.7rem;
}
.card-note { font-size: 0.76rem; color: var(--text-muted); margin-top: 0.7rem; line-height: 1.45; }

/* ─── KPI ───────────────────────────────────────────────────────────────── */
.kpi { position: relative; overflow: hidden; }
.kpi::after {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--amber);
}
.kpi .label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 600; }
.kpi .value { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; margin-top: 0.25rem; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 0.74rem; color: var(--text-muted); margin-top: 0.2rem; }
.kpi.good::after { background: var(--green); }
.kpi.warn::after { background: var(--orange); }
.kpi.bad::after { background: var(--red); }
.kpi.info::after { background: var(--blue); }

/* ─── Tables ────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th, td { padding: 0.5rem 0.7rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); font-weight: 700; background: var(--surface-alt);
  position: sticky; top: 0; z-index: 1;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sorted::after { content: ' ▾'; color: var(--amber); }
th.sorted.asc::after { content: ' ▴'; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 0.78rem; }
/* Tables whose first column carries prose: let it wrap instead of pushing the
   action column out of view. */
table.compact td:first-child { white-space: normal; min-width: 220px; max-width: 340px; }
table.compact td, table.compact th { padding: 0.45rem 0.55rem; }
tbody tr:hover { background: var(--surface-alt); }
tbody tr.clickable { cursor: pointer; }
tbody tr.is-anchor td:first-child { border-left: 3px solid var(--amber); font-weight: 600; }
tfoot td { font-weight: 700; border-top: 2px solid var(--border-strong); border-bottom: 0; background: var(--surface-alt); }
.neg { color: var(--red); }
.pos { color: var(--green); }

/* ─── Chips / pills ─────────────────────────────────────────────────────── */
.chip {
  display: inline-block; padding: 0.12rem 0.5rem; border-radius: 999px;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border);
}
.chip.green { background: rgba(16,185,129,0.12); color: var(--green); border-color: rgba(16,185,129,0.3); }
.chip.amber { background: rgba(232,163,23,0.14); color: var(--accent-text); border-color: rgba(232,163,23,0.35); }
.chip.red { background: rgba(220,38,38,0.1); color: var(--red); border-color: rgba(220,38,38,0.28); }
.chip.blue { background: rgba(37,99,235,0.1); color: var(--blue); border-color: rgba(37,99,235,0.28); }

/* ─── Risk / list items ─────────────────────────────────────────────────── */
.risk { display: flex; gap: 0.7rem; padding: 0.7rem 0; border-bottom: 1px solid var(--border); }
.risk:last-child { border-bottom: 0; }
.risk .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 0.38rem; flex: none; background: var(--text-faint); }
.risk.high .dot { background: var(--red); }
.risk.medium .dot { background: var(--orange); }
.risk.low .dot { background: var(--green); }
.risk h4 { font-size: 0.86rem; font-weight: 600; }
.risk p { font-size: 0.79rem; color: var(--text-muted); margin-top: 0.12rem; }

/* ─── Knobs ─────────────────────────────────────────────────────────────── */
.knob { margin-bottom: 0.9rem; }
.knob-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.25rem; }
.knob-head label { font-size: 0.78rem; font-weight: 600; }
.knob-head .val { font-family: var(--mono); font-size: 0.8rem; color: var(--accent-text); font-weight: 700; }
.knob input[type='range'] { width: 100%; accent-color: var(--amber); }
.knob .hint { font-size: 0.7rem; color: var(--text-faint); margin-top: 0.15rem; }
.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  padding: 0.5rem 0.6rem; font-size: 0.8rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface-alt);
}
.toggle-row input { accent-color: var(--amber); width: 15px; height: 15px; }
.btn {
  background: var(--navy-light); color: #fff; border: 0; border-radius: 6px;
  padding: 0.42rem 0.8rem; font-size: 0.78rem; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--navy); }
.btn.ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border-strong); }
.btn.ghost:hover { background: var(--surface-alt); color: var(--text); }
.btn-row { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.5rem; }

/* ─── Charts ────────────────────────────────────────────────────────────── */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-family: var(--font); fill: var(--text-muted); }
.chart .axis-line { stroke: var(--border-strong); stroke-width: 1; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .label { font-size: 10px; }
.chart .value-label { font-size: 10px; fill: var(--text); font-family: var(--mono); }
.legend { display: flex; gap: 0.9rem; flex-wrap: wrap; font-size: 0.74rem; color: var(--text-muted); margin-top: 0.5rem; }
.legend span { display: inline-flex; align-items: center; gap: 0.3rem; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* ─── Detail panel ──────────────────────────────────────────────────────── */
.detail {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%);
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: -8px 0 30px rgba(6,16,24,0.18); padding: 1.2rem; overflow-y: auto; z-index: 50;
}
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 0.8rem; }
.detail-head h3 { font-size: 1.05rem; font-weight: 700; }
.detail-head p { font-size: 0.78rem; color: var(--text-muted); }
.detail dl { display: grid; grid-template-columns: 1fr auto; gap: 0.35rem 1rem; font-size: 0.82rem; margin: 0.6rem 0; }
.detail dt { color: var(--text-muted); }
.detail dd { font-family: var(--mono); font-size: 0.79rem; text-align: right; }
.scrim { position: fixed; inset: 0; background: rgba(6,16,24,0.35); z-index: 49; }

/* ─── Tree ──────────────────────────────────────────────────────────────── */
.tree { font-size: 0.83rem; }
.tree .folder { font-weight: 700; margin-top: 0.7rem; color: var(--text); }
.tree .file { color: var(--text-muted); padding-left: 1.4rem; line-height: 1.75; }
.tree .file::before { content: '·  '; color: var(--amber); }

.mono-block {
  font-family: var(--mono); font-size: 0.72rem; background: var(--surface-alt);
  border: 1px solid var(--border); border-radius: 6px; padding: 0.7rem 0.8rem;
  overflow-x: auto; color: var(--text-muted); line-height: 1.6;
}

footer {
  max-width: 1360px; margin: 0 auto; padding: 1.5rem;
  font-size: 0.74rem; color: var(--text-faint); border-top: 1px solid var(--border); line-height: 1.6;
}
footer strong { color: var(--text-muted); }

@media (max-width: 720px) {
  .header-meta { gap: 1rem; }
  main { padding: 1rem 0.9rem 3rem; }
  .detail { width: 100%; }
}

/* ─── Embedded personal assistant (P0) ──────────────────────────────────── */
.d2d-asst-launch {
  position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 60;
  background: var(--navy); color: #fff; border: 0; border-radius: 999px;
  padding: 0.7rem 1.05rem; font-size: 0.82rem; font-weight: 700;
  box-shadow: var(--shadow-md); cursor: pointer; letter-spacing: 0.02em;
}
.d2d-asst-launch:hover { background: var(--navy-light); }
.d2d-asst-panel {
  position: fixed; right: 1.1rem; bottom: 4.2rem; z-index: 61;
  width: min(380px, calc(100vw - 1.5rem)); height: min(520px, calc(100vh - 6rem));
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 12px; box-shadow: var(--shadow-md); overflow: hidden;
}
.d2d-asst-head {
  display: flex; justify-content: space-between; gap: 0.8rem; align-items: flex-start;
  padding: 0.85rem 0.95rem; background: linear-gradient(135deg, var(--navy-deep), var(--navy-light));
  color: #fff;
}
.d2d-asst-head strong { display: block; font-size: 0.9rem; }
.d2d-asst-head p { font-size: 0.72rem; color: rgba(255,255,255,0.7); margin-top: 0.2rem; }
.d2d-asst-close {
  background: transparent; border: 0; color: rgba(255,255,255,0.85);
  font-size: 1.3rem; line-height: 1; cursor: pointer; padding: 0 0.2rem;
}
.d2d-asst-messages { flex: 1; overflow-y: auto; padding: 0.85rem; display: grid; gap: 0.55rem; align-content: start; }
.d2d-asst-empty { font-size: 0.8rem; color: var(--text-muted); line-height: 1.45; }
.d2d-asst-msg { display: flex; }
.d2d-asst-msg.is-user { justify-content: flex-end; }
.d2d-asst-bubble {
  max-width: 92%; padding: 0.55rem 0.7rem; border-radius: 10px;
  font-size: 0.8rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word;
}
.d2d-asst-msg.is-user .d2d-asst-bubble {
  background: var(--navy); color: #fff; border-bottom-right-radius: 4px;
}
.d2d-asst-msg.is-assistant .d2d-asst-bubble {
  background: var(--surface-alt); border: 1px solid var(--border); border-bottom-left-radius: 4px;
}
.d2d-asst-form {
  display: flex; gap: 0.4rem; padding: 0.65rem 0.75rem; border-top: 1px solid var(--border);
}
.d2d-asst-form input {
  flex: 1; border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 0.45rem 0.6rem; background: var(--bg);
}
.d2d-asst-foot {
  display: flex; justify-content: space-between; gap: 0.6rem; align-items: center;
  padding: 0.45rem 0.75rem 0.65rem; border-top: 1px solid var(--border);
  font-size: 0.68rem; color: var(--text-faint);
}
.d2d-asst-foot label { display: grid; gap: 0.15rem; color: var(--text-muted); font-weight: 600; }
.d2d-asst-foot select {
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface-alt);
  padding: 0.2rem 0.35rem; color: var(--text); font-weight: 500;
}
.d2d-asst-foot span { text-align: right; font-family: var(--mono); font-size: 0.64rem; }

/* ─── Timeline ──────────────────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 1.4rem; }
.timeline::before {
  content: ''; position: absolute; left: 0.35rem; top: 0.2rem; bottom: 0.2rem;
  width: 2px; background: var(--border-strong);
}
.tl-item { position: relative; padding: 0 0 1.1rem 0.9rem; }
.tl-item::before {
  content: ''; position: absolute; left: -1.18rem; top: 0.35rem;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--amber);
}
.tl-item.done::before { background: var(--green); border-color: var(--green); }
.tl-item.upcoming::before { background: var(--amber); }
.tl-item.planned::before { background: var(--surface-alt); border-color: var(--border-strong); }
.tl-date { font-family: var(--mono); font-size: 0.72rem; color: var(--text-muted); }
.tl-item h4 { font-size: 0.9rem; font-weight: 600; margin-top: 0.15rem; }
.tl-item p { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; }
.tl-meta { font-size: 0.72rem; color: var(--text-faint); margin-top: 0.25rem; }

/* ─── Document graph ────────────────────────────────────────────────────── */
.graph-wrap { overflow: auto; }
.graph-wrap svg { max-width: 100%; height: auto; }
.graph-node-cat { cursor: default; }
.graph-node-doc { cursor: pointer; }
.graph-edge-contains { stroke: var(--border-strong); stroke-width: 1; opacity: 0.55; }
.graph-edge-related { stroke: var(--amber); stroke-width: 1.5; stroke-dasharray: 4 4; opacity: 0.45; }
.doc-list-filters { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.7rem; }
.doc-list-filters button {
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: 6px;
  padding: 0.28rem 0.55rem; font-size: 0.74rem; font-weight: 600; cursor: pointer; color: var(--text-muted);
}
.doc-list-filters button[aria-pressed='true'] {
  background: var(--navy); color: #fff; border-color: var(--navy);
}

/* ─── Q&A ───────────────────────────────────────────────────────────────── */
.qa-item { padding: 0.85rem 0; border-bottom: 1px solid var(--border); }
.qa-item:last-child { border-bottom: 0; }
.qa-q { font-size: 0.88rem; font-weight: 600; margin-top: 0.35rem; }
.qa-a { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.4rem; padding-left: 0.7rem; border-left: 2px solid var(--border-strong); }
.qa-a.empty { font-style: italic; color: var(--text-faint); }
.qa-meta { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; font-size: 0.72rem; color: var(--text-faint); }
