:root {
  --bg: #0e1116;
  --surface: #161b22;
  --surface-2: #1c232d;
  --border: #2a323d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #4f8cff;
  --accent-600: #3b74e0;
  --ok: #3fb950;
  --warn: #d29922;
  --danger: #f85149;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 70% -10%, #1a2431 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Top bar (authenticated) */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  background: rgba(22, 27, 34, 0.8);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.brand { font-weight: 700; font-size: 18px; color: var(--text); }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; margin-left: 12px; }
.nav a {
  padding: 8px 14px; border-radius: 8px; color: var(--muted); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--surface-2); }
.nav-logout { margin-left: auto; }
.link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; }
.link:hover { color: var(--text); }

/* Page + footer */
.page { flex: 1; width: 100%; max-width: 960px; margin: 0 auto; padding: 32px 24px; }
.footer { text-align: center; color: var(--muted); padding: 24px; font-size: 13px; }
h1 { font-size: 24px; margin: 0 0 20px; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 12px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* Panels + grid */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.grid .panel { margin-bottom: 0; }
.metric { font-size: 26px; font-weight: 700; margin-bottom: 4px; }
.status-ok { color: var(--ok); }
.status-wait { color: var(--warn); }

.bar { height: 8px; background: var(--surface-2); border-radius: 6px; overflow: hidden; margin-top: 12px; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-600)); }

.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: 0; }

.plan-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.plan-card h3 { margin: 0; }
.plan-card form.row { margin-top: auto; }
.plan-card select { flex: 1; }

/* Forms */
form label { display: block; margin-bottom: 14px; font-size: 14px; color: var(--muted); }
form input[type=email], form input[type=password], form input[type=text], form select {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 15px;
}
form input:focus, form select:focus { outline: none; border-color: var(--accent); }
.hint { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.check input { width: auto; }
.row { display: flex; gap: 10px; align-items: center; }
.row input[type=text] { margin-top: 0; }

.btn {
  display: inline-block; padding: 10px 16px; border-radius: 8px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; text-align: center;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-600); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; border-color: var(--border); color: var(--danger); }
.btn-danger:hover { background: rgba(248, 81, 73, 0.12); }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.actions { display: flex; gap: 8px; }
.actions form { margin: 0; }
.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-ok { background: rgba(63, 185, 80, 0.15); color: var(--ok); }
.badge-wait { background: rgba(210, 153, 34, 0.15); color: var(--warn); }

/* Flash */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; font-size: 14px; border: 1px solid transparent; }
.flash-ok { background: rgba(63, 185, 80, 0.12); border-color: rgba(63, 185, 80, 0.4); color: #7ee787; }
.flash-error { background: rgba(248, 81, 73, 0.12); border-color: rgba(248, 81, 73, 0.4); color: #ff7b72; }

/* Auth (guest) card */
.auth { min-height: 70vh; display: flex; align-items: center; justify-content: center; }
.card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px; box-shadow: var(--shadow);
}
.card-brand { font-weight: 700; font-size: 20px; text-align: center; margin-bottom: 6px; }
.card h1 { text-align: center; font-size: 18px; margin: 0 0 24px; color: var(--muted); font-weight: 500; }
.card .btn-primary { width: 100%; }
.card-links { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; text-align: center; font-size: 14px; color: var(--muted); }

/* Operator console extras */
.tag {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  background: var(--accent); color: #fff; padding: 2px 7px; border-radius: 6px; vertical-align: middle;
}
.grid-metrics { margin-bottom: 20px; }
.nav-logout { display: flex; align-items: center; gap: 12px; }
.logs {
  margin: 0; padding: 16px; background: #0a0d12; border: 1px solid var(--border); border-radius: 8px;
  color: #c9d1d9; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  white-space: pre-wrap; word-break: break-word; max-height: 60vh; overflow: auto;
}

@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; }
  .page { padding: 20px 16px; }
  .nav-logout .muted { display: none; }
}

.receipt { max-width: 640px; margin: 0 auto; }
.receipt-actions { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.receipt hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
@media print {
  .no-print, .topbar, nav, footer { display: none !important; }
  body, .page { background: #fff; color: #000; }
  .panel { border: none; box-shadow: none; }
}
