:root {
  --bg0: #0c1218;
  --bg1: #121b24;
  --bg2: #182431;
  --panel: rgba(22, 34, 46, 0.88);
  --line: rgba(140, 175, 210, 0.14);
  --text: #e8eef5;
  --muted: #8fa3b8;
  --accent: #2f8fff;
  --accent-2: #19c3a8;
  --hot: #ff4d3a;
  --warm: #ff9f1c;
  --cool: #3dd6c6;
  --danger: #ff5c6c;
  --ok: #3ecf8e;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --font: "Manrope", "Segoe UI", sans-serif;
  --display: "Sora", "Manrope", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 10% -10%, rgba(47, 143, 255, 0.18), transparent 55%),
    radial-gradient(900px 600px at 100% 0%, rgba(25, 195, 168, 0.12), transparent 50%),
    linear-gradient(160deg, var(--bg0), var(--bg1) 45%, #0e1620);
}

body { min-height: 100vh; }

a { color: var(--accent); text-decoration: none; }
button, input { font: inherit; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 36px 32px 28px;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  animation: rise 0.55s ease both;
}

.brand {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: 1.55rem;
  margin: 0 0 6px;
}
.login-card .brand { margin-bottom: 28px; }

.brand span { color: var(--accent); }

.sub {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.field { display: grid; gap: 8px; margin-bottom: 16px; }
.field label {
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.field input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(8, 14, 20, 0.65);
  color: var(--text);
  border-radius: 12px;
  padding: 13px 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus {
  border-color: rgba(47, 143, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(47, 143, 255, 0.15);
}

.btn {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.15s ease, opacity 0.15s, background 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #1a6fd4);
  color: #fff;
  margin-top: 8px;
}
.btn-primary:hover { filter: brightness(1.06); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.btn-ghost:hover { color: var(--text); border-color: rgba(140, 175, 210, 0.35); }

.btn-soft {
  background: rgba(47, 143, 255, 0.12);
  color: #cfe3ff;
  border: 1px solid rgba(47, 143, 255, 0.25);
}
.btn-soft.active {
  background: rgba(47, 143, 255, 0.28);
  color: #fff;
  border-color: rgba(47, 143, 255, 0.5);
}

.error {
  margin-top: 14px;
  color: var(--danger);
  font-size: 0.9rem;
  min-height: 1.2em;
}

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.side {
  border-right: 1px solid var(--line);
  background: rgba(10, 16, 22, 0.72);
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.side .brand { font-size: 1.25rem; margin-bottom: 18px; padding: 0 8px; }
.nav-btn {
  text-align: left;
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 600;
}
.nav-btn:hover, .nav-btn.active {
  background: rgba(47, 143, 255, 0.12);
  color: var(--text);
}

.side-foot {
  margin-top: auto;
  padding: 12px 8px 0;
  display: grid;
  gap: 10px;
}
.user-chip {
  font-size: 0.85rem;
  color: var(--muted);
}

.main {
  padding: 28px 32px 48px;
  animation: rise 0.45s ease both;
}

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

h1 {
  font-family: var(--display);
  font-size: 1.7rem;
  letter-spacing: -0.03em;
  margin: 0 0 4px;
}
.lead { margin: 0; color: var(--muted); font-size: 0.95rem; }

.topbar-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
}

.day-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: rgba(8, 14, 20, 0.45);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}
.day-picker input[type="date"] {
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  outline: none;
  min-width: 9.5rem;
  color-scheme: dark;
}
.day-picker.is-active {
  border-color: rgba(47, 143, 255, 0.5);
  background: rgba(47, 143, 255, 0.16);
  color: #fff;
}

.range-switch {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  background: rgba(8, 14, 20, 0.45);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
}
.card .label {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 8px;
}
.card .value {
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.card .hint {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.panel-h h2 {
  margin: 0;
  font-size: 1.05rem;
  font-family: var(--display);
  letter-spacing: -0.02em;
}
.panel-b { padding: 16px 18px 20px; }

.heatmap-wrap {
  position: relative;
  width: 100%;
  overflow: auto;
  border-radius: 12px;
  background: #061018;
  max-height: min(72vh, 820px);
}
.heatmap-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
}

.legend {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--muted);
}
.legend-bar {
  width: 120px;
  height: 8px;
  border-radius: 99px;
  background: linear-gradient(90deg, rgba(61, 214, 198, 0.15), var(--cool), var(--warm), var(--hot));
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.table th, .table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}
.table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.table tr:hover td { background: rgba(47, 143, 255, 0.05); }
.bar {
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  min-width: 60px;
}
.bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  border-radius: inherit;
}

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.hidden { display: none !important; }

.tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 5;
  background: rgba(8, 14, 20, 0.92);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.82rem;
  max-width: 240px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s;
}
.tooltip.show { opacity: 1; transform: none; }

.settings-form { max-width: 420px; display: grid; gap: 12px; }
.msg { font-size: 0.9rem; color: var(--ok); min-height: 1.2em; }
.msg.err { color: var(--danger); }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 1200px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: relative;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .side .brand { width: 100%; margin-bottom: 4px; }
  .side-foot { margin-top: 0; width: 100%; grid-template-columns: 1fr auto; align-items: center; }
  .main { padding: 20px 16px 40px; }
}
