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

:root {
  --bg: #fff;
  --fg: #0a0a0a;
  --muted: #666;
  --border: #e5e5e5;
}

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Landing */
.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  text-align: center;
}

.logo {
  height: 100px;
  width: auto;
  margin-bottom: 0.875rem;
  display: block;
}

.mark {
  width: 36px;
  height: 36px;
  border: 1px solid var(--fg);
  margin-bottom: 0.875rem;
}

.landing-footer {
  margin-top: 1.25rem;
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

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

.landing-footer a:hover {
  color: var(--fg);
}

.landing h1 {
  font-size: clamp(2.25rem, 6.5vw, 3rem);
  font-weight: 400;
  letter-spacing: 0.02em;
}

.tagline {
  font-size: 1.25rem;
  color: var(--muted);
  margin-top: 0.3rem;
  font-weight: 300;
}

.beta {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 0.6rem;
  font-weight: 400;
}

.divider {
  width: 1px;
  height: 28px;
  background: var(--border);
  margin: 0.875rem 0;
}

.cta {
  font-size: 1rem;
  font-weight: 400;
}

.landing .link {
  margin-top: 0.4rem;
  color: var(--fg);
  text-decoration: none;
  font-size: 1rem;
  border-bottom: 1px solid var(--fg);
  padding-bottom: 1px;
}

.link:hover {
  opacity: 0.7;
}

/* Admin */
.admin {
  min-height: 100vh;
  padding: 1.5rem;
}

.admin-header {
  max-width: 1200px;
  margin: 0 auto 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--fg);
  text-decoration: none;
  font-size: 1.5rem;
  font-weight: 500;
}

.admin-logo {
  height: 36px;
  width: auto;
}

.admin-header h1 {
  font-size: 1.25rem;
  font-weight: 500;
}

.admin-header a {
  color: var(--fg);
  text-decoration: none;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--fg);
}

.admin-content {
  max-width: 1200px;
  margin: 0 auto;
}

.section {
  margin-bottom: 2.5rem;
}

.section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 1rem;
}

