/* ─── Reset ────────────────────────────────────────────────────────────────── */

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

:root {
  --bg: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --bg-code: #f6f5f4;
  --border: #e8e5e1;
  --border-light: #f0eeeb;
  --text: #1a1a1a;
  --text-secondary: #6b6b6b;
  --text-tertiary: #9b9b9b;
  --accent: #c96442;
  --accent-hover: #b85638;
  --accent-light: rgba(201, 100, 66, 0.08);
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --warning: #ca8a04;
  --warning-bg: #fefce8;
  --warning-border: #fef08a;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --transition: 150ms ease;
}

/* ─── Base ─────────────────────────────────────────────────────────────────── */

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-hover);
}

::selection {
  background: var(--accent-light);
  color: var(--text);
}

/* ─── Layout ──────────────────────────────────────────────────────────────── */

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
}

main.container {
  padding-top: 48px;
  padding-bottom: 80px;
}

/* ─── Navbar ──────────────────────────────────────────────────────────────── */

.navbar {
  border-bottom: 1px solid var(--border);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.nav-brand {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.2px;
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.nav-brand:hover {
  color: var(--text);
  opacity: 0.7;
}

.nav-logo {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.nav-brand-accent {
  color: var(--accent);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link {
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.nav-link:hover {
  color: var(--text);
  background: var(--bg-tertiary);
}

/* ─── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 550;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  line-height: 1.4;
}

.btn-primary {
  background: var(--text);
  color: #fff;
}

.btn-primary:hover {
  background: #333;
  color: #fff;
}

.btn-danger {
  background: transparent;
  color: var(--error);
  border: 1px solid var(--error-border);
}

.btn-danger:hover {
  background: var(--error-bg);
}

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

.btn-outline:hover {
  border-color: var(--text-tertiary);
  color: var(--text);
  background: var(--bg-secondary);
}

.btn-sm {
  padding: 5px 11px;
  font-size: 12.5px;
}

.btn-full {
  width: 100%;
  padding: 11px 18px;
}

/* ─── Forms ───────────────────────────────────────────────────────────────── */

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 9px 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  transition: all var(--transition);
  outline: none;
}

input:focus {
  border-color: var(--text-tertiary);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.04);
}

input::placeholder {
  color: var(--text-tertiary);
}

.required {
  color: var(--error);
  font-weight: 400;
}

.inline-form {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 28px;
}

.input-inline {
  flex: 1;
  max-width: 320px;
}

/* ─── Auth Pages ──────────────────────────────────────────────────────────── */

.auth-page {
  display: flex;
  justify-content: center;
  padding-top: 80px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
}

.auth-card h1 {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.4px;
  margin-bottom: 4px;
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 32px;
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 13.5px;
  color: var(--text-secondary);
}

/* ─── Alerts ──────────────────────────────────────────────────────────────── */

.alert {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 24px;
  line-height: 1.5;
}

.alert-error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error);
}

.alert-success {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: #15803d;
}

.key-alert {
  margin-top: 0;
  margin-bottom: 32px;
}

.key-display {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  background: var(--bg);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--success-border);
}

.key-display code {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  word-break: break-all;
  flex: 1;
  background: none;
  padding: 0;
  border: none;
}

/* ─── Page Header ─────────────────────────────────────────────────────────── */

.page-header {
  margin-bottom: 36px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.5px;
  color: var(--text);
}

.page-header p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

/* ─── Stats Grid ──────────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 40px;
}

.stat-card {
  background: var(--bg);
  padding: 22px 20px;
}

.stat-value {
  font-size: 28px;
  font-weight: 650;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.stat-label {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 500;
}

/* ─── Sections ────────────────────────────────────────────────────────────── */

.section {
  margin-bottom: 28px;
}

.section h2 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text);
}

/* ─── Tables ──────────────────────────────────────────────────────────────── */

.table-wrapper {
  overflow-x: auto;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.02em;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  color: var(--text);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--bg-secondary);
}

code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text);
}

