:root {
  /* StarQuest brand: Electric indigo & hot coral */
  --midnight: #1B1464;      /* Electric indigo: top bar, dark tiles */
  --midnight-2: #2A2380;
  --coral: #FF5A5F;         /* Hot coral: logo trail, highlights on dark */
  --coral-deep: #D42F35;    /* Hot coral (deep): buttons, links, eyebrows on light (meets 4.5:1 on white) */
  --gold: #FFC83D;          /* Star gold */
  --lavender: #C9C5F0;      /* Secondary text on indigo */
  --shell: #F7F6FF;         /* Page background */
  --ink: #1B1464;           /* Headings and body text */
  --muted: #625E86;
  --line: #E4E2F2;
  --card: #FFFFFF;
  /* Status colors are separate from the brand so warnings never look like buttons */
  --good: #1F7A5C;
  --warn: #B26B00;
  --bad: #A8192E;           /* Alert crimson: harm/IJ, abuse icon, inactive flags */
  --bad-bg: #FBE7EA;
  --radius: 14px;
  --head: "Playfair Display", Georgia, serif;
  --body: "Source Sans 3", system-ui, -apple-system, Segoe UI, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--body); color: var(--ink); background: var(--shell); font-size: 15px; line-height: 1.45; }
a { color: var(--coral-deep); }
h1, h2, h3 { font-family: var(--head); font-weight: 600; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.02rem; }
.container { max-width: 1240px; margin: 0 auto; padding: 0 24px; }

