@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #f0f2f8;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --text: #1a1d26;
  --text-muted: #5c6370;
  --border: #e2e6ef;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --success: #059669;
  --success-bg: #ecfdf5;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
}

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

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Customer header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.header .logo {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.header nav { display: flex; gap: 1.25rem; align-items: center; }
.header nav a {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: none;
}
.header nav a:hover { color: var(--primary); }

.container {
  max-width: 960px;
  margin: 2rem auto;
  padding: 0 1.5rem 3rem;
}

.container-wide { max-width: 1200px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
}

.card-header {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.card-header h1, .card-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
}

.card-header p, .subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Forms */
.field { margin-bottom: 1.15rem; }

.field label, .form-label {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.field-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.input, select, textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--primary);
  color: #fff;
  border: 0;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

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

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

.btn-block { width: 100%; }

/* Alerts */
.alert {
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  border: 1px solid transparent;
}

.alert-error { background: var(--error-bg); color: var(--error); border-color: #fecaca; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: #a7f3d0; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: #fde68a; }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.9rem;
}

.table th {
  background: var(--surface-2);
  font-weight: 600;
  text-align: left;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface-2); }

.table-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem !important;
}

/* Grid */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid .full { grid-column: 1 / -1; }

@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .header { padding: 1rem; flex-direction: column; gap: 0.75rem; }
}

.config-status {
  display: grid;
  gap: 0.5rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.stat-card .label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-card .value {
  font-size: 2rem;
  font-weight: 700;
  margin-top: 0.25rem;
  letter-spacing: -0.03em;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-neutral { background: var(--surface-2); color: var(--text-muted); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }

.badge-clickable {
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s, box-shadow 0.15s;
}

.badge-clickable:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.badge-action {
  background: #fef3c7;
  color: #b45309;
}

.badge-action:hover {
  background: #fde68a;
}

.field-highlight {
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  margin: -0.75rem;
  border: 2px solid var(--primary);
  transition: background 0.2s, border-color 0.2s;
}

/* Code / keys */
.code-block, pre.key-display {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 0.82rem;
  word-break: break-all;
  white-space: pre-wrap;
  line-height: 1.6;
}

/* Results */
.result { padding: 1.25rem; border-radius: var(--radius-sm); margin-top: 1rem; }
.result.success { background: var(--success-bg); border: 1px solid #a7f3d0; }
.result.error { background: var(--error-bg); border: 1px solid #fecaca; }

/* Admin layout */
.admin-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.admin-sidebar {
  width: 260px;
  background: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%);
  color: #fff;
  padding: 1.5rem 0 1rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: 4px 0 24px rgba(30, 27, 75, 0.12);
}

.admin-sidebar .brand {
  padding: 0 1.5rem 1.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  margin-bottom: 1rem;
}

.admin-sidebar .brand span {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(255,255,255,0.55);
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0 0.75rem;
  flex: 1;
}

.admin-nav a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 0.9rem;
  color: rgba(255,255,255,0.78);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.92rem;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.admin-nav a:hover,
.admin-nav a.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
  text-decoration: none;
}

.admin-nav a.active {
  box-shadow: inset 3px 0 0 #a5b4fc;
}

.admin-sidebar-footer {
  margin-top: auto;
  padding: 1rem 1.5rem 0;
  border-top: 1px solid rgba(255,255,255,0.12);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.admin-env-switch {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.admin-env-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.55);
}

.admin-env-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.admin-env-btn {
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.82);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.admin-env-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.14);
  color: #fff;
}

.admin-env-btn.active {
  background: rgba(165, 180, 252, 0.22);
  border-color: #a5b4fc;
  color: #fff;
}

.admin-env-btn:disabled {
  cursor: default;
  opacity: 1;
}

.admin-sidebar-footer a {
  color: rgba(255,255,255,0.55);
  font-size: 0.85rem;
  text-decoration: none;
}

.admin-sidebar-footer a:hover {
  color: #fff;
  text-decoration: none;
}

.admin-main {
  flex: 1;
  min-width: 0;
  padding: 2rem 2.5rem;
  overflow-x: auto;
}

.admin-content {
  max-width: 1120px;
}

.admin-main .page-title {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.35rem;
}

.admin-main .page-desc {
  color: var(--text-muted);
  margin-bottom: 1.75rem;
  max-width: 52rem;
}

/* Login page */
.admin-login-body {
  margin: 0;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at top right, rgba(165, 180, 252, 0.35), transparent 28rem),
    linear-gradient(135deg, #1e1b4b 0%, #312e81 52%, #4f46e5 100%);
  padding: 2rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
  padding: 2.5rem 2.25rem;
}

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

.login-logo {
  width: 3.25rem;
  height: 3.25rem;
  margin: 0 auto 1rem;
  border-radius: 1rem;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  font-size: 1.35rem;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.35);
}

.login-brand h1 {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-brand p {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-top: 0.45rem;
  line-height: 1.5;
}

.login-form .field:last-of-type {
  margin-bottom: 1.5rem;
}

.login-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.88rem;
}

.login-footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.login-footer a:hover {
  color: var(--primary);
}

.login-honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Settings sections */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 900px) {
  .admin-layout { flex-direction: column; }
  .admin-sidebar {
    width: 100%;
    height: auto;
    position: static;
    box-shadow: none;
  }
  .admin-nav {
    flex-direction: row;
    flex-wrap: wrap;
    padding-bottom: 0.75rem;
  }
  .admin-sidebar-footer {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 1rem;
  }
  .admin-main { padding: 1.25rem; }
  .settings-grid { grid-template-columns: 1fr; }
}

.config-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.config-row:last-child { border-bottom: none; }
.config-row .key { color: var(--text-muted); font-weight: 500; }
.config-row .val { font-family: monospace; font-size: 0.82rem; }

.form-section {
  margin-bottom: 1.5rem;
}

.form-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 1rem 0;
  font-size: 0.9rem;
}

.checkbox-field input { width: auto; }

.steps {
  display: grid;
  gap: 1rem;
  margin: 1.5rem 0;
}

.step {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.step-num {
  width: 2rem;
  height: 2rem;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.step-content h4 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.2rem; }
.step-content p { font-size: 0.875rem; color: var(--text-muted); }

.plan-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1rem 0;
}

.plan-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  transition: border-color 0.15s;
}

.plan-card:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.plan-card input { margin-right: 0.5rem; }
.plan-card-label {
  display: block;
  cursor: pointer;
}
.plan-card .plan-name { font-weight: 600; }
.plan-card .plan-price {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0.5rem 0 0.35rem;
}
.plan-card .plan-desc { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.25rem; }
.plan-card-static {
  cursor: default;
  background: var(--surface-elevated, #f8fafc);
}
.plan-cards-pricing {
  margin-top: 0.5rem;
}

.dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.dashboard-cta .card-header {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0.75rem;
}

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

.footer-links a { margin: 0 0.5rem; }