/* ─── Badges ──────────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11.5px;
  font-weight: 550;
  border-radius: 20px;
  letter-spacing: 0.01em;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.badge-error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error-border);
}

/* ─── Pagination ──────────────────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 28px;
}

.pagination-info {
  color: var(--text-secondary);
  font-size: 13px;
}

/* ─── Empty State ─────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}

/* ─── Error Pages ─────────────────────────────────────────────────────────── */

.error-page {
  text-align: center;
  padding-top: 100px;
}

.error-page h1 {
  font-size: 64px;
  font-weight: 700;
  color: var(--text-tertiary);
  margin-bottom: 8px;
  letter-spacing: -2px;
}

.error-page p {
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-size: 15px;
}

.text-error {
  color: var(--error);
  font-size: 12px;
}

/* ─── Docs Page ───────────────────────────────────────────────────────────── */

.docs-page {
  max-width: 720px;
}

.docs-page .page-header {
  margin-bottom: 48px;
}

.docs-page .page-header h1 {
  font-size: 28px;
  letter-spacing: -0.6px;
}

.docs-section {
  margin-bottom: 40px;
}

.docs-section h2 {
  font-size: 17px;
  font-weight: 620;
  margin-bottom: 10px;
  padding-top: 4px;
  color: var(--text);
  letter-spacing: -0.2px;
}

.docs-section h3 {
  font-size: 12px;
  font-weight: 550;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 20px;
  margin-bottom: 8px;
}

.docs-section p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 8px;
}

.docs-section p strong {
  color: var(--text);
  font-weight: 550;
}

.docs-section ul {
  padding-left: 20px;
  margin-top: 8px;
}

.docs-section li {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  line-height: 1.65;
}

.docs-page hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}

.code-block {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin-bottom: 12px;
}

.code-block pre {
  padding: 16px 18px;
  margin: 0;
}

.code-block code {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text);
  background: transparent;
  padding: 0;
  border-radius: 0;
  white-space: pre;
}

/* ─── Nav Link Icon (logout) ──────────────────────────────────────────────── */

.nav-link-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
}

.nav-link-icon svg {
  display: block;
}

/* ─── Pricing Card ────────────────────────────────────────────────────────── */

.pricing-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 36px;
}

.pricing-header {
  padding: 14px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.pricing-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pricing-body {
  padding: 24px 20px;
}

.pricing-rate {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 20px;
}

.pricing-amount {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -1px;
}

.pricing-unit {
  font-size: 14px;
  color: var(--text-secondary);
}

.pricing-features {
  padding-left: 18px;
  margin: 0;
}

.pricing-features li {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  line-height: 1.6;
}

/* ─── Monitor Page ────────────────────────────────────────────────────────── */

.stats-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.monitor-section {
  margin-bottom: 40px;
}

.monitor-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.monitor-section-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.monitor-section-sub {
  font-size: 12.5px;
  color: var(--text-tertiary);
}

/* ─── Uptime Bars ─────────────────────────────────────────────────────────── */

.uptime-container {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--bg);
}

.uptime-bars {
  display: flex;
  gap: 2px;
  height: 32px;
  align-items: stretch;
}

.uptime-bar {
  flex: 1;
  border-radius: 3px;
  min-width: 4px;
  cursor: pointer;
  transition: opacity var(--transition);
}

.uptime-bar:hover {
  opacity: 0.75;
}

.uptime-operational {
  background: var(--success);
}

.uptime-degraded {
  background: var(--warning);
}

.uptime-outage {
  background: var(--error);
}

.uptime-no_data {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
}

.uptime-legend {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.uptime-legend-items {
  display: flex;
  gap: 14px;
}

.uptime-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.uptime-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
}

.uptime-dot-operational { background: var(--success); }
.uptime-dot-degraded { background: var(--warning); }
.uptime-dot-outage { background: var(--error); }
.uptime-dot-nodata { background: var(--bg-tertiary); border: 1px solid var(--border); }

/* ─── Usage Chart ─────────────────────────────────────────────────────────── */

