:root {
  --bg: #f3f6fb;
  --bg-strong: #eaf0ff;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-strong: #ffffff;
  --text: #101828;
  --muted: #667085;
  --line: rgba(15, 23, 42, 0.10);
  --line-strong: rgba(15, 23, 42, 0.16);
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --success: #059669;
  --warning: #f59e0b;
  --danger: #dc2626;
  --shadow-lg: 0 28px 60px rgba(15, 23, 42, 0.10);
  --shadow-md: 0 16px 36px rgba(15, 23, 42, 0.08);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

body.theme-dark {
  --bg: #09111f;
  --bg-strong: #0f172a;
  --panel: rgba(15, 23, 42, 0.84);
  --panel-strong: #0f172a;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --line: rgba(148, 163, 184, 0.14);
  --line-strong: rgba(148, 163, 184, 0.22);
  --primary: #60a5fa;
  --primary-strong: #3b82f6;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --shadow-lg: 0 28px 60px rgba(2, 6, 23, 0.42);
  --shadow-md: 0 16px 36px rgba(2, 6, 23, 0.28);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.12), transparent 28%),
    radial-gradient(circle at bottom right, rgba(14, 165, 233, 0.10), transparent 24%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-strong) 100%);
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
code { font-family: Consolas, Monaco, monospace; }

