:root {
  color-scheme: light;
  --purple-950: #251238;
  --purple-900: #35184f;
  --purple-800: #4a246f;
  --purple-700: #6336a8;
  --purple-600: #7b4bc1;
  --purple-100: #eee6f8;
  --purple-50: #f7f3fb;
  --ink: #251f2b;
  --muted: #6f6676;
  --line: #dfd7e5;
  --surface: #ffffff;
  --bg: #f5f1f7;
  --success: #177245;
  --success-bg: #e3f5ec;
  --danger: #b42318;
  --danger-bg: #feeceb;
  --warning: #915b00;
  --shadow: 0 12px 32px rgba(53, 24, 79, 0.12);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% -10%, rgba(123, 75, 193, 0.18), transparent 30rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem max(1rem, env(safe-area-inset-left));
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid rgba(99, 54, 168, 0.12);
  backdrop-filter: blur(14px);
}

.brand { display: flex; align-items: center; gap: 0.7rem; text-decoration: none; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: white;
  background: linear-gradient(145deg, var(--purple-600), var(--purple-900));
  font-weight: 900;
  font-size: 1.35rem;
  box-shadow: 0 8px 18px rgba(99, 54, 168, 0.28);
}
.brand strong, .brand small { display: block; line-height: 1.05; }
.brand small { margin-top: 0.2rem; color: var(--muted); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; }

nav { display: none; position: absolute; top: 68px; right: 1rem; min-width: 160px; padding: 0.4rem; background: white; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
nav.open { display: grid; }
nav a { padding: 0.7rem 0.85rem; border-radius: 10px; text-decoration: none; font-weight: 700; }
nav a:hover, nav a:focus-visible { background: var(--purple-50); color: var(--purple-800); }
.icon-button { width: 44px; height: 44px; border: 0; border-radius: 12px; background: var(--purple-50); color: var(--purple-900); font-size: 1.3rem; }

main { width: min(1120px, 100%); flex: 1; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.hero { padding: clamp(2rem, 8vw, 5rem) 0; max-width: 760px; }
.hero h1 { margin: 0 0 1rem; font-size: clamp(2.3rem, 9vw, 5.6rem); line-height: 0.96; letter-spacing: -0.05em; color: var(--purple-950); }
.hero h1 span { color: var(--purple-600); }
.hero > p { max-width: 620px; color: var(--muted); font-size: clamp(1.05rem, 3vw, 1.3rem); }
.eyebrow { margin: 0 0 0.65rem; color: var(--purple-700); font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase; font-size: 0.75rem; }

.action-grid, .grid, .summary-grid { display: grid; gap: 1rem; }
.action-grid { grid-template-columns: 1fr; margin-top: 2rem; }
.action-card, .card {
  display: block;
  padding: 1.2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(53, 24, 79, 0.06);
}
.action-card { text-decoration: none; transition: transform 160ms ease, border-color 160ms ease; }
.action-card:hover { transform: translateY(-3px); border-color: var(--purple-600); }
.action-card strong { display: block; margin-bottom: 0.25rem; color: var(--purple-900); font-size: 1.08rem; }
.action-card span, .muted { color: var(--muted); }

.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; }
.page-head h1 { margin: 0; color: var(--purple-950); font-size: clamp(1.8rem, 6vw, 3.1rem); line-height: 1; letter-spacing: -0.035em; }
.page-head p { margin: 0.55rem 0 0; color: var(--muted); }

.card { margin-bottom: 1rem; }
.card h2, .card h3 { margin-top: 0; color: var(--purple-900); }
.compact { padding: 0.9rem 1rem; }
.inset { background: var(--purple-50); border-color: var(--purple-100); box-shadow: none; }
.success-card { background: var(--success-bg); border-color: #a9dec5; }
.danger-card { background: var(--danger-bg); border-color: #f5c2be; }

.field { display: grid; gap: 0.4rem; margin-bottom: 1rem; }
.field label, .field > span { font-weight: 750; font-size: 0.9rem; }
.field small { color: var(--muted); }
input, select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 0.68rem 0.8rem;
  color: var(--ink);
  background: white;
  border: 1px solid #cfc4d6;
  border-radius: 12px;
  outline: none;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--purple-600); box-shadow: 0 0 0 3px rgba(123, 75, 193, 0.14); }

.button-row { display: flex; flex-wrap: wrap; gap: 0.65rem; align-items: center; }
.button, button.button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.68rem 1rem;
  border: 1px solid transparent;
  border-radius: 12px;
  color: white;
  background: var(--purple-700);
  font-weight: 800;
  text-decoration: none;
}
.button:hover { background: var(--purple-800); }
.button.secondary { color: var(--purple-900); background: white; border-color: var(--line); }
.button.secondary:hover { background: var(--purple-50); }
.button.success { background: var(--success); }
.button.danger { color: var(--danger); background: white; border-color: #efb8b3; }
.button.small { min-height: 36px; padding: 0.4rem 0.65rem; font-size: 0.86rem; }
.button:disabled { cursor: not-allowed; opacity: 0.5; }

.route-card { position: relative; overflow: hidden; padding-left: 1.35rem; }
.route-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--purple-600); }
.route-meta { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 0.8rem; }
.route-meta strong { color: var(--purple-900); font-size: 1.1rem; }
.route-time { color: var(--purple-700); font-weight: 850; }
.offer-options { display: grid; gap: 0.55rem; }
.offer-option { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.7rem; padding: 0.8rem; border: 1px solid var(--line); border-radius: 12px; background: white; cursor: pointer; }
.offer-option:has(input:checked) { border-color: var(--purple-600); background: var(--purple-50); box-shadow: 0 0 0 2px rgba(123, 75, 193, 0.1); }
.offer-option input { width: 20px; min-height: 20px; margin: 0; accent-color: var(--purple-700); }
.price { white-space: nowrap; color: var(--purple-800); font-weight: 850; }
.total-bar { position: sticky; bottom: 0.75rem; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem; border-radius: 16px; color: white; background: var(--purple-950); box-shadow: var(--shadow); }
.total-bar strong { font-size: 1.3rem; }

