/* Esta dashboard styles — hand-written fallback (TDD 010: vendored Pico/htmx unavailable in the
 * build sandbox, so the app ships this and degrades to plain HTML forms; nothing functional depends
 * on htmx). Tokens are the validated dataviz reference palette: magnitude bars use one blue hue;
 * status colors (good/warning/serious/critical) are reserved for health/queue/message status and
 * always pair with an icon + text label, never colour alone. Light + dark are both selected. */

:root {
  --plane: #f9f9f7;
  --surface: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --muted: #898781;
  --border: rgba(11, 11, 11, 0.10);
  --gridline: #e1e0d9;
  --accent: #256abf;      /* blue 500 — magnitude / links */
  --accent-soft: #cde2fb; /* blue 100 — bar track */
  --good: #0ca30c;
  --warning: #b3760a;     /* darkened warning for legible text on light */
  --serious: #c85f34;
  --critical: #d03b3b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --plane: #0d0d0d;
    --surface: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --muted: #898781;
    --border: rgba(255, 255, 255, 0.10);
    --gridline: #2c2c2a;
    --accent: #3987e5;
    --accent-soft: #184f95;
    --good: #0ca30c;
    --warning: #fab219;
    --serious: #ec835a;
    --critical: #e66767;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text-primary);
  background: var(--plane);
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; margin-top: 1.5rem; }
small, .muted { color: var(--muted); }

header.topnav {
  display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1rem;
  padding: .75rem 1.25rem; background: var(--surface);
  border-bottom: 1px solid var(--border);
}
header.topnav .brand { font-weight: 700; margin-right: .5rem; }
header.topnav nav { display: flex; flex-wrap: wrap; gap: .1rem .9rem; }
header.topnav nav a { color: var(--text-secondary); font-size: .95rem; }
header.topnav nav a[aria-current="page"] { color: var(--accent); font-weight: 600; }
header.topnav form.logout { margin-left: auto; }

main { max-width: 1100px; margin: 0 auto; padding: 1.25rem; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .75rem; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: .75rem .9rem; display: block; color: inherit;
}
a.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile .label { color: var(--text-secondary); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.tile .value { font-size: 1.6rem; font-weight: 700; margin-top: .15rem; }
.tile .sub { color: var(--muted); font-size: .8rem; }
.row-title { color: var(--text-secondary); font-size: .85rem; font-weight: 600; margin: 1.25rem 0 .4rem; text-transform: uppercase; letter-spacing: .04em; }

/* magnitude bar (one hue) */
.bar-track { background: var(--accent-soft); border-radius: 4px; height: .7rem; overflow: hidden; }
.bar-fill { background: var(--accent); height: 100%; border-radius: 4px; }
meter { width: 100%; height: .8rem; }

/* funnel strip */
.funnel { display: flex; flex-direction: column; gap: .35rem; }
.funnel .stage { display: grid; grid-template-columns: 10rem 1fr 4rem; align-items: center; gap: .6rem; }
.funnel .stage .name { color: var(--text-secondary); font-size: .9rem; }
.funnel .stage .n { text-align: right; font-variant-numeric: tabular-nums; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .4rem .55rem; border-bottom: 1px solid var(--gridline); vertical-align: top; }
th { color: var(--text-secondary); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
tfoot td { font-weight: 600; border-top: 2px solid var(--border); }

/* status badges — icon + label, never colour alone */
.badge { display: inline-flex; align-items: center; gap: .25rem; font-size: .8rem; font-weight: 600; }
.badge::before { font-size: .85em; }
.badge.good { color: var(--good); } .badge.good::before { content: "\2714"; }
.badge.warning { color: var(--warning); } .badge.warning::before { content: "\26A0"; }
.badge.serious { color: var(--serious); } .badge.serious::before { content: "\25B2"; }
.badge.critical { color: var(--critical); } .badge.critical::before { content: "\2716"; }
.badge.neutral { color: var(--muted); } .badge.neutral::before { content: "\25CB"; }

/* filter bar */
form.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; margin-bottom: 1rem; }
form.filters label { display: flex; flex-direction: column; font-size: .75rem; color: var(--text-secondary); gap: .15rem; }
form.filters input, form.filters select {
  padding: .35rem .45rem; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text-primary); font: inherit;
}
button, input[type="submit"] {
  padding: .4rem .8rem; border: 1px solid var(--accent); border-radius: 6px;
  background: var(--accent); color: #fff; font: inherit; cursor: pointer;
}
button.ghost { background: transparent; color: var(--accent); }

.count-note { color: var(--muted); font-size: .85rem; margin: .25rem 0 .75rem; }
.empty { color: var(--muted); padding: 1rem 0; }
.pager { display: flex; gap: 1rem; margin-top: 1rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
.dir-in { color: var(--accent); font-weight: 600; }
.dir-out { color: var(--text-secondary); font-weight: 600; }
.msg { border-left: 3px solid var(--gridline); padding: .3rem 0 .3rem .75rem; margin: .5rem 0; }
.msg.inbound { border-left-color: var(--accent); }

/* login */
.login-wrap { max-width: 22rem; margin: 4rem auto; }
.error { color: var(--critical); }
