/* MRPscan look (same tokens as MRPanalytics): cream page, brand red, serif titles. */
:root {
  --page: #fbf7f0;
  --surface: #ffffff;
  --surface-2: #f4ecdc;
  --ink: #15120d;
  --ink-2: #4a4234;
  --muted: #857a63;
  --border: #e9ddc4;
  --accent: #d9291f;
  --accent-deep: #a81f17;

  --ok: #1a7a42;      --ok-bg: #e8f5ee;      --ok-bar: #2e9d5b;
  --warn: #8a6100;    --warn-bg: #fbf1d6;    --warn-bar: #d9a21b;
  --down: #a81f17;    --down-bg: #fdeae7;    --down-bar: #d9291f;
  --off: #857a63;     --off-bg: #f4ecdc;     --off-bar: #d6ccb6;

  --shadow: 0 10px 22px -16px rgba(60, 20, 15, 0.35);
  --radius: 16px;
  --serif: 'Playfair Display', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  padding: 0 16px 48px;
}
button { font: inherit; cursor: pointer; }
a { color: var(--accent-deep); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--down); }

.top {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 0 12px;
  display: flex;
  gap: 16px;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
}
.brand h1 {
  font: 700 30px/1.1 var(--serif);
  margin: 0;
  letter-spacing: -0.01em;
}
.brand h1::before {
  content: '';
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 10px;
  vertical-align: middle;
  box-shadow: 0 0 0 4px rgba(217, 41, 31, 0.18);
}
.sub { margin: 6px 0 0; color: var(--ink-2); }
.run { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 12px; font-size: 12.5px; }
.btn:disabled { opacity: 0.6; cursor: progress; }

.banner {
  max-width: 1280px;
  margin: 4px auto 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid #ecd9a0;
  font-weight: 500;
}

.tiles {
  max-width: 1280px;
  margin: 8px auto 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.tile .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.tile .value { font: 700 28px/1.2 var(--serif); margin-top: 4px; }
.tile .value.ok { color: var(--ok); }
.tile .value.warn { color: var(--warn); }
.tile .value.down { color: var(--down); }
.tile .hint { color: var(--ink-2); font-size: 12.5px; margin-top: 2px; overflow-wrap: anywhere; }

.tabs {
  max-width: 1280px;
  margin: 0 auto 16px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.tabs button {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 7px 16px;
  font-weight: 600;
  color: var(--ink-2);
}
.tabs button.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.count {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  text-align: center;
}

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

.group-title {
  font: 600 13px/1 var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 22px 2px 10px;
}
.group-title:first-child { margin-top: 4px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--off-bar);
  border-radius: var(--radius);
  padding: 16px 16px 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.card.ok { border-left-color: var(--ok-bar); }
.card.warn { border-left-color: var(--warn-bar); }
.card.down { border-left-color: var(--down-bar); }

.card-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.card-head h3 { font: 700 19px/1.2 var(--serif); margin: 0; overflow-wrap: anywhere; }
.purpose { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }

.pill {
  flex: none;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--off-bg);
  color: var(--off);
}
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.down { background: var(--down-bg); color: var(--down); }
.pill.checking { background: var(--surface-2); color: var(--ink-2); }
.pill.checking::before {
  content: '';
  display: inline-block;
  width: 8px; height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
  vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.summary { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.problems { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.problems li {
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.problems li.warn { background: var(--warn-bg); color: var(--warn); }
.problems li.down { background: var(--down-bg); color: var(--down); }

.avail .row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.avail .num { font-weight: 700; font-variant-numeric: tabular-nums; }
.meter { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.meter span { display: block; height: 100%; border-radius: 999px; background: var(--ok-bar); }
.meter span.warn { background: var(--warn-bar); }
.meter span.down { background: var(--down-bar); }

.exp { display: flex; flex-direction: column; gap: 4px; }
.exp-row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.exp-row .when { font-variant-numeric: tabular-nums; text-align: right; }
.days { font-weight: 700; }
.days.ok { color: var(--ok); }
.days.warn { color: var(--warn); }
.days.down { color: var(--down); }
.days.info { color: var(--muted); font-weight: 500; }
.tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 6px;
  padding: 1px 6px;
  background: var(--surface-2);
  color: var(--ink-2);
  margin-left: 4px;
  vertical-align: 1px;
}
.tag.live { background: var(--down-bg); color: var(--down); }
.tag.test { background: var(--warn-bg); color: var(--warn); }

details.more > summary {
  cursor: pointer;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 13px;
  list-style: none;
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: '▸ '; }
details.more[open] > summary::before { content: '▾ '; }
.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 4px 12px; margin: 10px 0 0; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.note { margin: 10px 0 0; color: var(--ink-2); font-size: 12.5px; }
pre.body {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px;
  font: 12px/1.45 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 220px;
  overflow: auto;
  margin: 8px 0 0;
}
.meta-note {
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 7px 10px;
  overflow-wrap: anywhere;
}

.card-foot {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stats { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; font-size: 12.5px; color: var(--muted); }
.spark { display: flex; gap: 2px; align-items: flex-end; height: 18px; }
.spark i { display: block; width: 5px; height: 100%; border-radius: 2px; background: var(--off-bar); }
.spark i.ok { background: var(--ok-bar); }
.spark i.warn { background: var(--warn-bar); }
.spark i.down { background: var(--down-bar); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions .links { display: flex; gap: 10px; flex-wrap: wrap; margin-right: auto; font-size: 12.5px; }

.filters { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.chip.active { background: var(--surface-2); border-color: var(--muted); color: var(--ink); }

.issue {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--off-bar);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.issue.warn { border-left-color: var(--warn-bar); }
.issue.down { border-left-color: var(--down-bar); }
.issue.resolved { border-left-color: var(--ok-bar); }
.issue-head { display: flex; gap: 10px; justify-content: space-between; align-items: flex-start; }
.issue-title { font-weight: 600; overflow-wrap: anywhere; }
.issue-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.timeline { list-style: none; padding: 0; margin: 10px 0 0; font-size: 12.5px; }
.timeline li { padding: 4px 0 4px 14px; border-left: 2px solid var(--border); position: relative; overflow-wrap: anywhere; }
.timeline li::before {
  content: '';
  position: absolute;
  left: -5px; top: 10px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--off-bar);
}
.timeline li.ok::before { background: var(--ok-bar); }
.timeline li.warn::before { background: var(--warn-bar); }
.timeline li.down::before { background: var(--down-bar); }
.timeline time { color: var(--muted); margin-right: 6px; }

.empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table.expiry { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.expiry th, table.expiry td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.expiry th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
table.expiry tr:last-child td { border-bottom: 0; }
table.expiry tr.info td { color: var(--muted); }

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  width: min(440px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 60px -20px rgba(21, 18, 13, 0.4);
}
dialog::backdrop { background: rgba(21, 18, 13, 0.35); }
dialog h2 { font: 700 20px/1.2 var(--serif); margin: 0 0 4px; }
dialog label { display: block; margin-top: 12px; font-weight: 600; font-size: 13px; }
dialog input, dialog textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  font-weight: 400;
  background: var(--page);
  color: var(--ink);
}
dialog input:focus, dialog textarea:focus { outline: 2px solid rgba(217, 41, 31, 0.35); border-color: var(--accent); }
.dialog-actions { display: flex; gap: 8px; margin-top: 18px; align-items: center; }
.spacer { flex: 1; }

@media (max-width: 560px) {
  .brand h1 { font-size: 25px; }
  .tile .value { font-size: 23px; }
  .run { width: 100%; justify-content: space-between; }
}
