*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

:root {
  --primary: #2e5cff;
  --accent:  #00c6a2;
  --danger:  #e53e5c;
  --warn:    #ff7a45;
  --ink:     #10203a;
  --muted:   #7a8aa6;
  --surface: #f6f8fc;
  --card:    #ffffff;
  --border:  rgba(16, 32, 58, 0.06);
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

/* ---------- login ---------- */

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 10% 10%, rgba(46, 92, 255, 0.10), transparent 60%),
    radial-gradient(1200px 500px at 90% 90%, rgba(0, 198, 162, 0.10), transparent 60%),
    var(--surface);
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 32px;
  background: var(--card);
  border-radius: 24px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(16, 32, 58, 0.10);
}

.login-badge { margin-bottom: 18px; }
.login-card h1 { margin: 0; font-size: 24px; }
.login-sub { color: var(--muted); font-size: 14px; margin: 6px 0 22px; }

.tabs {
  display: flex;
  padding: 4px;
  background: #eef1f7;
  border-radius: 14px;
  margin-bottom: 22px;
}
.tab {
  flex: 1;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  font-size: 13px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tab.active {
  background: white;
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(16, 32, 58, 0.06);
}

.link-btn {
  display: block;
  margin: 6px auto 0;
  background: transparent;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 6px 10px;
  text-align: center;
}
.link-btn:hover { color: var(--primary); }

.login-card label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 14px;
}

.login-card input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border: 1px solid #dde3ee;
  border-radius: 12px;
  font: inherit;
  color: var(--ink);
  background: #fafbff;
  transition: border-color 0.15s, background 0.15s;
}
.login-card input:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
}

.login-card button {
  width: 100%;
  padding: 13px 18px;
  border: 0;
  border-radius: 14px;
  background: var(--primary);
  color: white;
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.05s, opacity 0.15s;
}
.login-card button:hover  { opacity: 0.94; }
.login-card button:active { transform: translateY(1px); }
.login-card button:disabled { opacity: 0.6; cursor: default; }

.login-error {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(229, 62, 92, 0.10);
  color: var(--danger);
  font-size: 13px;
}

/* ---------- app shell ---------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 28px;
  background: linear-gradient(120deg, #ffffff 0%, #eaf0ff 100%);
  border-bottom: 1px solid var(--border);
}

.topbar-right { display: flex; align-items: center; gap: 16px; }

.brand { display: flex; align-items: center; gap: 14px; }
.brand-badge {
  width: 44px; height: 44px;
  border-radius: 14px;
  background: transparent;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.brand-badge img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.login-badge {
  width: 72px;
  height: 72px;
  border-radius: 22px;
}
.brand-name { font-weight: 800; font-size: 18px; }
.brand-sub  { font-size: 13px; color: var(--muted); }

.status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.status .dot { width: 10px; height: 10px; border-radius: 50%; background: #cfd6e4; }
.status.online .dot { background: var(--accent); box-shadow: 0 0 0 4px rgba(0,198,162,0.18); }

.ghost-btn {
  padding: 8px 14px;
  border: 1px solid #dde3ee;
  border-radius: 10px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.ghost-btn:hover { background: #f6f8fc; }

.user-menu { position: relative; }
.avatar-btn {
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 0;
  background: rgba(46, 92, 255, 0.12);
  color: var(--primary);
  font: inherit;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.05s, background 0.15s;
}
.avatar-btn:hover  { background: rgba(46, 92, 255, 0.18); }
.avatar-btn:active { transform: translateY(1px); }

.user-drop {
  position: absolute;
  right: 0;
  top: 52px;
  min-width: 240px;
  background: white;
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(16, 32, 58, 0.14);
  overflow: hidden;
  z-index: 20;
}
.user-drop-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.user-name  { font-weight: 700; color: var(--ink); font-size: 14px; }
.user-email { font-size: 12px; color: var(--muted); margin-top: 2px; }

.user-drop-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border: 0;
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.user-drop-item:hover { background: #f6f8fc; }
.drop-ico {
  display: inline-flex;
  width: 22px; height: 22px;
  align-items: center; justify-content: center;
  border-radius: 8px;
  background: rgba(229, 62, 92, 0.10);
  color: var(--danger);
  font-weight: 800;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.alerts {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 16px 20px;
  border-radius: 18px;
  background: rgba(229, 62, 92, 0.08);
  border: 1px solid rgba(229, 62, 92, 0.28);
  margin-bottom: 18px;
}
.alerts strong { color: var(--danger); }
.alerts p { margin: 0; color: var(--muted); font-size: 14px; }
.warn {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: var(--danger);
  color: white;
  display: grid; place-items: center;
  font-weight: 800;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.card {
  background: var(--card);
  border-radius: 22px;
  padding: 22px;
  border: 1px solid var(--border);
  box-shadow: 0 6px 24px rgba(16, 32, 58, 0.04);
}

.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.chip {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.chip-danger  { background: rgba(229, 62, 92, 0.12);  color: var(--danger); }
.chip-primary { background: rgba(46, 92, 255, 0.12);  color: var(--primary); }
.chip-warn    { background: rgba(255, 122, 69, 0.14); color: var(--warn); }
.chip-accent  { background: rgba(0, 198, 162, 0.14);  color: var(--accent); }

.value {
  font-size: 34px;
  font-weight: 800;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.value em {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  font-style: normal;
}

.hint  { font-size: 13px; color: var(--muted); margin-top: 8px; }
.ts    { font-size: 12px; color: var(--muted); }

.mode-value { font-size: 22px; }
.mode-pill-row { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.mode-pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef1f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.mode-pill.active {
  background: var(--primary);
  color: white;
}

/* ---------- charts (fixed height stops the resize loop) ---------- */

.chart-card { margin-bottom: 18px; }
.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}
.chart-head h3 { margin: 0; font-size: 16px; }
.chart-sub     { font-size: 12px; color: var(--muted); }

.chart-wrap {
  position: relative;
  width: 100%;
  height: 240px;
}
.chart-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.foot {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 20px 0 32px;
}

.alert-value { color: var(--danger); }

@media (max-width: 640px) {
  .topbar { padding: 16px 18px; }
  .wrap   { padding: 20px 16px 40px; }
  .value  { font-size: 28px; }
  .chart-wrap { height: 200px; }
}
