:root {
  --bg: #0b0f14;
  --bg-2: #0f141b;
  --panel: #141a22;
  --panel-2: #1a2230;
  --line: #243041;
  --line-soft: #1c2633;
  --text: #e7edf4;
  --muted: #8a97a8;
  --accent: #d4a537;
  --accent-soft: rgba(212, 165, 55, .14);
  --green: #3fb950;
  --yellow: #d29922;
  --red: #f85149;
  --blue: #58a6ff;
  --cyan: #58c4dc;
  --orange: #f38020;
  --radius: 14px;
  --side: 268px;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
button:hover { border-color: #33435a; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); color: #141006; border-color: var(--accent); font-weight: 650; }
button.primary:hover { filter: brightness(1.07); }
button.link { background: none; border: none; padding: 6px 4px; color: var(--muted); }
button.link.on { color: var(--accent); }
button.ghost { background: transparent; }
input { width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 12px; margin-top: 6px; }
input:focus, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
a { color: var(--blue); text-decoration: none; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.svg { display: inline-flex; width: 18px; height: 18px; flex-shrink: 0; }
.svg svg { width: 100%; height: 100%; }
.icon-btn { padding: 8px; border-radius: 10px; background: transparent; border-color: transparent; }
.icon-btn:hover { background: var(--panel-2); border-color: var(--line); }
.icon-btn .svg { width: 20px; height: 20px; }
.seal { display: inline-block; color: var(--accent); border: 1.5px solid var(--accent); border-radius: 6px;
  padding: 0 5px; margin-right: 6px; font-size: 13px; font-weight: 700; }

/* login */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; }
.login-brand { font-weight: 700; font-size: 18px; margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.login { width: 100%; max-width: 380px; display: grid; gap: 14px; }
.login h1 { margin: 0; font-size: 20px; }
.login label { color: var(--muted); font-size: 13px; }
.error-text { color: var(--red); min-height: 1.2em; margin: 0; }
button.big { padding: 17px; font-size: 17px; justify-content: center; }

/* shell */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--side); flex-shrink: 0; background: var(--bg-2); border-right: 1px solid var(--line-soft);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; transition: margin-left .2s ease, transform .2s ease; }
.app.side-collapsed .sidebar { margin-left: calc(-1 * var(--side)); }
.side-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 14px 10px;
  padding-top: calc(16px + env(safe-area-inset-top)); }
.brand { font-weight: 700; letter-spacing: .2px; }
.side-nav { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.nav-sec, .nav-group { margin: 2px 0; }
.nav-sec > summary, .nav-group > summary, .nav-item { list-style: none; display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 10px; cursor: pointer; color: var(--text); font-weight: 600; user-select: none;
  width: 100%; background: none; border: none; text-align: left; }
.nav-sec > summary::-webkit-details-marker, .nav-group > summary::-webkit-details-marker { display: none; }
.nav-sec > summary::after, .nav-group > summary::after { content: ""; margin-left: auto; width: 7px; height: 7px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; }
.nav-sec[open] > summary::after, .nav-group[open] > summary::after { transform: rotate(45deg); }
.nav-sec > summary:hover, .nav-group > summary:hover, .nav-item:hover, .nav-leaf:hover { background: var(--panel); }
.nav-item.active, .nav-leaf.active { background: var(--accent-soft); color: var(--accent); }
.nav-ico { display: inline-flex; width: 18px; height: 18px; color: var(--muted); }
.nav-ico svg { width: 100%; height: 100%; }
.nav-group { margin-left: 8px; }
.nav-group > summary { font-weight: 500; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .8px; padding: 7px 10px; }
.nav-leaf { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 10px 7px 16px; border: none; background: none;
  border-radius: 9px; text-align: left; font-size: 14px; color: var(--text); }
.nav-leaf .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot { border-top: 1px solid var(--line-soft); padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.side-user { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 15; }

.main { flex: 1; min-width: 0; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top)); background: rgba(11, 15, 20, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft); }
.top-title { font-weight: 700; flex: 1; }
.monitor-state { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.view { max-width: 1180px; margin: 0 auto; padding: 16px; }
.banner { max-width: 1180px; margin: 12px auto 0; padding: 10px 12px; border-radius: 10px; }
.banner.error { background: rgba(248, 81, 73, .12); border: 1px solid var(--red); }

/* status bits */
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex-shrink: 0; box-shadow: 0 0 0 3px rgba(138, 151, 168, .12); }
.dot.up { background: var(--green); box-shadow: 0 0 0 3px rgba(63, 185, 80, .16); }
.dot.degraded { background: var(--yellow); box-shadow: 0 0 0 3px rgba(210, 153, 34, .18); }
.dot.down { background: var(--red); box-shadow: 0 0 0 3px rgba(248, 81, 73, .18); }
.dot.running { background: var(--yellow); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.pill.running { background: rgba(210, 153, 34, .18); color: var(--yellow); }
.pill.success, .pill.up { background: rgba(63, 185, 80, .16); color: var(--green); }
.pill.failed, .pill.interrupted, .pill.down { background: rgba(248, 81, 73, .16); color: var(--red); }
.pill.degraded { background: rgba(210, 153, 34, .18); color: var(--yellow); }
.pill.never, .pill.unknown { background: var(--panel-2); color: var(--muted); }
.good { color: var(--green); } .warn { color: var(--yellow); } .bad { color: var(--red); }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 650; padding: 1px 7px;
  border-radius: 6px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.badge.cf { color: var(--orange); border-color: rgba(243, 128, 32, .4); background: rgba(243, 128, 32, .1); }
.badge.good { color: var(--green); border-color: rgba(63, 185, 80, .4); background: rgba(63, 185, 80, .1); }
.badge.warn { color: var(--yellow); border-color: rgba(210, 153, 34, .4); background: rgba(210, 153, 34, .1); }
.badge.bad { color: var(--red); border-color: rgba(248, 81, 73, .4); background: rgba(248, 81, 73, .1); }

/* panel */
.panel { background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%); border: 1px solid var(--line);
  border-radius: 18px; padding: 18px; margin-bottom: 22px; }
