/* ALBM Status — single stylesheet, no framework. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --text: #14171c;
  --muted: #646b78;
  --up: #16a34a;
  --up-soft: #dcfce7;
  --down: #dc2626;
  --down-soft: #fee2e2;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --off: #9aa1ad;
  --off-soft: #eef0f3;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --none: #e3e6eb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1015; --surface: #151a21; --surface-2: #1b2129; --border: #262d37;
    --text: #e8ebf0; --muted: #8d95a3;
    --up: #22c55e; --up-soft: rgba(34, 197, 94, .14);
    --down: #f87171; --down-soft: rgba(248, 113, 113, .14);
    --warn: #f59e0b; --warn-soft: rgba(245, 158, 11, .14);
    --off: #6b7380; --off-soft: rgba(107, 115, 128, .16);
    --accent: #3b82f6; --none: #262d37;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1015; --surface: #151a21; --surface-2: #1b2129; --border: #262d37;
  --text: #e8ebf0; --muted: #8d95a3;
  --up: #22c55e; --up-soft: rgba(34, 197, 94, .14);
  --down: #f87171; --down-soft: rgba(248, 113, 113, .14);
  --warn: #f59e0b; --warn-soft: rgba(245, 158, 11, .14);
  --off: #6b7380; --off-soft: rgba(107, 115, 128, .16);
  --accent: #3b82f6; --none: #262d37;
  --shadow: none;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0; letter-spacing: -.01em; }
code { font: .85em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.center { text-align: center; }
.inline { display: inline; margin: 0; }

.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 28px; padding-bottom: 32px; min-height: calc(100vh - 140px); }
.footer { color: var(--muted); font-size: .8rem; padding-bottom: 28px; text-align: center; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; text-decoration: none; }
.brand-logo { width: 34px; height: 34px; display: block; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav-link { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font: inherit; font-size: .9rem; background: none; border: 0; cursor: pointer; }
.nav-link:hover, .nav-link.active { color: var(--text); background: var(--surface-2); }
.nav-link .ic { width: 16px; height: 16px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 550; font-size: .9rem; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-block { width: 100%; }
.btn .ic { width: 16px; height: 16px; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer; padding: 0; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.icon-btn.danger:hover { color: var(--down); background: var(--down-soft); border-color: transparent; }
.icon-btn .ic { width: 16px; height: 16px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Cards & notices */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.flash, .notice { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; font-size: .9rem; border: 1px solid var(--border); background: var(--surface); }
.flash { border-color: color-mix(in srgb, var(--up) 35%, transparent); background: var(--up-soft); }
.notice { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.notice-bad { background: var(--down-soft); border-color: color-mix(in srgb, var(--down) 30%, transparent); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* Hero */
.hero { display: flex; align-items: center; gap: 16px; padding: 22px 24px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
.hero-up { background: linear-gradient(135deg, var(--up-soft), var(--surface) 70%); border-color: color-mix(in srgb, var(--up) 30%, var(--border)); }
.hero-down { background: linear-gradient(135deg, var(--down-soft), var(--surface) 70%); border-color: color-mix(in srgb, var(--down) 30%, var(--border)); }
.hero-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; flex: none; color: #fff; background: var(--off); }
.hero-up .hero-icon { background: var(--up); }
.hero-down .hero-icon { background: var(--down); }
.hero-icon .ic { width: 24px; height: 24px; stroke-width: 2.5; }
.hero-sub { margin: 2px 0 0; color: var(--muted); }
.hero-time { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .85rem; white-space: nowrap; }
.hero-time .ic { width: 15px; height: 15px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.stat-n { font-size: 1.6rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-n.up { color: var(--up); } .stat-n.down { color: var(--down); } .stat-n.muted { color: var(--muted); }
.stat-l { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }

/* Groups */
.group { margin-bottom: 14px; overflow: hidden; }
.group-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; cursor: pointer; list-style: none; user-select: none; }
.group-head::-webkit-details-marker { display: none; }
.group-head:hover { background: var(--surface-2); }
details[open] > .group-head { border-bottom: 1px solid var(--border); }
.group-name { font-weight: 650; flex: 1; min-width: 0; }
.group-state { font-size: .85rem; font-weight: 550; }
.state-up { color: var(--up); } .state-down { color: var(--down); } .state-pending { color: var(--warn); } .state-disabled { color: var(--muted); }
.chev { color: var(--muted); transition: transform .15s; transform: rotate(-90deg); }
details[open] .chev { transform: none; }

/* Rows */
.row { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-top: 1px solid var(--border); }
.group-body > .row:first-child { border-top: 0; }
.row.depth-1 { padding-left: 38px; } .row.depth-2 { padding-left: 58px; } .row.depth-3 { padding-left: 78px; }
.row-subgroup { background: var(--surface-2); font-weight: 600; font-size: .9rem; gap: 8px; padding-top: 8px; padding-bottom: 8px; }
.row-main { flex: 1; min-width: 0; }
.row-name { font-weight: 550; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; overflow-wrap: anywhere; }
.row-meta { color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.row-meta .ok { color: var(--up); } .row-meta .bad { color: var(--down); }
.sep { margin: 0 6px; opacity: .6; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--off); }
.dot-up { background: var(--up); box-shadow: 0 0 0 4px var(--up-soft); }
.dot-down { background: var(--down); box-shadow: 0 0 0 4px var(--down-soft); animation: pulse 1.8s ease-in-out infinite; }
.dot-pending { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px transparent; } }
@media (prefers-reduced-motion: reduce) { .dot-down { animation: none; } }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px 3px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; width: 112px; justify-content: center; flex: none; }
.badge .ic { width: 14px; height: 14px; stroke-width: 2.5; }
.badge-up { background: var(--up-soft); color: var(--up); }
.badge-down { background: var(--down-soft); color: var(--down); }
.badge-pending { background: var(--warn-soft); color: var(--warn); }
.badge-disabled { background: var(--off-soft); color: var(--muted); }
.chip { font-size: .72rem; font-weight: 550; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); padding: 0 7px; border-radius: 999px; }

/* History bars */
.bars { display: flex; align-items: stretch; gap: 2px; height: 26px; width: 240px; flex: none; }
.bar { display: block; flex: 1; border-radius: 2px; background: var(--none); }
.bar-up { background: var(--up); opacity: .85; }
.bar-partial { background: var(--warn); }
.bar-down { background: var(--down); }
.bar:hover { opacity: 1; filter: brightness(1.15); }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; margin-top: 22px; color: var(--muted); font-size: .8rem; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .bar { width: 8px; height: 14px; flex: none; }
.legend-note { width: 100%; justify-content: center; }

/* Admin */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-size: .85rem; margin-bottom: 6px; }
.back:hover { color: var(--text); }
.back .ic { width: 15px; height: 15px; }
.admin-row.is-group { background: var(--surface-2); }
.admin-row.is-group .row-name { font-weight: 650; }
.actions { display: flex; align-items: center; gap: 2px; flex: none; }

