/* IMEG-SolWatch design system (feature 2) — palette + type per the mockup:
   MY WORKING FOLDER/Mockups (referenced for design only; never imported).

   Theming (feature 13): every color below reads from the token layer in :root.
   Dark mode = the :root[data-theme="dark"] override block; the attribute is set
   by the no-flash script in base.html (localStorage "solwatch.theme", falling
   back to prefers-color-scheme on first visit). Add new colors as tokens, not
   literals, so both themes stay in sync. */

:root {
  color-scheme: light;

  --imeg-blue: #005596;
  --imeg-blue-dark: #003e6e;
  --imeg-navy: #0b3050;
  --imeg-red: #C1272D;
  --imeg-green: #3AAA35;
  --imeg-orange: #E8720C;
  --band-blue: #1d6fb8;      /* 60–79 review band */

  --bg: #f2f5f8;
  --card: #ffffff;
  --line: #dde5ec;
  --text: #1e293b;
  --muted: #64748b;
  --faint: #94a3b8;

  --heading: var(--imeg-navy);   /* h1–h3, card titles, KPI values */
  --link: var(--imeg-blue);      /* links + interactive accents on surfaces */
  --topbar-bg: #ffffff;
  --surface-2: #e8eef4;          /* inset fills: bar tracks, count pills, gauge */
  --row-hover: #eef5fb;
  --toggle-off: #cbd5e1;         /* feed switch "off" slider */

  /* tinted chip/callout pairs (bg + text) */
  --ok-bg: #e3f0e2;   --ok-text: #22701f;
  /* darker than --imeg-orange: chip text needs WCAG AA on the tinted bg */
  --warn-bg: #fdf3e7; --warn-text: #c2410c;
  --hot-bg: #f9e7e8;  --hot-text: var(--imeg-red);
  --info-bg: #eef5fb; --info-text: var(--imeg-blue);
  --none-bg: #eef2f6; --none-text: var(--muted);

  --radius: 12px;
  --radius-pill: 999px;
  --shadow: 0 1px 3px rgba(11, 48, 80, .08), 0 4px 14px rgba(11, 48, 80, .06);
  --shadow-hover: 0 4px 10px rgba(11, 48, 80, .12), 0 8px 24px rgba(11, 48, 80, .10);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --band-blue: #2f87d6;          /* brighter for contrast on dark surfaces */

  --bg: #0f172a;
  --card: #1e293b;
  --line: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --faint: #64748b;

  --heading: #dbe7f3;
  --link: #60a5fa;
  --topbar-bg: #152238;
  --surface-2: #2a3850;
  --row-hover: #162032;
  --toggle-off: #475569;

  --ok-bg: #10331a;   --ok-text: #6fd18a;
  --warn-bg: #3b2308; --warn-text: #fb923c;
  --hot-bg: #450a0a;  --hot-text: #f87171;
  --info-bg: #14304d; --info-text: #93c5fd;
  --none-bg: #283548; --none-text: #94a3b8;

  --shadow: 0 1px 3px rgba(0, 0, 0, .40), 0 4px 14px rgba(0, 0, 0, .30);
  --shadow-hover: 0 4px 10px rgba(0, 0, 0, .50), 0 8px 24px rgba(0, 0, 0, .40);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15px/1.5 Roboto, system-ui, "Segoe UI", sans-serif;
  overflow-x: hidden;   /* guards the hero band's full-bleed margins */
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 700; color: var(--heading); }
button { font-family: inherit; cursor: pointer; }
/* :where() keeps specificity at 0 so any later component rule wins */
input:where(:not([type="checkbox"], [type="radio"], [type="range"])), textarea {
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 8px; font: inherit;
}