.section-desc {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.section-desc code {
  font-family: ui-monospace, monospace;
  font-size: 0.8125rem;
  background: var(--border);
  padding: 0.1em 0.35em;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
}

.stat-card {
  padding: 1rem;
  border: 1px solid var(--border);
  background: var(--bg);
}

.stat-label {
  display: block;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.stat-value {
  font-size: 1rem;
  font-weight: 500;
}

.stat-value.ok { color: #16a34a; }
.stat-value.warn { color: #ca8a04; }
.stat-value.err { color: #dc2626; }

.sync-alert,
.latency-alert,
.node-health-alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}
.sync-alert.err,
.latency-alert.err,
.node-health-alert.err {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}
.sync-alert.warn,
.latency-alert.warn,
.node-health-alert.warn {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #b45309;
}

/* Live Lag */
.live-lag-link { font-size: 0.75rem; font-weight: 400; margin-left: 0.5rem; color: var(--muted); text-decoration: none; }
.live-lag-link:hover { color: var(--fg); }
.live-lag-section {
  background: var(--border);
  padding: 1.25rem;
  border-radius: 4px;
}

.live-lag {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.live-lag-value {
  font-size: 2rem;
  font-weight: 500;
}

.live-lag-value.ok { color: #16a34a; }
.live-lag-value.warn { color: #ca8a04; }
.live-lag-value.err { color: #dc2626; }

.live-lag-meta {
  font-size: 0.875rem;
  color: var(--muted);
}

.live-lag-updated {
  margin-left: 1rem;
  font-size: 0.75rem;
  opacity: 0.8;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

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

th {
  font-weight: 500;
  color: var(--muted);
}

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

.key-methods {
  font-size: 0.8125rem;
  color: var(--muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.key-cell {
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  word-break: break-all;
}

/* API Key cards */
.keys-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.key-card {
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.key-card:nth-child(odd) {
  background: #f0f0f0;
}

.key-card:nth-child(even) {
  background: #f8f8f8;
}

.key-card-header {
  padding: 1rem 1.25rem;
}

.key-card-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.key-name {
  font-weight: 500;
  font-size: 1rem;
}

.key-badge {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2em 0.5em;
  border-radius: 3px;
}

.badge-unlimited {
  background: #16a34a22;
  color: #16a34a;
}

.badge-throttle {
  background: var(--border);
  color: var(--muted);
}

.key-usage-badge {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2em 0.5em;
  border-radius: 3px;
  margin-left: auto;
}

.key-usage-badge.usage-low {
  background: #16a34a22;
  color: #16a34a;
}

.key-usage-badge.usage-medium {
  background: #ca8a0422;
  color: #ca8a04;
}

.key-usage-badge.usage-heavy {
  background: #dc262622;
  color: #dc2626;
}

.key-usage-bar-wrap {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin: 0.5rem 0 0.75rem;
}

.key-usage-bar {
  height: 100%;
  background: var(--muted);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.key-usage-bar.usage-low { background: #16a34a; }
.key-usage-bar.usage-medium { background: #ca8a04; }
.key-usage-bar.usage-heavy { background: #dc2626; }

.key-copy-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.key-key-display {
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  padding: 0.4rem 0.6rem;
  background: var(--border);
  border-radius: 4px;
  word-break: break-all;
  flex: 1;
  min-width: 0;
}

.key-copy-btns {
  display: flex;
  gap: 0.5rem;
}

.key-copy-btns .btn {
  min-width: 5.5rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
}

.key-key-full {
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  color: var(--fg);
  word-break: break-all;
  flex: 1;
  min-width: 0;
}

.key-key {
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.key-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.key-toggle, .create-unlimited {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  cursor: pointer;
}

.key-toggle input, .create-unlimited input {
  cursor: pointer;
}

.key-throttle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.key-throttle {
  width: 5rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.8125rem;
  font-family: inherit;
  border: 1px solid var(--border);
  background: var(--bg);
}

.key-monthly-input {
  width: 7rem;
}

.key-monthly-bar-wrap {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin: 0.25rem 0 0.25rem;
}

.key-monthly-bar {
  height: 100%;
  background: #16a34a;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.key-monthly-bar-wrap.key-monthly-over .key-monthly-bar {
  background: #dc2626;
}

.key-monthly-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.key-clear-stats {
  color: var(--muted);
  font-size: 0.8125rem;
}

.key-clear-stats:hover {
  color: var(--fg);
}

.key-card-stats {
  padding: 0.75rem 1.25rem;
  background: var(--border);
  font-size: 0.8125rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.key-card-stats .key-methods {
  max-width: 400px;
}

.key-card-breakdown,
.key-card-methods {
  padding: 0.5rem 1.25rem;
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.key-breakdown-label {
  font-weight: 500;
  color: var(--fg);
  margin-right: 0.35rem;
}

.key-errors {
  color: #dc2626;
  font-weight: 500;
}

.key-card-errors-alert {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: #dc262622;
  color: #dc2626;
  border-radius: 4px;
  font-size: 0.875rem;
}

.key-created {
  margin-left: auto;
}

.muted {
  color: var(--muted);
  font-size: 0.875rem;
}

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--fg);
  color: var(--bg);
  border: none;
  cursor: pointer;
}

.btn:hover {
  opacity: 0.9;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
}

.btn.revoke {
  background: #dc2626;
  color: #fff;
}

.form-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.form-row input {
  flex: 1;
  min-width: 180px;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  border: 1px solid var(--border);
  background: var(--bg);
}

.form-row input:focus {
  outline: none;
  border-color: var(--fg);
}

/* Mobile */
@media (max-width: 480px) {
  .landing {
    padding: 1.5rem 1rem;
  }

  .logo {
    height: 160px;
    margin-bottom: 2rem;
  }

  .mark {
    margin-bottom: 2rem;
  }

  .divider {
    margin: 2rem 0;
  }

  .admin {
    padding: 1rem;
  }

  th, td {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
  }

  .form-row {
    flex-direction: column;
  }

  .form-row input {
    min-width: 100%;
  }
}
