:root {
  --bg: #060a11;
  --card: rgba(18, 27, 43, 0.72);
  --stroke: rgba(148, 163, 184, 0.13);
  --stroke-strong: rgba(148, 163, 184, 0.22);
  --text: #e8eef8;
  --muted: #8798b0;
  --accent: #5eead4;
  --accent-deep: #2dd4bf;
  --accent-ink: #03231f;
  --blue: #60a5fa;
  --danger: #fb7185;
  --warn: #fbbf24;
  --ok: #34d399;
  --radius: 18px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1100px 560px at 74% -14%, rgba(45, 212, 191, 0.11), transparent 62%),
    radial-gradient(900px 520px at 6% -8%, rgba(96, 165, 250, 0.11), transparent 58%),
    radial-gradient(900px 700px at 52% 118%, rgba(99, 102, 241, 0.07), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  overflow-x: hidden;
}

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.045) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(ellipse 85% 65% at 50% 0%, rgba(0, 0, 0, 0.85), transparent 78%);
  mask-image: radial-gradient(ellipse 85% 65% at 50% 0%, rgba(0, 0, 0, 0.85), transparent 78%);
  opacity: 0.55;
}

.login-wrap, .app { position: relative; z-index: 1; }

button, input, textarea { font: inherit; }
code, .mono { font-family: var(--mono); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.empty { color: var(--muted); font-size: 12.5px; padding: 10px 2px; }

/* ---------- shared surface ---------- */

.login-card, .sidebar, .panel, .stat, .modal-card {
  background: linear-gradient(180deg, rgba(21, 31, 49, 0.86), rgba(11, 17, 28, 0.93));
  border: 1px solid var(--stroke);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.045),
    0 24px 60px -30px rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* ---------- login ---------- */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(404px, 100%);
  border-radius: 22px;
  padding: 34px 32px 26px;
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 26px;
  right: 26px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(94, 234, 212, 0.65), transparent);
}
.login-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 26px;
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #5eead4, #60a5fa);
  color: #04121a;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.4px;
  box-shadow: 0 12px 28px -14px rgba(45, 212, 191, 0.8);
  flex: 0 0 auto;
}
.login-badge {
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--muted);
  border: 1px solid var(--stroke);
  padding: 4px 9px;
  border-radius: 999px;
}
.login-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 640;
  letter-spacing: -0.025em;
}
.login-sub {
  margin: 0 0 24px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.65;
}
.form-error {
  color: var(--danger);
  min-height: 18px;
  margin-top: 10px;
  font-size: 12px;
}
.login-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.05em;
}
.login-foot .dot {
  width: 5px;
  height: 5px;
  box-shadow: none;
  background: var(--muted);
}

/* ---------- shell ---------- */

.app {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  gap: 20px;
  max-width: 1480px;
  margin: 0 auto;
  padding: 18px;
  align-items: start;
  align-content: start;
  min-height: 100vh;
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 18px;
  height: calc(100vh - 36px);
  border-radius: 20px;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 6px 0;
}
.brand-copy { display: flex; flex-direction: column; line-height: 1.05; }
.brand-copy strong { font-size: 13.5px; font-weight: 700; letter-spacing: 0.16em; }
.brand-copy small {
  font-size: 8.5px;
  color: var(--muted);
  letter-spacing: 0.18em;
  margin-top: 5px;
}

nav { display: flex; flex-direction: column; gap: 4px; }