/* Top bar */
.topbar { background: var(--midnight); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 12px 24px; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand img { border-radius: 10px; }
.brand-text { display: flex; flex-direction: column; }
.wordmark { font-family: var(--head); font-size: 1.35rem; font-weight: 700; line-height: 1.1; }
.tagline { font-size: .66rem; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); }
.topbar-right { display: flex; align-items: center; gap: 16px; font-size: .9rem; flex-wrap: wrap; }
.user { color: var(--lavender); }
.signout { color: #fff; border: 1px solid rgba(255,255,255,.3); padding: 6px 12px; border-radius: 999px; text-decoration: none; }
.signout:hover { border-color: var(--coral); color: var(--coral); }
.client-picker { display: flex; align-items: center; gap: 8px; color: var(--lavender); }
.client-picker select { background: var(--midnight-2); color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: 8px; padding: 6px 10px; font: inherit; }

main { padding-top: 28px; padding-bottom: 40px; min-height: 60vh; }
.loading, .empty { color: var(--muted); padding: 40px 0; }
.error-box { background: var(--bad-bg); border: 1px solid #F2B8C1; color: #7A1222; padding: 16px 18px; border-radius: var(--radius); }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.eyebrow { font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; color: var(--coral-deep); font-weight: 700; margin-bottom: 4px; }
.sub { color: var(--muted); }
.back { display: inline-block; margin-bottom: 12px; text-decoration: none; font-weight: 500; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.grid { display: grid; gap: 16px; }
.grid-portfolio { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-2 { grid-template-columns: 1fr; } }
section { margin-top: 22px; }

.fac-card { text-decoration: none; color: inherit; display: block; transition: border-color .15s, transform .15s; }
.fac-card:hover { border-color: var(--coral); transform: translateY(-1px); }
.fac-card h3 { margin-bottom: 2px; }
.fac-meta { color: var(--muted); font-size: .85rem; margin-bottom: 12px; }
.mini-stars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.mini-stars div { background: var(--shell); border-radius: 8px; padding: 6px 8px; text-align: center; }
.mini-stars .lbl { font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.mini-stars .val { font-family: var(--head); font-size: 1.25rem; font-weight: 700; }
.fac-foot { display: flex; justify-content: space-between; font-size: .84rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; gap: 8px; }
.fac-foot b { color: var(--ink); }

/* Star tiles */
.star-tile { text-align: left; }
.star-tile .lbl { font-size: .74rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; }
.stars { font-size: 1.5rem; letter-spacing: 2px; margin: 4px 0 2px; }
.stars .on { color: var(--gold); }
.stars .off { color: #E2E0F0; }
.star-tile .note { font-size: .82rem; color: var(--muted); }
.star-tile.overall { background: var(--midnight); color: #fff; border-color: var(--midnight); }
.star-tile.overall .lbl, .star-tile.overall .note { color: var(--lavender); }
.star-tile.overall .stars .off { color: #3A3390; }

/* Score breakdown */
.score-table { width: 100%; border-collapse: collapse; }
.score-table th, .score-table td { padding: 8px 6px; text-align: right; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.score-table th:first-child, .score-table td:first-child { text-align: left; }
.score-table th { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.score-table tr.total td { font-weight: 700; border-bottom: none; font-size: 1.05rem; }
.hint { font-size: .82rem; color: var(--muted); margin-top: 8px; }

.kpi { font-family: var(--head); font-size: 2rem; font-weight: 700; line-height: 1; }
.kpi-row { display: flex; gap: 28px; flex-wrap: wrap; margin: 6px 0 4px; }
.kpi-row .lbl { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 8px; border-bottom: 2px solid var(--line); white-space: nowrap; background: var(--card); position: sticky; top: 0; }
table.data td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr:hover td { background: #FAF9FF; }
.desc { max-width: 460px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0 12px; }
.filters select, .filters input { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.filters input { min-width: 220px; }

/* Pills */
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.pill.std { background: #E9E7FB; color: var(--midnight); }
.pill.cmp { background: #FFE8E9; color: #B3242A; }
.pill.both { background: #FFF3DC; color: #8A5B00; }
.pill.ic { background: #E3F3EE; color: #1F6B54; }
.pill.flag { background: var(--bad); color: #fff; }
.pill.warn { background: #FFF3DC; color: #8A5B00; }
.pill.ok { background: #E3F3EE; color: #1F6B54; }
.pill.gray { background: #EEEDF6; color: var(--muted); }

.ss { display: inline-block; width: 26px; height: 26px; line-height: 26px; text-align: center; border-radius: 6px; font-weight: 700; font-size: .85rem; }
.ss-low { background: #EEEDF6; color: var(--muted); }
.ss-mid { background: #FFF3DC; color: #8A5B00; }
.ss-harm { background: var(--bad-bg); color: var(--bad); }
.ss-ij { background: var(--bad); color: #fff; }

.flags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.tl-item:last-child { border-bottom: none; }
.tl-date { font-variant-numeric: tabular-nums; color: var(--muted); }

.footer { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; padding-top: 16px; padding-bottom: 28px; border-top: 1px solid var(--line); flex-wrap: wrap; gap: 8px; }
.client-picker[hidden] { display: none; }

/* ---- Uploads / Cutpoint ---- */
.navlink { color: #fff; text-decoration: none; font-weight: 500; }
.navlink:hover { color: var(--coral); }
.navlink[hidden] { display: none; }
.fs-mini { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .8rem; margin-top: 10px; flex-wrap: wrap; }
.bands { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 8px 0 14px; }
.band { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--shell); }
.band.here { background: var(--midnight); border-color: var(--midnight); color: #fff; }
.band.here .band-rng { color: var(--gold); }
.band-star { font-family: var(--head); font-weight: 700; font-size: 1.05rem; }
.band-rng { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
table.data th.num { text-align: right; }
table.qm td.proj, table.qm th.proj { background: #F4F2FF; }
.up { color: var(--good); font-size: .75rem; font-weight: 700; white-space: nowrap; }
.down { color: var(--bad); font-size: .75rem; font-weight: 700; white-space: nowrap; }
.stars-sm { color: var(--gold); letter-spacing: 1px; white-space: nowrap; }
.idr { margin: 6px 0 0; padding-left: 18px; font-size: .9rem; }
.linkbtn { background: none; border: none; color: var(--coral-deep); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 2px dashed var(--lavender); border-radius: var(--radius); padding: 36px; background: #fff; cursor: pointer; text-align: center; }
.dropzone.over { border-color: var(--coral); background: #FFF3F3; }
.queue { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.qitem { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: .9rem; display: flex; flex-direction: column; gap: 3px; }
.qname { font-weight: 700; display: flex; gap: 8px; align-items: center; }
.err { color: var(--bad); }
.warn-txt { color: #8A5B00; font-size: .85rem; }
.actions { display: flex; align-items: center; gap: 14px; }
.btn { background: var(--coral-deep); color: #fff; border: none; border-radius: 999px; padding: 10px 20px; font: inherit; font-weight: 700; cursor: pointer; }
.btn:disabled { background: #D6D4E8; cursor: default; }
sup { font-size: .65em; color: var(--muted); margin-left: 1px; }
.kpi-lbl { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.page-head .filters { margin: 0; align-items: center; }
button.signout { background: none; font: inherit; cursor: pointer; }
.signout[hidden] { display: none; }
.signin-wrap { display: grid; grid-template-columns: 1fr auto; gap: 48px; align-items: center; padding: 40px 0; }
.signin-copy h1 { font-size: 2.4rem; }
@media (max-width: 900px) { .signin-wrap { grid-template-columns: 1fr; } }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .85rem; cursor: pointer; }
.chip.on { background: var(--midnight); border-color: var(--midnight); color: #fff; }
.qmcard { margin-bottom: 18px; }
.qmcard .kpi { font-size: 1.5rem; }
tr.click { cursor: pointer; }
.coverage td.stale { color: var(--warn); font-weight: 600; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 4px 0 18px; }
.tab { padding: 10px 16px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tab.on { color: var(--ink); border-bottom-color: var(--coral-deep); }
.tab:hover { color: var(--ink); }
/* roadmap */
.rm-row { display: grid; grid-template-columns: 30px 200px 1fr auto; gap: 14px; align-items: start; padding: 14px 0; border-top: 1px solid var(--line); }
.rm-num { font-family: var(--head); font-size: 1.4rem; color: var(--coral-deep); font-weight: 600; }
.rm-row ul { margin: 0; padding-left: 18px; font-size: .9rem; }
.rm-row li { margin-bottom: 4px; }
.rm-row select { font: inherit; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; margin-left: 4px; }
.sim { margin-top: 8px; border-radius: 12px; background: var(--midnight); color: #fff; padding: 16px 18px; display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; }
.sim .big { font-family: var(--head); font-size: 2rem; font-weight: 600; }
.sim .lbl2 { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--lavender); }
.sim .gold { color: var(--gold); }
.btn.sm { padding: 6px 12px; font-size: .85rem; }
.btn.ghost { background: transparent; color: var(--coral-deep); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--coral-deep); }
.pill.gold { background: #FFF4D6; color: #7A5600; }
.pill.inplan { background: #E3F3EE; color: #1F6B54; }
select.status { font: inherit; font-size: .85rem; padding: 4px 6px; border: 1px solid var(--line); border-radius: 8px; }
.note-txt { white-space: pre-wrap; color: var(--muted); font-size: .85rem; margin-top: 2px; }
/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(27, 20, 100, .45); display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: var(--radius); padding: 22px 24px; width: 100%; max-width: 560px; }
.modal label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin: 12px 0 4px; }
.modal input, .modal select, .modal textarea { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); }
.modal textarea { min-height: 90px; }
.modal .row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.modal .actions-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; align-items: center; }
.modal .actions-row .left { margin-right: auto; }
.field-err { color: var(--bad); font-size: .85rem; margin-top: 4px; }
@media (max-width: 800px) { .rm-row { grid-template-columns: 24px 1fr; } .rm-row > ul, .rm-row > div:last-child { grid-column: 2; } .modal .row3 { grid-template-columns: 1fr; } }
.bar { height: 10px; background: #EEEDF6; border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--coral-deep); border-radius: 999px; }
.filters input[type="date"] { padding: 6px 8px; }
.radio label, label.chk { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--ink); margin: 6px 0; font-size: .92rem; }
.modal .radio input, .modal label.chk input { width: auto; }
.fac-list { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin-top: 4px; }
.fac-list.disabled { opacity: .5; }
code { background: #EEEDF6; padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.linkbtn.danger { color: var(--bad); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger:disabled { opacity: .45; cursor: not-allowed; }
.inactive-card { background: #FBFAFF; border-style: dashed; }
