:root {
  --mdr-orange: #E8820C;
  --mdr-orange-dark: #A8450A;
  --mdr-cyan: #4DD9FF;
  --mdr-dark: #0D0D0D;
  --mdr-silver: #C0C0C8;
  --content: #F5F5F0;
  --card: #ffffff;
  --border: #e2e2dc;
  --text: #1c1c1c;
  --muted: #707070;
  --neg: #c0392b;
  --pos: #27893f;
  --sidebar-w: 230px;
}

/* The HTML `hidden` attribute must win even over an inline `display` (e.g. the
   demo modal carries an inline `display:flex` for its shown state). Without this
   !important rule the UA `[hidden]{display:none}` loses to the inline style and
   the element is stuck visible. Fixes the always-on "Demo limit reached" modal. */
[hidden] { display: none !important; }

/* Report period selector (OI-007 — monthly / quarterly / annual rollups). */
.report-periods { display: flex; gap: 6px; margin: 6px 0 10px; }
.period-btn.active { background: var(--mdr-orange); color: #fff; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--content);
  color: var(--text);
  min-height: 100vh;
}

/* ---- layout ---- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--mdr-dark);
  color: var(--mdr-silver);
  flex-shrink: 0;
  padding: 20px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand { text-align: center; padding: 0 16px 16px; }
.sidebar .brand img { max-width: 130px; border-radius: 6px; }
.sidebar .brand .name { color: #fff; font-size: 14px; font-weight: 600; margin-top: 8px; }
.nav a {
  display: block;
  color: var(--mdr-silver);
  text-decoration: none;
  padding: 11px 22px;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.nav a:hover { background: #1b1b1b; color: #fff; }
.nav a.active { background: #1b1b1b; color: #fff; border-left-color: var(--mdr-orange); font-weight: 600; }

.main { flex: 1; min-width: 0; }
.topbar {
  background: var(--mdr-dark);
  border-bottom: 4px solid var(--mdr-orange);
  color: #fff;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar h1 { font-size: 19px; margin: 0; }
.hamburger { display: none; background: none; border: none; color: #fff; font-size: 24px; cursor: pointer; }
.content { padding: 24px 28px 60px; max-width: 1100px; }

/* ---- buttons ---- */
.btn {
  background: #AE6209; color: #fff; border: none;
  padding: 9px 18px; border-radius: 6px; font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none; display: inline-block;
}
.btn:hover { background: var(--mdr-orange-dark); }
.btn.secondary { background: #ddd; color: #333; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .6; cursor: default; }

/* ---- accessibility: visible keyboard focus (WCAG 2.4.7) ---- */
/* #AE6209 outline meets >=3:1 on light cards (4.61:1 vs #fff) AND the dark
   sidebar (4.21:1 vs #0D0D0D). :focus-visible = keyboard focus only; the UA
   default outline is left intact (never removed). */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.x:focus-visible {
  outline: 2px solid #AE6209;
  outline-offset: 2px;
}

/* screen-reader-only live region — visually hidden, no layout footprint */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---- stat cards ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px 18px; border-top: 4px solid var(--mdr-orange);
}
.card .num { font-size: 30px; font-weight: 700; color: var(--mdr-orange-dark); }
.card .label { font-size: 13px; color: var(--muted); margin-top: 2px; }
.card.alt { border-top-color: var(--mdr-cyan); }
.card.alt .num { color: #1c7c99; }

/* ---- sections / panels ---- */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; margin-bottom: 22px; }
.panel h2 { font-size: 16px; margin: 0 0 12px; color: var(--mdr-dark); border-bottom: 2px solid var(--mdr-orange); padding-bottom: 6px; }
/* Standalone auth panel — a decorative left accent marks it as its own section,
   distinct from the settings-form panels below (its Save is the only one that
   changes the password). Border only; no text recoloured. */
.panel-auth { border-left: 5px solid var(--mdr-orange); }