.status { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.25rem 0.55rem; border-radius: 999px; font-weight: 800; font-size: 0.78rem; }
.status.success { color: var(--success); background: var(--success-bg); }
.status.warning { color: var(--warning); background: #fff1d6; }
.status.neutral { color: var(--muted); background: #eeeaf0; }

.count-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.7rem; margin-bottom: 1rem; }
.count-card { padding: 0.9rem; background: var(--purple-950); color: white; border-radius: 14px; }
.count-card span, .count-card strong { display: block; }
.count-card span { min-height: 2.6rem; opacity: 0.78; font-size: 0.85rem; }
.count-card strong { margin-top: 0.3rem; font-size: 1.35rem; }

.person-list { display: grid; gap: 0.65rem; }
.person-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0.8rem; padding: 0.85rem; border: 1px solid var(--line); border-radius: 14px; background: white; }
.person-card.redeemed { background: var(--success-bg); border-color: #aadcc6; }
.person-card.no-order { opacity: 0.62; background: #f1eef3; }
.person-name { font-weight: 850; }
.person-offer { color: var(--muted); font-size: 0.88rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; background: white; font-size: 0.9rem; }
th, td { padding: 0.72rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--purple-900); background: var(--purple-50); font-size: 0.76rem; letter-spacing: 0.04em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }

.tabs { display: flex; gap: 0.35rem; overflow-x: auto; margin-bottom: 1rem; padding-bottom: 0.25rem; }
.tab { white-space: nowrap; padding: 0.55rem 0.8rem; border: 1px solid var(--line); border-radius: 999px; background: white; color: var(--muted); font-weight: 800; }
.tab.active { color: white; background: var(--purple-700); border-color: var(--purple-700); }
.split { display: grid; gap: 1rem; }
.participant-form, .participant-filters { display: grid; gap: 0.8rem; align-items: end; }
.participant-form .field, .participant-filters .field { margin-bottom: 0; }
.participant-name-input { min-width: 220px; }
.summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metric { padding: 1rem; border-radius: 14px; background: var(--purple-50); }
.metric span, .metric strong { display: block; }
.metric span { color: var(--muted); font-size: 0.82rem; }
.metric strong { color: var(--purple-900); font-size: 1.55rem; }

.toast { position: fixed; left: 50%; bottom: 1rem; z-index: 50; width: min(92vw, 480px); padding: 0.85rem 1rem; border-radius: 12px; color: white; background: var(--purple-950); box-shadow: var(--shadow); opacity: 0; transform: translate(-50%, 130%); transition: 180ms ease; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }
.loading { display: grid; place-items: center; min-height: 230px; color: var(--muted); }
.empty { padding: 1.4rem; color: var(--muted); text-align: center; border: 1px dashed #cfc4d6; border-radius: 14px; }

footer { display: flex; justify-content: space-between; gap: 1rem; padding: 1rem max(1rem, env(safe-area-inset-left)); color: var(--muted); background: white; border-top: 1px solid var(--line); font-size: 0.8rem; }

@media (min-width: 720px) {
  .icon-button { display: none; }
  nav { position: static; display: flex; min-width: auto; padding: 0; background: transparent; border: 0; box-shadow: none; }
  main { padding-top: 2.4rem; }
  .action-grid { grid-template-columns: repeat(3, 1fr); }
  .grid.two, .split { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .participant-form { grid-template-columns: minmax(220px, 2fr) minmax(120px, 1fr) minmax(130px, 1fr) auto; }
  .participant-filters { grid-template-columns: minmax(240px, 2fr) minmax(130px, 1fr) minmax(130px, 1fr); }
  .summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .count-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
