:root {
  --bg: #f4f5f8; --surface: #fff; --surface-2: #f0f2f6; --border: #e1e4ea;
  --text: #17191f; --muted: #646b78; --faint: #9aa1ad;
  --brand: #14213d; --accent: #2f6fed; --danger: #c92a2a; --ok: #2b8a3e;
  --shadow: 0 1px 2px rgba(20,25,40,.06), 0 4px 14px rgba(20,25,40,.06);
  --radius: 14px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --surface: #181b21; --surface-2: #20242c; --border: #2b3039;
    --text: #e8eaef; --muted: #a0a7b4; --faint: #6f7682; --brand: #e8eaef;
    --accent: #5b8cff; --danger: #ff6b6b; --ok: #69db7c;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.boot { padding: 40vh 0 0; text-align: center; color: var(--muted); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--danger); font-size: 14px; min-height: 1em; }

.input, .select { width: 100%; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 10px 12px; outline: none; }
.input:focus, .select:focus { border-color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 9px 14px; font-weight: 600; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.auth .card { width: 100%; max-width: 380px; }
.card h1 { margin: 0 0 4px; font-size: 22px; }
.card h2 { margin: 0 0 6px; font-size: 17px; }
.card p { margin: 0 0 16px; color: var(--muted); }
form.stack, .stack { display: grid; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.01em; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }

.top { display: flex; align-items: center; gap: 12px; padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.top .grow { flex: 1; }
.top nav { display: flex; gap: 4px; }
.top nav button { border: 0; background: none; padding: 8px 12px; border-radius: 8px; font-weight: 600; color: var(--muted); }
.top nav button.on { background: var(--surface-2); color: var(--text); }
.who { font-size: 13px; color: var(--muted); text-align: right; line-height: 1.2; }
main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
main h1 { font-size: 22px; margin: 0 0 16px; }

.apps { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.app-card { display: block; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--c); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); transition: transform .12s; }
.app-card:hover { transform: translateY(-2px); }
.app-card h3 { margin: 0 0 6px; font-size: 17px; }
.app-card p { margin: 0; color: var(--muted); font-size: 14px; }
.empty { padding: 28px; text-align: center; color: var(--faint); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-top: 1px solid var(--border); font-size: 14px; vertical-align: top; }
th { border-top: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-weight: 700; }
.badge.ok { color: var(--ok); } .badge.off { color: var(--danger); } .badge.admin { color: var(--accent); }
.row-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }
.grid2 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } .who { display: none; } .top { flex-wrap: wrap; } }
.checks { display: flex; gap: 12px; flex-wrap: wrap; }
.checks label { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; }
.section { margin-top: 24px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 12px; font-size: 14px; z-index: 80; opacity: 0; pointer-events: none; transition: all .2s; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
