:root {
  --bg: #0d1117; --panel: #151b24; --panel2: #1b2330; --line: #263041; --text: #e6edf3; --muted: #8b98a9;
  --up: #2fbf71; --down: #ef4b5a; --deg: #f0a43a; --paused: #6b7787; --pending: #5b8def; --accent: #4f8cff;
  --radius: 10px; --font: -apple-system, "Segoe UI", Inter, Roboto, sans-serif; --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }

/* layout */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; padding: 4px 8px 18px; }
.brand .logo { width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg, var(--up), var(--accent)); display: grid; place-items: center; color: #08110c; font-weight: 800; }
.nav { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--muted); border: 0; background: none; text-align: left; width: 100%; }
.nav:hover { background: var(--panel2); color: var(--text); }
.nav.active { background: var(--panel2); color: var(--text); font-weight: 600; }
.nav .count { margin-left: auto; font-size: 11px; background: var(--down); color: #fff; border-radius: 10px; padding: 0 7px; }
.side .foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
main { padding: 22px 28px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.topbar h1 { font-size: 20px; margin: 0; }
.topbar .spacer { flex: 1; }
input.search { background: var(--panel); border: 1px solid var(--line); color: var(--text); padding: 8px 12px; border-radius: 8px; width: 240px; }

.btn { background: var(--panel2); border: 1px solid var(--line); color: var(--text); padding: 7px 13px; border-radius: 8px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: #3a475c; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.danger { color: var(--down); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }

/* summary */
.summary { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 22px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.tile .v { font-size: 26px; font-weight: 700; margin-top: 4px; }
.tile.up .v { color: var(--up); } .tile.down .v { color: var(--down); } .tile.deg .v { color: var(--deg); } .tile.paused .v { color: var(--paused); }

/* monitor list */
.group { margin-bottom: 22px; }
.group h2 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 0 0 8px 2px; display: flex; gap: 8px; align-items: center; }
.list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { display: grid; grid-template-columns: 18px minmax(180px, 1.4fr) 92px minmax(200px, 1.6fr) 80px 80px; gap: 14px; align-items: center; padding: 11px 16px; border-top: 1px solid var(--line); cursor: pointer; }
.row:first-child { border-top: 0; }
.row:hover { background: var(--panel2); }
.row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .num { text-align: right; font-variant-numeric: tabular-nums; }
.row .num small { display: block; color: var(--muted); font-size: 11px; }
.dot { width: 11px; height: 11px; border-radius: 50%; background: var(--pending); box-shadow: 0 0 0 3px rgba(91,141,239,.15); }
.dot.up { background: var(--up); box-shadow: 0 0 0 3px rgba(47,191,113,.15); }
.dot.down { background: var(--down); box-shadow: 0 0 0 3px rgba(239,75,90,.2); animation: pulse 1.4s infinite; }
.dot.degraded { background: var(--deg); box-shadow: 0 0 0 3px rgba(240,164,58,.18); }
.dot.paused { background: var(--paused); box-shadow: none; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(239,75,90,.05); } }
.chip { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.isp { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: rgba(79,140,255,.14); color: #9fc0ff; margin-left: 6px; text-transform: none; }
.isp.backup { background: rgba(240,164,58,.15); color: var(--deg); }
.bars { display: flex; gap: 2px; height: 22px; align-items: stretch; }
.bars i { flex: 1; border-radius: 2px; background: var(--up); opacity: .9; min-width: 3px; }
.bars i.f { background: var(--down); }
.bars i.e { background: var(--line); }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* drawer */
.drawer-bg { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 10; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); background: var(--bg); border-left: 1px solid var(--line); z-index: 11; overflow-y: auto; padding: 22px 26px 60px; }
.drawer h2 { margin: 0; font-size: 20px; display: flex; align-items: center; gap: 10px; }
.drawer .meta { color: var(--muted); margin: 6px 0 14px; word-break: break-all; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.section h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.section h3 .tabs { margin-left: auto; }
.tabs button { background: none; border: 1px solid var(--line); color: var(--muted); padding: 2px 9px; font-size: 12px; }
.tabs button:first-child { border-radius: 6px 0 0 6px; } .tabs button:last-child { border-radius: 0 6px 6px 0; }
.tabs button.on { background: var(--panel2); color: var(--text); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.kpis .tile .v { font-size: 20px; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.t td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
.ok { color: var(--up); } .bad { color: var(--down); } .warn { color: var(--deg); }
pre.snip { background: #0a0e14; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; font: 12px/1.5 var(--mono); margin: 6px 0 12px; position: relative; }
.copy { float: right; }
svg.chart { width: 100%; height: 180px; display: block; }
svg.chart text { fill: var(--muted); font-size: 10px; }

/* modal + forms */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 20; display: grid; place-items: center; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: min(640px, 100%); max-height: 92vh; overflow-y: auto; padding: 22px 24px; }
.modal h2 { margin: 0 0 16px; font-size: 18px; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form .full { grid-column: 1 / -1; }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); }
label.f input, label.f select, label.f textarea { background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 8px 10px; font: inherit; }
label.f textarea { min-height: 70px; font-family: var(--mono); font-size: 12.5px; }
label.chk { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13px; }
.hint { font-size: 12px; color: var(--muted); grid-column: 1 / -1; margin-top: -4px; }
.err { color: var(--down); margin-top: 10px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.types { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; grid-column: 1 / -1; }
.types button { background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 9px 6px; text-align: center; font-size: 12.5px; }
.types button b { display: block; font-size: 13px; }
.types button span { color: var(--muted); font-size: 11px; }
.types button.on { border-color: var(--accent); background: rgba(79,140,255,.1); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; }
.login form { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: 340px; display: flex; flex-direction: column; gap: 12px; }
.login input { background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 10px 12px; font: inherit; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 30; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .side .foot, .brand { display: none; }
  .nav { width: auto; }
  main { padding: 16px; }
  .summary { grid-template-columns: repeat(2, 1fr); }
  .row { grid-template-columns: 14px 1fr 70px; }
  .row .bars, .row .chipcol, .row .lat { display: none; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .form { grid-template-columns: 1fr; }
  .types { grid-template-columns: repeat(2, 1fr); }
  input.search { width: 140px; }
}
