:root {
  --sidebar-bg: #0f1219;
  --sidebar-text: #e4e6eb;
  --main-bg: #f0f2f5;
  --card-bg: #fff;
  --text-primary: #1c1e21;
  --text-secondary: #65676b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #e74c3c;
  --success: #27ae60;
  --border: #e4e6eb;
  --warning: #f59e0b;
}

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

body {
  font-family: 'Geist Sans', -apple-system, sans-serif;
  background: var(--main-bg);
  color: var(--text-primary);
  min-height: 100vh;
}

code, pre, .token-box code, .webhook-url-box code {
  font-family: 'Geist Mono', 'Courier New', monospace;
}

/* ── Login Page ── */
.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0a0e17 0%, #1a2030 100%);
}

.login-card {
  background: var(--card-bg);
  padding: 2.5rem;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 400px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}

.login-logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: #fff;
}

.login-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.login-form input[type="text"],
.login-form input[type="password"],
.login-form input[type="email"] {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s;
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.remember-me {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.remember-me input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.login-form button {
  width: 100%;
  padding: 0.75rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.login-form button:hover {
  background: var(--accent-hover);
}

.login-footer {
  text-align: center;
  margin-top: 1.25rem;
}

.login-footer a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

.login-footer a:hover {
  text-decoration: underline;
}

.login-copyright {
  text-align: center;
  margin-top: 2rem;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.4);
}

.login-copyright a {
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-weight: 600;
}

.login-copyright a:hover {
  color: #fff;
}

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

.alert-error {
  background: #fde8e8;
  color: var(--danger);
}

.alert-success {
  background: #d4edda;
  color: #155724;
}

/* ── Layout ── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: 250px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 1.5rem;
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.sidebar-logo-icon {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.sidebar-status {
  padding: 0 1.5rem 1rem;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.status-badge {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #666;
}
.status-badge.online { background: var(--success); }
.status-badge.offline { background: var(--danger); }

.sidebar-nav {
  flex: 1;
  padding: 0.5rem 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1.5rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
}

.nav-item.active {
  background: rgba(59,130,246,0.15);
  color: var(--accent);
  font-weight: 500;
  border-right: 3px solid var(--accent);
}

.nav-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
}

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 0.5rem 1.5rem;
}

.nav-section-label {
  padding: 0.5rem 1.5rem 0.25rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.35);
  font-weight: 600;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.user-name {
  font-size: 0.85rem;
}

.user-role {
  font-size: 0.7rem;
}

.btn-logout {
  color: var(--sidebar-text);
  opacity: 0.7;
  text-decoration: none;
  font-size: 0.85rem;
}

.btn-logout:hover {
  opacity: 1;
}

/* ── Main Content ── */
.main-content {
  flex: 1;
  padding: 2rem;
  overflow-auto;
}

.main-content h1 {
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
  font-weight: 700;
}

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--card-bg);
  padding: 1.25rem;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid var(--border);
}

.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* ── Section Cards ── */
.section {
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid var(--border);
}

.section h3 {
  margin-bottom: 1rem;
  font-size: 1.05rem;
  font-weight: 600;
}

