/* Paralleye dashboard. Navy chrome, red accent, posture colours only for posture. */
:root {
  --navy: #1A1A2E;
  --navy-2: #2a2a46;
  --accent: #C0001A;
  --green: #2E9E5B;
  --amber: #E0A100;
  --red: #C0001A;
  --ink: #1f2430;
  --ink-2: #4b5160;
  --muted: #6b7280;
  --line: #e3e5ea;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --grey-1: #3d4150;
  --grey-2: #6e7385;
  --grey-3: #9ca1b0;
  --grey-4: #c9ccd5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 20, 40, 0.06), 0 1px 1px rgba(20, 20, 40, 0.04);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--navy); }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---------- header ---------- */
.topbar {
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 3px solid var(--accent);
}
.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 56px;
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 17px; color: #fff; text-decoration: none; letter-spacing: 0.01em; display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 10px; height: 22px; background: var(--accent); border-radius: 2px; display: inline-block; }
.brand small { font-weight: 400; color: #b9bbd0; font-size: 12px; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.nav a {
  color: #d6d7e6; text-decoration: none; padding: 8px 12px; border-radius: 6px; font-weight: 500;
}
.nav a:hover { background: var(--navy-2); color: #fff; }
.nav a.active { color: #fff; box-shadow: inset 0 -3px 0 var(--accent); border-radius: 0; }
.userbox { display: flex; align-items: center; gap: 10px; color: #b9bbd0; font-size: 13px; }
.role-pill { border: 1px solid #4a4a6a; border-radius: 999px; padding: 1px 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }

/* ---------- layout ---------- */
main { max-width: 1320px; margin: 0 auto; padding: 20px 16px 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
@media (max-width: 980px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .nav { order: 3; flex: 1 1 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .userbox { margin-left: auto; }
}
.section { margin-top: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  min-width: 0;
}

/* ---------- number cards ---------- */
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stat { position: relative; padding: 12px 14px 10px; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-value .unit { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.stat-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; min-height: 26px; }
.trend { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); white-space: nowrap; }
.trend .arrow { font-size: 14px; }
.trend.up .arrow { color: var(--green); }
.trend.down .arrow { color: var(--red); }
.trend.flat .arrow { color: var(--grey-3); }
.stat-compare { font-size: 11px; color: var(--muted); }
.stat svg.spark { flex: none; }

/* ---------- chart cards ---------- */
.chart-card { display: flex; flex-direction: column; }
.chart-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; min-height: 24px; }
.chart-hint { font-size: 12px; color: var(--muted); }
.chart-box { position: relative; width: 100%; height: 280px; }
.chart-box.tall { height: 360px; }
.chart-box.short { height: 200px; }
.chart-box.strip { height: 90px; }
.warn {
  display: flex; gap: 8px; align-items: flex-start;
  background: #fff7e6; border: 1px solid #f1d39a; color: #6b4b00;
  border-radius: 8px; padding: 6px 10px; font-size: 12px; margin-bottom: 6px;
}
.warn::before { content: "⚠"; font-weight: 700; }

/* ---------- buttons & inputs ---------- */
button, .btn {
  font: inherit; font-size: 13px; cursor: pointer;
  border-radius: 7px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 6px 12px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn:hover { border-color: var(--grey-3); }
button:focus-visible, .btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, tr:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: #a00016; border-color: #a00016; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); padding: 3px 8px; font-size: 12px; }
.btn-ghost:hover { background: #f0f1f4; border-color: transparent; }
.btn-danger { color: var(--accent); border-color: #e7b3bb; }
.btn-danger:hover { background: #fff1f3; border-color: var(--accent); }
.btn-small { padding: 3px 8px; font-size: 12px; }
.topbar button { background: transparent; color: #d6d7e6; border-color: #4a4a6a; }
.topbar button:hover { color: #fff; border-color: #8a8aa8; }
input, select {
  font: inherit; font-size: 13px; padding: 6px 9px; border-radius: 7px; border: 1px solid var(--line); background: #fff; color: var(--ink);
}
label.field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); font-weight: 600; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 10px; border-radius: 999px;
  background: var(--navy); color: #fff; font-size: 12px;
}
.chip button { background: transparent; border: 0; color: #fff; padding: 0 4px; font-size: 14px; line-height: 1; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.data th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
  border-bottom: 1px solid var(--line); padding: 8px 10px; white-space: nowrap; background: #fafbfc; position: sticky; top: 0;
}
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--ink); }
table.data th .sort { color: var(--accent); margin-left: 3px; }
table.data td { padding: 8px 10px; border-bottom: 1px solid #f0f1f4; vertical-align: middle; white-space: nowrap; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: #f7f8fb; }
table.data tr.inactive td { color: var(--muted); }
table.data td.num, table.data th.num { text-align: right; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

/* ---------- inline visuals ---------- */
.cellbar { display: inline-flex; align-items: center; gap: 8px; min-width: 120px; }
.cellbar .track { position: relative; width: 70px; height: 8px; background: #eef0f3; border-radius: 4px; overflow: hidden; flex: none; }
.cellbar .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; }
.cellbar .val { min-width: 34px; text-align: right; font-weight: 600; }
.fill.green { background: var(--green); }
.fill.amber { background: repeating-linear-gradient(45deg, var(--amber) 0 3px, #f3c64f 3px 5px); }
.fill.red { background: repeating-linear-gradient(-45deg, var(--red) 0 3px, #d9475a 3px 5px); }
.fill.grey { background: var(--grey-2); }
.zonebar { display: inline-flex; width: 110px; height: 10px; border-radius: 4px; overflow: hidden; gap: 1px; background: #fff; vertical-align: middle; }
.zonebar span { display: block; height: 100%; }
.zonebar .z-green { background: var(--green); }
.zonebar .z-yellow { background: repeating-linear-gradient(45deg, var(--amber) 0 3px, #f3c64f 3px 5px); }
.zonebar .z-red { background: repeating-linear-gradient(-45deg, var(--red) 0 3px, #d9475a 3px 5px); }
.zonelabel { font-size: 11px; color: var(--muted); margin-left: 6px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin-right: 6px; }
.dot.green { background: var(--green); }
.dot.amber { background: var(--amber); box-shadow: inset 0 0 0 2px #fff, 0 0 0 1px var(--amber); }
.dot.red { background: var(--red); border-radius: 2px; }
.dot.none { background: transparent; border: 1.5px solid var(--grey-3); }
.status-icon { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; color: #fff; flex: none; }
.status-icon.red { background: var(--red); }
.status-icon.amber { background: var(--amber); color: #1f1600; }
.status-icon.info { background: var(--grey-2); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: #eef0f3; color: var(--ink-2); }
.pill.off { background: #fde8eb; color: var(--accent); }

/* ---------- attention panel ---------- */
.attention { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; }
.attention li { display: flex; gap: 10px; align-items: center; padding: 8px 2px; border-bottom: 1px solid #f0f1f4; }
.attention li:last-child { border-bottom: 0; }
.attention a { font-weight: 600; text-decoration: none; }

/* ---------- legend for inline visuals ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); align-items: center; }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 5px; }

/* ---------- details / toggles ---------- */
details.data-toggle summary { cursor: pointer; font-weight: 600; padding: 6px 0; list-style: none; }
details.data-toggle summary::-webkit-details-marker { display: none; }
details.data-toggle summary::before { content: "▸ "; color: var(--accent); }
details.data-toggle[open] summary::before { content: "▾ "; }
.meta-list { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--ink-2); }
.meta-list b { color: var(--ink); font-weight: 600; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--navy); }
.login-card { width: 100%; max-width: 360px; background: #fff; border-radius: 12px; padding: 28px 24px; border-top: 4px solid var(--accent); }
.login-card h1 { margin-bottom: 4px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.login-card input { width: 100%; padding: 9px 11px; font-size: 14px; }
.login-card button { justify-content: center; padding: 9px; font-size: 14px; }
.form-error { color: var(--accent); font-size: 13px; min-height: 18px; }

.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff;
  padding: 10px 16px; border-radius: 8px; font-size: 13px; z-index: 50; box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

@media print {
  .topbar, .chart-tools button, .toolbar, .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
  main { max-width: none; padding: 0; }
}
