* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { background: var(--bg-0); color-scheme: dark; }

body {
  font-family: var(--font-ui);
  background:
    radial-gradient(circle at 14% 6%, rgba(255, 138, 61, 0.1), transparent 30rem),
    radial-gradient(circle at 90% 18%, rgba(255, 255, 255, 0.04), transparent 26rem),
    linear-gradient(160deg, var(--bg-0) 0%, var(--bg-1) 55%, var(--bg-0) 100%);
  background-attachment: fixed;
  color: var(--text-0);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
button, input, textarea, select { font-family: inherit; color: inherit; }
a { color: inherit; }

::selection { background: var(--accent-dim); color: var(--text-0); }

.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Typography */
.eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-2);
}
h1, h2, h3 { font-weight: 700; letter-spacing: -0.01em; color: var(--text-0); }
.page-title { font-size: 1.6rem; }
.section-title { font-size: 1.15rem; margin-bottom: var(--space-3); }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }

/* Layout shell */
.app-shell {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--space-5) + var(--safe-t)) var(--space-4) calc(var(--nav-h) + var(--space-7) + var(--safe-b));
  min-height: 100dvh;
}

@media (min-width: 900px) {
  .app-shell {
    max-width: none;
    margin: 0;
    padding: var(--space-6) var(--space-7) var(--space-7) calc(240px + var(--space-7));
  }
}

.app-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.app-header .brand-mark {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: linear-gradient(155deg, var(--accent), #d9601a);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.95rem; color: var(--accent-ink);
  flex: none;
}

.app-header .brand-text h1 { font-size: 1.15rem; }
.app-header .brand-text .eyebrow { margin-top: 1px; }

.header-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }

.live-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px;
  border-radius: var(--radius-pill);
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.live-pill .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-strong);
  box-shadow: 0 0 0 0 var(--accent-border);
  animation: pulse-dot 1.8s infinite;
}
@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(255,138,61,.5); }
  70% { box-shadow: 0 0 0 7px rgba(255,138,61,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,138,61,0); }
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-1);
}
.card-pad { padding: var(--space-5); }
.card + .card { margin-top: var(--space-4); }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--space-2); }

.card-glow-accent { border-color: var(--accent-border); box-shadow: var(--shadow-1), var(--shadow-accent); }

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface-strong);
  color: var(--text-0);
  border-radius: var(--radius-pill);
  padding: 12px 20px;
  font-size: 0.94rem;
  font-weight: 650;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.15s var(--ease), background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,0.08); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-block { width: 100%; }

.btn-accent {
  background: linear-gradient(155deg, var(--accent), #e06a1f);
  border-color: transparent;
  color: var(--accent-ink);
  box-shadow: var(--shadow-accent);
}
.btn-accent:hover { filter: brightness(1.06); }

.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-1); }
.btn-ghost:hover { background: var(--surface); }

.btn-sm { padding: 8px 14px; font-size: 0.82rem; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: 50%; flex: none; }

.btn-danger-ghost { border-color: rgba(255,69,58,0.4); color: #ff6961; background: rgba(255,69,58,0.12); }
.btn-danger-ghost:hover { background: rgba(255,69,58,0.2); }

/* Inputs */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.8rem; color: var(--text-2); font-weight: 600; }
.input, textarea.input, select.input {
  width: 100%;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-0);
  font-size: 0.95rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.input::placeholder { color: var(--text-3); }
.input:focus, textarea.input:focus, select.input:focus {
  outline: none;
  border-color: var(--accent-border);
  background: var(--surface-strong);
}
textarea.input { resize: vertical; min-height: 90px; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border: 1px solid var(--border-strong);
  background: var(--surface-strong);
  color: var(--text-1);
}
.badge-success { color: #8ff0bb; border-color: rgba(48,209,88,0.35); background: rgba(48,209,88,0.14); }
.badge-warn { color: #ffc978; border-color: rgba(255,159,10,0.35); background: rgba(255,159,10,0.14); }
.badge-danger { color: #ff9d97; border-color: rgba(255,69,58,0.35); background: rgba(255,69,58,0.14); }
.badge-accent { color: var(--accent-strong); border-color: var(--accent-border); background: var(--accent-dim); }

/* Section label row */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: var(--space-3);
  gap: var(--space-3);
}
.section-head .eyebrow { margin: 0; }

/* Empty / error / loading states */
.empty-state, .error-state {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--text-2);
}
.empty-state .glyph, .error-state .glyph { font-size: 1.8rem; margin-bottom: var(--space-2); opacity: 0.7; }
.empty-state p, .error-state p { font-size: 0.88rem; max-width: 320px; margin: 0 auto; }
.error-state { color: #ff9d97; }

.skeleton {
  position: relative;
  overflow: hidden;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
}
.skeleton::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
  transform: translateX(-100%);
  animation: skeleton-shimmer 1.4s infinite;
}
@keyframes skeleton-shimmer { to { transform: translateX(100%); } }
.skeleton-line { height: 14px; border-radius: 6px; }
.skeleton-block { height: 90px; }

/* Toasts */
#toast-root {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--space-4) + var(--safe-b));
  transform: translateX(-50%);
  z-index: 4000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: min(92vw, 420px);
  pointer-events: none;
}
@media (min-width: 900px) {
  #toast-root { bottom: var(--space-5); }
}
.toast {
  pointer-events: auto;
  background: rgba(28,28,30,0.92);
  border: 1px solid var(--border-strong);
  backdrop-filter: blur(14px);
  border-radius: var(--radius-md);
  padding: 13px 16px;
  font-size: 0.86rem;
  box-shadow: var(--shadow-2);
  display: flex; align-items: center; gap: 10px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(255,69,58,0.4); }