.nav-button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  text-align: left;
  transition: color 0.16s, background 0.16s, border-color 0.16s;
}
.nav-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
  opacity: 0.9;
}
.nav-button:hover {
  color: var(--text);
  background: rgba(148, 163, 184, 0.055);
}
.nav-button.active {
  color: #dcfff8;
  background: linear-gradient(90deg, rgba(45, 212, 191, 0.14), rgba(45, 212, 191, 0.025));
  border-color: rgba(45, 212, 191, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.nav-button.active svg { color: var(--accent); opacity: 1; }

.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid rgba(148, 163, 184, 0.1);
}
.user-chip { display: flex; align-items: center; gap: 9px; min-width: 0; }
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.16);
  font-size: 12px;
  font-weight: 600;
  color: #cfe0f8;
  flex: 0 0 auto;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.user-meta strong {
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-meta small {
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-top: 4px;
}

/* ---------- topbar ---------- */

main { min-width: 0; padding: 4px 4px 28px; }

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 2px 20px;
}
.title-block h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 640;
  letter-spacing: -0.025em;
}
#page-subtitle {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.01em;
}
.top-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: #8ff0d8;
  background: rgba(45, 212, 191, 0.07);
  border: 1px solid rgba(45, 212, 191, 0.2);
}
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.08);
  flex: 0 0 auto;
}
.status-pill.bad {
  color: #fda4af;
  background: rgba(244, 63, 94, 0.07);
  border-color: rgba(244, 63, 94, 0.25);
}
.status-pill.bad .dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(251, 113, 133, 0.08);
}
.status-pill.warn,
.status-pill.paused {
  color: #fcd34d;
  background: rgba(251, 191, 36, 0.07);
  border-color: rgba(251, 191, 36, 0.22);
}
.status-pill.warn .dot,
.status-pill.paused .dot {
  background: var(--warn, #fbbf24);
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.08);
}

.top-actions a.icon-button { text-decoration: none; color: inherit; }
.icon-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(148, 163, 184, 0.05);
  color: var(--muted);
  transition: color 0.16s, border-color 0.16s, background 0.16s;
}
.icon-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-button:hover {
  color: var(--accent);
  border-color: rgba(94, 234, 212, 0.35);
  background: rgba(45, 212, 191, 0.07);
}

/* ---------- pages ---------- */

.page {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.page:not(.hidden) { animation: rise 0.32s ease both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat {
  border-radius: var(--radius);
  padding: 17px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.stat::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 80% at 100% 0%, rgba(45, 212, 191, 0.08), transparent 58%);
}
.stat:hover {
  transform: translateY(-2px);
  border-color: rgba(94, 234, 212, 0.26);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 30px 70px -32px rgba(0, 0, 0, 0.85);
}
.stat-head { display: flex; align-items: center; gap: 10px; position: relative; z-index: 1; }
.stat-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: rgba(45, 212, 191, 0.09);
  border: 1px solid rgba(45, 212, 191, 0.18);
  flex: 0 0 auto;
}
.stat-icon svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.stat-label { color: var(--muted); font-size: 11.5px; letter-spacing: 0.02em; }
.stat strong {
  font-size: 31px;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  position: relative;
  z-index: 1;
}
.stat-sub { font-size: 11px; color: var(--muted); position: relative; z-index: 1; }

.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.panel-grid.two { grid-template-columns: minmax(0, 380px) minmax(0, 1fr); }
.panel-grid.two > .panel:first-child { align-self: start; }

