:root {
  --bg: hsl(217 33% 5%);
  --side: hsl(217 30% 7%);
  --surface: hsl(217 28% 9%);
  --surface-2: hsl(215 22% 13%);
  --border: hsl(215 15% 18%);
  --text: hsl(210 10% 95%);
  --muted: hsl(210 10% 64%);
  --primary: hsl(187 86% 53%);
  --primary-soft: hsl(187 86% 53% / .12);
  --on-primary: hsl(217 40% 7%);
  --ok: hsl(160 70% 45%);
  --warn: hsl(38 92% 55%);
  --bad: hsl(0 80% 66%);
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h3 { margin: 0 0 6px; }
.muted { color: var(--muted); margin: 0 0 16px; max-width: 760px; }
.small { font-size: 13px; margin: 0; }
.error { color: var(--bad); margin: 12px 0 0; }

button, input, select { font: inherit; }
input, select { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
button { cursor: pointer; border-radius: 10px; min-height: 40px; padding: 0 16px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-weight: 500; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--primary); color: var(--on-primary); border-color: transparent; font-weight: 600; }
button.primary:hover { background: hsl(187 80% 62%); }
button.ghost { background: transparent; }
button.danger { color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--text); }
.brand svg { width: 30px; height: 30px; color: var(--primary); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 22px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { margin-bottom: 8px; }
.panel button.primary { margin-top: 18px; width: 100%; }
.narrow { max-width: 420px; }

/* Shell */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; background: var(--side); border-right: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column; gap: 22px; }
.side .brand { padding: 0 8px; }
#tabs { display: flex; flex-direction: column; gap: 2px; }
#tabs button { border: 0; background: transparent; color: var(--muted); text-align: left; display: flex; align-items: center; justify-content: space-between; min-height: 42px; }
#tabs button:hover { color: var(--text); background: var(--surface-2); }
#tabs button.active { color: var(--text); background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--primary); }
.signout { margin-top: auto; }
.count { min-width: 22px; padding: 1px 7px; border-radius: 11px; background: var(--warn); color: var(--on-primary); font-size: 12px; font-weight: 700; text-align: center; }
.count:empty { display: none; }

.content { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 4; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 20px 28px; background: hsl(217 33% 5% / .9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
main { padding: 24px 28px 64px; max-width: 1240px; }
.flash { padding: 12px 16px; border-radius: 10px; background: var(--primary-soft); border: 1px solid hsl(187 86% 53% / .3); margin: 0 0 18px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; z-index: 5; height: auto; flex-direction: row; align-items: center; gap: 12px; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
  .side .brand span { display: none; }
  #tabs { flex-direction: row; }
  #tabs button { white-space: nowrap; min-height: 38px; }
  #tabs button.active { box-shadow: inset 0 -2px 0 var(--primary); }
  .signout { margin: 0 0 0 auto; white-space: nowrap; }
  .topbar { position: static; padding: 16px; }
  main { padding: 16px 16px 48px; }
}

/* Overview */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px 18px 16px; position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--primary); }
.stat.warn::before { background: var(--warn); }
.stat.bad::before { background: var(--bad); }
.stat.ok::before { background: var(--ok); }
.stat span { color: var(--muted); font-size: 13px; }
.stat b { display: block; font-size: 28px; margin-top: 6px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: var(--side); }
tbody tr:hover { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td .sub { color: var(--muted); font-size: 13px; }
td.actions { white-space: nowrap; }
td.actions button + button { margin-left: 6px; }
td input { min-height: 36px; max-width: 140px; }
.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.tag.ok { color: var(--ok); background: hsl(160 70% 45% / .12); }
.tag.warn { color: var(--warn); background: hsl(38 92% 55% / .12); }
.tag.bad { color: var(--bad); background: hsl(0 80% 66% / .12); }
.empty { color: var(--muted); padding: 36px; text-align: center; background: var(--surface); border: 1px dashed var(--border); border-radius: 14px; margin: 0; }

/* Features */
.flags { display: grid; gap: 12px; margin-bottom: 18px; }
.flag { display: grid; grid-template-columns: 1.2fr .6fr .6fr 2fr; gap: 14px; align-items: end; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.flag h3 { font-size: 15px; align-self: center; margin: 0; }
.flag label { margin-top: 0; }
.flag .check { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.flag .check input { width: 18px; min-height: 18px; accent-color: var(--primary); }
.flag .check label { margin: 0; color: var(--text); }
@media (max-width: 760px) { .flag { grid-template-columns: 1fr 1fr; } .flag h3 { grid-column: 1 / -1; } }

/* Dialog */
dialog { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; width: min(460px, 92vw); padding: 22px; }
dialog::backdrop { background: hsl(217 33% 3% / .7); backdrop-filter: blur(4px); }
dialog .muted { margin-bottom: 8px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