.app-shell, .guest-shell, .error-screen { min-height: 100vh; }
.shell-grid { display: grid; grid-template-columns: 288px 1fr; min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 22px;
  background: linear-gradient(180deg, #0b1220 0%, #111827 100%);
  color: #d8e2f0;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand-block { display: flex; align-items: center; gap: 14px; }
.brand-block h1, .brand-block p { margin: 0; }
.brand-icon {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  background: linear-gradient(140deg, #60a5fa, #2563eb);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: white;
}
.brand-subtitle { color: rgba(216, 226, 240, 0.72); font-size: 0.95rem; }
.eyebrow { margin: 0 0 6px; text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.72rem; color: var(--muted); }
.sidebar-nav { display: grid; gap: 8px; }
.sidebar-nav a {
  padding: 13px 15px;
  border-radius: 14px;
  color: rgba(216, 226, 240, 0.9);
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.sidebar-nav a.active, .sidebar-nav a:hover { background: rgba(255,255,255,.10); color: white; transform: translateX(2px); }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.10); padding-top: 18px; }
.sidebar-footer p { margin: 0 0 4px; font-weight: 700; }
.sidebar-footer span { color: rgba(216, 226, 240, 0.72); }

.content-wrap { padding: 26px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}
.topbar-heading h2 { margin: 0; font-size: clamp(1.8rem, 2.8vw, 2.45rem); }
.topbar-subtitle, .helper-text, .muted, .page-intro p:last-child, .hero-panel p { color: var(--muted); }
.topbar-actions, .compact-actions, .inline-form, .inline-check, .form-actions, .preview-actions, .danger-zone, .hero-pills, .metric-row, .list-row, .wizard-actions, .wizard-actions-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.page-content { display: grid; gap: 24px; }

.panel, .guest-card, .error-card, .stat-card, .hero-panel, .verification-card {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,.42);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
}
.panel, .guest-card, .verification-card { padding: 24px; }
.hero-panel { padding: 24px 26px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.hero-panel h3, .panel-head h3, .page-intro h3, .verification-card h2 { margin: 0; }
.hero-panel-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.stats-grid, .panel-grid, .analytics-grid, .detail-grid, .form-grid, .grid-2, .toolbar-grid, .wizard-layout, .quick-actions-grid {
  display: grid;
  gap: 20px;
}
.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.panel-grid, .analytics-grid { grid-template-columns: 1.9fr 1fr; }
.detail-grid { grid-template-columns: 380px 1fr; }
.stat-card { padding: 24px; }
.stat-card span { display: block; color: var(--muted); margin-bottom: 10px; }
.stat-card strong { display: block; font-size: 2rem; margin-bottom: 8px; }
.accent-green { background: linear-gradient(135deg, rgba(16,185,129,.16), var(--panel-strong)); }
.accent-blue { background: linear-gradient(135deg, rgba(37,99,235,.16), var(--panel-strong)); }
.accent-warm { background: linear-gradient(135deg, rgba(245,158,11,.16), var(--panel-strong)); }

.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.split { align-items: center; }

.btn, .theme-toggle, .wizard-tab, .quick-action, .copy-link { transition: transform .18s ease, background .18s ease, border-color .18s ease, color .18s ease; }
.btn {
  border: none;
  border-radius: 14px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:hover, .theme-toggle:hover, .quick-action:hover { transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-strong)); color: white; }
.btn-secondary { background: rgba(148,163,184,.16); color: var(--text); }
.btn-danger { background: rgba(220,38,38,.12); color: var(--danger); }
.btn-sm { padding: 8px 12px; font-size: .88rem; }

.theme-toggle, .icon-btn {
  border: 1px solid var(--line);
  background: rgba(148,163,184,.08);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
}
.mobile-only { display: none; }
.icon-btn { width: 44px; height: 44px; display: inline-grid; place-items: center; }

.alert { border-radius: 18px; padding: 15px 18px; border: 1px solid transparent; }
.alert-success { background: rgba(16,185,129,.12); border-color: rgba(16,185,129,.22); color: #047857; }
.alert-danger { background: rgba(220,38,38,.12); border-color: rgba(220,38,38,.22); color: #b91c1c; }
body.theme-dark .alert-success { color: #6ee7b7; }
body.theme-dark .alert-danger { color: #fca5a5; }
.alert-list { margin: 10px 0 0; padding-left: 18px; }
.generated-key-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { text-align: left; padding: 16px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table th { font-size: .82rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.data-table th a { color: inherit; }
.table-subtext { color: var(--muted); }
.actions-cell { display: flex; justify-content: flex-end; gap: 8px; }
.empty-cell { text-align: center; color: var(--muted); padding: 36px; }
.truncate-cell, .break-word, .code-block { word-break: break-word; }
.truncate-cell { max-width: 260px; }
.toolbar-grid { grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(0, 1fr)) auto; margin-bottom: 16px; }

.stack-form { display: grid; gap: 18px; }
.form-grid, .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.full-width { grid-column: 1 / -1; }
label { display: grid; gap: 8px; }
label > span { font-weight: 700; }
input, select, textarea {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,.82);
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
}
body.theme-dark input, body.theme-dark select, body.theme-dark textarea { background: rgba(15,23,42,.82); }
textarea { resize: vertical; }
input.is-invalid, select.is-invalid, textarea.is-invalid { border-color: rgba(220,38,38,.65); box-shadow: 0 0 0 4px rgba(220,38,38,.08); }
.field-error { color: var(--danger); font-size: .88rem; }
.checkbox { display: flex; align-items: center; gap: 10px; align-self: end; }
.checkbox input { width: auto; }
.helper-card {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(37,99,235,.08);
  border: 1px solid rgba(37,99,235,.16);
  color: var(--primary-strong);
}
body.theme-dark .helper-card { color: #93c5fd; }

.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 6px 12px; font-size: .78rem; font-weight: 700; }
.badge-success { background: rgba(16,185,129,.14); color: #047857; }
.badge-primary { background: rgba(37,99,235,.14); color: #1d4ed8; }
.badge-danger { background: rgba(220,38,38,.14); color: #b91c1c; }
.badge-muted { background: rgba(148,163,184,.18); color: var(--muted); }
body.theme-dark .badge-success { color: #6ee7b7; }
body.theme-dark .badge-primary { color: #93c5fd; }
body.theme-dark .badge-danger { color: #fca5a5; }

.chart-canvas { width: 100%; height: 320px !important; }
.doughnut { height: 280px !important; }
.metric-stack, .list-stack { display: grid; gap: 14px; }
.metric-row, .list-row {
  justify-content: space-between;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.44);
}
body.theme-dark .metric-row, body.theme-dark .list-row { background: rgba(15,23,42,.34); }
.quick-actions-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.quick-action {
  display: block;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(148,163,184,.10);
  border: 1px solid var(--line);
  font-weight: 600;
}

.wizard-layout { grid-template-columns: minmax(0, 1.5fr) 360px; align-items: start; }
.wizard-main { display: grid; gap: 18px; }
.wizard-progress { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.wizard-tab {
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,.56);
  color: var(--text);
  border-radius: 16px;
  padding: 14px;
  text-align: left;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
body.theme-dark .wizard-tab { background: rgba(15,23,42,.56); }
.wizard-tab span {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-right: 8px;
  border-radius: 999px;
  background: rgba(148,163,184,.20);
}
.wizard-tab.active { border-color: rgba(37,99,235,.28); background: rgba(37,99,235,.08); color: var(--primary-strong); }
.wizard-step { display: none; }
.wizard-step.active { display: block; }
.wizard-actions { justify-content: space-between; }

.preview-panel { position: sticky; top: 24px; }
.preview-image-wrap {
  display: grid;
  place-items: center;
  padding: 18px;
  border-radius: 20px;
  background: rgba(248,250,252,.8);
  border: 1px solid var(--line);
  margin-bottom: 18px;
}
body.theme-dark .preview-image-wrap { background: rgba(9,17,31,.8); }
.qr-preview-image {
  width: min(100%, 290px);
  display: block;
  border-radius: 24px;
  background: white;
  padding: 12px;
}
.preview-meta { display: grid; gap: 12px; }
.preview-meta div, .detail-list div {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(148,163,184,.08);
}
.preview-meta dt, .detail-list dt {
  color: var(--muted);
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 6px;
}
.preview-meta dd, .detail-list dd { margin: 0; font-weight: 600; }
.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.detail-list.single-column { grid-template-columns: 1fr; }
.code-block {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 16px;
  padding: 16px;
  overflow: auto;
}
.copy-link { border: none; background: none; padding: 0; color: var(--primary); cursor: pointer; font: inherit; text-align: left; }
.copy-link.copied { color: var(--success); }
.mini-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  padding: 8px;
  border-radius: 16px;
  background: white;
  border: 1px solid var(--line);
}
.danger-zone { justify-content: space-between; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.pagination { display: flex; gap: 10px; margin-top: 18px; }
.pagination a {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(148,163,184,.12);
}
.pagination a.active { background: var(--primary); color: white; }

.action-menu { position: relative; }
.action-menu summary { list-style: none; }
.action-menu summary::-webkit-details-marker { display: none; }
.action-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 180px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 8px;
  display: grid;
  z-index: 5;
}
.action-menu-list a { padding: 10px 12px; border-radius: 12px; }
.action-menu-list a:hover { background: rgba(148,163,184,.12); }

.guest-grid {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.2fr minmax(320px, 460px);
  gap: 24px;
  padding: 30px;
}
.guest-hero, .guest-card { padding: 36px; }
.guest-hero {
  border-radius: 32px;
  background: linear-gradient(135deg, rgba(9,17,31,.96), rgba(37,99,235,.86));
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.guest-hero .eyebrow { color: rgba(216,226,240,.76); }
.guest-hero h1 { margin: 0 0 16px; font-size: clamp(2.4rem, 4vw, 4.1rem); line-height: 1.05; }
.guest-hero p { max-width: 620px; color: rgba(216,226,240,.88); }
.hero-pills { justify-content: flex-start; margin-top: 24px; }
.hero-pills span { padding: 10px 14px; border-radius: 999px; background: rgba(255,255,255,.14); }
.guest-card { align-self: center; }
.guest-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.guest-card-head h2 { margin: 0 0 6px; }
.guest-card-head p { margin: 0; color: var(--muted); }
.auth-header h2 { margin: 0 0 8px; font-size: 2rem; }
.form-switch { text-align: center; color: var(--muted); }
.page-intro { display: grid; gap: 6px; }
.page-intro h3 { font-size: 1.7rem; }

.verification-shell { max-width: 720px; margin: 0 auto; width: 100%; }
.verification-card p { color: var(--muted); }
.error-screen { display: grid; place-items: center; padding: 24px; }
.error-card { width: min(560px, 100%); padding: 36px; text-align: center; }
.text-link { color: var(--primary); font-weight: 700; }

@media (max-width: 1240px) {
  .wizard-layout, .stats-grid, .panel-grid, .analytics-grid, .detail-grid { grid-template-columns: 1fr; }
  .preview-panel { position: static; }
}

@media (max-width: 980px) {
  .shell-grid { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform .22s ease;
    z-index: 30;
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-grid; }
  .content-wrap { padding: 18px; }
  .topbar { flex-wrap: wrap; }
  .guest-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .stats-grid, .toolbar-grid, .form-grid, .grid-2, .detail-list, .quick-actions-grid, .wizard-progress { grid-template-columns: 1fr; }
  .topbar-actions, .hero-panel-actions, .wizard-actions, .wizard-actions-right, .inline-form, .form-actions, .danger-zone { width: 100%; }
  .topbar-actions > *, .hero-panel-actions > *, .wizard-actions > *, .wizard-actions-right > *, .inline-form > *, .form-actions > *, .danger-zone > * { flex: 1 1 100%; }
  .actions-cell { justify-content: flex-start; }
}
