/* READERP panel.
   Self-contained: an on-premise panel must work without reaching a CDN.

   Built to be scanned, not read. A manager opens this between two meetings:
   the figure that needs attention has to be findable in about two seconds,
   which is why colour is reserved for status and nothing else competes. */

:root {
  --ink:        #0f1d24;
  --ink-2:      #40575f;
  --ink-3:      #7a9099;
  --line:       #d6e0e3;
  --line-soft:  #e7eef0;
  --bg:         #f3f6f7;
  --surface:    #ffffff;
  --surface-2:  #eef3f4;

  --nav-bg:     #0f1d24;
  --nav-ink:    #b9cbd2;
  --nav-ink-2:  #7e97a1;
  --nav-active: #1d3038;

  --accent:     #0d6c79;
  --accent-2:   #0a545e;
  --accent-bg:  #e0eff1;

  --ok:         #14724c;
  --ok-bg:      #dff0e8;
  --warn:       #8a6212;
  --warn-bg:    #f8efd8;
  --danger:     #a52e2b;
  --danger-bg:  #fbe7e6;

  --r:          4px;
  --sidebar:    236px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------- shell ---------------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar); flex: 0 0 var(--sidebar);
  background: var(--nav-bg); color: var(--nav-ink);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand {
  padding: 18px 20px 16px; font-weight: 700; letter-spacing: .06em;
  color: #fff; font-size: 16px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .brand small {
  display: block; font-weight: 400; font-size: 11px; letter-spacing: .04em;
  color: var(--nav-ink-2); margin-top: 3px; text-transform: none;
}
.navgroup { padding: 14px 0 4px; }
.navgroup h4 {
  margin: 0 0 6px; padding: 0 20px;
  font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--nav-ink-2); font-weight: 600;
}
.sidebar nav a {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 20px; color: var(--nav-ink); font-size: 14px;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.sidebar nav a.on { background: rgba(255,255,255,.10); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.sidebar nav a .tag {
  font-size: 10.5px; color: var(--nav-ink-2);
  font-variant-numeric: tabular-nums;
}
.sidebar .foot {
  margin-top: auto; padding: 14px 20px; font-size: 12px; color: var(--nav-ink-2);
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar .foot a { color: var(--nav-ink); }
.sidebar .foot .who { color: #fff; font-size: 13px; margin-bottom: 2px; }

.content { flex: 1; min-width: 0; padding: 26px 30px 80px; max-width: 1500px; }

/* ---------------- headings ---------------- */
.page-head { margin-bottom: 22px; }
h1 { font-size: 23px; margin: 0 0 5px; letter-spacing: -.015em; }
h2 { font-size: 16px; margin: 30px 0 12px; }
.sub { color: var(--ink-3); font-size: 14px; margin: 0; max-width: 78ch; }
.eyebrow {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); font-weight: 600; margin: 0 0 6px;
}

/* ---------------- KPI strip ---------------- */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 8px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 15px 16px; display: flex; flex-direction: column; gap: 4px;
}
.kpi .k-label { font-size: 12.5px; color: var(--ink-3); }
.kpi .k-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .k-foot  { font-size: 11.5px; color: var(--ink-3); }
.kpi.ok     .k-value { color: var(--ok); }
.kpi.warning .k-value { color: var(--warn); }
.kpi.danger .k-value { color: var(--danger); }

/* ---------------- cards ---------------- */
.cards { display: grid; gap: 13px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 17px 18px 15px; display: flex; flex-direction: column; gap: 9px;
}
.card .id { font: 600 11px/1 ui-monospace, Consolas, monospace; letter-spacing: .09em; color: var(--accent); }
.card h3 { margin: 0; font-size: 16px; }
.card h3 a { color: var(--ink); }
.card p { margin: 0; font-size: 14px; color: var(--ink-2); }
.card .why {
  font-size: 12.5px; color: var(--ink-3); line-height: 1.5;
  border-left: 2px solid var(--line); padding-left: 10px;
}
.card footer {
  margin-top: auto; padding-top: 11px; border-top: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card .last { font-size: 12px; color: var(--ink-3); }

.catcard { display: block; }
.catcard h3 { font-size: 17px; }
.catcard .count { font-size: 12.5px; color: var(--ink-3); }

/* ---------------- buttons ---------------- */
button, .btn {
  display: inline-block; background: var(--accent); color: #fff; border: 0;
  padding: 8px 15px; border-radius: var(--r); font: 600 14px/1.25 inherit; cursor: pointer;
}
button:hover, .btn:hover { background: var(--accent-2); text-decoration: none; color: #fff; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--accent-bg); color: var(--accent-2); }
.btn.sm, button.sm { padding: 5px 11px; font-size: 13px; }
.btn.danger { background: var(--danger); }

/* ---------------- tables ---------------- */
.tablewrap {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  overflow: auto; max-height: 72vh;
}
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
thead th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2);
  font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 700; border-bottom: 1px solid var(--line);
}
tbody tr:hover { background: #f7fafb; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
/* Sticky heading: a table 800 rows long is unreadable once the header scrolls away. */
thead th { position: sticky; top: 0; z-index: 1; }
td.emph { font-weight: 700; }
td.muted { color: var(--ink-3); font-size: 12px; white-space: normal; max-width: 260px; }
td.wide { white-space: normal; min-width: 250px; }
tfoot td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--line); }

/* ---------------- pills ---------------- */
.pill {
  display: inline-block; padding: 2px 9px; border-radius: 10px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em; white-space: nowrap;
}
.pill.danger  { background: var(--danger-bg); color: var(--danger); }
.pill.warning { background: var(--warn-bg);   color: var(--warn); }
.pill.ok      { background: var(--ok-bg);     color: var(--ok); }
.pill.muted   { background: #e9edee;          color: var(--ink-3); }

/* ---------------- meta bar & notices ---------------- */
.meta {
  display: flex; flex-wrap: wrap; gap: 7px 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 11px 15px; margin: 0 0 16px; font-size: 13px; color: var(--ink-2);
}
.meta b { color: var(--ink); font-weight: 600; }
.actions { display: flex; gap: 9px; margin: 0 0 15px; align-items: center; flex-wrap: wrap; }

.notice {
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  background: var(--surface); border-radius: var(--r);
  padding: 13px 15px; margin: 0 0 16px; font-size: 13.5px; color: var(--ink-2);
}
.notice.err  { border-left-color: var(--danger); }
.notice.wait { border-left-color: var(--warn); }
.notice.good { border-left-color: var(--ok); }
.notice b { color: var(--ink); }
.notice ul { margin: 7px 0 0; padding-left: 18px; }
.notice li { margin-bottom: 3px; }

.spinner {
  display: inline-block; width: 12px; height: 12px; margin-right: 7px;
  border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* ---------------- forms ---------------- */
.form-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 18px 20px; margin-bottom: 20px;
}
label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 4px; }
input[type=text], input[type=number], input[type=email], input[type=password], select, textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line);
  border-radius: var(--r); font: inherit; font-size: 14px;
  background: #fff; color: var(--ink);
}
input.sm, select.sm { padding: 4px 7px; font-size: 13px; }
.grid { display: grid; gap: 12px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.inline { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }

.secret {
  font: 13px ui-monospace, Consolas, monospace; word-break: break-all;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r); padding: 9px 11px; margin: 6px 0;
}

/* ---------------- login ---------------- */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login { width: 100%; max-width: 380px; background: var(--surface);
         border: 1px solid var(--line); border-radius: var(--r); padding: 30px 28px; }
.login .mark { font: 700 13px/1 ui-monospace, Consolas, monospace;
               letter-spacing: .2em; color: var(--accent); margin-bottom: 20px; }
.login h1 { font-size: 19px; margin-bottom: 20px; }
.login input { margin-bottom: 15px; }
.login button { width: 100%; padding: 10px; }
.login .err { background: var(--danger-bg); color: var(--danger); padding: 9px 12px;
              border-radius: var(--r); font-size: 13.5px; margin-bottom: 15px; }

.empty { color: var(--ink-3); padding: 44px 0; text-align: center; }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex: none; }
  .sidebar nav { display: flex; flex-wrap: wrap; }
  .content { padding: 20px 16px 60px; }
}

/* A database whose name disagrees with its own movement data. Rare, and the
   whole reason the period screen shows evidence instead of just two numbers. */
tr.row-flag td { background: var(--warn-bg); }
