:root {
  --navy: #14213d;
  --navy-2: #1f2f52;
  --cream: #f7f3ea;
  --paper: #ffffff;
  --ink: #1b1b1f;
  --muted: #6b6b76;
  --line: #e4ded1;
  --gold: #a9834a;
  --green: #2f7d4f;
  --green-bg: #e6f2ea;
  --amber: #a26200;
  --amber-bg: #fdf1dc;
  --red: #b3261e;
  --red-bg: #fbe7e5;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 4px 16px rgba(20, 33, 61, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.4 Inter, system-ui, sans-serif;
  background: var(--cream);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }

/* Splash */
.splash { min-height: 100vh; display: grid; place-items: center; background: var(--navy); }
.splash-card { background: var(--cream); border-radius: 20px; padding: 48px 40px; text-align: center; width: min(420px, calc(100% - 32px)); }
.crest { font: 600 13px Inter; letter-spacing: .3em; text-transform: uppercase; color: var(--gold); }
.splash h1 { font: 600 44px 'Cormorant Garamond', serif; margin: 6px 0 4px; color: var(--navy); }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: var(--navy); color: #fff;
}
.brand select {
  background: transparent; color: #fff; border: 0; font: 600 24px 'Cormorant Garamond', serif;
  padding: 4px 24px 4px 0; appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, #fff 50%), linear-gradient(135deg, #fff 50%, transparent 50%);
  background-position: right 8px center, right 3px center; background-size: 5px 5px; background-repeat: no-repeat;
}
.brand select option { color: var(--ink); }
.brand select:disabled { background-image: none; cursor: default; opacity: 1; }
.tabs { display: flex; gap: 6px; margin: 0 auto; }
.tab {
  background: transparent; color: rgba(255,255,255,.75); border: 0; border-radius: 999px;
  padding: 10px 18px; font-weight: 500; min-height: 44px;
}
.tab.active { background: var(--cream); color: var(--navy); }
.pill { display: inline-block; min-width: 26px; padding: 1px 8px; border-radius: 999px; background: var(--gold); color: #fff; font-size: 13px; margin-left: 4px; }
.user { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.link { background: none; border: 0; color: rgba(255,255,255,.85); text-decoration: underline; text-underline-offset: 3px; }
.sync { width: 10px; height: 10px; border-radius: 50%; background: #7a8; display: inline-block; }
.sync.stale { background: #e0a400; }
.sync.err { background: #e5484d; }

main { padding: 20px; max-width: 1280px; margin: 0 auto; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--paper); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat.accent { background: var(--navy); color: #fff; }
.stat-n, .stepper output { font-variant-numeric: lining-nums tabular-nums; }
.stat-n { font: 600 40px/1 Inter, system-ui, sans-serif; letter-spacing: -.02em; }
.stat-l { font-size: 13px; color: var(--muted); margin-top: 6px; text-transform: uppercase; letter-spacing: .06em; }
.stat.accent .stat-l { color: rgba(255,255,255,.7); }

.toolbar, .searchbar { margin-bottom: 14px; }
input[type=search], .searchbar input, #approve-name, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: 12px 16px;
}
.searchbar input { font-size: 24px; padding: 18px 22px; border-radius: 16px; box-shadow: var(--shadow); border-color: transparent; }
input:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

/* Cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.card {
  display: flex; align-items: center; gap: 14px; text-align: left; width: 100%;
  background: var(--paper); border: 0; border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); color: inherit;
}
.card:active { transform: scale(.995); }
.card .body { flex: 1; min-width: 0; }
.card .name { font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .sub { color: var(--muted); font-size: 14px; display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 2px; }
.card .actions { display: flex; gap: 8px; }

.avatar, .photo-lg {
  flex: none; border-radius: 50%; background: var(--navy-2) center/cover no-repeat; color: #fff;
  display: grid; place-items: center; font-family: 'Cormorant Garamond', serif; font-weight: 600; overflow: hidden;
}
.avatar { width: 56px; height: 56px; font-size: 22px; }
.avatar img, .photo-lg img { width: 100%; height: 100%; object-fit: cover; }
.photo-lg { width: 140px; height: 140px; font-size: 52px; border-radius: 20px; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #eee; color: #444; }
.badge.vip { background: #f3e9d6; color: #7a5a22; }
.badge.ok { background: var(--green-bg); color: var(--green); }
.badge.warn { background: var(--amber-bg); color: var(--amber); }
.badge.bad { background: var(--red-bg); color: var(--red); }
.badge.bday { background: #fde8f1; color: #9b2c5a; }
.badge.book { background: #e7edf8; color: var(--navy); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.btn {
  border: 0; border-radius: 12px; padding: 12px 18px; min-height: 48px; font-weight: 600;
  background: #ece6d9; color: var(--navy);
}
.btn.primary { background: var(--navy); color: #fff; }
.btn.go { background: var(--green); color: #fff; }
.btn.danger { background: var(--red); color: #fff; }
.btn.ghost { background: transparent; color: var(--navy); border: 1px dashed var(--line); }
.btn.big { font-size: 18px; padding: 16px 28px; width: 100%; margin-top: 16px; }
.btn:disabled { opacity: .5; cursor: default; }

/* Location chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; clear: both; }
.toolbar .chips { margin-top: 10px; }
.chip {
  border: 1px solid var(--line); background: var(--paper); color: var(--navy); border-radius: 999px;
  padding: 8px 16px; min-height: 44px; font-weight: 500;
}
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip .n { font-variant-numeric: lining-nums tabular-nums; opacity: .7; margin-left: 4px; }
.card .loc { color: var(--navy); font-weight: 600; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Sheet */
dialog.sheet { border: 0; border-radius: 22px; padding: 0; width: min(760px, calc(100% - 24px)); max-height: calc(100vh - 32px); background: var(--cream); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
dialog.sheet.small { width: min(440px, calc(100% - 24px)); }
dialog::backdrop { background: rgba(20, 33, 61, .55); }
.sheet-inner { padding: 24px; position: relative; }
.close { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 32px; color: var(--muted); width: 48px; height: 48px; }
.profile { display: flex; gap: 20px; align-items: center; }
.p-head h2 { font: 600 34px/1.1 'Cormorant Garamond', serif; margin: 0; color: var(--navy); }
.p-meta { color: var(--muted); margin-top: 4px; }
.alert { margin-top: 14px; padding: 12px 14px; border-radius: 12px; font-weight: 500; }
.alert.warn { background: var(--amber-bg); color: var(--amber); }
.alert.bad { background: var(--red-bg); color: var(--red); }
.alert.info { background: #e7edf8; color: var(--navy); }
.alert.ok { background: var(--green-bg); color: var(--green); }
.alert .note { font-weight: 400; color: var(--ink); white-space: pre-wrap; }

fieldset.guests { border: 0; margin: 18px 0 0; padding: 16px; background: var(--paper); border-radius: var(--radius); }
fieldset.guests legend { font: 600 22px 'Cormorant Garamond', serif; color: var(--navy); padding: 0; float: left; width: 100%; margin-bottom: 8px; }
.steppers { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; clear: both; }
.sg-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
.stepper { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.stepper span { flex: 1; }
.stepper button { width: 48px; height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--cream); font-size: 24px; color: var(--navy); }
.stepper output { min-width: 32px; text-align: center; font: 600 24px Inter, system-ui, sans-serif; }
.guest-names { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.guest-row { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 8px; }
.guest-row input { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--paper); padding: 0 12px; min-height: 44px; }
.seg button.on { background: var(--navy); color: #fff; }
.guest-row .rm { border: 0; background: none; font-size: 22px; color: var(--muted); width: 40px; }
textarea { margin-top: 10px; resize: vertical; }
.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
/* Keep Sign in / Save visible however long the sheet is */
#sheet .sheet-actions { position: sticky; bottom: 0; margin: 18px -24px -24px; padding: 14px 24px 20px; background: var(--cream); border-top: 1px solid var(--line); z-index: 1; }
.sheet-actions .btn { min-width: 140px; }
.sheet-actions .btn.go { flex: 1; font-size: 18px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120%);
  background: var(--navy); color: #fff; padding: 14px 22px; border-radius: 14px; font-weight: 500;
  transition: transform .25s ease, opacity .25s ease; z-index: 50; max-width: calc(100% - 32px);
  opacity: 0; pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.err { background: var(--red); }

@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; }
  .tabs { order: 3; width: 100%; margin: 0; }
  .tab { flex: 1; }
  .user { margin-left: auto; }
  main { padding: 16px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .steppers { grid-template-columns: 1fr; }
  .profile { flex-direction: column; text-align: center; }
  .badges { justify-content: center; }
  .guest-row { grid-template-columns: 1fr 1fr; }
}
