@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

:root {
  --bg: #0a0e27;
  --surface: #141a3d;
  --surface-raised: #1c2452;
  --border: #2b3368;
  --violet: #7c6cf2;
  --blue: #4c8df6;
  --gold: #e7b65c;
  --green: #4ecda0;
  --red: #f0667a;
  --text: #f4f5fb;
  --text-dim: #9aa1cc;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .num, .brand-name {
  font-family: 'Space Grotesk', sans-serif;
}

.app {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: #090c1f;
  border-right: 1px solid var(--border);
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand-mark { width: 30px; height: 30px; flex-shrink: 0; }
.brand-name { font-weight: 700; font-size: 16px; line-height: 1.15; }
.brand-tagline { font-size: 10.5px; color: var(--text-dim); margin-top: 1px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  color: var(--text-dim);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--surface); color: var(--text); }
.nav a.active { background: var(--surface-raised); color: var(--text); box-shadow: inset 2px 0 0 var(--violet); }
.nav svg { width: 17px; height: 17px; opacity: .85; flex-shrink: 0; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-dim);
}
.sidebar-footer button {
  background: none; border: none; color: var(--text-dim); font-size: 12.5px;
  cursor: pointer; padding: 0; margin-top: 6px; text-decoration: underline;
}
.sidebar-footer button:hover { color: var(--text); }

/* ---------- Main ---------- */
.main { flex: 1; padding: 30px 36px 60px; max-width: 1180px; }

.topbar { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 26px; flex-wrap: wrap; gap: 10px; }
.topbar h1 { font-size: 22px; margin: 0; font-weight: 600; }
.topbar .date { color: var(--text-dim); font-size: 13.5px; }

/* ---------- KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 26px; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  position: relative;
}
.kpi.hero {
  background: linear-gradient(155deg, var(--surface-raised) 0%, var(--surface) 65%);
  border-color: #3a3f86;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 22px 100%, 0 calc(100% - 22px));
}
.kpi .label { font-size: 12.5px; color: var(--text-dim); font-weight: 500; }
.kpi .num { font-size: 26px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.kpi.hero .num { font-size: 30px; background: linear-gradient(90deg, #fff, var(--gold) 120%); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.card-head h2 { font-size: 15.5px; margin: 0; font-weight: 600; }

.tabs { display: flex; gap: 4px; background: var(--bg); border-radius: 8px; padding: 3px; }
.tabs button {
  background: none; border: none; color: var(--text-dim); font-size: 12.5px; font-weight: 500;
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font-family: inherit;
}
.tabs button.active { background: var(--violet); color: #fff; }

.two-col { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 880px) { .two-col { grid-template-columns: 1fr; } .kpi-grid { grid-template-columns: repeat(2,1fr); } }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--text-dim); font-weight: 500; font-size: 12px; padding: 0 10px 8px; border-bottom: 1px solid var(--border); }
td { padding: 9px 10px; border-bottom: 1px solid #1c2452; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.site-dot { width: 7px; height: 7px; border-radius: 2px; display: inline-block; margin-right: 8px; background: var(--violet); }

/* ---------- Forms ---------- */
label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 5px; font-weight: 500; }
input, select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 7px; padding: 9px 11px; font-size: 13.5px; font-family: inherit; margin-bottom: 13px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--violet); outline-offset: 1px; border-color: var(--violet); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

button.primary {
  background: var(--violet); color: #fff; border: none; border-radius: 8px;
  padding: 10px 18px; font-size: 13.5px; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: background .15s;
}
button.primary:hover { background: #6c5ce7; }
button.ghost {
  background: none; border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 9px 16px; font-size: 13px; cursor: pointer; font-family: inherit;
}
button.ghost:hover { border-color: var(--violet); }
button.danger-link { background: none; border: none; color: var(--red); font-size: 12px; cursor: pointer; padding: 0; }

.empty { color: var(--text-dim); font-size: 13.5px; padding: 14px 0; text-align: center; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge.ok { background: rgba(78,205,160,.15); color: var(--green); }
.badge.off { background: rgba(240,102,122,.15); color: var(--red); }

/* ---------- Chart ---------- */
.chart-wrap { width: 100%; overflow-x: auto; }
svg.chart { width: 100%; height: 190px; }
.chart-bar { fill: var(--violet); }
.chart-bar:hover { fill: var(--blue); }
.chart-label { fill: var(--text-dim); font-size: 10px; font-family: 'IBM Plex Sans', sans-serif; }

/* ---------- Login ---------- */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 30% 20%, #1c2452 0%, var(--bg) 60%); }
.login-box { width: 330px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 32px 28px; }
.login-box .brand { justify-content: center; margin-bottom: 22px; }
.login-box h1 { font-size: 17px; text-align: center; margin: 0 0 20px; font-weight: 600; }
.login-error { background: rgba(240,102,122,.12); color: var(--red); font-size: 13px; padding: 9px 12px; border-radius: 7px; margin-bottom: 13px; display: none; }

.modal-overlay { position: fixed; inset: 0; background: rgba(5,7,20,.6); display: none; align-items: center; justify-content: center; z-index: 50; }
.modal-overlay.open { display: flex; }
.modal { width: 380px; max-width: 92vw; background: var(--surface-raised); border: 1px solid var(--border); border-radius: 12px; padding: 22px 24px; max-height: 86vh; overflow-y: auto; }
.modal h3 { margin: 0 0 16px; font-size: 15.5px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
