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

:root {
  --bg:        #1C1C1E;
  --surface:   #2C2C2E;
  --border:    #3A3A3C;
  --green:     #4A7C59;
  --green-dim: rgba(74,124,89,0.15);
  --blue:      #5B9BD5;
  --gold:      #E9A800;
  --text:      #FFFFFF;
  --muted:     #8E8E93;
  --danger:    #FF453A;
  --radius:    12px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
}

/* ── Login ───────────────────────────────────────────────────────────────── */

.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .wordmark {
  font-size: 22px;
  font-weight: 700;
  color: var(--green);
  letter-spacing: -0.5px;
}

.login-logo .subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

.login-card h1 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 24px;
  text-align: center;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}

.field input:focus { border-color: var(--green); }

.btn-primary {
  width: 100%;
  padding: 13px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity 0.15s;
}

.btn-primary:hover { opacity: 0.88; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.error-banner {
  background: rgba(255,69,58,0.12);
  border: 1px solid rgba(255,69,58,0.35);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--danger);
  margin-bottom: 16px;
  display: none;
}

.error-banner.visible { display: block; }

/* ── Dashboard layout ────────────────────────────────────────────────────── */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.header-brand .wordmark {
  font-size: 17px;
  font-weight: 700;
  color: var(--green);
}

.header-brand .divider {
  width: 1px;
  height: 18px;
  background: var(--border);
}

.header-brand .page-title {
  font-size: 15px;
  color: var(--muted);
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-logout:hover { border-color: var(--text); color: var(--text); }

.dashboard-body {
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

/* ── Toolbar ─────────────────────────────────────────────────────────────── */

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

.toolbar-title {
  font-size: 13px;
  color: var(--muted);
}

.time-selector {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
}

.time-btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.time-btn:hover { color: var(--text); }
.time-btn.active { background: var(--green); color: #fff; }

/* ── Summary cards ───────────────────────────────────────────────────────── */

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.card-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

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

/* ── Charts ──────────────────────────────────────────────────────────────── */

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
  gap: 16px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.chart-card h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.chart-card .chart-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px;
}

.chart-wrap {
  position: relative;
  height: 220px;
}

/* ── States ──────────────────────────────────────────────────────────────── */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28,28,30,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  display: none;
}

.loading-overlay.visible { display: flex; }

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-note {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: 40px 0;
}

@media (max-width: 600px) {
  .charts-grid { grid-template-columns: 1fr; }
  .dashboard-body { padding: 16px; }
}
