/* Admin console: calm, dense, legible.  No animation flourishes. */
:root {
  color-scheme: light dark;
  --bg: #f4f5f7; --panel: #ffffff; --text: #16181d; --text2: #4a5160; --muted: #7a8291; --line: #e2e5ea; --hover: #f0f2f6;
  --accent: #2b6cb0; --accent-ink: #ffffff; --ok: #1a7f4b; --warn: #b7791f; --bad: #c0362c; --info: #2b6cb0;
  --c1: #2b6cb0; --c2: #c0362c; --c3: #b7791f; --c4: #7b4bb5;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1115; --panel: #171a21; --text: #e8eaef; --text2: #b3b9c6; --muted: #838b9b; --line: #272c37; --hover: #1e222b;
          --accent: #6ea8ea; --accent-ink: #0b1220; --ok: #4cc38a; --warn: #e0a84b; --bad: #f0776d; --info: #6ea8ea;
          --c1: #6ea8ea; --c2: #f0776d; --c3: #e0a84b; --c4: #b995e8; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
a { color: var(--accent); } button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; }
.muted { color: var(--muted); } .mono { font-family: var(--mono); font-size: 12.5px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* login */
.login { max-width: 360px; margin: 12vh auto; padding: 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; gap: 12px; }
.login h1 { margin: 0 0 4px; font-size: 20px; } .login label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text2); }
.login input { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.login .err { color: var(--bad); min-height: 1.3em; font-size: 13px; margin: 0; }

/* shell */
.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 10px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.side h1 { font-size: 15px; margin: 0 8px 12px; }
.side button.nav { text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--text2); display: flex; justify-content: space-between; align-items: center; }
.side button.nav:hover { background: var(--hover); } .side button.nav[aria-current="page"] { background: var(--hover); color: var(--text); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.side .spacer { flex: 1; } .side .who { font-size: 12px; color: var(--muted); padding: 6px 10px; word-break: break-all; }
.main { padding: 18px 22px 60px; min-width: 0; }
.topline { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.topline h2 { margin: 0; font-size: 20px; } .topline .grow { flex: 1; }
.livedot { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); } .livedot i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.livedot.on i { background: var(--ok); }
.strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 8px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; } .tile .l { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tile .v { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; } .tile .v.bad { color: var(--bad); } .tile .v.warn { color: var(--warn); } .tile .s { font-size: 12px; color: var(--muted); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 16px; min-width: 0; }
.card h3 { margin: 0 0 10px; font-size: 14px; } .grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; } .grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1000px) { .grid3 { grid-template-columns: 1fr; } } @media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }
.tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
input[type=search], input[type=text], input[type=email], input[type=password], select, textarea { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.btn { padding: 6px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); cursor: pointer; } .btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; } .btn.danger { color: var(--bad); border-color: var(--bad); } .btn.sm { padding: 3px 8px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; position: sticky; top: 0; background: var(--panel); }
tbody tr:hover { background: var(--hover); } td.wrap { white-space: normal; min-width: 180px; max-width: 420px; word-break: break-word; }
td .actions { display: flex; gap: 6px; }
tr.failed td { background: color-mix(in srgb, var(--bad) 8%, transparent); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--hover); color: var(--text2); border: 1px solid var(--line); }
.badge.ok { color: var(--ok); border-color: var(--ok); } .badge.bad { color: var(--bad); border-color: var(--bad); } .badge.warn { color: var(--warn); border-color: var(--warn); } .badge.info { color: var(--info); border-color: var(--info); }
.empty { padding: 22px; text-align: center; color: var(--muted); }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; padding-top: 10px; color: var(--muted); font-size: 12.5px; }

.alerts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.alert { display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); border-left-width: 5px; background: var(--panel); }
.alert.high { border-left-color: var(--bad); } .alert.medium { border-left-color: var(--warn); } .alert.info { border-left-color: var(--info); } .alert .t { flex: 1; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.chart { position: relative; } .chart .ct { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text2); margin-bottom: 4px; } .chart canvas { width: 100%; height: 110px; display: block; }
.chart .tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px; font-size: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.2); white-space: nowrap; }
.bar { height: 8px; background: var(--hover); border-radius: 6px; overflow: hidden; } .bar > i { display: block; height: 100%; background: var(--accent); }
.minibars { display: flex; gap: 3px; align-items: flex-end; height: 44px; } .minibars i { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; }

/* dialogs + toasts */
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); padding: 18px; max-width: min(720px, 94vw); width: 100%; }
dialog::backdrop { background: rgba(0,0,0,.45); } dialog h3 { margin: 0 0 8px; } dialog .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
dialog label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text2); margin-top: 10px; } dialog textarea { min-height: 90px; }
dialog section { margin-top: 14px; } dialog section h4 { margin: 0 0 6px; font-size: 12.5px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { padding: 9px 14px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--ok); box-shadow: 0 4px 16px rgba(0,0,0,.25); max-width: 380px; }
.toast.err { border-left-color: var(--bad); }

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; } .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side h1 { width: 100%; } .side .spacer { display: none; } .main { padding: 14px 12px 60px; }
}
