:root {
  --navy: #10253f;
  --navy-2: #0b1b2f;
  --navy-3: #1b3554;
  --gold: #c6a15b;
  --gold-deep: #8a6a2f;
  --gold-soft: #f3e9d5;
  --white: #fbf8f2;
  --paper: #ffffff;
  --ink: #16222f;
  --muted: #5b6573;
  --line: #e6dfd2;
  --line-2: #d8cfbf;
  --good: #2f6b4f;
  --good-bg: #e5f1ea;
  --warn: #8a5a12;
  --warn-bg: #fbefd9;
  --bad: #a3312b;
  --bad-bg: #f9e3e1;
  --info: #23507e;
  --info-bg: #e3edf8;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 37, 63, .06), 0 8px 24px -12px rgba(16, 37, 63, .18);
  --display: "Fraunces", Georgia, serif;
  --body: "Manrope", "Segoe UI", sans-serif;
  --focus: 0 0 0 3px rgba(198, 161, 91, .55);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: var(--body);
  color: var(--ink);
  background: var(--white);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; letter-spacing: -.01em; margin: 0 0 .4em; color: var(--navy); line-height: 1.15; }
h1 { font-size: clamp(1.7rem, 2.4vw, 2.3rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.08rem; }
p { margin: 0 0 .8em; }
a { color: var(--info); }
small, .muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--gold); color: var(--navy); padding: 8px 14px; border-radius: 8px; z-index: 100; font-weight: 700; }
.skip-link:focus { left: 12px; }