.panel-empty { color: var(--muted); text-align: center; padding: 30px 10px; }
.p-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.p-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.p-title h1 { margin: 0; font-size: 22px; line-height: 1.2; }
.p-sub { color: var(--muted); font-size: 13px; margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.p-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin: 18px 0 14px; }
.tile { background: var(--bg); border: 1px solid var(--line-soft); border-radius: 12px; padding: 11px 12px; min-width: 0; }
.tile .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .7px; }
.tile .v { font-size: 20px; font-weight: 700; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .s { color: var(--muted); font-size: 12px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.bars-wrap { margin: 6px 0 6px; }
.bars-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; font-size: 13px; color: var(--muted); }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.seg button { border: none; background: none; padding: 4px 10px; border-radius: 7px; font-size: 12px; color: var(--muted); }
.seg button.on { background: var(--panel-2); color: var(--text); }
.bars { display: flex; gap: 3px; height: 34px; align-items: stretch; }
.bar { flex: 1; border-radius: 3px; background: var(--line); min-width: 2px; }
.bar.ok { background: var(--green); } .bar.warn { background: var(--yellow); } .bar.bad { background: var(--red); }
.bar.none { background: var(--line-soft); }
.bars-foot { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 5px; }

.sec { border-top: 1px solid var(--line-soft); margin-top: 14px; padding-top: 6px; }
.sec > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 8px 2px;
  font-weight: 650; user-select: none; }
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary .count { color: var(--muted); font-weight: 500; font-size: 13px; }
.sec > summary .end { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.sec > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; margin: 0 2px; }
.sec[open] > summary::before { transform: rotate(45deg); }

.rows { display: grid; gap: 8px; padding: 4px 0 6px; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line-soft); border-radius: 12px; }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .u { font: 12px var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .r { display: flex; align-items: center; gap: 8px; flex-shrink: 0; font-size: 13px; }
.row .icon-btn { padding: 6px; }
.toggle { position: relative; width: 36px; height: 21px; border-radius: 999px; background: var(--line); border: none; padding: 0; flex-shrink: 0; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 15px; height: 15px; border-radius: 50%; background: #c7d0db; transition: left .15s; }
.toggle.on { background: var(--green); }
.toggle.on::after { left: 18px; background: #fff; }

.dns-card { background: var(--bg); border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px; margin: 6px 0 10px; }
.dns-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.dns-host { font: 600 14px var(--mono); }
.rec { display: grid; grid-template-columns: 62px 1fr auto; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line-soft); font-size: 13px; }
.rec:last-of-type { border-bottom: none; }
.rec .v { font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rtype { font: 700 11px var(--mono); color: var(--cyan); }
.meta { color: var(--muted); font-size: 12px; margin-top: 8px; }
.hist { margin-top: 8px; font-size: 12px; color: var(--muted); }
.hist summary { cursor: pointer; }
.step-pre { margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; font: 12.5px/1.5 var(--mono); color: var(--cyan); }

/* list */
.list-head { display: flex; justify-content: space-between; align-items: center; margin: 4px 2px 10px; }
.list-head h2 { margin: 0; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .9px; font-weight: 650; }
.chips { display: flex; gap: 6px; }
.chip { padding: 5px 12px; border-radius: 999px; font-size: 13px; background: var(--panel); }
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: rgba(212, 165, 55, .45); }
.list { display: grid; gap: 8px; }
.item { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.2fr) 90px 80px 120px 40px; align-items: center; gap: 12px;
  width: 100%; text-align: left; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line-soft); border-radius: 14px; }
