:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --ink: #1b1f24;
  --ink-2: #4a525c;
  --ink-3: #7c858f;
  --line: #e4e1db;
  --line-2: #efece7;
  --accent: #1f4e5f;
  --accent-ink: #ffffff;
  --accent-soft: #e6eef1;
  --high: #b42318;
  --high-soft: #fdecea;
  --med: #a15c07;
  --med-soft: #fdf3e2;
  --low: #475467;
  --low-soft: #eef0f3;
  --ok: #1d7a4f;
  --ok-soft: #e7f4ec;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 24, 28, .05);
  --font: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 13px; font-weight: 600; margin: 0 0 8px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.num, td.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }

/* layout */
.topbar { background: var(--ink); color: #fff; }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 24px; height: 52px; }
.brand { font-weight: 600; color: #fff; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 18px; height: 18px; border-radius: 4px; background: linear-gradient(135deg, #5fa8bd, #1f4e5f); display: inline-block; }
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.nav a { color: #c9cfd6; padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
.nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); text-decoration: none; }
.nav a.active { color: #fff; background: rgba(255, 255, 255, .12); }
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #c9cfd6; }
.topbar-right select { background: transparent; color: #fff; border: 1px solid #3a424b; border-radius: 6px; padding: 3px 6px; font: inherit; }
.topbar-right select option { color: var(--ink); }
.linkbtn { background: none; border: 0; color: #c9cfd6; cursor: pointer; font: inherit; padding: 0; white-space: nowrap; }
.linkbtn:hover { color: #fff; }
.page { max-width: 1240px; margin: 0 auto; padding: 24px 20px 64px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--ink-3); margin-top: 4px; }

/* panels & stats */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-pad { padding: 18px 20px; }
.panel + .panel, .panel + .grid, .grid + .panel { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 2fr 1fr; }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { font-size: 12px; color: var(--ink-3); }
.stat .value { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat.high .value { color: var(--high); }
.stat.med .value { color: var(--med); }
.stat.ok .value { color: var(--ok); }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fbfaf8; }
th:first-child { border-top-left-radius: var(--radius); }
th:last-child { border-top-right-radius: var(--radius); }
td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fcfbf9; }
td a.rowlink { color: var(--ink); font-weight: 500; }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill.high { background: var(--high-soft); color: var(--high); }
.pill.medium { background: var(--med-soft); color: var(--med); }
.pill.low { background: var(--low-soft); color: var(--low); }
.pill.ok, .pill.active { background: var(--ok-soft); color: var(--ok); }
.pill.needs_reauth, .pill.error { background: var(--high-soft); color: var(--high); }
.pill.disconnected, .pill.ignored, .pill.cleared { background: var(--low-soft); color: var(--low); }
.pill.resolved { background: var(--ok-soft); color: var(--ok); }
.pill.open { background: var(--accent-soft); color: var(--accent); }
.count { display: inline-block; min-width: 26px; text-align: center; padding: 1px 6px; border-radius: 6px; font-weight: 600; font-variant-numeric: tabular-nums; }
.count.high { background: var(--high-soft); color: var(--high); }
.count.medium { background: var(--med-soft); color: var(--med); }
.count.low { background: var(--low-soft); color: var(--low); }
.count.zero { color: #c3c8ce; font-weight: 400; }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #cfcac2; text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: #183f4d; }
.btn.danger { color: var(--high); }
.btn.sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=search], select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 60px; resize: vertical; }
label { font-size: 13px; color: var(--ink-2); display: block; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field .help, .helptext { font-size: 12px; color: var(--ink-3); margin-top: 4px; display: block; }
.errorlist { color: var(--high); font-size: 12px; margin: 4px 0 0; padding: 0; list-style: none; }
.checks-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 16px; max-height: 220px; overflow-y: auto; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.checks-list label, .inline-check { display: flex; gap: 8px; align-items: center; margin: 0; color: var(--ink); font-size: 13px; }
ul.plain { list-style: none; margin: 0; padding: 0; }
form.inline { display: inline; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input { width: auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 8px 12px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--ink); border-color: var(--accent); font-weight: 500; }
.tabs a:hover { text-decoration: none; color: var(--ink); }

/* findings */
.finding { border-bottom: 1px solid var(--line-2); padding: 14px 20px; }
.finding:last-child { border-bottom: 0; }
.finding-head { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.finding-title { font-weight: 500; }
.finding-meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.finding-detail { color: var(--ink-2); margin-top: 6px; }
.finding details { margin-top: 8px; }
.finding summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.items { margin-top: 8px; font-size: 13px; }
.items td { padding: 5px 10px; }
.notes { margin-top: 10px; border-left: 2px solid var(--line); padding-left: 12px; font-size: 13px; }
.notes .n { margin-bottom: 6px; }
.action-form { margin-top: 10px; display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.action-form textarea { min-height: 36px; height: 36px; }

/* messages */
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; background: var(--accent-soft); color: var(--accent); border: 1px solid #cfe0e6; }
.messages li.error { background: var(--high-soft); color: var(--high); border-color: #f6c9c4; }
.messages li.warning { background: var(--med-soft); color: var(--med); border-color: #f3dcb2; }
.messages li.success { background: var(--ok-soft); color: var(--ok); border-color: #c7e6d4; }
.note-box { background: var(--med-soft); color: var(--med); border-radius: 8px; padding: 10px 14px; font-size: 13px; }
.empty { padding: 40px 20px; text-align: center; color: var(--ink-3); }
.empty strong { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

/* auth shell */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: 0 8px 30px rgba(20, 24, 28, .06); }
.auth-card .brand { color: var(--ink); margin-bottom: 18px; }
.auth-card h1 { font-size: 20px; margin-bottom: 6px; }
.auth-card p { color: var(--ink-2); margin: 0 0 18px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 10px 14px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: 12px; margin: 16px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-card form p { margin-bottom: 12px; }
.auth-card input { margin-top: 2px; }

td:first-child { min-width: 160px; }
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .topbar-inner { flex-wrap: wrap; height: auto; padding: 10px 16px 0; gap: 8px 12px; }
  .topbar-right { margin-left: auto; }
  .topbar-right select { max-width: 150px; }
  .nav { order: 3; flex-basis: 100%; padding-bottom: 8px; }
  .page { padding: 18px 16px 48px; }
  .hide-sm { display: none; }
  .action-form { grid-template-columns: 1fr; }
}
@media print {
  .topbar, .action-form, .btn, .tabs, form, .messages { display: none !important; }
  body { background: #fff; }
  .grid-2 { grid-template-columns: 1fr; }
  .panel { box-shadow: none; border-color: #ddd; }
  details { display: block; }
  details > * { display: block; }
}

/* health score */
.score { display: inline-flex; align-items: center; justify-content: center; min-width: 38px; padding: 2px 8px; border-radius: 999px; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 13px; }
.score.good { background: var(--ok-soft); color: var(--ok); }
.score.fair { background: var(--med-soft); color: var(--med); }
.score.poor { background: var(--high-soft); color: var(--high); }
.score.none { color: #c3c8ce; }
.score.lg { font-size: 22px; padding: 6px 14px; min-width: 64px; }
.spark polyline { stroke: var(--ink-3); }
.spark.good polyline { stroke: var(--ok); }
.spark.fair polyline { stroke: var(--med); }
.spark.poor polyline { stroke: var(--high); }
.head-score { display: flex; align-items: center; gap: 12px; }

/* close */
.bar { height: 8px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.task { border-top: 1px solid var(--line-2); padding: 12px 20px; }
.task-row { display: flex; gap: 12px; align-items: flex-start; }
.task-title { font-weight: 500; }
.task.done .task-title { color: var(--ink-3); text-decoration: line-through; }
.check { width: 22px; height: 22px; flex: none; border-radius: 6px; border: 1.5px solid #c9c4bb; background: #fff; cursor: pointer; color: #fff; font-weight: 700; line-height: 1; padding: 0; margin-top: 1px; }
.check.on { background: var(--ok); border-color: var(--ok); }
.check[disabled] { cursor: default; }
.overdue { color: var(--high); font-weight: 500; }
.grid-2 > div > .panel + .panel { margin-top: 16px; }

/* reports */
.up { color: var(--ok); }
.down { color: var(--high); }
.neg, .negt { color: var(--high); fill: var(--high); }
.chart .rev { fill: var(--accent); }
.chart .cost { fill: #c9b99b; }
.chart .axis { stroke: var(--line); }
.chart .lbl { font-size: 11px; fill: var(--ink-3); font-family: var(--font); }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; }
.key.rev { background: var(--accent); }
.key.cost { background: #c9b99b; }
@media print { .noprint { display: none !important; } .report .stats { grid-template-columns: repeat(5, 1fr); } }

/* nav dropdown */
.nav { overflow: visible; }
.navmenu { position: relative; }
.navmenu summary { list-style: none; color: #c9cfd6; padding: 6px 10px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.navmenu summary::-webkit-details-marker { display: none; }
.navmenu summary:hover, .navmenu[open] summary, .navmenu summary.active { color: #fff; background: rgba(255, 255, 255, .12); }
.navmenu-list { position: absolute; top: calc(100% + 6px); left: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(20, 24, 28, .12); padding: 6px; min-width: 180px; z-index: 20; }
.navmenu-list a { display: block; color: var(--ink); padding: 7px 10px; border-radius: 6px; }
.navmenu-list a:hover { background: var(--bg); text-decoration: none; }
@media (max-width: 900px) { .nav { overflow-x: auto; } .navmenu-list { position: fixed; top: auto; left: 16px; right: 16px; } }

/* statements */
.stmt td.cell { min-width: 170px; }
.inline-details { display: inline-block; position: relative; }
.inline-details summary { color: var(--accent); cursor: pointer; list-style: none; display: inline; }
.inline-details summary::-webkit-details-marker { display: none; }
.upload-pop { position: absolute; z-index: 10; top: 22px; right: 0; width: 260px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(20,24,28,.12); padding: 12px; display: grid; gap: 8px; }