.toast.success { border-color: rgba(48,209,88,0.4); }

/* "Face ID"-style authentication moment — a brief scan animation before a
   login/check-in confirmation resolves, then a checkmark hand-off. */
.auth-check { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.auth-scan {
  width: 56px; height: 56px;
  border: 3px solid var(--accent);
  border-radius: 16px;
  position: relative;
  animation: auth-scan-pulse 1.1s ease-in-out infinite;
}
.auth-scan::before { content: ""; position: absolute; inset: 15px 13px 23px; border-left: 3px solid var(--accent); border-right: 3px solid var(--accent); }
.auth-scan::after { content: ""; position: absolute; left: 15px; right: 15px; bottom: 12px; height: 7px; border-bottom: 3px solid var(--accent); border-radius: 0 0 10px 10px; }
@keyframes auth-scan-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(0.9); opacity: 0.75; } }

.auth-done {
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: #30d158;
  color: #ffffff;
  font-size: 1.6rem;
  font-weight: 800;
  animation: auth-done-in 0.3s var(--ease);
}
@keyframes auth-done-in { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.auth-check p { color: var(--text-2); font-size: 0.86rem; margin: 0; }

@media (prefers-reduced-motion: reduce) {
  .auth-scan { animation: none; }
}

/* iOS-style grouped list (Settings-app rows: one rounded container, inset
   separators, no per-row borders/gaps) */
.ios-list {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.ios-list-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 13px 16px;
  color: var(--text-0);
  position: relative;
  font-size: 0.9rem;
  cursor: pointer;
}
.ios-list-item:active { background: rgba(255,255,255,0.06); }
.ios-list-item + .ios-list-item::before {
  content: "";
  position: absolute;
  top: 0; right: 0;
  left: var(--inset, 16px);
  border-top: 1px solid var(--border);
}
.ios-list-item .ios-list-icon { flex: none; font-size: 1.05rem; width: 22px; text-align: center; }
.ios-list-item .ios-list-body { flex: 1; min-width: 0; }
.ios-list-item .ios-list-body strong { display: block; font-size: 0.9rem; overflow-wrap: anywhere; }
.ios-list-item .ios-list-body span { display: block; color: var(--text-2); font-size: 0.78rem; margin-top: 2px; overflow-wrap: anywhere; }
.ios-list-item .ios-chev { flex: none; color: var(--text-3); font-size: 1rem; }
.ios-list-item .ios-list-trail { flex: none; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* iOS-style segmented control */
.ios-segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 2px;
  border-radius: 10px;
  background: rgba(120,120,128,0.32);
  margin-bottom: var(--space-4);
}
.ios-segmented button {
  appearance: none; border: 0; background: transparent;
  min-height: 32px;
  border-radius: 8px;
  color: var(--text-0);
  font-size: 0.8rem;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.ios-segmented button.selected {
  background: var(--surface-selected);
  color: var(--text-0);
  box-shadow: 0 3px 8px rgba(0,0,0,0.3);
}

/* iOS-style native alert dialog (replaces window.confirm) */
.ios-alert-layer {
  position: fixed; inset: 0; z-index: 7000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(0,0,0,0.4);
  animation: ios-alert-bg 0.18s ease;
}
.ios-alert-layer.closing { opacity: 0; transition: opacity 0.16s ease; }
@keyframes ios-alert-bg { from { opacity: 0; } }
.ios-alert {
  width: 270px;
  overflow: hidden;
  border-radius: 14px;
  background: rgba(40, 40, 44, 0.92);
  backdrop-filter: blur(30px) saturate(1.8);
  -webkit-backdrop-filter: blur(30px) saturate(1.8);
  border: 1px solid var(--border);
  text-align: center;
  animation: ios-alert-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes ios-alert-in { from { opacity: 0; transform: scale(1.15); } }
.ios-alert-text { padding: 19px 16px 17px; }
.ios-alert-title { margin: 0; font-size: 0.98rem; font-weight: 700; color: var(--text-0); }
.ios-alert-msg { margin: 5px 0 0; font-size: 0.8rem; line-height: 1.4; color: var(--text-1); }
.ios-alert-actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border-top: 1px solid var(--border); }
.ios-alert-btn {
  min-height: 44px;
  border: 0;
  background: none;
  color: var(--accent-strong);
  font-size: 0.95rem;
  cursor: pointer;
}
.ios-alert-btn + .ios-alert-btn { border-left: 1px solid var(--border); }
.ios-alert-btn.strong { font-weight: 700; }
.ios-alert-btn.destructive { color: var(--danger); font-weight: 700; }
.ios-alert-btn:active { background: rgba(255,255,255,0.08); }

@media (prefers-reduced-motion: reduce) {
  .ios-alert, .ios-alert-layer { animation: none; }
}

/* Modal / bottom sheet */
.sheet-overlay {
  position: fixed; inset: 0;
  background: rgba(4,4,6,0.5);
  backdrop-filter: blur(10px) saturate(1.3);
  -webkit-backdrop-filter: blur(10px) saturate(1.3);
  z-index: 3000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.sheet-overlay.show { opacity: 1; pointer-events: auto; }
@media (min-width: 640px) { .sheet-overlay { align-items: center; } }

.sheet {
  width: 100%;
  max-width: 480px;
  max-height: 86vh;
  overflow-y: auto;
  background: rgba(28, 28, 30, 0.9);
  backdrop-filter: blur(24px) saturate(1.6);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  border: 1px solid var(--border-strong);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--space-5);
  padding-bottom: calc(var(--space-6) + var(--safe-b));
  transform: translateY(24px);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: var(--shadow-2);
}
.sheet-overlay.show .sheet { transform: translateY(0); }
@media (min-width: 640px) {
  .sheet { border-radius: var(--radius-lg); border-bottom: 1px solid var(--border-strong); transform: scale(0.96); }
  .sheet-overlay.show .sheet { transform: scale(1); }
}
.sheet-handle {
  width: 36px; height: 4px; border-radius: var(--radius-pill);
  background: var(--border-strong);
  margin: 0 auto var(--space-4);
}
@media (min-width: 640px) { .sheet-handle { display: none; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); }
.sheet-close {
  width: 32px; height: 32px; border-radius: 50%; border: 0;
  background: var(--surface-strong); color: var(--text-1); cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
}

/* Bottom navigation (mobile) */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 2000;
  padding: 10px 10px calc(10px + var(--safe-b));
  background: rgba(20, 20, 22, 0.82);
  backdrop-filter: blur(20px) saturate(1.6);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
}
@media (min-width: 900px) { .bottom-nav { display: none; } }

.nav-item {
  appearance: none; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 10px;
  color: var(--text-2);
  border-radius: var(--radius-sm);
  font-size: 0.66rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  transition: color 0.15s ease;
  flex: 1;
  min-width: 0;
}
.nav-item .nav-icon { font-size: 1.15rem; line-height: 1; transition: transform 0.15s var(--ease); }
.nav-item.active { color: var(--accent-strong); }
.nav-item.active .nav-icon { transform: translateY(-1px); }
.nav-item:active .nav-icon { transform: scale(0.9); }

/* Sidebar (desktop) */
.sidebar {
  display: none;
}
@media (min-width: 900px) {
  .sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 240px;
    padding: var(--space-6) var(--space-4);
    border-right: 1px solid var(--border);
    background: rgba(9, 9, 11, 0.5);
    backdrop-filter: blur(16px);
  }
  .sidebar .brand { display: flex; align-items: center; gap: 10px; margin-bottom: var(--space-6); padding: 0 var(--space-2); }
  .sidebar .brand .brand-mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(155deg, var(--accent), #d9601a); display:flex; align-items:center; justify-content:center; font-weight:800; color: var(--accent-ink); font-size:0.85rem; }
  .sidebar .brand strong { font-size: 0.95rem; }
  .sidebar-item {
    appearance: none; border: none; background: none; cursor: pointer;
    display: flex; align-items: center; gap: 12px;
    padding: 11px var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--text-1);
    font-size: 0.88rem;
    font-weight: 600;
    text-align: left;
  }
  .sidebar-item .nav-icon { font-size: 1.05rem; }
  .sidebar-item:hover { background: var(--surface); color: var(--text-0); }
  .sidebar-item.active { background: var(--accent-dim); color: var(--accent-strong); }
}

/* Views */
.view { display: none; animation: view-in 0.28s var(--ease); }
.view.active { display: block; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* Scroll on entry animation helper */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.5s var(--ease), transform 0.5s var(--ease); }
.reveal.in { opacity: 1; transform: translateY(0); }

@media (hover: none), (pointer: coarse) {
  .btn:hover, .sidebar-item:hover { background: initial; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