/* ── Top nav ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 28px;
  background: var(--topbar-bg); border-bottom: 1px solid var(--line);
  padding: 0 24px; height: 58px; position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 19px; }
.brand img { height: 30px; }
.brand .logo-white { display: none; }
:root[data-theme="dark"] .brand .logo-color { display: none; }
:root[data-theme="dark"] .brand .logo-white { display: inline; }
.brand .brand-imeg { color: var(--link); font-weight: 700; }
.brand .brand-name { color: var(--heading); font-weight: 400; }
.topbar nav { display: flex; gap: 4px; height: 100%; }
.topbar nav a {
  display: flex; align-items: center; padding: 0 14px; color: var(--muted);
  font-weight: 500; border-bottom: 3px solid transparent; border-top: 3px solid transparent;
}
.topbar nav a:hover { color: var(--link); text-decoration: none; }
.topbar nav a.active { color: var(--link); border-bottom-color: var(--imeg-orange); }
.topbar .spacer { margin-left: auto; }
.avatar-menu { position: relative; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; border: 0;
  background: var(--imeg-navy); color: #fff; font-weight: 700; font-size: 13px;
}
:root[data-theme="dark"] .avatar { background: var(--imeg-blue); }
.avatar-dropdown {
  display: none; position: absolute; right: 0; top: 44px; min-width: 200px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-hover); padding: 10px; z-index: 60;
}
/* Feature 21: the profile menu opens on click (JS toggles .open on
   .avatar-menu), never on hover — don't reintroduce a :hover opener. */
.avatar-menu.open .avatar-dropdown { display: block; }
.avatar-dropdown .who { color: var(--muted); font-size: 13px; padding: 4px 6px 10px;
                        border-bottom: 1px solid var(--line); margin-bottom: 6px;
                        overflow-wrap: anywhere; }
