:root {
  --bg: #0a0e17;
  --surface: #111827;
  --surface2: #1a2234;
  --border: #2a3548;
  --text: #e8edf5;
  --muted: #8896ab;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --ring: #10b981;
  --no-ring: #f97316;
}

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

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

.hidden { display: none !important; }

/* Auth pages */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: radial-gradient(ellipse at top, #1a2744 0%, var(--bg) 60%);
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.logo {
  text-align: center;
  margin-bottom: 2rem;
}

.logo h1 {
  font-size: 1.75rem;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo p { color: var(--muted); font-size: 0.9rem; margin-top: 0.25rem; }

.form-group { margin-bottom: 1.25rem; }

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

input, textarea, select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

textarea { min-height: 160px; resize: vertical; font-family: monospace; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: white;
  width: 100%;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { border-color: var(--accent); }

.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

.auth-switch {
  text-align: center;
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-switch a { color: var(--accent); cursor: pointer; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-error { background: rgba(239,68,68,0.15); border: 1px solid var(--danger); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,0.15); border: 1px solid var(--success); color: #86efac; }
.alert-info { background: rgba(59,130,246,0.15); border: 1px solid var(--accent); color: #93c5fd; }

/* Dashboard layout */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .logo { text-align: left; margin-bottom: 2rem; }
.sidebar .logo h1 { font-size: 1.25rem; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: 0.25rem;
  transition: all 0.2s;
  font-size: 0.95rem;
}

.nav-item:hover, .nav-item.active {
  background: var(--surface2);
  color: var(--text);
}

.nav-item.active { border-left: 3px solid var(--accent); }

.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 2rem;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.top-bar h2 { font-size: 1.5rem; }

.balance-badge {
  background: linear-gradient(135deg, #1e3a5f, #1a2744);
  border: 1px solid var(--border);
  padding: 0.5rem 1.25rem;
  border-radius: 20px;
  font-weight: 600;
}

.balance-badge span { color: var(--success); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card h3 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: var(--text);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }

.stat-card {
  background: var(--surface2);
  border-radius: 10px;
  padding: 1.25rem;
  text-align: center;
}

.stat-card .value {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.stat-card .label { color: var(--muted); font-size: 0.85rem; }

.stat-card.ring .value { color: var(--ring); }
.stat-card.no-ring .value { color: var(--no-ring); }
.stat-card.total .value { color: var(--accent); }

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.tab {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
}

.tab.active { background: var(--surface2); color: var(--text); }

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
  margin-bottom: 1rem;
}

.upload-zone:hover { border-color: var(--accent); }
.upload-zone p { color: var(--muted); margin-top: 0.5rem; font-size: 0.9rem; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th { color: var(--muted); font-weight: 500; font-size: 0.8rem; text-transform: uppercase; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-ringing { background: rgba(16,185,129,0.2); color: var(--ring); }
.badge-no-ring { background: rgba(249,115,22,0.2); color: var(--no-ring); }
.badge-failed { background: rgba(239,68,68,0.2); color: var(--danger); }
.badge-pending { background: rgba(136,150,171,0.2); color: var(--muted); }
.badge-running { background: rgba(59,130,246,0.2); color: var(--accent); }
.badge-completed { background: rgba(34,197,94,0.2); color: var(--success); }

.progress-bar {
  height: 8px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
  margin: 0.5rem 0;
}

.progress-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #8b5cf6);
  border-radius: 4px;
  transition: width 0.3s;
}

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }

.logout-btn {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-card h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

@media (max-width: 900px) {
  .sidebar { width: 100%; height: auto; position: relative; }
  .main-content { margin-left: 0; }
  .grid-2, .grid-4 { grid-template-columns: 1fr; }
  .app-layout { flex-direction: column; }
}