/* ── Tables ── */
.table-responsive {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

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

.table th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table tbody tr:hover {
  background: #f8f9fa;
}

.text-center { text-align: center; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-error { background: #f8d7da; color: #721c24; }
.badge-admin { background: #dbeafe; color: #1e40af; }
.badge-customer { background: #e2e3e5; color: #383d41; }
.badge-demo { background: #fef3c7; color: #92400e; }
.badge-warning { background: #fef3c7; color: #92400e; }

/* ── Webhook URL Box ── */
.webhook-url-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 0.75rem 0;
}

.webhook-url-box code {
  background: #f1f5f9;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  word-break: break-all;
  flex: 1;
  border: 1px solid var(--border);
}

/* ── Forms ── */
.form-add-user {
  background: #f8f9fa;
  padding: 1.25rem;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form .form-group,
.form-add-user .form-group {
  margin-bottom: 1rem;
}

.form label,
.form-add-user label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.form input,
.form select,
.form-add-user input,
.form-add-user select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.form input:focus,
.form select:focus,
.form-add-user input:focus,
.form-add-user select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.field-help {
  display: block;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 0.35rem;
  line-height: 1.5;
  padding: 0.25rem 0;
}

.help-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.5rem;
}

.form-inline input,
.form-inline select {
  padding: 0.5rem 0.75rem;
  margin-right: 0.5rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.form-inline button {
  margin-bottom: 0.5rem;
}

/* ── Info Box ── */
.info-box {
  background: #f0f7ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.info-box strong {
  display: block;
  margin-bottom: 0.5rem;
  color: #1e40af;
}

.info-box ol {
  padding-left: 1.25rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

/* ── Action Groups ── */
.action-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.inline-form {
  display: inline-flex;
  gap: 0.25rem;
  align-items: center;
}

/* ── Buttons ── */
.btn-primary {
  padding: 0.6rem 1.5rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  background: #f5f5f5;
  font-weight: 500;
  transition: all 0.15s;
}

.btn-sm:hover {
  background: #e8e8e8;
}

.btn-danger {
  background: #fde8e8;
  color: var(--danger);
  border-color: #fca5a5;
}

.btn-danger:hover {
  background: #f8d7da;
}

/* ── Token Box ── */
.token-box {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.token-box code {
  background: #f1f5f9;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  word-break: break-all;
  border: 1px solid var(--border);
}

/* ── Test Result ── */
.test-result {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.test-success {
  background: #d4edda;
  color: #155724;
}

.test-error {
  background: #f8d7da;
  color: #721c24;
}

/* ── Dashboard Footer ── */
.dashboard-footer {
  text-align: center;
  padding: 1.5rem 2rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  margin-left: 250px;
}

.dashboard-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.dashboard-footer a:hover {
  text-decoration: underline;
}

/* ── Expired Banner ── */
.alert-expired {
  background: linear-gradient(135deg, #fef2f2, #fee2e2);
  border: 1px solid #fca5a5;
  color: #991b1b;
  padding: 1rem 1.25rem;
  border-radius: 10px;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.alert-expired a {
  color: #1e40af;
  font-weight: 600;
  text-decoration: none;
}

.alert-expired a:hover { text-decoration: underline; }

/* ── Quick Start Steps ── */
.quick-start-steps { display: flex; flex-direction: column; gap: 1rem; }
.qs-step {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 0.75rem;
  border-radius: 8px;
  background: #f8f9fa;
  border: 1px solid var(--border);
}
.qs-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.qs-step p { margin-top: 0.25rem; font-size: 0.85rem; color: var(--text-secondary); }
.qs-step a { color: var(--accent); }

/* ── Download Button ── */
.btn-download {
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

/* ── Copied state ── */
.btn-copied {
  background: #d4edda !important;
  color: #155724 !important;
  border-color: #a3d9b1 !important;
}

/* ── Text colors ── */
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--text-secondary); font-size: 0.85rem; }

/* ── Mobile Topbar ── */
.mobile-topbar {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--sidebar-bg);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 90;
}

.mobile-menu-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.25rem;
}

.mobile-brand {
  font-weight: 600;
  font-size: 1rem;
  flex: 1;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

.sidebar-overlay.active {
  display: block;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .mobile-topbar { display: flex; }
  .sidebar {
    position: fixed;
    left: -250px;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: left 0.3s ease;
  }
  .sidebar.open { left: 0; }
  .main-content {
    padding: 1rem;
    margin-top: 0;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .dashboard-footer {
    margin-left: 0;
  }
  .token-box {
    flex-direction: column;
    align-items: flex-start;
  }
  .action-group {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .table th, .table td {
    padding: 0.5rem;
    font-size: 0.8rem;
  }
}