.panel {
  border-radius: var(--radius);
  padding: 20px;
  min-width: 0;
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.panel-head h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 620;
  letter-spacing: -0.01em;
}
.panel-sub {
  margin: 5px 0 0;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.01em;
}
.panel-chip.warn {
  color: var(--warn);
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.07);
}
.panel-chip {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(148, 163, 184, 0.04);
  padding: 4px 9px;
  border-radius: 8px;
  white-space: nowrap;
}
.live-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  letter-spacing: 0.14em;
  color: #6ee7b7;
  border: 1px solid rgba(52, 211, 153, 0.2);
  background: rgba(52, 211, 153, 0.06);
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.live-chip .dot { width: 5px; height: 5px; box-shadow: none; }
.live-chip.paused {
  color: #fcd34d;
  border-color: rgba(251, 191, 36, 0.22);
  background: rgba(251, 191, 36, 0.07);
}
.live-chip.paused .dot { background: #fbbf24; }

/* ---------- buttons ---------- */

button {
  border-radius: 10px;
  border: 1px solid transparent;
  color: inherit;
  cursor: pointer;
  transition: filter 0.15s, transform 0.12s, background 0.15s, border-color 0.15s, color 0.15s;
}
button:focus-visible {
  outline: 2px solid rgba(94, 234, 212, 0.55);
  outline-offset: 2px;
}
.primary {
  background: linear-gradient(180deg, #5eead4, #2dd4bf);
  color: var(--accent-ink);
  font-weight: 700;
  padding: 9px 16px;
  border-color: rgba(94, 234, 212, 0.5);
  box-shadow:
    0 12px 28px -16px rgba(45, 212, 191, 0.85),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.primary:hover { filter: brightness(1.05); transform: translateY(-1px); }
.primary:disabled {
  opacity: 0.4;
  filter: none;
  transform: none;
  cursor: not-allowed;
  box-shadow: none;
}
.ghost {
  background: rgba(148, 163, 184, 0.05);
  border-color: rgba(148, 163, 184, 0.16);
  color: #d7e2f2;
  padding: 8px 13px;
  font-size: 12px;
}
.ghost:hover {
  border-color: rgba(94, 234, 212, 0.35);
  color: #d9fff7;
  background: rgba(45, 212, 191, 0.06);
}
.danger {
  background: transparent;
  border-color: rgba(251, 113, 133, 0.22);
  color: #fda4af;
  padding: 7px 11px;
  font-size: 11.5px;
}
.danger:hover { background: rgba(251, 113, 133, 0.08); border-color: rgba(251, 113, 133, 0.4); }
.block { width: 100%; }

/* ---------- forms ---------- */

label {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 12px;
  letter-spacing: 0.01em;
}
input, textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  background: rgba(7, 11, 18, 0.62);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 10px;
  color: var(--text);
  padding: 9px 11px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input::placeholder, textarea::placeholder { color: rgba(135, 152, 176, 0.55); }
input:focus, textarea:focus {
  border-color: rgba(94, 234, 212, 0.5);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.11);
  background: rgba(9, 14, 23, 0.9);
}
input[type="file"] { padding: 8px; color: var(--muted); font-size: 12px; }
input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(148, 163, 184, 0.08);
  color: var(--text);
  cursor: pointer;
}
.stack { display: flex; flex-direction: column; gap: 2px; }
.stack button { margin-top: 6px; }

/* ---------- tables ---------- */

.table-wrap { overflow: auto; margin: -2px -4px -4px; padding: 0 4px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
thead th {
  text-align: left;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding: 6px 10px 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  white-space: nowrap;
}
tbody td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.075);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(148, 163, 184, 0.028); }
th:first-child, td:first-child { padding-left: 12px; }
td .mono { font-size: 11.5px; color: #c7d8ee; }
td .row { gap: 6px; flex-wrap: nowrap; }
td button { padding: 6px 10px; font-size: 11px; border-radius: 8px; }

.hint {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.65;
  margin: 8px 0 0;
}
.hint code {
  color: #c7d8ee;
  background: rgba(148, 163, 184, 0.08);
  padding: 1px 5px;
  border-radius: 5px;
}

/* ---------- badges / tags ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.badge.ok {
  color: #6ee7b7;
  background: rgba(52, 211, 153, 0.07);
  border-color: rgba(52, 211, 153, 0.22);
}
.badge.off {
  color: #94a3b8;
  background: rgba(148, 163, 184, 0.05);
  border-color: rgba(148, 163, 184, 0.14);
}
.tag {
  display: inline-block;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  color: #a9bdd8;
  background: rgba(148, 163, 184, 0.04);
  margin-right: 3px;
}

/* ---------- regions / events ---------- */

.region-list { display: flex; flex-direction: column; gap: 14px; }
.region-item {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) 108px;
  align-items: center;
  gap: 12px;
}
.region-name {
  font-family: var(--mono);
  font-size: 11px;
  color: #a9bdd8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.region-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.09);
  overflow: hidden;
}
.region-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #5eead4, #60a5fa);
  box-shadow: 0 0 12px rgba(94, 234, 212, 0.35);
  transition: width 0.4s ease;
}
.region-meta {
  font-size: 10.5px;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.event-list {
  display: flex;
  flex-direction: column;
  max-height: 324px;
  overflow: auto;
}
.event-list.tall { max-height: 68vh; }
.event {
  display: grid;
  grid-template-columns: 62px 44px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding: 9px 6px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.06);
}
.event:last-child { border-bottom: 0; }
.event time {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}
.event .lvl {
  font-size: 9px;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.event .lvl.info { color: #7dd3fc; }
.event .lvl.warn { color: var(--warn); }
.event .lvl.error { color: var(--danger); }
.event .txt { font-size: 12px; color: #c6d5e8; overflow-wrap: anywhere; }

/* ---------- result / key ---------- */

.result {
  margin-top: 16px;
  border: 1px solid rgba(94, 234, 212, 0.22);
  background: linear-gradient(180deg, rgba(45, 212, 191, 0.07), rgba(45, 212, 191, 0.015));
  border-radius: 13px;
  padding: 14px;
}
.result p { margin: 0 0 10px; font-size: 12px; color: #cfe6e2; line-height: 1.6; }
.key-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(7, 11, 18, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 10px;
  padding: 9px 10px;
  margin: 8px 0 10px;
}
.key-row code {
  flex: 1;
  overflow: auto;
  white-space: nowrap;
  font-size: 11.5px;
  color: #8ff0d8;
}

/* ---------- modal / toast ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(4, 8, 14, 0.68);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal-card {
  width: min(780px, 100%);
  border-radius: var(--radius);
  padding: 20px;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.modal-head h3 { margin: 0; font-size: 15.5px; font-weight: 620; }
.modal-head .icon-button { font-size: 18px; line-height: 1; }
.modal-card textarea {
  min-height: 260px;
  margin: 12px 0 16px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 12.5px;
  background: rgba(15, 23, 38, 0.94);
  border: 1px solid rgba(94, 234, 212, 0.25);
  box-shadow: 0 22px 60px -22px rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
}
.toast.error { border-color: rgba(251, 113, 133, 0.4); color: #fecdd3; }

/* ---------- responsive ---------- */

@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-grid { grid-template-columns: minmax(0, 1fr); }
  .panel-grid.two { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
  }
  .sidebar {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "brand spacer foot"
      "nav nav nav";
    align-items: center;
    padding: 10px 12px;
    gap: 6px 10px;
    border-radius: 16px;
    overflow: visible;
  }
  .sidebar .brand { grid-area: brand; padding: 0; }
  .sidebar-foot { grid-area: foot; }
  .brand-copy { display: none; }
  .brand-mark { width: 32px; height: 32px; border-radius: 9px; font-size: 11px; }
  nav {
    grid-area: nav;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
    min-width: 0;
    width: 100%;
    overflow: visible;
  }
  .nav-button {
    padding: 8px 9px;
    min-height: 36px;
    font-size: 11.5px;
    gap: 6px;
    flex: 0 0 auto;
  }
  #range-switch button, .live-toggle, .overview-actions .ghost { min-height: 32px; }
  .nav-button svg { width: 15px; height: 15px; }
  .sidebar-foot {
    margin: 0;
    padding: 0;
    border: 0;
    flex: 0 0 auto;
  }
  .user-meta { display: none; }
  .avatar { width: 28px; height: 28px; border-radius: 8px; font-size: 11px; }
  main { padding: 0 0 20px; }
  .topbar { padding: 4px 2px 14px; }
  .title-block h2 { font-size: 20px; }
  #page-subtitle { font-size: 11.5px; }
}

@media (max-width: 560px) {
  .stat-grid { gap: 10px; }
  .stat { padding: 14px; border-radius: 15px; }
  .stat strong { font-size: 25px; }
  .stat-icon { width: 27px; height: 27px; border-radius: 8px; }
  .panel { padding: 16px; border-radius: 15px; }
  .panel-grid { gap: 12px; }
  .top-actions .status-pill { padding: 0 9px; }
  .status-pill { font-size: 10px; }
  .login-card { padding: 28px 22px 22px; }
  .event { grid-template-columns: 56px 40px minmax(0, 1fr); gap: 8px; }
  .region-item { grid-template-columns: 68px minmax(0, 1fr) 92px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- visualization layer ---------- */

.overview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.range-switch {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: rgba(148, 163, 184, 0.06);
  border: 1px solid var(--stroke);
  border-radius: 10px;
}
.range-switch button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 11px;
  font-size: 11px;
  border-radius: 7px;
}
.range-switch button.active {
  background: rgba(45, 212, 191, 0.14);
  color: #d9fff7;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.overview-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.live-toggle { display: inline-flex; align-items: center; gap: 7px; }
.live-toggle:not(.on) { color: var(--muted); }
.live-toggle:not(.on) .dot { background: var(--muted); box-shadow: none; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}
.kpi {
  position: relative;
  overflow: hidden;
  min-width: 0;
  padding: 14px 14px 11px;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(21, 31, 49, 0.86), rgba(11, 17, 28, 0.93));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.045),
    0 18px 44px -30px rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(12px);
}
.kpi::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 100% 0%, rgba(45, 212, 191, 0.07), transparent 60%);
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 1; }
.kpi-label { color: var(--muted); font-size: 10.5px; letter-spacing: 0.02em; }
.kpi-value {
  position: relative;
  z-index: 1;
  margin: 7px 0 2px;
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-bottom {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  min-height: 30px;
}
.kpi-delta { font-size: 10px; color: var(--muted); white-space: nowrap; }
.kpi-delta.up { color: var(--ok); }
.kpi-delta.bad { color: var(--danger); }
.kpi-value.bad { color: var(--danger); }
.kpi-value.warn { color: var(--warn); }
.spark { width: 88px; height: 30px; flex: 0 0 auto; overflow: visible; }
.spark .area { fill: rgba(94, 234, 212, 0.1); }
.spark .line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.viz-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
}
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.panel.viz { padding: 16px 16px 10px; }

.chart { width: 100%; min-width: 0; }
.chart-lg { height: 276px; }
.chart-md { height: 240px; }
.chart-sm { height: 190px; }
.chart-map { height: 300px; }
.chart-gauge { height: 148px; }
.chart-donut { height: 208px; }
.chart-topo { height: 560px; }

.chart { position: relative; }
.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
  z-index: 3;
}
.rank-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 64px;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 4px;
  border: 0;
  border-bottom: 1px solid rgba(148, 163, 184, .08);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
}
.rank-row:hover { background: rgba(94, 234, 212, .04); }
.rank-spark {
  display: block;
  width: 64px;
  height: 16px;
  margin-top: 3px;
  overflow: visible;
}
.topo-spark { margin: 8px 0 12px; }
.topo-spark .rank-spark { width: 100%; height: 34px; }
.topo-spark span { display: block; margin-top: 2px; font-size: 9px; color: var(--muted); }
.rank-spark path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.3;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
}
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 10px; color: var(--muted); }
.chart-legend span.off { opacity: .35; text-decoration: line-through; }
.u-tip {
  position: absolute;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 9px;
  border-radius: 8px;
  background: rgba(15, 23, 38, .96);
  border: 1px solid rgba(148, 163, 184, .22);
  font-size: 10px;
  color: var(--muted);
  pointer-events: none;
  box-shadow: 0 10px 30px -16px rgba(0, 0, 0, .9);
  white-space: nowrap;
}
.u-tip.hidden { display: none; }
.u-tip-time { color: #e8eef8; font-weight: 600; }
.u-tip-in { color: #5eead4; }
.u-tip-out { color: #60a5fa; }
.chart-legend span::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: currentColor;
  margin-right: 5px;
}
.chart-legend .in { color: var(--accent); }
.chart-legend .out { color: var(--blue); }

.capacity-wrap { display: flex; flex-direction: column; gap: 4px; }
.capacity-regions { display: flex; flex-direction: column; gap: 9px; padding: 0 4px 6px; }
.capacity-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 64px;
  gap: 8px;
  align-items: center;
  font-size: 10.5px;
}
.capacity-name { color: var(--muted); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; }
.capacity-bar { height: 5px; border-radius: 999px; background: rgba(148, 163, 184, 0.09); overflow: hidden; }
.capacity-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--blue)); }
.capacity-value { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.ranking { display: flex; flex-direction: column; gap: 11px; padding: 4px 0 6px; }
.rank-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 64px; gap: 5px 10px; align-items: center; }
.rank-name {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  color: #c7d8ee;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rank-status { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 6px rgba(52, 211, 153, 0.55); flex: 0 0 auto; }
.rank-value { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rank-bar { grid-column: 1 / -1; height: 4px; border-radius: 999px; background: rgba(148, 163, 184, 0.08); overflow: hidden; }
.rank-bar span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), rgba(94, 234, 212, 0.25)); }