/* ---- item list ---- */
.item { border-left: 3px solid var(--mdr-orange); padding: 9px 12px; margin: 10px 0; background: #fafaf7; border-radius: 0 6px 6px 0; }
.item.neg { border-left-color: var(--neg); }
.item .head { font-size: 15px; font-weight: 600; }
.item .head a { color: var(--mdr-orange-dark); text-decoration: none; }
.item.neg .head a { color: var(--neg); }
.item .meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.item .snip { font-size: 13px; color: #444; margin-top: 4px; line-height: 1.4; }
.item .score { float: right; font-size: 12px; color: #737373; }
.item .x { float: right; cursor: pointer; color: #737373; font-weight: 700; margin-left: 10px; }
.item .x:hover { color: var(--neg); }

.badge { font-size: 11px; padding: 1px 7px; border-radius: 3px; color: #fff; margin-left: 6px; }
.badge.neg { background: var(--neg); }
.badge.pos { background: var(--pos); }
.badge.cat { background: #AE6209; }
.badge.tier { background: #555; }
/* Monitoring-mode panel: flex row of toggle buttons + a live status badge.
   #fff text on #AE6209 (active) = 4.61:1 and on #555 (off/normal) = 7.0:1 —
   both pass WCAG AA (4.5:1). No #E8820C on any text-bearing element. */
.mode-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.badge.mode { background: #AE6209; }
.badge.mode.off { background: #555; }
#modeNote { margin-top: 8px; }

/* ---- filters ---- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filters label { font-size: 12px; color: var(--muted); display: block; }
.filters select, .filters input, .searchbar select, .searchbar input {
  padding: 7px 9px; border: 1px solid #ccc; border-radius: 5px; font-size: 14px; font-family: inherit;
}

/* ---- manual search bar ---- */
.searchbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.searchbar input.term { flex: 1; min-width: 200px; }
.chips { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: #efe9e0; border: 1px solid var(--border); border-radius: 16px; padding: 4px 10px; font-size: 13px; }
.chip span.cat { color: var(--mdr-orange-dark); font-weight: 600; }
.chip .x { cursor: pointer; color: #696969; margin-left: 6px; font-weight: 700; }
.chip .x:hover { color: var(--neg); }

/* The dismiss/remove ✕ controls are real <button>s (keyboard-operable). Strip
   button chrome so they render exactly like the old inline ✕ span; the
   .item .x / .chip .x rules above still supply float, color, weight, margin. */
button.x { appearance: none; -webkit-appearance: none; background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }

/* ---- tables (sources) ---- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--muted); font-weight: 600; }
.status-ok { color: var(--pos); font-weight: 600; }
.status-fail { color: var(--neg); font-weight: 600; }
.status-off { color: var(--muted); }

/* ---- forms (settings) ---- */
.field { margin: 14px 0; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.field small { font-weight: 400; color: var(--muted); }
.field input[type=text], .field input[type=email], .field input[type=number], .field textarea, .field select {
  width: 100%; padding: 9px; border: 1px solid #ccc; border-radius: 5px; font-size: 14px; font-family: inherit;
}
.field textarea { min-height: 90px; resize: vertical; }
.row2 { display: flex; gap: 16px; flex-wrap: wrap; }
.row2 > .field { flex: 1; min-width: 200px; }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--mdr-dark); color: #fff; padding: 12px 18px; border-radius: 8px; border-left: 4px solid var(--mdr-orange); font-size: 14px; opacity: 0; transition: opacity .2s; z-index: 50; }
.toast.show { opacity: 1; }
.toast-action { color: var(--mdr-orange); font-weight: 600; text-decoration: underline; cursor: pointer; white-space: nowrap; }
.toast-action:hover { color: var(--mdr-cyan); }
.empty { color: #707070; font-size: 14px; padding: 12px; }
.miss-row { padding: 6px 0; border-bottom: 1px solid var(--border, #e3e3dc); font-size: 14px; }
.preview-box { margin-top: 12px; padding: 12px 14px; background: #F5F5F0; border-left: 4px solid var(--mdr-orange); border-radius: 6px; font-size: 14px; }
.miss-samples { margin: 8px 0 0; padding-left: 18px; }
.miss-samples li { margin: 4px 0; }
.demo-banner { background: #FFF3E0; color: #0D0D0D; border-bottom: 2px solid var(--mdr-orange); padding: 8px 16px; font-size: 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.demo-banner .btn { margin-left: auto; }
.muted { color: var(--muted); font-size: 13px; }

/* ---- responsive ---- */
@media (max-width: 760px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .hamburger { display: block; }
  .content { padding: 16px; }
}

/* ===========================================================================
   /report — client-facing monthly rollup (Step C3 styling)
   APPEND-ONLY. All screen selectors are net-new report-* classes; existing
   selectors appear only inside @media print (req 6). Uses :root MDR tokens
   and the established card / panel-heading / Segoe UI idioms.
   =========================================================================== */

/* ---- report container: neutralize the outer .panel so sections aren't card-in-card ---- */
.panel[data-report] {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
}
.report-meta { margin-bottom: 4px; }
.report-summary { margin-bottom: 0; }

/* ---- 1. page header ---- */
.report-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 22px;
  padding-bottom: 12px;
  border-bottom: 3px solid var(--mdr-orange);
}
.report-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--mdr-dark);
}
.report-stat {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.report-stat .muted { font-weight: 400; }

/* ---- 2. responsive 3-up grid of card sections ---- */
.report-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 22px;
}
.report-grid > section,
.report-top {
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 4px solid var(--mdr-orange);
  border-radius: 10px;
  padding: 16px 18px;
}
.report-top { margin-bottom: 22px; }

/* section headings — mirror the .panel h2 orange-underline idiom */
.report-grid > section h3,
.report-top h3 {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--mdr-dark);
  border-bottom: 2px solid var(--mdr-orange);
  padding-bottom: 6px;
}

/* small-caption sizing — no global .small rule exists, so scope it to report */
.report-grid .small,
.report-top .small,
.report-summary-box .small {
  font-size: 11px;
}

/* ---- 3. tables — elevate beyond the inherited global table rules ---- */
.report-table { width: 100%; border-collapse: collapse; }
.report-table td {
  padding: 9px 10px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.report-table tr:last-child td { border-bottom: none; }
/* AODA: report tables gained <th> headers for screen-reader semantics.
   tbody th (row-header cells) must render IDENTICALLY to the <td> they
   replaced — this overrides the global th{muted,bold} so nothing changes
   visually. thead th (column headers) keep the global header styling. */
.report-table tbody th {
  padding: 9px 10px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
  font-weight: 400;
  color: var(--text);
}
.report-table tbody tr:last-child th { border-bottom: none; }
.report-table td.num {
  text-align: right;
  font-weight: 700;
  color: var(--mdr-orange-dark);
  white-space: nowrap;
}

/* ---- 4. Top Stories — score cell as a prominent pill, readable headlines ---- */
/* score cell is now <th scope="row" class="num"> — mirror the td.num pill so it looks unchanged */
.report-top .report-table td.num,
.report-top .report-table tbody th.num {
  width: 1%;
  text-align: center;
  white-space: nowrap;
  background: var(--mdr-orange-dark);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  border-radius: 12px;
  padding: 4px 10px;
}
.report-top .report-table td a {
  color: var(--mdr-orange-dark);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}
.report-top .report-table td a:hover { text-decoration: underline; }
.report-top .report-table td .muted.small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

/* ---- 5. AI executive summary — client-deliverable centerpiece ---- */
.report-summary-box {
  background: #fffaf4;                        /* faint warm tint */
  border: 1px solid var(--border);
  border-left: 5px solid var(--mdr-orange);
  border-radius: 10px;
  padding: 22px 26px;
  margin-bottom: 22px;
}
.report-summary-label {
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--mdr-orange-dark);
}
.report-summary-label .muted,
.report-summary-label .small {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--muted);
}
.report-summary-box p {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
}
.report-summary-box .muted { font-size: 13px; }

/* ---- 6. print: clean client PDF ---- */
@media print {
  .sidebar,
  .topbar,
  .hamburger { display: none !important; }

  html, body { background: #fff !important; color: #000 !important; }
  .layout { display: block !important; }
  .main { min-width: 0 !important; }
  .content { max-width: none !important; padding: 0 18px !important; }

  /* preserve accent colors in print */
  .report-header,
  .report-grid > section,
  .report-top,
  .report-summary-box,
  .report-table td.num,
  .report-top .report-table td.num,
  .report-top .report-table tbody th.num {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* don't fracture cards/rows across pages */
  .report-grid > section,
  .report-top,
  .report-summary-box,
  .report-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .report-summary-box { background: #fff !important; }
  .report-top .report-table td a { color: #000 !important; }
}

/* ---- responsive: collapse grid on narrow screens ---- */
@media (max-width: 760px) {
  .report-grid { grid-template-columns: 1fr; }
  .report-header { flex-direction: column; align-items: flex-start; }
}
