:root {
  --bg: #f5f5f7;
  --nav: rgba(255, 255, 255, 0.82);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --card: #ffffff;
  --line: rgba(0, 0, 0, 0.08);
  --blue: #0071e3;
  --ok: #248a3d;
  --err: #d70015;
}
html[data-theme="dark"] {
  --bg: #000000;
  --nav: rgba(29, 29, 31, 0.94);
  --text: #f5f5f7;
  --muted: #86868b;
  --card: #1d1d1f;
  --line: rgba(255, 255, 255, 0.1);
  --blue: #2997ff;
  --ok: #30d158;
  --err: #ff453a;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  letter-spacing: -0.011em;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.navbar-brand .fn-icon { width: 32px; height: 32px; border-radius: 9px; }
.app-nav {
  background: var(--nav);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
  padding: 0.55rem 0;
}
.app-nav .navbar-brand {
  display: inline-flex; align-items: center; gap: 0.55rem;
  color: var(--text); font-weight: 600; letter-spacing: -0.03em;
}
.app-nav .nav-link { color: var(--muted); font-weight: 500; }
.app-nav .nav-link.active, .app-nav .nav-link:hover { color: var(--text); }
.navbar-toggler { border-color: var(--line); }
.nav-end { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.nav-end.ms-auto { margin-left: auto; }
.nav-rfc { font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.nav-btn { width: auto !important; margin: 0; padding: 0.4rem 0.9rem; }
.page { flex: 1; padding: 2rem 0 3.5rem; }
.page-head, .view-hero, .drive-hero {
  text-align: center;
  max-width: 640px;
  margin: 0 auto 2rem;
}
.page-head h1, .view-hero h1, .drive-hero h1 {
  font-size: clamp(1.7rem, 3vw, 2.3rem);
  font-weight: 600;
  letter-spacing: -0.04em;
  margin: 0 0 0.6rem;
}
.page-head p, .view-hero p, .drive-hero p {
  color: var(--muted);
  margin: 0;
  line-height: 1.55;
  font-size: 1.05rem;
}
.view-stack { max-width: 640px; margin: 0 auto; }
.view-stack.wide { max-width: 960px; }
.narrow-card {
  max-width: 420px; margin: 3rem auto; background: var(--card);
  border: 1px solid var(--line); border-radius: 20px; padding: 1.6rem;
}
.narrow-card h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.03em; }
.card-panel, .panel.card-panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 1.2rem 1.25rem;
}
.hero-actions { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; margin-top: 1.2rem; }
.btn-primary.inline, .btn-secondary.inline { width: auto; display: inline-block; margin: 0; padding: 0.65rem 1.2rem; }
.faq-item { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 0.9rem 1rem; margin-bottom: 0.6rem; }
.faq-item summary { cursor: pointer; font-weight: 600; }
.faq-item p { color: var(--muted); margin: 0.6rem 0 0; font-size: 0.92rem; }
.brand { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 1.1rem; }
.brand-title { margin: 0; font-weight: 600; font-size: 1.15rem; letter-spacing: -0.03em; }
.brand-sub { margin: 0.1rem 0 0; color: var(--muted); font-size: 0.75rem; }
.fn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 11px;
  background: color-mix(in srgb, var(--blue) 12%, transparent);
  color: var(--blue);
}
.fn-icon svg { width: 20px; height: 20px; }
.theme-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; font-size: 0.8rem; color: var(--muted); }
.theme-toggle-form { margin: 0; }
.theme-toggle {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; cursor: pointer;
}
.theme-toggle:hover { border-color: var(--blue); color: var(--blue); }
.theme-ico, .theme-ico svg { width: 20px; height: 20px; display: block; }
body.is-gate { position: relative; min-height: 100vh; }
body.is-gate .page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: calc(100vh - 2rem); }
.gate-top { position: absolute; top: 1rem; right: 1rem; z-index: 2; }
.gate-card .fn-icon { margin: 0 auto; }
.gate-wrap { width: 100%; }
.gate-card {
  max-width: 400px; margin: 0 auto; text-align: center;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 22px; padding: 2rem 1.6rem 1.7rem;
}
.gate-card h1 { font-size: 1.6rem; font-weight: 600; letter-spacing: -0.03em; margin: 0.8rem 0 0.35rem; }
.gate-card .lead-copy { color: var(--muted); margin: 0 0 0.5rem; }
.gate-card form { text-align: left; margin-top: 1rem; }
.gate-alt { margin: 0.85rem 0 0; font-size: 0.85rem; color: var(--muted); }
.gate-alt a { color: var(--blue); text-decoration: none; }
.users-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.users-table th, .users-table td { text-align: left; padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.users-table th { color: var(--muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; }
.inline-form { display: flex; gap: 0.35rem; align-items: center; margin: 0.25rem 0; }
.inline-form input { width: auto; flex: 1; margin: 0; }
.inline-form .btn-ghost { width: auto; margin: 0; padding: 0.35rem 0.7rem; }
.table-wrap { overflow-x: auto; }
.account-card {
  border-top: 1px solid var(--line);
  padding: 0.95rem 0 0.15rem;
}
.account-card:first-of-type { border-top: 0; padding-top: 0.2rem; }
.account-meta {
  display: flex; flex-wrap: wrap; gap: 0.35rem 0.7rem;
  align-items: center; margin-bottom: 0.65rem;
}
.account-meta strong { word-break: break-word; }
.account-row {
  display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center;
  margin: 0.35rem 0;
}
.account-row input {
  width: auto; flex: 1 1 180px; min-width: 0; margin: 0;
}
.account-row .btn-ghost,
.account-row form { width: auto; margin: 0; }
.account-row form .btn-ghost { display: inline-block; width: auto; margin: 0; }
.activity-filter { display: flex; gap: 0.6rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.activity-filter label { flex: 1; min-width: 220px; margin: 0; }
.activity-filter .btn-secondary, .activity-filter .btn-ghost { width: auto; margin: 0; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.drive-hero { text-align: center; max-width: 640px; margin: 0 auto 2rem; }
.drive-hero h1 { font-size: clamp(1.7rem, 3vw, 2.3rem); font-weight: 600; letter-spacing: -0.04em; margin: 0 0 0.6rem; }
.drive-hero p { color: var(--muted); margin: 0; line-height: 1.55; font-size: 1.05rem; }
.drive-steps { list-style: none; padding: 0; margin: 0 auto; max-width: 640px; }
.drive-steps.admin-steps { max-width: 720px; }
.drive-step {
  display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 1rem;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 1.25rem 1.3rem; margin-bottom: 0.9rem; text-align: left;
  overflow: hidden;
}
.drive-body { min-width: 0; }
.drive-step.is-done { border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.drive-num {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--blue); color: #fff; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.drive-step.is-done .drive-num { background: var(--ok); }
.drive-body h2 { font-size: 1.05rem; font-weight: 600; margin: 0.15rem 0 0.4rem; letter-spacing: -0.02em; }
.drive-body p { color: var(--muted); margin: 0 0 0.7rem; line-height: 1.45; }
.drive-mini { color: var(--muted); padding-left: 1.1rem; margin: 0 0 0.9rem; font-size: 0.9rem; }
.drive-mini li { margin: 0.25rem 0; }
.panel { margin: 1.1rem 0; }
.panel h2 { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 0 0 0.7rem; }
.hint { color: var(--muted); font-size: 0.8rem; line-height: 1.4; margin: 0 0 0.7rem; }
.hint.ok { color: var(--ok); }
label { display: block; font-size: 0.78rem; font-weight: 500; margin: 0.55rem 0; color: var(--muted); }
input, select {
  display: block; width: 100%; margin-top: 0.28rem;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 0.55rem 0.7rem; font: inherit;
}
.check { display: flex; align-items: center; gap: 0.45rem; font-size: 0.82rem; color: var(--text); }
.check input { width: auto; margin: 0; }
.check-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.btn-primary, .btn-secondary, .btn-ghost {
  display: block; width: 100%; text-align: center; text-decoration: none;
  border-radius: 980px; padding: 0.62rem 0.9rem; margin: 0.45rem 0;
  font: inherit; font-weight: 500; cursor: pointer; border: 1px solid transparent;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-secondary { background: transparent; color: var(--blue); border-color: var(--line); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.flash { border-radius: 12px; padding: 0.55rem 0.7rem; font-size: 0.8rem; margin: 0.35rem 0; }
.flash-success { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.flash-error, .flash-warning { background: color-mix(in srgb, var(--err) 14%, transparent); color: var(--err); }
.flash-info { background: color-mix(in srgb, var(--blue) 12%, transparent); color: var(--blue); }
.hero { text-align: center; padding: 0.5rem 0 2.2rem; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 3rem); font-weight: 600; letter-spacing: -0.038em; line-height: 1.1; margin: 0.7rem 0; }
.hero p { color: var(--muted); font-size: 1.08rem; max-width: 36rem; margin: 0 auto; }
.badge { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--blue); font-size: 0.75rem; font-weight: 600; }
.section-label { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 0.9rem; }
h1, h2, h3, h4, h5, h6,
.card, .card-body, .card-title, .card-text {
  color: var(--text);
}
.card {
  background: var(--card);
  border-color: var(--line);
}
.apple-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}
.apple-card .card-body { padding: 1.25rem; }
.apple-card h3 { font-size: 1.02rem; font-weight: 600; margin: 0.85rem 0 0.4rem; color: var(--text); }
.drive-body h2, .faq-item summary, .wait-card h2, .gate-card h1, .hero h1,
.page-head h1, .view-hero h1, .drive-hero h1 {
  color: var(--text);
}
.apple-card p { color: var(--muted); font-size: 0.9rem; margin: 0 0 0.8rem; }
.pill { display: inline-block; border: 1px solid var(--line); border-radius: 980px; padding: 0.2rem 0.65rem; font-size: 0.7rem; color: var(--muted); }
.step { display: flex; gap: 0.85rem; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 1rem; height: 100%; }
.step-num { width: 32px; height: 32px; border-radius: 980px; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0; }
.step strong { display: block; font-size: 0.95rem; }
.step span { color: var(--muted); font-size: 0.84rem; }
.cta { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 1rem 1.2rem; text-align: center; color: var(--muted); }
.dash-head h1 { font-size: 2rem; font-weight: 600; letter-spacing: -0.04em; margin: 0; }
.dash-head p { color: var(--muted); margin: 0.3rem 0 1.2rem; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.8rem; margin-bottom: 1.5rem; }
.metrics div { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 0.9rem 1rem; }
.metrics span { display: block; color: var(--muted); font-size: 0.72rem; }
.metrics strong { font-size: 1.2rem; font-weight: 600; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--card); }
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th, td { padding: 0.65rem 0.75rem; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; }
.mono { font-family: ui-monospace, monospace; font-size: 0.72rem; }
.log { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 0.9rem; font-size: 0.75rem; max-height: 220px; overflow: auto; color: var(--muted); }
.empty { color: var(--muted); }
.status-dot { display: inline-block; background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); border-radius: 980px; padding: 0.2rem 0.7rem; font-size: 0.75rem; font-weight: 600; }
.rfc { font-weight: 600; margin: 0.5rem 0 0; }
.preset-row { display: flex; gap: 0.35rem; }
.preset-row form { flex: 1; }
.preset-row .btn-ghost { margin: 0.2rem 0; }
.faq { margin-top: 1.4rem; color: var(--muted); font-size: 0.85rem; }
.faq summary { cursor: pointer; font-weight: 500; color: var(--text); }
.faq-q { margin: 0.8rem 0 0.2rem; color: var(--text); font-weight: 600; font-size: 0.82rem; }
.faq-a { margin: 0; font-size: 0.8rem; line-height: 1.45; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
.mini { margin: 0.6rem 0 0.2rem; font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.wait-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(10px);
}
.wait-overlay[hidden] { display: none !important; }
.wait-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 2rem 1.6rem 1.6rem;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0,0,0,0.18);
}
.wait-card h2 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 1rem 0 0.4rem;
}
.wait-card p { color: var(--muted); margin: 0; line-height: 1.45; }
.wait-timer { margin-top: 1rem !important; font-variant-numeric: tabular-nums; font-weight: 500; color: var(--text) !important; }
.wait-spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--blue);
  animation: wait-spin 0.8s linear infinite;
}
@keyframes wait-spin { to { transform: rotate(360deg); } }
body.is-waiting { overflow: hidden; }
.app-footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding: 1.1rem 0;
  text-align: center;
}
.app-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}
@media (max-width: 860px) {
  .metrics { grid-template-columns: 1fr 1fr; }
  .page { padding: 1.2rem 0 2rem; }
}