.topo-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 16px; }
.topo-side {
  border-left: 1px solid rgba(148, 163, 184, 0.1);
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.topo-card { display: flex; flex-direction: column; gap: 7px; }
.topo-card h4 { margin: 0 0 4px; font-size: 13px; }
.topo-kv { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; color: var(--muted); }
.topo-kv strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.rollout-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 18px; align-items: start; }
.rollout-list { display: flex; flex-direction: column; max-height: 250px; overflow: auto; }
.rollout-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px 58px;
  gap: 10px;
  align-items: center;
  padding: 8px 6px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.06);
  font-size: 11px;
}
.rollout-row .mono { font-size: 10.5px; }
.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; }
.status-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-acked { color: var(--ok); }
.status-failed { color: var(--danger); }
.status-pending { color: var(--warn); }
.status-offline { color: var(--muted); }

.panel-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.event-search {
  width: 170px;
  margin: 0;
  padding: 6px 10px;
  font-size: 11px;
  border-radius: 8px;
  background: rgba(7, 11, 18, 0.55);
}
.event-filters { display: flex; gap: 4px; }
.event-filters button {
  padding: 5px 9px;
  font-size: 9.5px;
  letter-spacing: 0.06em;
  border: 1px solid var(--stroke);
  background: transparent;
  color: var(--muted);
  border-radius: 7px;
}
.event-filters button.active {
  color: var(--accent);
  border-color: rgba(94, 234, 212, 0.3);
  background: rgba(45, 212, 191, 0.08);
}