.item:hover { border-color: #33435a; }
.item.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.item .who { display: flex; align-items: center; gap: 11px; min-width: 0; }
.item .nm { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .chipset { display: flex; gap: 5px; flex-wrap: wrap; min-width: 0; }
.item .host { font: 11px var(--mono); padding: 2px 7px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.item .num { text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; }
.item .num small { display: block; color: var(--muted); font-size: 11px; }
.item .last { text-align: right; }
.item .go { justify-self: end; }
.run-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%;
  text-align: left; padding: 12px 14px; background: var(--panel); border-radius: 14px; border: 1px solid var(--line-soft); }
.run-row .sub, .pk-row .sub { color: var(--muted); font-size: 12px; }

/* security */
.card-title { margin: 0 0 4px; font-size: 17px; }
.field { display: block; color: var(--muted); font-size: 13px; margin: 12px 0; }
.pk-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pk-row:last-child { border-bottom: none; }
.pk-row button { padding: 6px 10px; color: var(--red); }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.build { text-align: center; font-size: 12px; }
.switch-row { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; margin: 6px 0 4px; }
.switch-row input { width: auto; margin: 0; }

/* sheets */
.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: flex; align-items: flex-end; justify-content: center; z-index: 40; }
.sheet-body { width: 100%; max-width: 640px; max-height: 88vh; overflow: auto; background: var(--panel);
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); border: 1px solid var(--line); margin: 0; }
.sheet-body h2 { margin: 0 0 4px; font-size: 18px; }
.step { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 10px 0; background: var(--bg); }
.step-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 600; }
.step-host { font: 12px var(--mono); color: var(--muted); }
.step pre { margin: 8px 0 0; white-space: pre-wrap; word-break: break-word; font: 12.5px/1.5 var(--mono); color: var(--cyan); }
.step label { display: flex; align-items: center; gap: 6px; font-weight: 400; color: var(--muted); font-size: 13px; }
.step label input { width: auto; margin: 0; }
.step.off pre { opacity: .35; }
.sheet-actions { display: flex; gap: 10px; margin-top: 14px; }
.sheet-actions button { flex: 1; padding: 13px; justify-content: center; }

/* console */
.console { position: fixed; inset: 0; background: #010409; z-index: 50; display: flex; flex-direction: column; }
.console-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px;
  padding-top: calc(10px + env(safe-area-inset-top)); border-bottom: 1px solid var(--line); background: var(--panel); }
.console-title { font-weight: 650; text-align: center; }
.console-meta { padding: 6px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
.console-out { flex: 1; overflow: auto; padding: 10px 12px calc(16px + env(safe-area-inset-bottom));
  font: 12.5px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; -webkit-overflow-scrolling: touch; }
.l { min-height: 1.5em; }
.l-out { color: #c9d1d9; }
.l-cmd { color: var(--cyan); margin-top: 6px; }
.l-cmd::before { content: "$ "; color: var(--accent); }
.l-rc { color: var(--muted); font-size: 11.5px; }
.l-rc.bad { color: var(--red); font-weight: 700; }
.l-step { color: var(--accent); font-weight: 700; margin-top: 14px; padding-top: 8px; border-top: 1px dashed var(--line); }
.l-step:first-child { margin-top: 0; border-top: none; padding-top: 0; }
.l-hello, .l-ok { color: var(--green); }
.l-sys { color: var(--muted); }
.l-error { color: var(--red); font-weight: 700; }
.l-end { margin-top: 12px; font-weight: 700; }
.l-end.success { color: var(--green); }
.l-end.failed, .l-end.interrupted { color: var(--red); }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(22px + env(safe-area-inset-bottom));
  max-width: calc(100% - 32px); background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 10px 14px; z-index: 60; box-shadow: 0 6px 24px rgba(0, 0, 0, .45); font-size: 14px; }
.toast.ok { border-color: var(--green); }
.toast.bad { border-color: var(--red); }

.only-narrow { display: none; }

@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .item { grid-template-columns: minmax(0, 1.6fr) 80px 74px 110px 40px; }
  .item .chipset { display: none; }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 20; transform: translateX(-100%); box-shadow: 0 0 40px rgba(0, 0, 0, .5); }
  .app.side-open .sidebar { transform: none; }
  .app.side-collapsed .sidebar { margin-left: 0; }
  .only-narrow { display: inline-flex; }
}
@media (max-width: 640px) {
  .view { padding: 12px; }
  .panel { padding: 14px; border-radius: 16px; }
  .p-title h1 { font-size: 19px; }
  .p-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .p-actions button { justify-content: center; padding: 11px 8px; white-space: nowrap; }
  .p-actions button.primary { grid-column: 1 / -1; padding: 13px; font-size: 16px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile .v { font-size: 17px; }
  .bars { gap: 2px; height: 28px; }
  .item { grid-template-columns: minmax(0, 1fr) auto 36px; gap: 10px; padding: 12px; }
  .item .num.lat, .item .num.up { display: none; }
  .item .last { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
  .item .mob { display: block !important; color: var(--muted); font-size: 11px; }
  .rec { grid-template-columns: 52px 1fr; }
  .rec .x { grid-column: 2; }
  .row { flex-wrap: wrap; }
  .row .r { width: 100%; justify-content: flex-end; }
}
.item .mob { display: none; }
