:root {
  color-scheme: dark;
  --bg: #0b1120;
  --panel: #111a2c;
  --border: #23314a;
  --text: #e7edf7;
  --muted: #8d9bb5;
  --blue: #4f8cff;
  --green: #28c997;
  --red: #f05c72;
  --yellow: #f4b942;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, sans-serif;
}

.hidden { display: none !important; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(circle at top, #192b4b, var(--bg) 60%);
}

.login-card {
  width: 100%;
  max-width: 390px;
  padding: 36px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 25px 70px #0005;
}

.login-card h1 { margin: 18px 0 5px; }
.login-card .muted { margin: 0 0 28px; }

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--blue);
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 800;
  color: white;
}

label {
  display: block;
  margin: 16px 0 8px;
  color: var(--muted);
  font-size: 13px;
}

input {
  width: 100%;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #0b1323;
  color: white;
  outline: none;
}

input:focus { border-color: var(--blue); }

button {
  border: 0;
  border-radius: 9px;
  padding: 12px 18px;
  background: var(--blue);
  color: white;
  font-weight: 600;
  cursor: pointer;
}

#login-form button { width: 100%; margin-top: 24px; }

button:disabled { opacity: .6; cursor: wait; }

.error { color: var(--red); font-size: 13px; }

header {
  min-height: 80px;
  padding: 18px 5%;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: #0e1728;
}

.brand, .header-actions, .metric-heading {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand h2 { margin: 0; font-size: 17px; }
.brand span { font-size: 12px; color: var(--muted); }

.header-actions { flex-wrap: wrap; }
.secondary { background: #1b2940; border: 1px solid var(--border); }

.live {
  color: var(--green);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.live i {
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--green);
}

main { max-width: 1450px; margin: auto; padding: 30px 5%; }

.welcome, .panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.welcome h1 { margin: 0 0 8px; font-size: 26px; }
.muted, .panel-header p { color: var(--muted); font-size: 13px; }

.server-info {
  padding: 13px 18px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 10px;
}

.server-info span, .server-info strong { display: block; }
.server-info span { color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.server-info strong { font-size: 12px; }

.status-banner {
  margin: 25px 0;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--muted);
  font-size: 13px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.metric-card, .panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.metric-card { padding: 22px; }
.metric-heading { justify-content: space-between; font-size: 13px; color: var(--muted); }

.metric-icon {
  background: #1b2b48;
  color: #8fb5ff;
  padding: 7px;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 700;
}

.metric-value {
  margin: 24px 0 18px;
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -1px;
}

.metric-value small { font-size: 16px; color: var(--muted); margin-left: 5px; }

.metric-bar {
  height: 6px;
  background: #26334b;
  border-radius: 20px;
  overflow: hidden;
}

.metric-bar div {
  height: 100%;
  width: 0;
  background: var(--green);
  transition: width .4s;
}

.metric-card p { font-size: 12px; color: var(--muted); margin: 13px 0 0; }

.panel { margin-top: 25px; padding: 24px; }
.panel-header h2 { margin: 0; font-size: 18px; }
.panel-header p { margin: 7px 0 0; }
#last-updated { color: var(--muted); font-size: 12px; }

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

.chart-box {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 11px;
  min-width: 0;
}

.chart-box h3 { font-size: 13px; color: var(--muted); margin: 0 0 15px; }
canvas { width: 100%; height: 190px; display: block; }

.alarm-summary {
  padding: 8px 12px;
  background: #12352f;
  color: var(--green);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
}

.table-wrap { overflow-x: auto; margin-top: 22px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; }
th, td { padding: 15px 12px; border-bottom: 1px solid var(--border); }
td:last-child { color: var(--muted); max-width: 500px; }

.badge {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.badge.ok { background: #12352f; color: var(--green); }
.badge.alarm { background: #421d2a; color: var(--red); }
.badge.other { background: #3a3020; color: var(--yellow); }

footer {
  margin: 30px 0 10px;
  padding: 20px 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

@media (max-width: 1050px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 650px) {
  header { align-items: flex-start; flex-direction: column; }
  main { padding: 22px 4%; }
  .metrics-grid, .charts-grid { grid-template-columns: 1fr; }
  .metric-value { font-size: 34px; }
  .panel { padding: 16px; }
  .login-card { padding: 25px; }
}