.avatar-dropdown .who-name { font-weight: 700; color: inherit; }
.avatar-dropdown .who-email { font-size: 12px; color: var(--faint); }
.avatar-dropdown .role-badge {
  display: inline-block; margin-top: 6px; margin-right: 4px; font-size: 11px;
  font-weight: 700; padding: 2px 9px; border-radius: var(--radius-pill);
  background: var(--hot-bg); color: var(--hot-text);
}
.avatar-dropdown .role-badge-viewas { background: var(--imeg-orange); color: #fff; }
.avatar-dropdown .menu-item {
  display: block; width: 100%; background: none; border: 0; text-align: left;
  padding: 8px 6px; border-radius: 6px; color: var(--hot-text);
  font-weight: 500; font-size: 14px; text-decoration: none; cursor: pointer;
}
.avatar-dropdown .menu-item:hover { background: var(--hot-bg); text-decoration: none; }
.avatar-dropdown .menu-sep { border-top: 1px solid var(--line); margin: 6px 0; }
/* The profile menu's Sol Debrief item deep-links to /settings#debrief; without
   this the anchored heading hides under the 58px sticky topbar. */
#debrief { scroll-margin-top: 70px; }

/* ── Theme toggle (sun/moon) ─────────────────────────────────────────────── */
.theme-toggle {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.theme-toggle:hover { color: var(--link); border-color: var(--link); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
/* pre-auth pages (no topbar): pin the toggle to the corner */
.theme-toggle-floating { position: fixed; top: 14px; right: 16px; z-index: 70;
                         box-shadow: var(--shadow); }
/* Feature 26: anonymous MVP chrome — the avatar's slot holds a login nudge */
.login-cta { padding: 8px 16px; font-size: 13px; white-space: nowrap;
             text-decoration: none; }
.login-cta:hover { text-decoration: none; }

main { max-width: 1280px; margin: 0 auto; padding: 0 20px 72px; }

/* ── Hero band ───────────────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(120deg, var(--imeg-blue) 0%, var(--imeg-blue-dark) 100%);
  /* full-bleed: stretch to the viewport, keep content aligned with main */
  margin: 0 calc(50% - 50vw); padding: 26px calc(50vw - 50%) 30px;
  color: #fff;
}
:root[data-theme="dark"] .hero {
  background: linear-gradient(120deg, #0d3a63 0%, #092b4a 100%);
}
.hero .kicker { font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
                color: #bcd7ec; font-weight: 500; }
.hero h1 { color: #fff; margin: 4px 0 16px; font-size: 28px; }
.hero .searchrow { display: flex; gap: 10px; max-width: 900px; }
.hero .searchbox { flex: 1; display: flex; align-items: center; gap: 8px;
  background: #fff; border-radius: var(--radius-pill); padding: 0 18px; }
/* the searchbox stays white in both themes — pin its text dark */
.hero .searchbox input { flex: 1; border: 0; outline: none; padding: 12px 0;
  font-size: 15px; background: none; color: #1e293b; }
.btn { border: 0; border-radius: var(--radius-pill); padding: 11px 22px;
       font-weight: 700; font-size: 14px; }
.btn-orange { background: var(--imeg-orange); color: #fff; }
.btn-orange:hover { filter: brightness(1.08); }
.btn-navy { background: var(--imeg-blue-dark); color: #fff; border: 1px solid rgba(255,255,255,.35); }
.btn-navy:hover { filter: brightness(1.15); }

/* ── Filter toolbar (feature 17) ─────────────────────────────────────────── */
/* Every facet is the same .ms dropdown, in one bar above the results; the
   quick filters + closes-range + presets live in the "More" popover. Sticks
   under the topbar (58px) so filters stay reachable while scrolling. */
.filterbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
             background: var(--card); border: 1px solid var(--line);
             border-radius: var(--radius); box-shadow: var(--shadow);
             padding: 10px 12px; margin: 20px 0 4px;
             position: sticky; top: 58px; z-index: 45; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: var(--radius-pill); padding: 5px 13px; font-size: 13px; font-weight: 500;
}
.pill[aria-pressed="true"] { background: var(--ok-bg); border-color: var(--imeg-green);
                             color: var(--ok-text); }
.range-val { color: var(--link); font-weight: 700; }

/* ── Filter toolbar: closes-within dual range (feature 14) ───────────────── */
.dual-range { position: relative; height: 26px; }
.dual-range input[type="range"] {
  position: absolute; inset: 0; width: 100%; margin: 0; background: none;
  pointer-events: none; -webkit-appearance: none; appearance: none;
}
.dual-range input[type="range"]::-webkit-slider-thumb {
  pointer-events: auto; -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--imeg-blue); border: 2px solid var(--card);
  box-shadow: var(--shadow); cursor: pointer;
}
.dual-range input[type="range"]::-moz-range-thumb {
  pointer-events: auto; width: 12px; height: 12px; border-radius: 50%;
  background: var(--imeg-blue); border: 2px solid var(--card);
  box-shadow: var(--shadow); cursor: pointer;
}
.dr-track { position: absolute; top: 50%; transform: translateY(-50%);
            left: 0; right: 0; height: 6px; background: var(--surface-2);
            border-radius: var(--radius-pill); }
.dr-fill { position: absolute; top: 0; height: 100%; background: var(--imeg-blue);
           border-radius: var(--radius-pill); }
.dr-nums { display: flex; align-items: center; gap: 6px; margin-top: 4px;
           color: var(--muted); font-size: 12px; }
.dr-nums input[type="number"] { width: 58px; padding: 3px 6px; font-size: 12px; }

/* ── The uniform facet dropdown (features 14 + 17) ───────────────────────── */
.ms { position: relative; }
.ms-trigger {
  display: flex; align-items: center; gap: 6px; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; color: var(--text); font-size: 13px; font-weight: 500;
}
.ms-trigger:hover { border-color: var(--link); }
.ms-trigger.on { border-color: var(--imeg-blue); color: var(--link); }
.ms-trigger .ms-count { color: var(--link); font-weight: 700; }
.ms-trigger .ms-caret { margin-left: 2px; color: var(--faint); }
.ms-pop {
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 40;
  width: min(320px, 92vw);
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-hover); padding: 8px;
}
.ms-pop.flip { left: auto; right: 0; }   /* set by JS near the viewport edge */
.ms-search { width: 100%; font-size: 13px; }
.ms-tools { display: flex; gap: 10px; padding: 6px 2px 4px; }
.ms-tools button { background: none; border: 0; padding: 0; color: var(--link);
                   font-size: 12px; font-weight: 600; }
.ms-tools button:hover { text-decoration: underline; }
.ms-list { max-height: 240px; overflow-y: auto; }
.ms-item { display: flex; align-items: center; gap: 8px; padding: 4px 2px;
           font-size: 13px; color: var(--text); cursor: pointer; border-radius: 6px; }
.ms-item:hover { background: var(--row-hover); }
.ms-item[hidden] { display: none; }
.ms-item .ms-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-item .n { margin-left: auto; color: var(--faint); font-size: 11px;
              background: var(--surface-2); border-radius: var(--radius-pill);
              padding: 1px 7px; flex: none; }
.ms-item input { accent-color: var(--imeg-blue); }

/* ── "More" popover: quick filters + closes-range + presets (feature 17) ── */
.more-pop { width: min(340px, 92vw); padding: 10px 14px 14px; }
.more-pop h4 { font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
               color: var(--faint); font-weight: 700; margin: 16px 0 8px; }
.more-pop h4:first-child { margin-top: 2px; }
.more-pop label.check { display: flex; align-items: center; gap: 8px; padding: 4px 0;
                        color: var(--text); cursor: pointer; font-size: 13.5px; }
.more-pop label.check input { accent-color: var(--imeg-blue); }

/* ── Filter presets (feature 14; lives in the More popover since 17) ─────── */
.preset-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.preset-apply {
  flex: 1; text-align: left; background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; color: var(--text); font-size: 13px;
  font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.preset-apply:hover { border-color: var(--link); color: var(--link); }
.preset-row .n { color: var(--faint); font-size: 11px; background: var(--surface-2);
                 border-radius: var(--radius-pill); padding: 1px 7px; flex: none; }
.preset-del { background: none; border: 0; color: var(--faint); padding: 2px 4px;
              font-size: 12px; flex: none; }
.preset-del:hover { color: var(--hot-text); }
.preset-save { background: none; border: 1px dashed var(--line); border-radius: 8px;
               width: 100%; padding: 6px 10px; color: var(--muted); font-size: 13px; }
.preset-save:hover { border-color: var(--link); color: var(--link); }
.preset-empty { color: var(--faint); font-size: 12px; margin: 2px 0 6px; }

/* ── Active-filter chips (feature 14) ────────────────────────────────────── */
.chips-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
               margin: 0 0 12px; }
.f-chip {
  display: inline-flex; align-items: center; gap: 7px; max-width: 320px;
  background: var(--info-bg); color: var(--info-text); border: 0;
  border-radius: var(--radius-pill); padding: 5px 12px; font-size: 12px;
  font-weight: 600;
}
.f-chip > :first-child { overflow: hidden; text-overflow: ellipsis; }
.f-chip .x { font-size: 10px; opacity: .7; }
.f-chip:hover { background: var(--imeg-blue); color: #fff; }
.f-chip:hover .x { opacity: 1; }
.f-clear { background: none; border: 0; color: var(--hot-text); font-size: 12px;
           font-weight: 600; padding: 5px 6px; }
.f-clear:hover { text-decoration: underline; }

/* ── KPI cards ───────────────────────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
       box-shadow: var(--shadow); padding: 14px 18px; }
.kpi .v { font-size: 26px; font-weight: 700; color: var(--heading); }
.kpi .l { font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
          color: var(--faint); font-weight: 500; }
.kpi.hot .v { color: var(--hot-text); }

.results-head { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin: 20px 0 12px; }
.results-head .matches { font-weight: 700; color: var(--heading); }
.results-head .sort { margin-left: auto; display: flex; gap: 8px; align-items: center;
                      color: var(--muted); font-size: 13px; }
select { background: var(--card); border: 1px solid var(--line); border-radius: 8px;
         padding: 7px 10px; color: var(--text); font-family: inherit; }

/* ── Solicitation cards ──────────────────────────────────────────────────── */
.sol { display: grid; grid-template-columns: 84px 1fr 168px; gap: 16px;
       background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
       box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; }
.sol:hover { box-shadow: var(--shadow-hover); }
.badge { align-self: start; width: 64px; height: 64px; border-radius: 10px;
         display: flex; flex-direction: column; align-items: center; justify-content: center;
         color: #fff; font-weight: 700; }
.badge .s { font-size: 24px; line-height: 1; }
.badge .t { font-size: 9px; letter-spacing: .08em; opacity: .85; }
.badge.b80 { background: var(--imeg-green); }
.badge.b60 { background: var(--band-blue); }
.badge.b40 { background: var(--imeg-orange); }
.badge.b0  { background: var(--muted); }   /* --faint fails AA for the white score */
:root[data-theme="dark"] .badge.b0 { background: #475569; }
.sol h2 { margin: 0 0 6px; font-size: 17px; }
.sol h2 a { color: var(--heading); }
.sol .meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap;
             gap: 4px 14px; margin-bottom: 10px; }
.sol .meta strong { color: var(--text); font-weight: 500; }
.sol .side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.chip { border-radius: var(--radius-pill); padding: 4px 12px; font-size: 12px; font-weight: 700; }
.chip.close-ok { background: var(--warn-bg); color: var(--warn-text); }
.chip.close-hot { background: var(--hot-bg); color: var(--hot-text); }
.chip.close-none { background: var(--none-bg); color: var(--none-text); }
.chip-ok { background: var(--ok-bg); color: var(--ok-text); }
/* Status badge (feature 26 WS4): Open/Pending/Closed on cards, table rows,
   and the detail header; unknown statuses fall back to the base style. */
.status-badge { border-radius: var(--radius-pill); padding: 4px 12px;
                font-size: 12px; font-weight: 700; white-space: nowrap;
                background: var(--none-bg); color: var(--none-text); }
.status-badge.st-open { background: var(--ok-bg); color: var(--ok-text); }
.status-badge.st-pending { background: var(--warn-bg); color: var(--warn-text); }
.status-badge.st-closed { background: var(--hot-bg); color: var(--hot-text); }
.sol-table .status-badge { padding: 2px 9px; font-size: 11px; }
.btn-details { background: var(--imeg-blue); color: #fff; border: 0;
               border-radius: 8px; padding: 9px 16px; font-weight: 600; font-size: 13px;
               margin-top: auto; }
.btn-details:hover { background: var(--imeg-blue-dark); text-decoration: none; }
a.btn-details { display: inline-block; }

/* Copy-link 🔗 (feature 19): cards + table rows reveal the button on hover
   (or focus); touch devices, with no hover to reveal it, show it always. */
.side-row { margin-top: auto; display: flex; gap: 8px; }
.side-row .btn-details { margin-top: 0; }
.side-top { display: flex; gap: 8px; align-items: center; }
/* Sources directory (feature 26): the hero's state filter dropdown */
.src-state { border: 0; border-radius: var(--radius-pill); padding: 0 18px;
             font-size: 15px; background: #fff; color: #1e293b; }
.copy-link { background: var(--card); border: 1px solid var(--line); color: var(--link);
             border-radius: 8px; padding: 8px 10px; font-size: 13px; line-height: 1; }
.copy-link:hover { border-color: var(--link); }
.sol .copy-link, .sol-table .copy-link { opacity: 0; transition: opacity .15s; }
.sol:hover .copy-link, .sol .copy-link:focus-visible,
.sol-table tbody tr:hover .copy-link, .sol-table .copy-link:focus-visible { opacity: 1; }
.sol-table .copy-link { border: 0; background: transparent; padding: 2px 4px; }
@media (hover: none) {
  .sol .copy-link, .sol-table .copy-link { opacity: 1; }
}

.legend { display: flex; flex-wrap: wrap; gap: 20px; color: var(--muted); font-size: 12px;
          padding: 18px 4px; }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%;
               margin-right: 6px; vertical-align: -1px; }
.empty-state { text-align: center; color: var(--muted); padding: 48px 0; }

/* ── Cards/Table view toggle + table view ────────────────────────────────── */
.view-toggle { display: flex; border: 1px solid var(--line); border-radius: var(--radius-pill);
               overflow: hidden; background: var(--card); }
.view-toggle button { border: 0; background: none; padding: 6px 14px; font-size: 13px;
                      font-weight: 600; color: var(--muted); }
.view-toggle button[aria-pressed="true"] { background: var(--imeg-blue); color: #fff; }

.sol-table-wrap { background: var(--card); border: 1px solid var(--line);
                  border-radius: var(--radius); box-shadow: var(--shadow);
                  max-height: calc(100vh - 160px); overflow: auto; }
.sol-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.sol-table th {
  position: sticky; top: 0; z-index: 1; background: var(--imeg-navy); color: #fff;
  text-align: left; padding: 9px 10px; font-size: 11px; letter-spacing: .05em;
  text-transform: uppercase; white-space: nowrap; cursor: pointer; user-select: none;
}
.sol-table th:hover { background: var(--imeg-blue-dark); }
.sol-table th.num { text-align: right; }
.sol-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.sol-table tbody tr:last-child td { border-bottom: 0; }
.sol-table tbody tr:hover td { background: var(--row-hover); }
.sol-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.sol-table td.wide { min-width: 260px; }
.sol-table td a { color: var(--heading); font-weight: 600; }
.sol-table .tscore { font-weight: 700; }
.sol-table .tscore.b80 { color: var(--imeg-green); }
.sol-table .tscore.b60 { color: var(--band-blue); }
.sol-table .tscore.b40 { color: var(--imeg-orange); }
.sol-table .tscore.b0  { color: var(--faint); }
.sol-table .dl-hot { color: var(--hot-text); font-weight: 700; }
/* Compact table (feature 16): same columns, denser rows and smaller type. */
.sol-table--compact { font-size: 12px; }
.sol-table--compact th { padding: 6px 8px; font-size: 10px; }
.sol-table--compact td { padding: 3px 8px; }

/* ── Detail page ─────────────────────────────────────────────────────────── */
.crumbs { color: var(--faint); font-size: 13px; margin: 18px 0 6px; }
.detail { display: grid; grid-template-columns: 1fr 360px; gap: 24px; align-items: start; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
         box-shadow: var(--shadow); padding: 22px; margin-bottom: 18px; }
.detail h1 { margin: 0 0 8px; font-size: 24px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 4px; }
.btn-ghost { background: var(--card); border: 1px solid var(--line); color: var(--link);
             border-radius: var(--radius-pill); padding: 9px 16px; font-weight: 600; font-size: 13px; }
.btn-ghost:hover { border-color: var(--link); }
.section-label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
                 color: var(--faint); font-weight: 700; margin: 18px 0 8px; }
.why { background: var(--info-bg); border-left: 4px solid var(--imeg-blue); border-radius: 6px;
       padding: 12px 16px; }
.description { white-space: pre-line; }
.doc-empty { border: 1px dashed var(--line); border-radius: 10px; padding: 18px;
             color: var(--faint); text-align: center; }
.docs { width: 100%; border-collapse: collapse; font-size: 14px; }
.docs td { padding: 9px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.docs tr:last-child td { border-bottom: 0; }
.docs .doc-name { word-break: break-word; }
.docs .doc-type { font-size: 11px; color: var(--faint); text-transform: uppercase;
                  letter-spacing: .06em; margin-left: 6px; }
.docs .doc-action { text-align: right; white-space: nowrap; width: 1%; padding-left: 12px; }
.docs .doc-size { color: var(--muted); font-size: 12px; margin-right: 10px; }
.docs .doc-error { color: var(--faint); font-style: italic; }

.gauge-wrap { display: flex; gap: 18px; align-items: center; }
.gauge-wrap .verdict { font-weight: 700; color: var(--heading); }
.gauge-wrap .sub { color: var(--muted); font-size: 13px; }
.gauge-track { stroke: var(--surface-2); }
.bars .bar-row { display: grid; grid-template-columns: 90px 1fr 34px; gap: 10px;
                 align-items: center; margin-bottom: 8px; font-size: 13px; }
.bars .track { background: var(--surface-2); border-radius: var(--radius-pill); height: 8px; }
.bars .fill { height: 8px; border-radius: var(--radius-pill); background: var(--imeg-green); }
.bars .fill.mid { background: var(--imeg-orange); }
.bars .fill.low { background: var(--faint); }
.bars .n { text-align: right; color: var(--muted); }
.facts { width: 100%; border-collapse: collapse; font-size: 14px; }
.facts td { padding: 9px 0; border-bottom: 1px solid var(--line); }
.facts td:first-child { color: var(--muted); width: 45%; }
.facts tr:last-child td { border-bottom: 0; }
.status-open { color: var(--imeg-green); font-weight: 700; }
.fact-hot { color: var(--hot-text); font-weight: 700; }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-card { max-width: 400px; margin: 9vh auto; background: var(--card);
              border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-hover);
              padding: 32px; }
.login-card .brand { justify-content: center; margin-bottom: 14px; }
.login-card h1 { text-align: center; font-size: 20px; margin: 0 0 18px; }
.login-card label { display: block; margin: 14px 0 4px; color: var(--muted); font-size: 13px;
                    font-weight: 500; }
.login-card input { width: 100%; border: 1px solid var(--line); border-radius: 8px;
                    padding: 10px 12px; font-size: 15px; }
.login-card input:focus { outline: 2px solid var(--link); border-color: transparent; }
.login-card button { width: 100%; margin-top: 20px; }
.error { color: var(--hot-text); background: var(--hot-bg); border-radius: 8px; padding: 10px 14px; }
.notice { color: var(--info-text); background: var(--info-bg); border-radius: 8px; padding: 10px 14px; }

.coming-soon { background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius);
               color: var(--muted); font-size: 16px; padding: 40px; text-align: center;
               margin-top: 28px; }

/* ── Toasts (feature 15) ─────────────────────────────────────────────────── */
/* Filled by the shared toast() helper in base.html; redirect ?ok=/?err=
   flashes surface here too. Click a toast to dismiss it early. */
#toasts { position: fixed; bottom: 22px; right: 22px; z-index: 200;
          display: flex; flex-direction: column; gap: 10px;
          max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--card); color: var(--text);
         border: 1px solid var(--line); border-left: 4px solid var(--imeg-green);
         border-radius: 10px; box-shadow: var(--shadow-hover);
         padding: 11px 16px; font-size: 14px; cursor: pointer;
         overflow-wrap: anywhere; animation: toast-in .18s ease; }
.toast-err { border-left-color: var(--imeg-red); }
.toast-info { border-left-color: var(--imeg-blue); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ── Loading skeleton + error state (feature 15) ─────────────────────────── */
.skel { position: relative; overflow: hidden; background: var(--surface-2);
        border-radius: 6px; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
  animation: skel-shimmer 1.2s infinite; }
:root[data-theme="dark"] .skel::after {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .07), transparent); }
@keyframes skel-shimmer { to { transform: translateX(100%); } }
.load-error { text-align: center; color: var(--muted); padding: 48px 20px; }
.load-error .btn { margin-top: 14px; }
.empty-state .btn { margin-top: 14px; }
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  .skel::after { animation: none; }
}

/* ── Prefs form widgets (feature 16) ─────────────────────────────────────── */
/* Shared by the /feed Sol Debrief card and /settings (moved from feed.html). */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--toggle-off);
                  border-radius: var(--radius-pill); transition: .15s; }
.switch .slider:before { content: ""; position: absolute; height: 16px; width: 16px;
                         left: 3px; top: 3px; background: #fff; border-radius: 50%;
                         transition: .15s; }
.switch input:checked + .slider { background: var(--imeg-green); }
.switch input:checked + .slider:before { transform: translateX(16px); }
.debrief-row { display: flex; align-items: center; justify-content: space-between;
               gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line);
               font-size: 13.5px; }
