/* BCIL Price Desk. Navy sidebar, light grey ground, white cards, teal accent,
   amber for anything still to confirm. Fonts: Inter (text), Space Grotesk (headings, figures). */

@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("/static/fonts/space-grotesk-latin-wght-normal.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  --navy: #0b1f33;
  --navy-2: #16314d;
  --ground: #f4f6f8;
  --card: #ffffff;
  --teal: #0f766e;
  --teal-soft: #e3f2f0;
  --amber: #b45309;
  --amber-soft: #fdf1e1;
  --ink: #14212e;
  --ink-2: #51606f;
  --line: #e2e7ec;
  --line-strong: #c5ced6;
  --critical: #b3261e;
  --critical-soft: #fbe9e7;
  /* Coverage states: always shown with their label and count, never by colour alone. */
  --cov-matched: #0f766e;
  --cov-proxy: #257de0;
  --cov-quotes: #6b7785;
  --cov-review: #b45309;
  --radius: 10px;
  --font-text: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 15px/1.5 var(--font-text);
}
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; margin: 0; text-wrap: balance; }
h1 { font-size: 1.75rem; font-weight: 600; }
h2 { font-size: 1.15rem; font-weight: 600; margin-bottom: 0.75rem; }
h3 { font-size: 0.95rem; font-weight: 600; }
h4 { font-size: 0.85rem; font-weight: 600; color: var(--ink-2); margin-bottom: 0.35rem; }
p { margin: 0 0 0.6rem; }
a { color: var(--teal); text-underline-offset: 2px; }
a:hover { color: #0b5a54; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--ink-2); }
.small { font-size: 0.82rem; }
.num { font-variant-numeric: tabular-nums; }

.skip-link { position: absolute; left: -999px; top: 0; background: var(--card); padding: 0.5rem 1rem; z-index: 10; }
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--navy);
  color: #d6e0ea;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 0.7rem; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px; background: var(--teal); color: #fff;
  display: grid; place-items: center; font: 700 1.1rem var(--font-display);
}
.brand-name { display: block; font: 600 1rem var(--font-display); color: #fff; }
.brand-sub { display: block; font-size: 0.75rem; color: #9fb2c5; }
.brand-dark .brand-name { color: var(--ink); }
.brand-dark .brand-sub { color: var(--ink-2); }
.sidebar nav { display: flex; flex-direction: column; gap: 0.2rem; }
.nav-link {
  color: #d6e0ea; text-decoration: none; padding: 0.55rem 0.75rem; border-radius: 8px;
  border-left: 3px solid transparent;
}
.nav-link:hover { background: var(--navy-2); color: #fff; }
.nav-link.is-active { background: var(--navy-2); color: #fff; border-left-color: #2dd4bf; font-weight: 600; }
.sidebar :focus-visible { outline-color: #5eead4; }
.account { margin-top: auto; font-size: 0.85rem; }
.account-name { color: #fff; font-weight: 600; overflow-wrap: anywhere; }
.account-role { color: #9fb2c5; margin-bottom: 0.6rem; }
.content { padding: 1.5rem 1.75rem 3rem; display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.page-head p { margin: 0.3rem 0 0; }
.crumbs { font-size: 0.82rem; margin: 0 0 0.25rem; color: var(--ink-2); }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.card-head h2 { margin: 0; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 0.9rem; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 1.25rem; }
section > h2 { margin-bottom: 0.75rem; }
.benchmark, .kpi { display: flex; flex-direction: column; gap: 0.35rem; }
.benchmark-head { display: flex; justify-content: space-between; gap: 0.5rem; align-items: flex-start; }
.benchmark p, .kpi p { margin: 0; }

/* ---------- figures: every number is a button that opens its evidence ---------- */
.fig {
  appearance: none; background: none; border: 0; padding: 0.05rem 0.15rem; margin: -0.05rem -0.15rem;
  font: inherit; color: var(--ink); cursor: pointer; text-align: left; border-radius: 4px;
  font-variant-numeric: tabular-nums;
}
.fig .fig-value { font-weight: 600; text-decoration: underline dotted var(--line-strong); text-underline-offset: 3px; }
.fig:hover { background: var(--teal-soft); }
.fig:hover .fig-value { text-decoration-color: var(--teal); }
.fig-unit { color: var(--ink-2); font-size: 0.82em; font-weight: 400; }
.fig-blank .fig-value { color: var(--ink-2); font-weight: 400; }
.fig-confirm .fig-value { text-decoration-color: var(--amber); }
.fig-lg .fig-value { font: 600 1.35rem var(--font-display); }
.fig-xl .fig-value { font: 600 1.75rem var(--font-display); }
.fig-xl, .fig-lg { font-variant-numeric: normal; }
.fig-change .fig-value { font-weight: 600; }
.delta { font-size: 0.7em; color: var(--ink-2); margin-right: 0.15rem; }

/* ---------- tags ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 0.3rem; white-space: nowrap;
  font-size: 0.75rem; font-weight: 600; line-height: 1.3;
  padding: 0.15rem 0.5rem; border-radius: 999px;
  background: #eef1f4; color: var(--ink-2);
}
.tag-confirm { background: var(--amber-soft); color: var(--amber); white-space: normal; border-radius: 8px; }
.tag-ok { background: var(--teal-soft); color: var(--teal); }
.tag-critical { background: var(--critical-soft); color: var(--critical); }
.tag-warning { background: var(--amber-soft); color: var(--amber); }
.tag-coverage::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--cov-review); }
.tag-public_grade_matched::before { background: var(--cov-matched); }
.tag-proxy::before { background: var(--cov-proxy); }
.tag-supplier_quotes_only::before { background: var(--cov-quotes); }
.confirm-list { margin: 0.25rem 0 0; padding-left: 1.1rem; color: var(--amber); font-size: 0.85rem; }
.confirm-list li { margin-bottom: 0.1rem; }
.confirm-title { margin: 0.4rem 0 0; }

/* ---------- coverage bar: one whole split into parts ---------- */
.segbar { display: flex; gap: 2px; height: 8px; margin: 0.6rem 0; }
.segbar-part { flex: 1 1 0; border-radius: 999px; min-width: 4px; }
.seg-public_grade_matched { background: var(--cov-matched); }
.seg-proxy { background: var(--cov-proxy); }
.seg-supplier_quotes_only { background: var(--cov-quotes); }
.seg-under_review { background: var(--cov-review); }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; padding: 0; margin: 0.4rem 0 0; font-size: 0.85rem; color: var(--ink); }
.legend li { display: inline-flex; align-items: center; gap: 0.4rem; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.swatch-line { width: 16px; height: 0; border-top: 2px solid; border-radius: 0; }
.swatch-dot { width: 9px; height: 9px; border-radius: 50%; }

/* ---------- definition pairs ---------- */
.pairs { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.3rem 0.9rem; margin: 0; }
.pairs dt { color: var(--ink-2); }
.pairs dd { margin: 0; }
.pairs-inline { font-size: 0.82rem; }
.case-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem 1.5rem; margin-bottom: 0.75rem; }
.offer + .offer { margin-top: 0.8rem; padding-top: 0.8rem; border-top: 1px solid var(--line); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -0.2rem; }
.table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.table caption { text-align: left; color: var(--ink-2); font-size: 0.82rem; padding-bottom: 0.4rem; caption-side: top; }
.table th, .table td { text-align: left; vertical-align: top; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--line); }
.table thead th { font-size: 0.72rem; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.03em; vertical-align: bottom; border-bottom-color: var(--line-strong); }
.table tbody th { font-weight: 600; min-width: 13rem; }
.table td { min-width: 5.5rem; }
.table td:has(.tag-confirm) { min-width: 8.5rem; }
.table tbody tr:last-child > * { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfc; }
.table-compact th, .table-compact td { padding: 0.4rem 0.6rem; }
.table-compact tbody th { min-width: 0; }

/* ---------- alerts ---------- */
.alerts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.alert { border: 1px solid var(--line); border-left: 3px solid var(--line-strong); border-radius: 8px; padding: 0.6rem 0.8rem; }
.alert p { margin: 0.3rem 0 0; }
.alert-head { display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; }
.alert-warning { border-left-color: var(--amber); }
.alert-critical { border-left-color: var(--critical); }

/* ---------- forms and buttons ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 0.8rem 1rem; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 150px; flex: 1 1 150px; }
.field-wide { flex: 3 1 260px; }
.field-actions { flex: 0 0 auto; flex-direction: row; min-width: 0; }
label { font-size: 0.78rem; font-weight: 600; color: var(--ink-2); }
input, select {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 0.45rem 0.6rem; min-height: 38px; width: 100%;
}
.button {
  font: 600 0.9rem var(--font-text); border-radius: 8px; padding: 0.5rem 0.9rem; min-height: 38px;
  border: 1px solid transparent; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center;
}
.button-primary { background: var(--teal); color: #fff; }
.button-primary:hover { background: #0b5a54; color: #fff; }
.button-ghost { background: transparent; color: #d6e0ea; border-color: #3a536d; }
.button-ghost:hover { background: var(--navy-2); color: #fff; }
.button-ghost-dark { background: #fff; color: var(--ink); border-color: var(--line-strong); }
.button-ghost-dark:hover { background: var(--ground); color: var(--ink); }
.htmx-request { opacity: 0.6; transition: opacity 150ms; }

/* ---------- chart ---------- */
.chart-box { position: relative; height: 320px; margin-top: 0.5rem; }

/* ---------- figure popover ---------- */
.popover {
  position: fixed; inset: auto; margin: 0; width: min(380px, calc(100vw - 24px));
  max-height: min(70vh, 520px); overflow: auto;
  background: var(--card); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(11, 31, 51, 0.18); padding: 0.9rem 1rem; font-size: 0.85rem;
}
.popover::backdrop { background: transparent; }
.popover h3 { font-size: 1.2rem; margin-bottom: 0.1rem; }
.popover .popover-unit { color: var(--ink-2); font-weight: 400; font-size: 0.85rem; }
.popover dl { display: grid; grid-template-columns: 6.2rem minmax(0, 1fr); gap: 0.3rem 0.7rem; margin: 0.6rem 0 0; }
.popover dt { color: var(--ink-2); }
.popover dd { margin: 0; overflow-wrap: anywhere; }
.popover .popover-reason { margin: 0.5rem 0 0; color: var(--ink-2); }
.popover .popover-flag { margin: 0.5rem 0 0; }
.popover-close { float: right; margin: -0.3rem -0.4rem 0 0.5rem; background: none; border: 0; font: inherit; font-size: 1.2rem; line-height: 1; cursor: pointer; color: var(--ink-2); padding: 0.2rem 0.4rem; border-radius: 4px; }
.popover-close:hover { background: var(--ground); }

/* ---------- login ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.75rem; width: min(400px, 100%); display: flex; flex-direction: column; gap: 0.9rem; }
.login-card form { display: flex; flex-direction: column; gap: 0.45rem; }
.login-card .button { justify-content: center; margin-top: 0.6rem; }
.form-error { background: var(--critical-soft); color: var(--critical); border-radius: 8px; padding: 0.5rem 0.7rem; margin: 0; }

/* ---------- phone width: the sidebar stacks above the content ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; gap: 0.75rem; padding: 0.9rem 1rem; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; gap: 0.3rem; }
  .nav-link { border-left: 0; border-bottom: 3px solid transparent; padding: 0.4rem 0.6rem; }
  .nav-link.is-active { border-bottom-color: #2dd4bf; }
  .account { margin-top: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.8rem; }
  .account-role { margin: 0; }
  .content { padding: 1rem 1rem 2.5rem; }
  h1 { font-size: 1.45rem; }
  .card { padding: 0.9rem; }
  .chart-box { height: 260px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
