:root {
  --bg: #08121f;
  --bg-alt: #0f1f31;
  --panel: #11253c;
  --panel-border: #1f3c5a;
  --text: #d9ecff;
  --muted: #89a7c4;
  --accent: #40e4b9;
  --warn: #ff8f66;
  --danger: #ff6f6f;
  --shadow: 0 14px 30px rgba(1, 9, 16, 0.45);
  --radius: 14px;
  --radius-sm: 10px;
  --surface: rgba(16, 38, 58, 0.9);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", "Trebuchet MS", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 12%, rgba(26, 65, 103, 0.95) 0%, transparent 40%),
    radial-gradient(circle at 88% 0%, rgba(30, 76, 58, 0.8) 0%, transparent 38%),
    linear-gradient(135deg, var(--bg), #06101c 54%, #0c1829);
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(180, 220, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(180, 220, 255, 0.055) 1px, transparent 1px);
  background-size: 30px 30px;
  mask-image: radial-gradient(circle at 55% 20%, black 45%, transparent 100%);
}

.page-graphs .bg-grid {
  display: none;
}

.layout {
  max-width: 1500px;
  margin: 0 auto;
  padding: 20px;
  position: relative;
  z-index: 1;
}

.panel {
  position: relative;
  overflow: hidden;
  background: linear-gradient(170deg, rgba(20, 42, 65, 0.95), rgba(10, 27, 43, 0.93));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: none;
  padding: 16px;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(130deg, rgba(148, 207, 255, 0.08), transparent 30% 70%, rgba(64, 228, 185, 0.07));
  pointer-events: none;
}

.panel > * {
  position: relative;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: 11px;
  font-weight: 700;
}

h1 {
  margin: 6px 0 0;
  font-size: clamp(24px, 2.2vw, 31px);
  letter-spacing: 0.01em;
}

h2 {
  margin: 0;
  font-size: 18px;
  color: #bddfff;
  letter-spacing: 0.01em;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.city-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.city-switch-label {
  display: inline-block;
  min-width: 280px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(173, 216, 255, 0.22);
  background: rgba(10, 27, 44, 0.68);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.btn-nav {
  min-width: 88px;
  padding: 8px 10px;
}

.notice-line {
  min-height: 20px;
  margin: 2px 0 12px;
  color: var(--warn);
  font-size: 13px;
}

.btn {
  border: 1px solid #3f6588;
  background: linear-gradient(180deg, #2b516f, #1f3d57);
  color: #ebf8ff;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
  box-shadow: 0 6px 14px rgba(5, 18, 30, 0.35);
}

.btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(5, 18, 30, 0.45);
}

.btn:active {
  transform: translateY(0);
}

.btn-sync-spinning {
  pointer-events: none;
}

.btn-sync-spinning::after {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 8px;
  border-radius: 999px;
  border: 2px solid rgba(223, 242, 255, 0.55);
  border-top-color: #ffffff;
  vertical-align: -2px;
  animation: sync-spin 800ms linear infinite;
}

@keyframes sync-spin {
  to {
    transform: rotate(360deg);
  }
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  filter: none;
  box-shadow: none;
}

.btn:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(64, 228, 185, 0.6);
  outline-offset: 2px;
}

.btn-warn {
  border-color: #9e5d45;
  background: linear-gradient(180deg, #7c4433, #603024);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.status-card {
  min-height: 136px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(160, 206, 255, 0.18);
}

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.action-strip {
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: linear-gradient(180deg, rgba(15, 36, 56, 0.94), rgba(10, 28, 44, 0.95));
}

.ops-password-input {
  min-width: 240px;
  max-width: 320px;
}

.ops-command-box {
  width: 100%;
  min-height: 94px;
  margin: 8px 0 10px;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  padding: 8px 9px;
  border: 1px solid rgba(177, 219, 255, 0.13);
  border-radius: 9px;
  background: rgba(11, 29, 45, 0.48);
}

.kv span {
  color: var(--muted);
}

.kv strong {
  text-align: right;
  max-width: 64%;
  word-break: break-word;
}

.kv.long strong {
  max-width: 78%;
}

.recommendation-card .kv strong {
  font-size: 14px;
}

input,
select {
  width: 100%;
  border: 1px solid #426683;
  border-radius: 8px;
  background: #0c1e31;
  color: var(--text);
  padding: 8px 9px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:hover,
select:hover {
  border-color: #5e87aa;
}

.data-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 12px;
}

.status-only-grid {
  grid-template-columns: 1fr 1fr;
}

.city-overview-card {
  border-color: #2f6d95;
  padding: 18px;
}

.city-overview-card .city-head,
.city-overview-card .row4 {
  gap: 12px;
}

.city-overview-card strong {
  font-size: 17px;
  letter-spacing: 0.01em;
}

.city-head {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.row4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.muted {
  color: var(--muted);
  font-size: 12px;
  display: block;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  border: 1px solid rgba(173, 216, 255, 0.14);
  border-radius: 10px;
  overflow: hidden;
}

th,
td {
  padding: 9px 8px;
  border-bottom: 1px solid rgba(180, 220, 255, 0.12);
}

th {
  text-align: left;
  color: #a8d5ff;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(18, 43, 67, 0.85);
}

td {
  color: #e8f5ff;
  vertical-align: top;
  background: rgba(8, 24, 38, 0.35);
}

tbody tr:hover td {
  background: rgba(20, 47, 72, 0.48);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.json-box {
  background: #091829;
  border: 1px solid #1b3c58;
  border-radius: 10px;
  padding: 12px;
  max-height: 300px;
  overflow: auto;
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  font-family: "Consolas", "Courier New", monospace;
}

.news-list,
.errors-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.news-list li,
.errors-list li {
  padding: 10px;
  border: 1px solid rgba(145, 198, 255, 0.24);
  border-radius: 10px;
  background: rgba(12, 31, 47, 0.78);
}

.full-row {
  grid-column: 1 / -1;
}

.compact-row {
  margin: 0;
}

.graph-controls {
  margin-bottom: 12px;
}

.chart-panel {
  margin-top: 12px;
}

.chart-svg {
  width: 100%;
  height: 340px;
  display: block;
  border: 1px solid rgba(153, 203, 255, 0.34);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(11, 29, 45, 0.95), rgba(7, 18, 31, 0.98));
  box-shadow: inset 0 1px 0 rgba(164, 214, 255, 0.1);
}

.chart-legend {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.individual-charts {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.metric-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.metric-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: #d5ecff;
  padding: 6px 9px;
  border-radius: 8px;
  border: 1px solid rgba(165, 212, 255, 0.2);
  background: rgba(10, 27, 44, 0.65);
}

.metric-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--accent);
}

.metric-toggle-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.metric-chart-card {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(153, 203, 255, 0.2);
  background: linear-gradient(180deg, rgba(9, 24, 38, 0.92), rgba(7, 18, 31, 0.95));
  content-visibility: auto;
  contain-intrinsic-size: 280px;
}

.metric-chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.metric-chart-controls {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.metric-range-select {
  width: auto;
  min-width: 132px;
}

.metric-chart-head h3 {
  margin: 0;
  font-size: 14px;
  color: #cbe5ff;
}

.metric-chart-head strong {
  font-size: 14px;
  color: #dff3ff;
}

.metric-chart-svg {
  width: 100%;
  height: 190px;
  display: block;
  border: 1px solid rgba(153, 203, 255, 0.2);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(11, 29, 45, 0.72), rgba(7, 18, 31, 0.88));
}

.metric-chart-slot {
  min-height: 190px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 7px 9px;
  border-radius: 8px;
  background: rgba(10, 27, 44, 0.72);
  border: 1px solid rgba(165, 212, 255, 0.14);
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
}

.bad {
  color: var(--danger);
}

.warn {
  color: var(--warn);
}

.good {
  color: var(--accent);
}

@media (max-width: 1180px) {
  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .data-grid {
    grid-template-columns: 1fr;
  }

  .city-head,
  .row4,
  .chart-legend {
    grid-template-columns: 1fr;
  }

  .individual-charts {
    grid-template-columns: 1fr;
  }

  .metric-controls {
    width: 100%;
  }

  .status-only-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .topbar,
  .action-strip,
  .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .actions {
    width: 100%;
  }

  .inline-field {
    width: 100%;
  }

  .city-switch {
    width: 100%;
  }

  .city-switch-label {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 760px) {
  .status-grid {
    grid-template-columns: 1fr;
  }

  .btn {
    flex: 1;
    text-align: center;
  }

  h1 {
    font-size: 22px;
  }
}
