:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --text: #1b1f24;
  --muted: #5d6673;
  --line: #e3e6ea;
  --accent: #1f5eff;
  --accent-ink: #ffffff;
  --accent-soft: #e8efff;
  --green: #147a45; --green-soft: #e3f5ea;
  --amber: #8a5a00; --amber-soft: #fff3d6;
  --red: #b3261e; --red-soft: #fde8e7;
  --blue: #1d4ed8; --blue-soft: #e5edff;
  --purple: #6b3fb8; --purple-soft: #efe8fb;
  --grey: #4b5563; --grey-soft: #eef0f3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.05);
  --side: #0f1729;
  --side-text: #c9d2e3;
  --side-active: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117; --panel: #151b24; --panel-2: #1a212c; --text: #e6e9ee; --muted: #9aa4b2;
    --line: #2a3340; --accent: #5b8cff; --accent-soft: #1b2744;
    --green: #4cc38a; --green-soft: #12291e; --amber: #f0b44c; --amber-soft: #2d2410;
    --red: #ff7b72; --red-soft: #33191a; --blue: #7ea6ff; --blue-soft: #16223d;
    --purple: #b79cf2; --purple-soft: #251d38; --grey: #b0b8c4; --grey-soft: #222a35;
    --side: #0a0e15;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 650; }
h3 { font-size: 14px; margin: 16px 0 8px; font-weight: 650; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

.layout { display: flex; min-height: 100vh; }
.side {
  width: 228px; flex: 0 0 228px; background: var(--side); color: var(--side-text);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { color: #fff; font-weight: 700; font-size: 15px; padding: 4px 10px 16px; display: flex; gap: 8px; align-items: center; }
.brand .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); display: inline-block; }
.side a { color: var(--side-text); padding: 7px 10px; border-radius: 7px; display: flex; justify-content: space-between; }
.side a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.side a.active { background: rgba(255,255,255,.1); color: var(--side-active); }
.side .group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7d879b; padding: 14px 10px 4px; }
.side .count { background: rgba(255,255,255,.12); border-radius: 20px; padding: 0 7px; font-size: 12px; }
.side .spacer { flex: 1; }
.side .who { font-size: 12px; padding: 10px; border-top: 1px solid rgba(255,255,255,.08); margin-top: 10px; }
.side .who button { background: none; border: 0; color: var(--side-text); padding: 0; cursor: pointer; font: inherit; text-decoration: underline; }

.main { flex: 1; min-width: 0; padding: 24px 28px 60px; max-width: 1280px; }
.pagehead { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.tight { padding: 0; overflow: hidden; }
.card.tight > h2 { padding: 14px 16px 0; }
.grid { display: grid; gap: 16px; }
.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)); }
.split { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 16px; align-items: start; }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 24px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: 12px; }
.bar { height: 6px; background: var(--grey-soft); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar.warn > span { background: var(--amber); }
.bar.full > span { background: var(--red); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--panel-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 12px; font-weight: 550; white-space: nowrap; }
.badge.grey { background: var(--grey-soft); color: var(--grey); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.purple { background: var(--purple-soft); color: var(--purple); }
.score { display: inline-flex; gap: 2px; }
.score i { width: 8px; height: 8px; border-radius: 2px; background: var(--grey-soft); display: inline-block; }
.score i.on { background: var(--accent); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 8px; font: inherit; font-weight: 550;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; background: var(--panel-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--red); }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }

label { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 4px; }
.help { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=password], input[type=url], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit;
  background: var(--panel); color: var(--text);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; margin: 12px 0 4px; }
.check input { width: 16px; height: 16px; }
.formrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 16px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid transparent; }
.flash.ok { background: var(--green-soft); color: var(--green); }
.flash.error { background: var(--red-soft); color: var(--red); }
.flash.link { background: var(--blue-soft); color: var(--blue); }
.notice { padding: 12px 14px; border-radius: 8px; background: var(--amber-soft); color: var(--amber); margin-bottom: 14px; }
.notice.red { background: var(--red-soft); color: var(--red); }
.notice.blue { background: var(--blue-soft); color: var(--blue); }

.checks { list-style: none; padding: 0; margin: 0; }
.checks li { display: flex; gap: 8px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.checks li:last-child { border-bottom: 0; }
.checks .ic { width: 18px; flex: 0 0 18px; font-weight: 700; }
.checks .ok .ic { color: var(--green); }
.checks .bad .ic { color: var(--red); }
.checks .warn .ic { color: var(--amber); }
.checks .detail { color: var(--muted); font-size: 12.5px; word-break: break-word; }

.emailpreview { border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); padding: 14px; white-space: pre-wrap; font-size: 13.5px; }
.emailpreview .subj { font-weight: 650; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.evidence { margin: 0; padding-left: 18px; }
.evidence li { margin-bottom: 6px; }
.evidence a { font-size: 12px; word-break: break-all; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; }
.feed li:last-child { border-bottom: 0; }
.feed .when { color: var(--muted); font-size: 12px; white-space: nowrap; min-width: 88px; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
details.more summary { cursor: pointer; color: var(--accent); font-weight: 550; margin: 8px 0; }
.settings-nav { position: sticky; top: 16px; }
.settings-nav a { display: block; padding: 6px 10px; border-radius: 6px; color: var(--muted); }
.settings-nav a:hover { background: var(--panel); text-decoration: none; }
code.block { display: block; padding: 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; word-break: break-all; white-space: pre-wrap; }
.dev-banner { background: #b3261e; color: #fff; text-align: center; padding: 6px; font-weight: 600; }
.login { max-width: 420px; margin: 12vh auto; padding: 0 16px; }
.login .card { padding: 28px; text-align: center; }
.ms-btn { display: inline-flex; gap: 10px; align-items: center; padding: 10px 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); font-weight: 600; }
.ms-btn:hover { text-decoration: none; background: var(--panel-2); }
.pager { display: flex; gap: 8px; justify-content: flex-end; padding: 12px; }

@media (max-width: 960px) {
  .split, .g2, .g3 { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; flex: none; padding: 10px; }
  .side .group, .side .spacer { display: none; }
  .brand { padding: 4px 10px; width: 100%; }
  .main { padding: 16px; }
}