.drawer { position: fixed; inset: 0; z-index: 45; }
.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 14, 0.55);
  backdrop-filter: blur(4px);
}
.drawer-card {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(480px, 100%);
  padding: 22px;
  overflow: auto;
  background: linear-gradient(180deg, #101a2b, #0a121f);
  border-left: 1px solid var(--stroke);
  box-shadow: -30px 0 80px rgba(0, 0, 0, 0.5);
  animation: slidein 0.24s ease both;
}
@keyframes slidein {
  from { transform: translateX(24px); opacity: 0.5; }
  to { transform: none; opacity: 1; }
}
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.drawer-head h3 { margin: 0; font-size: 17px; letter-spacing: -0.01em; }
.drawer-section { margin-top: 18px; }
.drawer-section h4 {
  margin: 0 0 10px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.drawer-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.drawer-kpi { border: 1px solid var(--stroke); border-radius: 10px; padding: 10px 12px; background: rgba(7, 11, 18, 0.4); }
.drawer-kpi span { display: block; font-size: 10px; color: var(--muted); margin-bottom: 4px; }
.drawer-kpi strong { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.drawer-chart { height: 180px; }

.agent-health { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.agent-health .warn, .agent-health.warn { color: var(--warn); }

.quota-cell { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.quota-bar {
  flex: 1 1 auto;
  height: 5px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.09);
  overflow: hidden;
}
.quota-bar span { display: block; height: 100%; border-radius: 999px; }
.quota-text { font-size: 10px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.mini-bar { height: 3px; margin-top: 5px; border-radius: 999px; background: rgba(148, 163, 184, 0.08); overflow: hidden; }
.mini-bar span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), rgba(94, 234, 212, 0.25)); }

.uplot { font-family: var(--sans); }
.uplot .u-legend { display: none; }
.uplot .u-axis { color: var(--muted); font-size: 10px; }
.uplot .u-cursor-pt { background: var(--accent) !important; }

@media (max-width: 1400px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .viz-grid > .span-7,
  .viz-grid > .span-6 { grid-column: span 12; }
  .viz-grid > .span-3,
  .viz-grid > .span-4,
  .viz-grid > .span-5 { grid-column: span 6; }
  .topo-layout { grid-template-columns: minmax(0, 1fr); }
  .topo-side { border-left: 0; border-top: 1px solid rgba(148, 163, 184, 0.1); padding: 14px 0 0; }
  .chart-topo { height: 440px; }
}
@media (max-width: 860px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .viz-grid > .panel { grid-column: span 12; }
  .rollout-layout { grid-template-columns: minmax(0, 1fr); }
  .chart-lg { height: 230px; }
  .chart-map { height: 260px; }
  .chart-topo { height: 380px; }
  .overview-toolbar { align-items: flex-start; }
}
@media (max-width: 560px) {
  .kpi { padding: 12px; }
  .kpi-value { font-size: 22px; }
  .spark { width: 66px; }
  .chart-lg { height: 200px; }
  .chart-md { height: 210px; }
  .chart-donut { height: 190px; }
  .drawer-card { width: 100%; }
  .overview-actions { width: 100%; justify-content: flex-end; }
}

/* Dense command-center layout for 1440x900-class screens. */
@media (min-width: 1180px) and (max-height: 960px) {
  .app { padding: 12px 16px; gap: 14px; }
  .topbar { padding-bottom: 10px; }
  .title-block h2 { font-size: 21px; }
  #page-subtitle { margin-top: 3px; }
  .overview-toolbar { margin-bottom: 10px; }
  .kpi-grid { gap: 10px; }
  .kpi { padding: 11px 13px 9px; }
  .kpi-value { font-size: 24px; margin: 5px 0 0; }
  .kpi-bottom { min-height: 26px; }
  .spark { height: 26px; }
  .viz-grid { gap: 12px; }
  .panel.viz { padding: 13px 14px 8px; }
  .panel-head { margin-bottom: 10px; }
  .panel-head h3 { font-size: 13.5px; }
  .panel-sub { margin-top: 3px; font-size: 10px; }
  .chart-lg { height: 188px; }
  .chart-map { height: 196px; }
  .chart-md { height: 176px; }
  .chart-donut { height: 172px; }
  .chart-gauge { height: 108px; }
  .event-list { max-height: 168px; }
}

.ov-event-tools { gap: 6px; justify-content: flex-end; }
.ov-event-tools .ghost { padding: 5px 8px; font-size: 9.5px; min-height: 0; }

.alert-chip {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 9px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  color: #fcd34d;
  border: 1px solid rgba(251, 191, 36, .3);
  background: rgba(251, 191, 36, .08);
  white-space: nowrap;
}
.alert-chip.bad { color: #fda4af; border-color: rgba(251, 113, 133, .35); background: rgba(244, 63, 94, .08); }

@media (min-width: 1180px) and (max-height: 960px) {
  /* Reflow the seven overview panels into two rows so the whole command
     surface fits a 1440x900 screen without scrolling. */
  .viz-grid > .panel:nth-child(1) { grid-column: span 5; }
  .viz-grid > .panel:nth-child(2) { grid-column: span 3; }
  .viz-grid > .panel:nth-child(3) { grid-column: span 4; }
  .viz-grid > .panel:nth-child(4) { grid-column: span 2; }
  .viz-grid > .panel:nth-child(5) { grid-column: span 3; }
  .viz-grid > .panel:nth-child(6) { grid-column: span 4; }
  .viz-grid > .panel:nth-child(7) { grid-column: span 3; }
  .viz-grid > .panel:nth-child(3) .chart-map { height: 186px; }
  .viz-grid > .panel:nth-child(4) .rank-spark { display: none; }
}

.badge.warn {
  color: #fcd34d;
  background: rgba(251, 191, 36, .08);
  border-color: rgba(251, 191, 36, .24);
}
.badge.warn::before { background: var(--warn); }
