:root {
  color-scheme: dark;
  --bg: #0b1020;
  --bg-soft: #111a2e;
  --panel: #151f35;
  --panel-strong: #1b2741;
  --border: #293653;
  --text: #e9eef8;
  --muted: #9aa9c5;
  --muted-strong: #c2cedf;
  --accent: #55a7ff;
  --accent-strong: #7cc0ff;
  --success: #39c98e;
  --warning: #f4b942;
  --high: #ff7a59;
  --critical: #f05252;
  --info: #5aa9e6;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
  --radius: 14px;
  --radius-small: 9px;
  --sidebar-width: 260px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.light {
  color-scheme: light;
  --bg: #eef2f7;
  --bg-soft: #e4eaf2;
  --panel: #ffffff;
  --panel-strong: #f5f8fc;
  --border: #d4dce8;
  --text: #172033;
  --muted: #61708a;
  --muted-strong: #33415c;
  --accent: #1677d2;
  --accent-strong: #0d5aa3;
  --shadow: 0 15px 35px rgba(39, 58, 88, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  font-size: 14px;
  line-height: 1.45;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-strong);
}

[hidden] {
  display: none !important;
}

.login-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(85, 167, 255, 0.18), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(57, 201, 142, 0.12), transparent 30rem),
    var(--bg);
}

.login-card {
  width: min(430px, 100%);
  padding: 36px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(21, 31, 53, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

body.light .login-card {
  background: rgba(255, 255, 255, 0.94);
}

.login-card h1 {
  margin: 18px 0 6px;
  font-size: 26px;
  letter-spacing: -0.03em;
}

.login-subtitle {
  margin: 0 0 28px;
  color: var(--muted);
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: linear-gradient(135deg, #1e9bff, #43d7b5);
  color: white;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.08em;
  box-shadow: 0 12px 24px rgba(30, 155, 255, 0.25);
}

.brand-mark.small {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  font-size: 21px;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 17px;
  color: var(--muted-strong);
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  padding: 10px 12px;
  color: var(--text);
  background: var(--bg-soft);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(85, 167, 255, 0.16);
}

.button,
.icon-button {
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  padding: 9px 13px;
  color: var(--text);
  background: var(--panel-strong);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.button:hover,
.icon-button:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.button.primary {
  border-color: transparent;
  background: linear-gradient(135deg, #1e88e5, #2fbf9a);
  color: white;
  font-weight: 700;
}

.button.secondary {
  background: transparent;
}

.button.danger {
  border-color: rgba(240, 82, 82, 0.5);
  color: var(--critical);
}

.button.small {
  padding: 5px 9px;
  font-size: 12px;
}

.button.full {
  width: 100%;
}

.form-error {
  margin: 8px 0 14px;
  padding: 10px 12px;
  border: 1px solid rgba(240, 82, 82, 0.45);
  border-radius: var(--radius-small);
  color: #ffb5b5;
  background: rgba(240, 82, 82, 0.12);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: rgba(17, 26, 46, 0.96);
  overflow-y: auto;
  z-index: 20;
}

body.light .sidebar {
  background: rgba(255, 255, 255, 0.96);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.sidebar-brand strong {
  font-size: 17px;
  letter-spacing: -0.02em;
}

.sidebar-brand span {
  color: var(--muted);
  font-size: 12px;
}

.navigation {
  display: grid;
  gap: 3px;
  padding: 14px 12px;
}

.navigation a {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--muted-strong);
  font-weight: 600;
}

.navigation a:hover,
.navigation a.active {
  color: var(--text);
  background: var(--panel-strong);
}

.navigation a.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.main-column {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 16, 32, 0.86);
  backdrop-filter: blur(14px);
}

body.light .topbar {
  background: rgba(238, 242, 247, 0.88);
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.03em;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.refresh-state {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.refresh-state::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 999px;
  background: var(--success);
}

.content {
  padding: 28px;
}

.mobile-only {
  display: none;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.cards {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card,
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset;
}

.card {
  padding: 18px;
}

.card .label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.card .value {
  margin-top: 8px;
  font-size: 27px;
  font-weight: 750;
  letter-spacing: -0.04em;
}

.card .hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.panel {
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2,
.panel-header h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.panel-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.panel-body {
  padding: 18px;
}

.panel-body.flush {
  padding: 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin-bottom: 18px;
}

.toolbar label {
  min-width: 150px;
  margin: 0;
}

.toolbar label.grow {
  flex: 1;
  min-width: 220px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody tr:hover {
  background: rgba(85, 167, 255, 0.04);
}

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

tr.clickable {
  cursor: pointer;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge.online,
.badge.success,
.badge.active {
  color: var(--success);
  background: rgba(57, 201, 142, 0.13);
}

.badge.offline,
.badge.critical,
.badge.failed {
  color: var(--critical);
  background: rgba(240, 82, 82, 0.13);
}

.badge.warning,
.badge.inactive {
  color: var(--warning);
  background: rgba(244, 185, 66, 0.14);
}

.badge.high {
  color: var(--high);
  background: rgba(255, 122, 89, 0.14);
}

.badge.info,
.badge.not-found {
  color: var(--info);
  background: rgba(90, 169, 230, 0.13);
}

.text-success {
  color: var(--success);
}

.text-warning {
  color: var(--warning);
}

.text-critical {
  color: var(--critical);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

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

.strong {
  font-weight: 750;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

.chart-box {
  position: relative;
  height: 270px;
  padding: 8px 6px 2px;
}

.chart-box.small {
  height: 210px;
}

canvas.chart {
  width: 100%;
  height: 100%;
  display: block;
}

.progress {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-soft);
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.progress.warning > span {
  background: var(--warning);
}

.progress.critical > span {
  background: var(--critical);
}

.score-ring {
  position: relative;
  width: 148px;
  height: 148px;
  display: grid;
  place-items: center;
  margin: auto;
  border-radius: 50%;
  background: conic-gradient(var(--success) calc(var(--score) * 1%), var(--bg-soft) 0);
}

.score-ring::before {
  content: "";
  position: absolute;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  background: var(--panel);
}

.score-ring span {
  position: relative;
  font-size: 30px;
  font-weight: 800;
}

.event-list {
  display: grid;
}

.event-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
}

.event-item:last-child {
  border-bottom: 0;
}

.event-item .message {
  font-weight: 650;
}

.event-item .meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.plain-list {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

.plain-list li + li {
  margin-top: 8px;
}

.empty-state {
  padding: 34px 20px;
  color: var(--muted);
  text-align: center;
}

.form-grid {
  display: grid;
  gap: 14px;
  max-width: 520px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.tabs button {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--muted-strong);
  background: transparent;
  cursor: pointer;
}

.tabs button.active {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(85, 167, 255, 0.11);
}

.split-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
}

@media (max-width: 1280px) {
  .grid.cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .split-view {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    width: min(310px, 86vw);
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
  }

  body.navigation-open .sidebar {
    transform: translateX(0);
  }

  .mobile-only {
    display: inline-flex;
  }

  .topbar {
    padding: 16px 18px;
  }

  .topbar-actions {
    margin-left: auto;
  }

  .refresh-state {
    display: none;
  }

  .content {
    padding: 18px;
  }

  .grid.cards,
  .grid.two,
  .grid.three {
    grid-template-columns: 1fr;
  }

  .toolbar label {
    min-width: 100%;
  }
}

@media (max-width: 560px) {
  .topbar h1 {
    font-size: 20px;
  }

  .button.secondary {
    padding: 7px 9px;
    font-size: 12px;
  }

  .event-item {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 9px 10px;
  }
}
