:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2d3a;
  --text: #e4e4e7;
  --text-muted: #8b8d98;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --warning: #f59e0b;
  --success: #22c55e;
  --green: #22c55e;
  --yellow: #f59e0b;
  --red: #ef4444;
}

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

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

.hidden { display: none !important; }
.error { color: var(--danger); font-size: 0.875rem; margin-top: 0.5rem; }

/* Auth Gate */
#auth-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.auth-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.auth-box h1 { font-size: 1.25rem; margin-bottom: 1.5rem; }

.auth-box input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.auth-box button {
  width: 100%;
  padding: 0.625rem;
  background: var(--primary);
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 0.875rem;
  cursor: pointer;
}
.auth-box button:hover { background: var(--primary-hover); }

/* Dashboard Layout */
#dashboard {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
header h1 { font-size: 1.25rem; }

section { margin-bottom: 2rem; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
h2 { font-size: 1rem; font-weight: 600; }

/* Buttons */
.btn, .btn-sm {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.75rem; }
.btn:hover, .btn-sm:hover { background: var(--border); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-warning { background: var(--warning); border-color: var(--warning); color: black; }

/* Summary Cards */
#summary-section {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}
.summary-label { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.summary-value { font-size: 1.5rem; font-weight: 700; }

/* Status Badge */
.status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.status-active { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.status-blocked { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.status-cutoff { background: rgba(239, 68, 68, 0.15); color: var(--red); }

/* Progress Bar */
.progress-bar-container {
  position: relative;
  height: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: visible;
}

.progress-bar {
  height: 100%;
  border-radius: 12px;
  transition: width 0.5s ease, background 0.5s ease;
  min-width: 2px;
}

.progress-markers {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
}

.progress-marker {
  position: absolute;
  top: -18px;
  font-size: 0.625rem;
  color: var(--text-muted);
  transform: translateX(-50%);
}
.progress-marker::after {
  content: '';
  position: absolute;
  top: 18px;
  left: 50%;
  width: 1px;
  height: 24px;
  background: var(--border);
}

/* Alert Banner */
.alert-banner {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-weight: 500;
  color: var(--red);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
th, td {
  padding: 0.625rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
}
th {
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
tr:last-child td { border-bottom: none; }

.actions { display: flex; gap: 0.5rem; }

/* Charts */
.chart-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  height: 300px;
}

.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.chart-half h2 { margin-bottom: 0.75rem; }

.date-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.date-controls input {
  padding: 0.375rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.75rem;
}
.date-controls span { color: var(--text-muted); font-size: 0.75rem; }

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
}
.modal-sm { max-width: 360px; }
.modal-lg { max-width: 640px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 1.25rem;
}
.modal-body label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
}
.modal-body input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.875rem;
}
.hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.375rem; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.warning-box {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid var(--warning);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  color: var(--warning);
  margin-bottom: 1rem;
}

pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  font-size: 0.8125rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Responsive */
@media (max-width: 768px) {
  #summary-section { grid-template-columns: repeat(2, 1fr); }
  .chart-row { grid-template-columns: 1fr; }
  .section-header { flex-wrap: wrap; gap: 0.5rem; }
  .date-controls { flex-wrap: wrap; }
}