/* ---------- buttons & form controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  font: 600 .92rem/1 var(--body); border-radius: 999px; border: 1px solid transparent;
  padding: .72em 1.2em; cursor: pointer; text-decoration: none; transition: transform .12s, background .15s, border-color .15s;
  background: var(--navy); color: #fff; white-space: nowrap;
}
.btn:hover { background: var(--navy-3); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.gold { background: var(--gold); color: var(--navy-2); }
.btn.gold:hover { background: #d4b273; }
.btn.ghost { background: transparent; color: var(--navy); border-color: var(--line-2); }
.btn.ghost:hover { border-color: var(--navy); background: #fff; }
.btn.danger { background: transparent; color: var(--bad); border-color: #e6bdb9; }
.btn.small { padding: .5em .85em; font-size: .82rem; }
.btn.link { background: none; color: var(--info); padding: .2em 0; border-radius: 4px; }
.btn.link:hover { text-decoration: underline; }

label { display: grid; gap: 5px; font-weight: 600; font-size: .85rem; color: var(--navy); }
label .hint { font-weight: 500; color: var(--muted); font-size: .78rem; }
input, select, textarea {
  font: 500 .93rem var(--body); color: var(--ink); background: #fff; border: 1px solid var(--line-2);
  border-radius: var(--radius-sm); padding: .62em .75em; width: 100%; min-height: 42px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold-deep); box-shadow: var(--focus); }
input[type="checkbox"] { width: auto; min-height: 0; }
input[type="file"] { padding: .45em; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 6px; }
.form-error { color: var(--bad); font-weight: 600; font-size: .86rem; min-height: 1.2em; margin: 0; }

/* ---------- surfaces ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card.flat { box-shadow: none; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.eyebrow { font: 700 .7rem/1 var(--body); letter-spacing: .16em; text-transform: uppercase; color: var(--gold-deep); margin-bottom: 8px; display: block; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }

.badge { display: inline-flex; align-items: center; gap: 4px; font: 700 .7rem/1 var(--body); letter-spacing: .04em; text-transform: uppercase; padding: .45em .65em; border-radius: 999px; background: #eef0f3; color: var(--navy); white-space: nowrap; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.gold { background: var(--gold-soft); color: var(--gold-deep); }
.badge.sample { background: var(--gold); color: var(--navy-2); }

.empty { text-align: center; padding: 28px 16px; color: var(--muted); border: 1px dashed var(--line-2); border-radius: var(--radius); background: #fdfbf7; }
.empty strong { display: block; color: var(--navy); font-family: var(--display); font-size: 1.05rem; margin-bottom: 4px; }
.notice { border-radius: var(--radius-sm); padding: 12px 14px; background: var(--info-bg); color: var(--info); font-size: .88rem; }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.notice.gold { background: var(--gold-soft); color: #5e4518; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); background: #faf7f1; font-weight: 700; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fdfaf4; }
td .sub { display: block; color: var(--muted); font-size: .8rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--navy); color: #dfe6ef; padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; padding: 4px 8px 12px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand svg { width: 34px; height: 34px; flex: none; }
.brand b { font: 600 1.05rem var(--display); letter-spacing: .14em; }
.brand b span { color: var(--gold); }
.brand small { display: block; color: #9fb0c4; font-size: .66rem; letter-spacing: .14em; text-transform: uppercase; }
.nav { display: grid; gap: 2px; }
.nav .group { font: 700 .66rem var(--body); letter-spacing: .16em; text-transform: uppercase; color: #7f93ab; padding: 12px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; color: #dfe6ef; text-decoration: none; padding: 9px 10px; border-radius: 9px; font-weight: 600; font-size: .9rem; }
.nav a svg { width: 18px; height: 18px; opacity: .8; flex: none; }
.nav a:hover { background: rgba(255,255,255,.06); }
.nav a[aria-current="page"] { background: rgba(198,161,91,.16); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.side-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding-top: 12px; font-size: .82rem; display: grid; gap: 8px; }
.side-foot .who { color: #fff; font-weight: 700; }
.side-foot .btn.ghost { color: #fff; border-color: rgba(255,255,255,.25); }
.side-foot .btn.ghost:hover { background: rgba(255,255,255,.08); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 28px; border-bottom: 1px solid var(--line); background: rgba(251,248,242,.92); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 20; }
.topbar .menu-btn { display: none; }
.content { padding: 26px 28px 60px; max-width: 1320px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 0; color: var(--muted); }
.sample-banner { background: #fff; padding: 8px 28px; font-size: .84rem; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.sample-banner select { width: auto; min-height: 34px; padding: .3em .5em; font-size: .82rem; }
.sample-info { position: relative; }
.sample-info summary { cursor: pointer; color: var(--info); font-weight: 600; list-style: none; padding: 4px 6px; border-radius: 6px; }
.sample-info summary::before { content: "i"; display: inline-grid; place-items: center; width: 16px; height: 16px; margin-right: 5px; border-radius: 50%; border: 1.5px solid currentColor; font: 700 .68rem/1 Georgia, serif; font-style: italic; }
.sample-info summary::-webkit-details-marker { display: none; }
.sample-pop { position: absolute; left: 0; top: calc(100% + 6px); z-index: 30; width: min(360px, 80vw); background: #fff; border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); color: var(--ink); line-height: 1.45; }
.scrim { display: none; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; inset: auto 0 0 0; height: 3px; background: linear-gradient(90deg, var(--gold), transparent); opacity: .7; }
.kpi .label { font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.kpi .value { font: 600 1.75rem/1.1 var(--display); color: var(--navy); margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.kpi .foot { font-size: .78rem; color: var(--muted); }
.kpi.alert .value { color: var(--bad); }

/* ---------- bars ---------- */
.bars { display: grid; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 70px; gap: 10px; align-items: center; font-size: .85rem; }
.bar-track { height: 10px; background: #f0ebe1; border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--navy); border-radius: 99px; }
.bar-fill.gold { background: var(--gold); }

/* ---------- home health ---------- */
.health-hero { display: grid; grid-template-columns: auto 1fr; gap: 26px; align-items: center; background: linear-gradient(135deg, var(--navy) 0%, #183457 100%); color: #e8eef5; border: 0; }
.health-hero h2, .health-hero h3 { color: #fff; }
.health-hero .muted { color: #b6c3d3; }
.ring { --v: 0; width: 148px; height: 148px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--gold) calc(var(--v) * 1%), rgba(255,255,255,.12) 0); position: relative; }
.ring::before { content: ""; position: absolute; inset: 12px; border-radius: 50%; background: var(--navy); }
.ring span { position: relative; text-align: center; }
.ring b { display: block; font: 600 2.6rem/1 var(--display); color: #fff; }
.ring small { color: #b6c3d3; font-size: .62rem; letter-spacing: .08em; text-transform: uppercase; display: block; max-width: 96px; margin: 4px auto 0; line-height: 1.2; }
.comp-grid { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.comp { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 6px; align-content: start; }
.comp .score { font: 600 1.6rem/1 var(--display); color: var(--navy); }
.comp .meter { height: 6px; border-radius: 99px; background: #efe9de; overflow: hidden; }
.comp .meter i { display: block; height: 100%; background: var(--gold); }
.comp dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; font-size: .78rem; }
.comp dt { color: var(--muted); }
.comp dd { margin: 0; text-align: right; font-weight: 600; }
.comp .missing { font-size: .78rem; color: var(--warn); }
details.method { font-size: .85rem; }
details.method summary { cursor: pointer; font-weight: 700; color: var(--navy); }

/* ---------- timeline & stages ---------- */
.stages { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; margin: 12px 0 6px; padding: 0; }
.stages li { list-style: none; height: 8px; border-radius: 99px; background: #e9e3d7; }
.stages li.done { background: var(--navy); }
.stages li.current { background: var(--gold); }
.stage-caption { font-size: .82rem; color: var(--muted); margin-bottom: 6px; }
.stage-caption b { color: var(--navy); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); display: grid; gap: 14px; }
.timeline li { position: relative; font-size: .88rem; }
.timeline li::before { content: ""; position: absolute; left: -25px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--gold); }
.timeline time { color: var(--muted); font-size: .78rem; display: block; }
.progress-units { display: flex; gap: 3px; flex-wrap: wrap; margin: 6px 0; }
.progress-units i { width: 14px; height: 14px; border-radius: 3px; background: #eae4d8; }
.progress-units i.on { background: var(--navy); }

/* ---------- lists ---------- */
.list { display: grid; gap: 0; }
.list > * { padding: 12px 0; border-bottom: 1px solid var(--line); }
.list > *:last-child { border-bottom: 0; }
.item-title { font-weight: 700; color: var(--navy); }
.offer { border: 1px solid #e7d6b2; background: linear-gradient(140deg, #fffaf0, #f7ecd6); border-radius: var(--radius); padding: 16px; display: grid; gap: 6px; }
.offer .offer-text { font: 600 1.15rem var(--display); color: var(--gold-deep); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.filters label { min-width: 150px; }
.filters input[type="search"] { min-width: 220px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button { border: 1px solid var(--line-2); background: #fff; border-radius: 999px; padding: .5em 1em; font: 600 .84rem var(--body); cursor: pointer; color: var(--navy); }
.tabs button[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.lane { background: #f6f2ea; border-radius: var(--radius); padding: 10px; display: grid; gap: 8px; align-content: start; min-height: 120px; }
.lane h3 { font-size: .8rem; font-family: var(--body); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); display: flex; justify-content: space-between; }
.lane .card { padding: 12px; box-shadow: none; }

/* ---------- modal & toast ---------- */
dialog { border: 0; border-radius: 18px; padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 30px 80px -20px rgba(11,27,47,.5); color: var(--ink); }
dialog::backdrop { background: rgba(11, 27, 47, .55); }
.modal-body { padding: 24px; overflow-y: auto; max-height: calc(100vh - 40px); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.icon-btn { border: 0; background: transparent; cursor: pointer; font-size: 1.4rem; line-height: 1; color: var(--muted); padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: #f2ede4; color: var(--navy); }
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 200; }
.toast { background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 600; font-size: .88rem; max-width: 360px; animation: rise .25s ease-out; }
.toast.bad { background: var(--bad); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.skeleton { background: linear-gradient(90deg, #efe9de 0%, #f8f4ec 50%, #efe9de 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius); min-height: 120px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .g4, .comp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 272px; z-index: 60; transform: translateX(-100%); transition: transform .22s ease; }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(11,27,47,.45); z-index: 50; }
  .topbar { padding: 10px 16px; }
  .topbar .menu-btn { display: inline-flex; }
  .content { padding: 18px 16px 50px; }
  .sample-banner { padding: 9px 16px; }
  .g2, .g3, .g4, .form-grid { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .health-hero { grid-template-columns: 1fr; justify-items: start; }
  .bar-row { grid-template-columns: 110px 1fr 56px; }
}
@media (max-width: 520px) {
  .comp-grid { grid-template-columns: 1fr; }
  .filters label, .filters input[type="search"] { min-width: 0; width: 100%; }
  .topbar .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- AI ---------- */
.chat-log { display: grid; gap: 10px; max-height: 52vh; min-height: 160px; overflow-y: auto; padding: 4px 2px 12px; }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.msg-body { max-width: 78%; padding: 10px 14px; border-radius: 14px; background: #f3efe6; font-size: .92rem; }
.msg.user .msg-body { background: var(--navy); color: #fff; }
.consent { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; font-size: .84rem; color: var(--ink); }
.consent input { margin-top: 3px; }
.designs { display: grid; gap: 16px; }
.design { display: grid; gap: 8px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.design:last-child { border-bottom: 0; }
.design-imgs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.design-imgs figure { margin: 0; }
.design-imgs img, .design-wait { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; background: #efe9de; display: grid; place-items: center; font-size: .82rem; color: var(--muted); }
.design-wait.pending { animation: shimmer 1.2s infinite; background: linear-gradient(90deg, #efe9de 0%, #f8f4ec 50%, #efe9de 100%); background-size: 200% 100%; }
.design-imgs figcaption { font-size: .74rem; color: var(--muted); margin-top: 2px; }
@media (max-width: 860px) { .msg-body { max-width: 92%; } .sample-banner { padding: 8px 16px; } }
