:root {
  --bg: #0f172a;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #697386;
  --line: #d9dee8;
  --accent: #2563eb;
  --danger: #b42318;
  --success: #067647;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; background: #eef2f7; color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar { display: flex; align-items: center; gap: 18px; min-height: 56px; padding: 0 20px; background: var(--bg); color: #fff; position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; white-space: nowrap; }
.nav { display: flex; align-items: center; gap: 6px; flex: 1; flex-wrap: wrap; }
.nav a { color: #dbeafe; padding: 9px 11px; border-radius: 8px; }
.nav a.active, .nav a:hover { background: rgba(255,255,255,0.12); text-decoration: none; color: #fff; }
.user { opacity: .85; font-size: 14px; }
.container { max-width: 1660px; margin: 22px auto; padding: 0 18px; }
.panel, .login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: 0 8px 28px rgba(15, 23, 42, 0.06); margin-bottom: 18px; }
.login-card { max-width: 430px; margin: 80px auto; }
h1, h2, h3 { margin-top: 0; }
.muted { color: var(--muted); font-size: 14px; }
.stack { display: grid; gap: 14px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px 14px; align-items: end; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
label { display: grid; gap: 5px; font-size: 14px; color: #334155; }
label.check { display: flex; align-items: center; gap: 7px; min-height: 38px; }
input, select, button { font: inherit; border-radius: 8px; }
input, select { width: 100%; padding: 9px 10px; border: 1px solid #cbd5e1; background: #fff; }
button { border: 0; background: var(--accent); color: #fff; padding: 10px 14px; cursor: pointer; font-weight: 600; }
button:hover { filter: brightness(0.96); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.danger { background: var(--danger); }
.actions { margin-top: 12px; display: flex; gap: 14px; align-items: center; }
.form-wide { grid-column: 1 / -1; }
.checks-box { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; border: 1px dashed #cbd5e1; border-radius: 10px; padding: 10px; background: #f8fafc; }
.alert { padding: 12px 14px; border-radius: 10px; margin: 12px 0; border: 1px solid; }
.alert.error { background: #fef3f2; border-color: #fecdca; color: #7a271a; }
.alert.success { background: #ecfdf3; border-color: #abefc6; color: #054f31; }
.status-line { padding: 10px 12px; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; }
.cards { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card { min-width: 150px; max-width: 260px; border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; background: #fff; }
.card .title { color: var(--muted); font-size: 13px; }
.card .value { font-weight: 800; font-size: 20px; margin-top: 2px; }
.card .subtitle { color: var(--muted); font-size: 12px; margin-top: 3px; }
.graph-wrap { position: relative; min-height: 560px; }
.loader { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255,255,255,0.86); border-radius: 10px; z-index: 2; font-weight: 700; color: #334155; }
.loader.hidden { display: none; }
#fig { width: 100%; min-height: 680px; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 9px 8px; text-align: left; vertical-align: top; }
th { background: #f8fafc; font-size: 13px; color: #475569; }
.user-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.user-row input[name="username"] { width: 180px; }
.user-row input[name="password"] { width: 240px; }
.delete-form { display: inline-block; margin-top: 7px; }
.small-id { color: var(--muted); font-size: 12px; width: 36px; }
.badge { display: inline-block; border-radius: 999px; padding: 3px 8px; color: #fff; font-size: 12px; font-weight: 700; }
.badge.ok { background: var(--success); }
.badge.off { background: #667085; }
.row-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.error-text { color: var(--danger); font-size: 13px; max-width: 420px; }
.markdown-doc { white-space: pre-wrap; line-height: 1.55; overflow-x: auto; background: #f8fafc; border: 1px solid var(--line); padding: 14px; border-radius: 10px; }
@media (max-width: 720px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 12px; }
  .nav { gap: 2px; }
  .grid-form { grid-template-columns: 1fr; }
}
.nav-logout { margin: 0; display: inline; }
.nav-logout button { background: transparent; color: #dbeafe; padding: 9px 11px; border-radius: 8px; }
.nav-logout button:hover { background: rgba(255,255,255,0.12); color: #fff; filter: none; }
.audit-json { white-space: pre-wrap; word-break: break-word; font-size: 12px; }