.usage-chart-container {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--bg);
}

.usage-chart-container canvas {
  width: 100%;
  display: block;
}

/* ─── Provider Cards ──────────────────────────────────────────────────────── */

.provider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.provider-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--bg);
}

.provider-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.provider-name {
  font-size: 12.5px;
  font-weight: 500;
}

.provider-op {
  font-size: 11px;
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: 10px;
}

.provider-card-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
}

.provider-stat {
  display: flex;
  flex-direction: column;
}

.provider-stat-value {
  font-size: 18px;
  font-weight: 650;
  color: var(--text);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.provider-stat-label {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.provider-stat-success { color: var(--success); }
.provider-stat-failure { color: var(--error); }

.provider-bar-track {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  margin-bottom: 8px;
  overflow: hidden;
}

.provider-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 300ms ease;
}

.provider-bar-good { background: var(--success); }
.provider-bar-warn { background: var(--warning); }
.provider-bar-bad { background: var(--error); }

.provider-failure-rate {
  font-size: 11.5px;
  color: var(--text-tertiary);
}

/* ─── Logs page extras ────────────────────────────────────────────────────── */

.badge-platform {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid rgba(201, 100, 66, 0.15);
}

.provider-tag {
  font-size: 11px;
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
}

.text-muted {
  color: var(--text-tertiary);
  font-size: 12px;
}

.text-nowrap {
  white-space: nowrap;
}

/* ─── Home Page ───────────────────────────────────────────────────────────── */

.home-hero {
  text-align: center;
  padding: 64px 0 48px;
}

.home-hero h1 {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--text);
  line-height: 1.15;
}

.home-subtitle {
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.6;
  max-width: 520px;
  margin: 12px auto 0;
}

.home-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 28px;
}

.home-actions .btn {
  padding: 11px 24px;
  font-size: 14px;
}

.uptime-avail {
  font-variant-numeric: tabular-nums;
}

.home-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 40px;
}

.home-feature {
  background: var(--bg);
  padding: 24px 22px;
}

.home-feature h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -0.2px;
}

.home-feature p {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.55;
}

@media (max-width: 640px) {
  .home-hero {
    padding: 40px 0 32px;
  }

  .home-hero h1 {
    font-size: 26px;
  }

  .home-subtitle {
    font-size: 14px;
  }

  .home-actions {
    flex-direction: column;
    align-items: center;
  }

  .home-features {
    grid-template-columns: 1fr;
  }
}

/* ─── Billing Page ────────────────────────────────────────────────────────── */

.cards-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
}

.card-row:last-child {
  border-bottom: none;
}

.card-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-brand {
  font-size: 13px;
  font-weight: 600;
  text-transform: capitalize;
  color: var(--text);
}

.card-form {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--bg-secondary);
}

.card-element-wrapper {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
}

/* Toggle switch */
.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text);
  user-select: none;
}

.toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-switch {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: all var(--transition);
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--bg);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition);
}

.toggle-input:checked + .toggle-switch {
  background: var(--success);
  border-color: var(--success);
}

.toggle-input:checked + .toggle-switch::after {
  transform: translateX(16px);
}

.topoff-form {
  margin: 0;
}

.topoff-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.topoff-settings {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  margin-top: 4px;
}

/* ─── Footer ──────────────────────────────────────────────────────────────── */

.footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  text-align: center;
  margin-top: 80px;
}

.footer p {
  color: var(--text-tertiary);
  font-size: 12.5px;
}

/* ─── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  main.container {
    padding-top: 32px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-grid-3 {
    grid-template-columns: 1fr;
  }

  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .input-inline {
    max-width: none;
  }

  .nav-links {
    gap: 2px;
  }

  .nav-link {
    font-size: 13px;
    padding: 6px 8px;
  }

  .auth-page {
    padding-top: 48px;
  }

  .provider-grid {
    grid-template-columns: 1fr;
  }

  .uptime-legend-items {
    display: none;
  }
}
