/* Post Office -- dashboard styling.
   "AI From the Old Guy" branding: Deep Tech Blue (#1A365D), Automation Teal (#00A3B4) */

:root {
  --bg: #ffffff;
  --fg: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #1A365D;
  --teal: #00A3B4;
  --ok: #15803d;
  --ok-bg: #f0fdf4;
  --warn: #b45309;
  --warn-bg: #fefce8;
  --crit: #b91c1c;
  --crit-bg: #fef2f2;
  --none: #94a3b8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --fg: #f8fafc;
    --muted: #94a3b8;
    --line: #334155;
    --accent: #38bdf8;
    --teal: #2dd4bf;
    --ok: #4ade80;
    --ok-bg: #14532d;
    --warn: #facc15;
    --warn-bg: #713f12;
    --crit: #f87171;
    --crit-bg: #7f1d1d;
    --none: #64748b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main { max-width: 1160px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

/* ── Top bar ─────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .75rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.brand { font-weight: 700; font-size: 1.1rem; color: #1A365D; text-decoration: none; }
.topbar .env { color: var(--muted); font-size: .82rem; }

.nav-links {
  display: flex; gap: 18px; margin-left: 20px; align-items: center;
}
.nav-links a {
  color: #475569; text-decoration: none; font-size: 13.5px; font-weight: 500;
  padding: 4px 8px; border-radius: 6px; transition: color 0.15s, background 0.15s;
}
.nav-links a:hover { color: #1A365D; background: #f1f5f9; }
.nav-links a.active { color: #1A365D; font-weight: 700; background: #e2e8f0; }

.btn-sync {
  font: inherit; cursor: pointer; font-size: 0.85rem; font-weight: 600;
  background: #1A365D; color: #fff;
  border: 0; border-radius: 6px; padding: .45rem .9rem;
  transition: background 0.15s;
}
.btn-sync:hover { background: #00A3B4; }

footer {
  max-width: 1160px; margin: 0 auto; padding: 1.5rem 1.25rem 2.5rem;
  color: var(--muted); font-size: .82rem; border-top: 1px solid var(--line);
}

/* ── Typography & Cards ──────────────────────────────────────────────── */
h1 { font-size: 1.5rem; margin: .4rem 0 1rem; color: #1A365D; }
h2 { font-size: 1.15rem; margin: 1.75rem 0 .75rem; color: #1A365D; }
h3 { font-size: .85rem; margin: 0 0 .35rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
a { color: #00A3B4; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
.muted { color: var(--muted); }
.tiny { font-size: .78rem; }

.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .5rem; }
.crumbs a { text-decoration: none; color: #00A3B4; }

.card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.stat-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}
.stat-title { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.stat-value { font-size: 1.45rem; font-weight: 700; margin: 0.2rem 0; }
.stat-sub { font-size: 0.8rem; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-size: 0.86rem; font-weight: 600; cursor: pointer;
  padding: 0.45rem 0.9rem; border-radius: 6px; border: 1px solid transparent;
  text-decoration: none; transition: all 0.15s;
}
.btn-primary { background: #1A365D; color: #fff; }
.btn-primary:hover { background: #00A3B4; }
.btn-secondary { background: #fff; color: #1e293b; border-color: #cbd5e1; }
.btn-secondary:hover { background: #f8fafc; border-color: #94a3b8; }
.btn-outline { background: transparent; color: #00A3B4; border-color: #00A3B4; }
.btn-outline:hover { background: #f0fdfa; }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.8rem; }

/* ── Badges & Alerts ─────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 7px; border-radius: 4px;
  font-size: 0.76rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em;
}
.badge-ok { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.badge-warn { background: #fef9c3; color: #a16207; border: 1px solid #fef08a; }
.badge-crit { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.badge-info { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.badge-neutral { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }

.alert-box {
  padding: 0.75rem 1rem; border-radius: 8px; font-size: 0.88rem;
}
.alert-ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-warn { background: #fefce8; border: 1px solid #fef08a; color: #854d0e; }
.alert-crit { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

/* ── Tables ──────────────────────────────────────────────────────────── */
.modern-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.modern-table th, .modern-table td { text-align: left; padding: .65rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.modern-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: #f8fafc; }
.modern-table th.sortable { cursor: pointer; user-select: none; }
.modern-table th.sortable:hover { background: #f1f5f9; color: #1A365D; }
.modern-table td.num, .modern-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.modern-table tbody tr:hover { background: #f8fafc; }

.mini-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.mini-table th, .mini-table td { text-align: left; padding: 4px 6px; border-bottom: 1px solid #f1f5f9; }
.mini-table th { font-size: 0.72rem; text-transform: uppercase; color: var(--muted); }

/* ── Meters ──────────────────────────────────────────────────────────── */
.meter {
  position: relative; height: 22px; border-radius: 4px;
  background: color-mix(in srgb, var(--fg) 8%, transparent);
  overflow: hidden; min-width: 120px;
}
.meter-sm { height: 16px; }
.meter-xs { height: 6px; margin-top: .25rem; min-width: 80px; }
.meter-fill { height: 100%; background: var(--none); transition: width .2s; }
.meter-ok   .meter-fill { background: var(--ok); }
.meter-warn .meter-fill { background: var(--warn); }
.meter-crit .meter-fill { background: var(--crit); }
.meter-label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 600; color: var(--fg);
  white-space: nowrap;
}

.account { border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.1rem; }
.account .meter { height: 30px; }
.facts { display: flex; flex-wrap: wrap; gap: 1.5rem; margin: 1rem 0 0; }
.facts div { min-width: 8rem; }
.facts dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.facts dd { margin: .15rem 0 0; font-weight: 600; }

.pill {
  display: inline-block; padding: .1rem .5rem; border-radius: 999px;
  font-size: .76rem; border: 1px solid var(--line); color: var(--muted);
  margin: .1rem .15rem .1rem 0; white-space: nowrap;
}
.pill-ok   { color: var(--ok);   border-color: var(--ok);   background: var(--ok-bg); }
.pill-warn { color: var(--warn); border-color: var(--warn); background: var(--warn-bg); }
.pill-crit { color: var(--crit); border-color: var(--crit); background: var(--crit-bg); }

.warning {
  margin: 1rem 0; padding: .75rem .9rem; border-radius: 8px;
  background: var(--warn-bg); border: 1px solid var(--warn); color: var(--fg);
  font-size: .88rem;
}
.warning p { margin: .4rem 0 0; }

.flash { padding: .6rem .9rem; border-radius: 8px; font-size: .9rem; margin-bottom: 1rem; }
.flash-ok   { background: var(--ok-bg);   border: 1px solid var(--ok); }
.flash-warn { background: var(--warn-bg); border: 1px solid var(--warn); }

.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty h1 { color: var(--fg); }