.debrief-row:last-of-type { border-bottom: 0; }
.seg { display: inline-flex; border: 1px solid var(--line);
       border-radius: var(--radius-pill); overflow: hidden; }
.seg label { padding: 5px 14px; font-size: 13px; cursor: pointer; }
.seg input { display: none; }
.seg input:checked + span { font-weight: 700; }
.seg label:has(input:checked) { background: var(--imeg-blue); color: #fff; }

/* Preferred-view radio cards (onboarding wizard + prefs form). */
.view-cards { display: flex; gap: 10px; flex-wrap: wrap; }
.view-card { display: flex; flex-direction: column; align-items: center; gap: 4px;
             border: 1px solid var(--line); border-radius: var(--radius);
             background: var(--card); padding: 10px 18px; cursor: pointer;
             font-size: 13px; font-weight: 600; color: var(--muted); }
.view-card input { display: none; }
.view-card .vc-glyph { font-size: 20px; line-height: 1; }
.view-card:hover { border-color: var(--link); }
.view-card:has(input:checked) { border-color: var(--imeg-blue); color: var(--heading);
                                background: var(--info-bg); }

/* ── First-run onboarding wizard (feature 16) ────────────────────────────── */
.onboard-overlay { position: fixed; inset: 0; z-index: 300; background: rgba(6, 18, 36, .55);
                   display: flex; align-items: center; justify-content: center;
                   padding: 16px; overflow-y: auto; }
.onboard-card { background: var(--card); border: 1px solid var(--line);
                border-radius: 14px; box-shadow: var(--shadow-hover);
                padding: 28px 30px; max-width: 620px; width: 100%;
                max-height: calc(100vh - 32px); overflow-y: auto; }
.onboard-card h2 { margin: 0 0 4px; font-size: 21px; }
.onboard-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 6px; }
.onboard-hint { text-transform: none; letter-spacing: 0; font-weight: 400;
                color: var(--muted); }
.onboard-actions { display: flex; gap: 12px; align-items: center; margin-top: 22px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .detail { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { gap: 10px; padding: 0 12px; overflow-x: auto; }
  /* overflow-x:auto makes the topbar a clip context, which would swallow the
     absolutely-positioned profile dropdown — pin it to the viewport instead */
  .avatar-dropdown { position: fixed; top: 62px; right: 8px; left: auto; }
  /* a wrapped filterbar is several rows tall — don't let it eat the screen */
  .filterbar { position: static; }
  .hero .searchrow { flex-direction: column; }
  .sol { grid-template-columns: 64px 1fr; }
  .sol .side { grid-column: 1 / -1; flex-direction: row; align-items: center;
               justify-content: space-between; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
}
