/* ============================================================================
   DRHP Intelligence Dashboard — institutional-grade UI
   Navy / Emerald / Gold on white. Inter throughout. 8-pt spacing system.
   ========================================================================== */
:root {
  /* Brand */
  --navy:       #062B4A;   /* dark navy — TEXT ONLY */
  --teal:       #064E45;   /* dark teal theme block (tabs, table headers) */
  --teal-deep:  #003F3F;
  --teal-active:#0E8F72;
  --navy-800:   #122F55;
  --navy-700:   #1B3B63;
  --navy-600:   #2A4A72;
  --emerald:    #0E7A5F;
  --emerald-600:#0F8568;
  --emerald-soft:#E7F2EE;
  --gold:       #B98A2E;     /* readable gold for text/badges */
  --gold-bright:#D6A64B;
  --gold-soft:  #F8F0DD;
  --slate:      #51607A;     /* WATCH */
  --slate-soft: #EDF0F4;
  --grey:       #8A93A1;     /* INSUFFICIENT */
  --grey-soft:  #F0F2F5;

  /* Neutrals */
  --bg:         #FFFFFF;
  --canvas:     #EDF6F0;   /* pale-mint tile tone */
  --accent-butter: #E8C95E;
  --butter-soft: rgba(232,201,94,0.14);
  --butter-border: rgba(232,201,94,0.28);
  --border:     #DDE7DF;
  --border-soft:#E9F0EC;
  --ink:        #1F2937;
  --ink-soft:   #6B7280;
  --ink-faint:  #9CA3AF;
  --red:        #B0413A;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --shadow-xs: 0 1px 2px rgba(15,45,82,0.05);
  --shadow-sm: 0 1px 3px rgba(15,45,82,0.06), 0 1px 2px rgba(15,45,82,0.04);
  --shadow-md: 0 4px 14px rgba(15,45,82,0.06), 0 2px 6px rgba(15,45,82,0.05);
  --shadow-lg: 0 10px 30px rgba(15,45,82,0.10);
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;

  --sidebar-w: 232px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink);
  background-color: #F8F7F0;
  background-image:
    radial-gradient(960px 540px at 100% -6%, rgba(232,201,94,0.10), transparent 60%),
    radial-gradient(840px 620px at -6% 6%, rgba(16,122,90,0.06), transparent 56%);
  background-attachment: fixed;
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; color: var(--navy); letter-spacing: -0.01em; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed; top: 0; left: 0; width: var(--sidebar-w); height: 100vh;
  background:
    linear-gradient(180deg, rgba(255,224,130,0.06), rgba(0,0,0,0) 22%),
    linear-gradient(180deg, #014C4C 0%, #013638 100%);
  color: #EAF6F1; display: flex; flex-direction: column; padding: 22px 16px; z-index: 20;
}
.side-brand { display: flex; align-items: center; gap: 11px; padding: 2px 6px 20px; }
.side-logo-box {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
  background: transparent; box-shadow: none; border-radius: 0;
}
.side-logo-box img { height: 40px; width: auto; display: block; filter: drop-shadow(0 1px 4px rgba(0,0,0,0.30)); }
.side-brand-txt { display: flex; flex-direction: column; line-height: 1.1; }
.side-brand-txt strong { color: #fff; font-size: 15px; font-weight: 700; letter-spacing: 0.04em; }
.side-brand-txt span { color: #E2B964; font-size: 9.5px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; }

/* small Munshot branding capsule under the logo */
.brand-capsule {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  margin: 0 6px 16px; padding: 4px 11px 4px 5px; border-radius: 999px;
  background: rgba(214,166,75,0.10); border: 1px solid rgba(214,166,75,0.30);
  color: #E2B964; font-size: 9.5px; font-weight: 600; letter-spacing: 0.03em;
}
.brand-capsule strong { color: #F2D99A; font-weight: 700; }
.bc-mark { width: 17px; height: 17px; border-radius: 50%; background: rgba(255,255,255,0.92); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.bc-mark img { height: 11px; width: auto; display: block; }
.side-label { font-size: 9.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: #7FB0A4; padding: 6px 10px; }
.side-nav { display: flex; flex-direction: column; gap: 3px; margin-top: 2px; }
.snav {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 11px; border: 0; border-radius: 9px; background: transparent;
  color: #A8C8BE; font-family: var(--font); font-size: 12.5px; font-weight: 500; cursor: pointer;
  text-align: left; transition: background .15s, color .15s;
}
.snav .ic { width: 19px; height: 19px; opacity: 0.9; }
.snav:hover { background: rgba(255,255,255,0.06); color: #fff; }
.snav.active {
  background: linear-gradient(180deg, rgba(15,139,116,0.34), rgba(11,111,99,0.30));
  color: #fff; box-shadow: inset 3px 0 0 var(--accent-butter), 0 0 0 1px rgba(232,201,94,0.12), 0 6px 16px rgba(232,201,94,0.10);
}
.snav.active .ic { color: #6FE0C0; opacity: 1; }
.side-foot { margin-top: auto; padding-top: 16px; }
.export-btn {
  display: flex; align-items: center; justify-content: center; gap: 9px; width: 100%;
  padding: 11px; border: 1px solid rgba(255,255,255,0.16); border-radius: 10px;
  background: rgba(255,255,255,0.04); color: #DCEFE8; font-family: var(--font); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s;
}
.export-btn:hover { background: rgba(255,255,255,0.10); }
.export-btn .ic { width: 17px; height: 17px; }

/* ---------- Main ---------- */
.main { margin-left: var(--sidebar-w); min-height: 100vh; }
.topbar {
  position: relative; overflow: hidden; background: linear-gradient(180deg, #FFFDF8 0%, #FFFFFF 62%);
  border-bottom: 1px solid var(--border);
  padding: 16px 26px; display: flex; align-items: center; justify-content: space-between; gap: 22px;
}
.topbar-flourish {
  position: absolute; top: 0; right: 0; width: 420px; height: 100%;
  background:
    radial-gradient(120% 160% at 100% 0%, rgba(14,122,95,0.10) 0%, rgba(14,122,95,0) 42%),
    radial-gradient(120% 180% at 88% 0%, rgba(6,78,69,0.10) 0%, rgba(6,78,69,0) 50%);
  pointer-events: none;
}
.title-wrap { position: relative; z-index: 2; }
.title-wrap h1 { font-size: 23px; font-weight: 700; letter-spacing: -0.02em; }
.title-wrap p { margin: 3px 0 0; color: var(--ink-soft); font-size: 12px; font-weight: 500; }
.head-right { position: relative; z-index: 2; display: flex; align-items: center; gap: 14px; }
.week-selector {
  display: flex; align-items: center; gap: 11px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--r); padding: 7px 13px; box-shadow: var(--shadow-xs);
}
.week-selector .ic { color: var(--emerald); width: 20px; height: 20px; }
.ws-week { font-size: 12px; font-weight: 700; color: var(--navy); white-space: nowrap; }
.ws-asof { font-size: 10.5px; color: var(--ink-faint); margin-top: 1px; }
.updated-badge {
  display: inline-flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--emerald); background: var(--emerald-soft); border-radius: 999px; padding: 5px 11px; white-space: nowrap;
}
.updated-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--emerald); box-shadow: 0 0 0 3px rgba(14,122,95,0.16); }

/* ---------- Pill tabs ---------- */
.pill-tabs { display: flex; gap: 7px; flex-wrap: wrap; padding: 14px 26px 0; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px;
  border: 1px solid #DCE6DE; border-radius: 999px; background: linear-gradient(180deg, #FFFDF7 0%, #F6F8F3 100%);
  color: var(--ink-soft); font-family: var(--font); font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all .16s ease;
}
.pill .pn {
  display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px;
  border-radius: 50%; background: var(--grey-soft); color: var(--ink-soft); font-size: 10px; font-weight: 700;
}
.pill:hover { border-color: var(--emerald); color: var(--teal); background: #F5F7EF; }
.pill.active { background: linear-gradient(135deg, #0C6B5B 0%, #0A7B68 100%); border-color: #0A7B68; color: #fff; box-shadow: var(--shadow-md), inset 0 1px 0 rgba(232,201,94,0.20); }
.pill.active .pn { background: rgba(255,255,255,0.22); color: #fff; }

/* ---------- Content & sections ---------- */
.content { padding: 18px 26px 56px; }
.tab-panel[hidden] { display: none; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.eyebrow { font-size: 10px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: #087A5A; }
.section-title { font-size: 18px; font-weight: 700; margin-top: 5px; letter-spacing: -0.02em; }
.block { margin-bottom: 18px; }

/* ---------- Cards ---------- */
.card {
  background: linear-gradient(180deg, #FFFDF8 0%, #F9FBF7 100%); border: 1px solid #DDE7DF; border-radius: var(--r-lg);
  box-shadow: 0 6px 20px rgba(8,45,38,0.06), inset 0 1px 0 rgba(232,201,94,0.10); padding: 18px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h3 { font-size: 12.5px; font-weight: 600; color: var(--navy); letter-spacing: 0.02em; text-transform: uppercase; }
.panel-divider { height: 1px; background: var(--border-soft); margin: 22px 0; }
.muted { color: var(--ink-faint); }
.tiny { font-size: 11.5px; }

/* ---------- KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 13px; }
.kpi {
  background: linear-gradient(180deg, #FFFDF8 0%, #F9FBF7 100%); border: 1px solid #DDE7DF; border-radius: var(--r-lg);
  padding: 17px 17px 15px; box-shadow: 0 6px 20px rgba(8,45,38,0.06), inset 0 1px 0 rgba(232,201,94,0.10); transition: transform .18s ease, box-shadow .18s ease;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi .kpi-icon { width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; background: var(--canvas); color: var(--navy); margin-bottom: 11px; }
.kpi .kpi-icon .ic { width: 17px; height: 17px; }
.kpi .kpi-label { font-size: 10.5px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-soft); }
.kpi .kpi-value { font-size: 26px; font-weight: 700; color: var(--navy); line-height: 1.05; margin-top: 3px; letter-spacing: -0.02em; }
.kpi .delta { margin-top: 9px; font-size: 10.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px; }
.kpi.dig   .kpi-icon { background: var(--emerald-soft); color: var(--emerald); }
.kpi.mon   .kpi-icon { background: var(--gold-soft); color: var(--gold); }
.kpi.watch .kpi-icon { background: var(--slate-soft); color: var(--slate); }
.delta.up   { color: var(--emerald); background: var(--emerald-soft); }
.delta.down { color: var(--red); background: #F6E9E7; }
.delta.flat { color: var(--ink-soft); background: var(--grey-soft); }
.delta.none { color: var(--ink-faint); background: var(--grey-soft); font-weight: 500; }

/* ---------- Column layouts ---------- */
.cols-3 { display: grid; grid-template-columns: 1.12fr 1fr 0.95fr; gap: 16px; align-items: start; }
.cols-2 { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; align-items: start; }

/* ---------- Tags / badges ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 6px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap;
}
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.dig   { background: var(--emerald-soft); color: var(--emerald); }
.tag.mon   { background: var(--gold-soft); color: var(--gold); }
.tag.watch { background: var(--slate-soft); color: var(--slate); }
.tag.insuf { background: var(--grey-soft); color: var(--grey); }

.stamp {
  display: inline-flex; align-items: center; padding: 2px 7px; border: 1px solid var(--border);
  border-radius: 5px; font-size: 9.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-soft); background: var(--canvas); margin: 0 5px 4px 0;
}
.stamp.week { color: var(--navy); border-color: #D5DEEA; background: #EEF3F9; }
.stamp.ipo  { color: var(--emerald); border-color: #CFE6DD; background: var(--emerald-soft); }

/* confidence dot */
.cdot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-left: 6px; vertical-align: middle; }
.cdot.low { background: var(--gold-bright); }
.cdot.web { background: var(--navy-600); }

/* ---------- Source links ---------- */
.src { display: inline-flex; gap: 7px; align-items: center; margin-top: 5px; }
.src-link {
  display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 600;
  color: var(--ink-soft); border: 1px solid var(--border); border-radius: 5px; padding: 2px 7px;
  background: var(--bg); transition: all .14s; white-space: nowrap;
}
.src-link:hover { color: var(--navy); border-color: var(--navy-600); background: #F4F7FB; text-decoration: none; }
.src-link.pdf:hover { color: var(--emerald); border-color: var(--emerald); }
.src-link svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.company a { color: var(--navy); }
.company a:hover { color: var(--emerald); text-decoration: underline; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
thead th {
  position: sticky; top: 0; background: linear-gradient(180deg, #0C6B5B 0%, #0A7B68 100%); color: #EAF7F2; font-weight: 600; text-align: left;
  padding: 9px 12px; font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase; white-space: nowrap; z-index: 1;
}
thead th:first-child { border-radius: var(--r-sm) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--r-sm) 0 0; }
tbody td { padding: 9px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tbody tr { transition: background .12s; }
tbody tr:nth-child(even) { background: #FBFCFD; }
tbody tr:hover { background: #F4F8F7; }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.company { font-weight: 600; color: var(--navy); }
.subtle { color: var(--ink-faint); }
a { color: var(--emerald); text-decoration: none; }
a:hover { text-decoration: underline; }
.score-cell { font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.table-foot { margin-top: 14px; font-size: 11.5px; color: var(--ink-faint); }

.mini-table td { padding: 9px 4px; border-bottom: 1px solid var(--border-soft); }
.mini-table tr:last-child td { border-bottom: none; }
.mini-table tr:hover { background: transparent; }
.mini-table .score-cell { font-size: 15px; }

/* ---------- Alerts ---------- */
.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list li { display: flex; gap: 11px; padding: 9px 0; border-bottom: 1px solid var(--border-soft); font-size: 12.5px; line-height: 1.45; }
.alert-list li:last-child { border-bottom: none; }
.alert-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; background: var(--teal-active); }
.alert-dot.green { background: var(--emerald); }
.alert-dot.gold  { background: var(--gold-bright); }
.alert-dot.grey  { background: var(--grey); }
.alert-list b { color: var(--navy); font-weight: 600; }
.stage2-note { margin-top: 14px; font-size: 11.5px; color: var(--ink-faint); font-style: italic; }

/* ---------- Sector concentration ---------- */
.sector-chips { display: flex; flex-direction: column; gap: 4px; }
.sector-chip { display: flex; align-items: center; gap: 11px; padding: 6px 0; border-bottom: 1px solid var(--border-soft); }
.sector-chip:last-child { border-bottom: none; }
.sector-chip .sc-ico { width: 32px; height: 32px; border-radius: 9px; background: var(--canvas); display:flex; align-items:center; justify-content:center; color: var(--emerald); flex: 0 0 auto; }
.sector-chip .sc-ico .ic { width: 17px; height: 17px; }
.sector-chip .sc-name { flex: 1; font-weight: 600; font-size: 13px; color: var(--ink); }
.sector-chip .sc-count { font-size: 16px; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.concentration-note { margin-top: 16px; padding: 12px 14px; background: var(--canvas); border: 1px solid var(--border-soft); border-radius: var(--r-sm); font-size: 12px; color: var(--ink-soft); line-height: 1.45; }
.concentration-note b { color: var(--navy); }

/* ---------- Bars ---------- */
.bars { display: flex; flex-direction: column; gap: 13px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 52px; align-items: center; gap: 12px; }
.bar-row .bl { font-size: 12.5px; font-weight: 500; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: var(--grey-soft); border-radius: 6px; height: 15px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, #0A5E54, var(--teal-active)); min-width: 3px; }
.bar-fill.green { background: linear-gradient(90deg, var(--emerald), var(--emerald-600)); }
.bar-row .bv { font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; color: var(--navy); font-weight: 700; }

/* ---------- Donut ---------- */
.donut-wrap { display: flex; align-items: center; gap: 22px; }
.donut { flex: 0 0 auto; }
.legend { display: flex; flex-direction: column; gap: 9px; font-size: 12.5px; flex: 1; }
.legend .li { display: flex; align-items: center; gap: 9px; color: var(--ink-soft); }
.legend .li b { margin-left: auto; color: var(--navy); font-variant-numeric: tabular-nums; }
.legend .sw { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; }

/* ---------- Insights ---------- */
.insights { display: flex; flex-direction: column; gap: 14px; }
.insight { display: flex; gap: 13px; align-items: flex-start; }
.insight .ico { width: 34px; height: 34px; border-radius: 9px; background: var(--gold-soft); color: var(--gold); display:flex; align-items:center; justify-content:center; flex: 0 0 auto; }
.insight .ico .ic { width: 17px; height: 17px; }
.insight .it { font-size: 12px; color: var(--ink-soft); line-height: 1.5; }
.insight .it b { color: var(--navy); font-weight: 600; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 72px 24px; background: var(--bg); border: 1px dashed var(--border); border-radius: var(--r-lg); }
.empty-state .es-ico { width: 60px; height: 60px; border-radius: 16px; background: var(--canvas); color: var(--navy); display: flex; align-items: center; justify-content: center; margin: 0 auto 18px; }
.empty-state .es-ico .ic { width: 28px; height: 28px; }
.empty-state h3 { font-size: 19px; margin-bottom: 9px; }
.empty-state p { color: var(--ink-soft); max-width: 460px; margin: 0 auto; font-size: 13.5px; line-height: 1.55; }
.es-badge { display: inline-block; margin-top: 18px; padding: 6px 14px; border-radius: 999px; background: var(--gold-soft); color: var(--gold); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; }

/* ---------- Footer ---------- */
.foot { margin-top: 36px; padding-top: 18px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--ink-faint); display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.legend-inline { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.legend-inline span { display: inline-flex; align-items: center; gap: 6px; }

.errbox { padding: 60px 24px; text-align: center; color: var(--red); }

/* Dense appendix */
#tab-appendix table { font-size: 12px; }
#tab-appendix thead th, #tab-appendix tbody td { padding: 9px 9px; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) { .cols-3, .cols-2 { grid-template-columns: 1fr; } .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 820px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .topbar { flex-direction: column; align-items: flex-start; padding: 20px; }
  .content, .pill-tabs { padding-left: 20px; padding-right: 20px; }
}

/* ============================================================================
   PRINT — A4. Show every tab in order; appendix lands on its own landscape page.
   ========================================================================== */
@media print {
  @page { size: A4; margin: 13mm; }
  body { background: #fff; font-size: 11px; }
  .no-print, .sidebar, .pill-tabs { display: none !important; }
  .main { margin-left: 0; }
  .topbar { border: none; padding: 0 0 12px; }
  .topbar-flourish { display: none; }
  .content { padding: 0; }
  .tab-panel { display: block !important; }
  .tab-panel + .tab-panel { break-before: page; }
  .block, .card, .kpi, tr, .insight, .bar-row, .sector-chip, .alert-list li, .empty-state { break-inside: avoid; }
  thead { display: table-header-group; }
  thead th { position: static; }
  .card, .kpi { box-shadow: none; }
  .table-wrap { overflow: visible; }
  @page appendix { size: A4 landscape; margin: 12mm; }
  #tab-appendix { page: appendix; }
  #tab-appendix table { font-size: 9.5px; }
  #tab-appendix thead th, #tab-appendix tbody td { padding: 5px 6px; }
  .print-title { display: block !important; font-size: 9px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--emerald); margin-bottom: 4px; }
}
.print-title { display: none; }