/* Forms */
.narrow { max-width: 380px; margin: 40px auto 0; }
.form { padding: 24px; }
.form h1 { margin-bottom: 16px; }
.login-icon { display: grid; place-items: center; width: 44px; height: 44px; margin: 0 auto 12px; border-radius: 12px; background: var(--surface-2); color: var(--muted); }
.field { margin: 0 0 18px; min-width: 0; border: 0; padding: 0; }
.field > label, .field > legend, .label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 6px; padding: 0; }
input:not([type=radio]):not([type=checkbox]), select, textarea {
  width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: .92rem;
}
textarea, #f-token, #f-cmd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--down); }
.field-error { color: var(--down); font-size: .82rem; margin: 6px 0 0; }
.hint { color: var(--muted); font-size: .8rem; margin: 6px 0 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.input-group { display: flex; gap: 8px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; padding: 8px 0; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }
.kinds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kind { position: relative; cursor: pointer; }
.kind input { position: absolute; opacity: 0; pointer-events: none; }
.kind-body { display: flex; flex-direction: column; gap: 3px; height: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.kind-body span { color: var(--muted); font-size: .8rem; line-height: 1.4; }
.kind:hover .kind-body { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.kind input:checked + .kind-body { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.kind input:focus-visible + .kind-body { outline: 2px solid var(--accent); outline-offset: 2px; }
.code { position: relative; margin-top: 8px; }
.code pre { margin: 0; padding: 12px 44px 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; font: .8rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-all; }
.code .copy { position: absolute; top: 6px; right: 6px; }
.copy.copied { color: var(--up); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 18px; border-top: 1px solid var(--border); }

/* Small screens */
@media (max-width: 860px) { .bars { width: 160px; } }
@media (max-width: 720px) {
  .kinds { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .hero { flex-wrap: wrap; padding: 18px; }
  .hero-time { margin-left: 60px; }
  .bars { display: none; }
  .nav-link span { display: none; }
}
@media (max-width: 520px) {
  .stats { gap: 8px; }
  .stat { padding: 10px 12px; }
  .kinds { grid-template-columns: 1fr; }
  .row { padding-left: 14px; padding-right: 14px; gap: 10px; flex-wrap: wrap; }
  .row.depth-1, .row.depth-2, .row.depth-3 { padding-left: 28px; }
  .badge { width: auto; }
  .admin-row .actions { width: 100%; justify-content: flex-end; }
  .page-head { flex-wrap: wrap; align-items: flex-start; }
}
.chip-warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
