:root {
  --bg: #f5f6f8; --panel: #ffffff; --text: #1d2330; --muted: #6b7385; --border: #e1e4ea;
  --accent: #2f5fd0; --accent-text: #ffffff;
  --sev-critical: #a31a2c; --sev-high: #d4462f; --sev-medium: #d98a1c; --sev-low: #3b82a6; --sev-info: #7b8494;
  --ok: #2e8b57; --warn: #d98a1c; --bad: #c0392b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151c; --panel: #1b1f29; --text: #e6e8ee; --muted: #9aa2b4; --border: #2c3240;
    --accent: #6d93f0; --accent-text: #0e1220;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0 0 12px; font-weight: 600; }
h2 { font-size: 20px; } h3 { font-size: 15px; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1em; }

#app { display: flex; min-height: 100vh; }
.sidebar { width: 210px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--border); padding: 16px 0; display: flex; flex-direction: column; }
.sidebar .brand { font-weight: 700; font-size: 18px; padding: 0 20px 16px; }
.sidebar a { padding: 9px 20px; color: var(--text); display: flex; justify-content: space-between; align-items: center; }
.sidebar a.active { background: var(--bg); color: var(--accent); font-weight: 600; border-left: 3px solid var(--accent); padding-left: 17px; }
.sidebar .whoami { margin-top: auto; border-top: 1px solid var(--border); padding-top: 8px; }
.sidebar .whoami a { font-size: 13px; color: var(--muted); }
.sidebar #logout { text-align: left; padding: 9px 20px; }
main { flex: 1; padding: 24px; min-width: 0; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 16px; }
.kpi .value { font-size: 28px; font-weight: 700; }
.kpi .label { color: var(--muted); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr.clickable { cursor: pointer; } tr.clickable:hover { background: var(--bg); }
.table-wrap { overflow-x: auto; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; color: #fff; background: var(--sev-info); white-space: nowrap; }
.sev-critical { background: var(--sev-critical); } .sev-high { background: var(--sev-high); }
.sev-medium { background: var(--sev-medium); } .sev-low { background: var(--sev-low); } .sev-info { background: var(--sev-info); }
.st-online, .st-succeeded { background: var(--ok); } .st-offline, .st-failed, .st-rejected { background: var(--bad); }
.st-pending_approval, .st-pending, .st-paused { background: var(--warn); }
.st-queued, .st-dispatched, .st-running { background: var(--accent); color: var(--accent-text); }
.st-completed { background: var(--ok); } .st-revoked, .st-aborted { background: var(--bad); }
.st-unmanaged, .st-cancelled { background: var(--sev-info); }
.badge { background: var(--warn); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; }

button, .btn { background: var(--accent); color: var(--accent-text); border: 0; border-radius: 6px; padding: 7px 14px; font: inherit; cursor: pointer; }
button.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
button.danger { background: var(--bad); color: #fff; }
button.link { background: none; color: var(--accent); padding: 0; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; }
textarea { width: 100%; min-height: 70px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }

.login { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
.login form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }

.bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: var(--accent); }
pre { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px; overflow: auto; max-height: 420px; white-space: pre-wrap; font-size: 12px; }
.analysis { white-space: pre-wrap; }
dialog { border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: var(--text); width: min(900px, 94vw); padding: 16px; }
dialog::backdrop { background: rgba(0,0,0,.4); }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

@media (max-width: 760px) {
  #app { flex-direction: column; }
  .sidebar { width: auto; flex-direction: row; overflow-x: auto; padding: 8px; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar .brand { display: none; }
  .sidebar a { white-space: nowrap; padding: 8px 12px; }
  .sidebar a.active { border-left: 0; padding-left: 12px; }
  main { padding: 16px; }
}

.warn-card { border-left: 4px solid var(--warn); }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; }
.form-grid .full { grid-column: 1 / -1; margin: 0; }
#notif-form > label { max-width: 320px; }
label.check { flex-direction: row; align-items: center; gap: 4px; color: var(--text); }
td.days { display: flex; flex-wrap: wrap; gap: 6px 10px; }
code { font-size: 12px; }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-left: 4px solid var(--ok); border-radius: 6px; padding: 10px 16px; box-shadow: 0 4px 16px rgba(0,0,0,.15); z-index: 10; max-width: 420px; }
.toast.error-toast { border-left-color: var(--bad); }
@media (max-width: 760px) { .sidebar .whoami { margin-top: 0; border-top: 0; padding-top: 0; display: flex; } }
code.fp { font-size: 15px; font-weight: 700; letter-spacing: .05em; background: var(--bg); padding: 1px 6px; border-radius: 4px; }
a.secondary-btn { display: block; text-align: center; background: transparent; color: var(--text); border: 1px solid var(--border); }

svg.chart { width: 100%; height: auto; display: block; margin: 4px 0 12px; }
svg.chart .grid { stroke: var(--border); stroke-width: 1; }
svg.chart .axis { fill: var(--muted); font-size: 11px; }
svg.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .dot { fill: var(--accent); stroke: var(--panel); stroke-width: 2; }
svg.chart .hit { fill: transparent; cursor: default; }
svg.chart .hit:hover { fill: var(--accent); fill-opacity: .25; }

img.qr { display: block; margin: 10px 0; background: #fff; padding: 6px; border-radius: 8px; image-rendering: pixelated; }
