:root {
  --navy: #0b1f3a;
  --blue: #2563eb;
  --blue-soft: #e8efff;
  --emerald: #059669;
  --emerald-soft: #e6f6f0;
  --red: #b42318;
  --red-soft: #fdecea;
  --slate: #475569;
  --slate-2: #94a3b8;
  --line: #e2e8f0;
  --bg: #f6f8fb;
  --card: #ffffff;
  --text: #0f172a;
  --radius: 10px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; line-height: 1.5; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--slate); }
.small { font-size: 12px; }

/* sign-in */
.signin { max-width: 400px; margin: 12vh auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 32px; }
.signin .brand { display: flex; align-items: center; gap: 12px; font-weight: 700; color: var(--navy); font-size: 15px; margin-bottom: 22px; }
.signin .brand img { height: 40px; width: auto; }
.signin .brand span { padding-left: 12px; border-left: 1px solid var(--line); }
.field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; }
.field input, .field select, .filters select, .filters input {
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font: inherit; background: #fff;
}
.code-input { letter-spacing: 10px; font-size: 22px; text-align: center; }
.btn { background: var(--navy); color: #fff; border: 0; border-radius: 8px; padding: 10px 16px; font-weight: 600; }
.btn.secondary { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn:disabled { opacity: .5; cursor: default; }
.error { color: var(--red); background: var(--red-soft); padding: 8px 10px; border-radius: 8px; margin-top: 10px; }
.note { background: var(--blue-soft); color: var(--navy); padding: 8px 10px; border-radius: 8px; margin-top: 10px; }

/* shell */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #cbd5e1; padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; }
.side .logo { color: #fff; font-weight: 600; font-size: 13px; letter-spacing: .04em; padding: 0 10px 18px; display: grid; gap: 6px; }
.side .logo img { height: 46px; width: auto; }
.side .logo span { color: #cbd5e1; }
.side .org { color: #fff; padding: 0 10px; font-weight: 600; }
.side .plan { padding: 0 10px 14px; font-size: 12px; color: #94a3b8; }
.side a { color: #cbd5e1; padding: 8px 10px; border-radius: 8px; display: block; }
.side a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.side a.on { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.side .spacer { flex: 1; }
.side .who { font-size: 12px; padding: 10px; color: #94a3b8; border-top: 1px solid rgba(255,255,255,.1); }
.side .who button { background: none; border: 0; color: #cbd5e1; padding: 0; text-decoration: underline; }
.main { padding: 22px 28px 60px; max-width: 1240px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar select { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; font: inherit; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card .help { font-size: 12px; color: var(--slate); margin-top: -6px; margin-bottom: 12px; }

/* brand headline */
.kpi .name { font-weight: 700; font-size: 15px; display: flex; justify-content: space-between; }
.kpi .big { font-size: 34px; font-weight: 700; color: var(--navy); line-height: 1.1; margin-top: 6px; }
.kpi .sub { color: var(--slate); font-size: 12px; }
.kpi .row { display: flex; gap: 18px; margin-top: 12px; }
.kpi .row div b { display: block; font-size: 16px; }
.delta-up { color: var(--emerald); font-weight: 600; }
.delta-down { color: var(--red); font-weight: 600; }

/* bars */
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar { display: grid; grid-template-columns: 130px 1fr 52px; align-items: center; gap: 10px; font-size: 13px; }
.bar .track { background: #eef2f7; border-radius: 6px; height: 18px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--slate-2); border-radius: 6px; }
.bar.own .fill { background: var(--blue); }
.bar.own .label { font-weight: 700; color: var(--blue); }
.bar .val { text-align: right; font-variant-numeric: tabular-nums; }

/* heat table */
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
th { color: var(--slate); font-weight: 600; font-size: 12px; }
td.heat { text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; border-radius: 6px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* insights */
.insight { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: start; }
.insight .dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; }
.insight.bad .dot { background: var(--red-soft); color: var(--red); }
.insight.good .dot { background: var(--emerald-soft); color: var(--emerald); }
.insight.info .dot { background: var(--blue-soft); color: var(--blue); }
.insight .t { font-weight: 700; }
.insight .d { color: var(--slate); }
.insight a { white-space: nowrap; font-weight: 600; }

/* answers */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.answer .q { font-weight: 700; font-size: 15px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 10px; }
.chip { background: #eef2f7; color: var(--slate); border-radius: 999px; padding: 2px 9px; font-size: 12px; }
.chip.own { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.chip.err { background: var(--red-soft); color: var(--red); }
.answer .text { white-space: pre-wrap; background: #fbfcfe; border: 1px solid var(--line); border-radius: 8px; padding: 12px; max-height: 260px; overflow: hidden; position: relative; }
.answer .text.open { max-height: none; }
.answer .text:not(.open)::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 50px; background: linear-gradient(transparent, #fbfcfe); }
mark { background: #fef3c7; padding: 0 2px; border-radius: 3px; }
mark.own { background: #dbe7ff; color: var(--navy); font-weight: 700; }
.order { margin: 10px 0 6px; font-size: 13px; }
.refs { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.refs li { margin: 2px 0; }
.tag { font-size: 11px; border-radius: 4px; padding: 1px 6px; margin-left: 6px; }
.tag.own { background: var(--emerald-soft); color: var(--emerald); font-weight: 600; }
.tag.comp { background: #eef2f7; color: var(--slate); }
.linkbtn { background: none; border: 0; color: var(--blue); padding: 0; font-weight: 600; }

.empty { text-align: center; padding: 40px; color: var(--slate); }
.glossary dt { font-weight: 700; margin-top: 8px; }
.glossary dd { margin: 0; color: var(--slate); }
@media (max-width: 900px) { .shell { grid-template-columns: 1fr; } .side { display: none; } .g2, .g3 { grid-template-columns: 1fr; } }

textarea { font: inherit; }
::placeholder { color: #94a3b8; }
.answer .text table.md { border-collapse: collapse; margin: 6px 0; white-space: normal; font-size: 13px; }
.answer .text table.md th, .answer .text table.md td { border: 1px solid var(--line); padding: 4px 8px; text-align: start; vertical-align: top; }
.answer .text table.md th { background: #f1f5f9; }
