:root {
  --bg: #faf7f4;
  --surface: #ffffff;
  --surface-2: #f3eee9;
  --border: #e7dfd7;
  --text: #2a2320;
  --muted: #776b64;
  --accent: #e0485f;
  --accent-strong: #c73049;
  --accent-soft: #fde8eb;
  --gold: #f6b73c;
  --danger: #c62f2f;
  --shadow: 0 1px 2px rgb(42 35 32 / 0.06), 0 6px 20px rgb(42 35 32 / 0.06);
  --radius: 14px;

  --st-idea: #7b8794;
  --st-buy: #d98a00;
  --st-purchased: #2f7bd8;
  --st-received: #8a4fd6;
  --st-wrapped: #1f9d6b;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17131a;
    --surface: #221d25;
    --surface-2: #2c2630;
    --border: #3a333f;
    --text: #f2edf0;
    --muted: #ab9fa8;
    --accent: #ff6b80;
    --accent-strong: #ff8597;
    --accent-soft: #3d2129;
    --danger: #ff6b6b;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 6px 20px rgb(0 0 0 / 0.25);

    --st-idea: #9aa6b2;
    --st-buy: #f0a826;
    --st-purchased: #5b9cf0;
    --st-received: #a97cf0;
    --st-wrapped: #3cc28d;

    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent-strong); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: clamp(1.6rem, 4vw, 2.1rem); letter-spacing: -0.02em; }
h2 { font-size: 1.2rem; }

.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;
}

.container { max-width: 1120px; margin: 0 auto; padding: 24px 16px 64px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px max(16px, calc((100vw - 1120px) / 2 + 16px));
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar[hidden] { display: none; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.brand-mark { font-size: 1.3rem; }
.account { display: flex; align-items: center; gap: 10px; min-width: 0; }
.account-name { color: var(--muted); font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: min(40ch, 42vw); }
@media (max-width: 560px) { .account-name { display: none; } }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px;
  border: 1px solid transparent; border-radius: 10px;
  background: var(--accent); color: #fff;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background 0.15s, transform 0.05s, border-color 0.15s;
}
.btn:hover { background: var(--accent-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: 0.875rem; }
.btn-icon { min-height: 32px; width: 32px; padding: 0; }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
input, select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.form-error { color: var(--danger); font-size: 0.9rem; min-height: 1.3em; margin: 0; }

/* ---------- Auth ---------- */
.auth {
  display: grid; grid-template-columns: 1.1fr 1fr; gap: 40px; align-items: center;
  min-height: calc(100vh - 120px);
}
@media (max-width: 820px) { .auth { grid-template-columns: 1fr; gap: 24px; min-height: 0; } }
.auth-hero h1 { font-size: clamp(2rem, 6vw, 3rem); margin-bottom: 12px; }
.auth-hero p { color: var(--muted); font-size: 1.1rem; max-width: 46ch; }
.auth-steps { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; padding: 0; list-style: none; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.auth-card { padding: 28px; display: grid; gap: 16px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; gap: 4px; background: var(--surface-2); border-radius: 12px; }
.tabs button { min-height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.auth-card form { display: grid; gap: 14px; }

/* ---------- Status pills ---------- */
.pill {
  --c: var(--st-idea);
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--c) 14%, transparent);
  color: color-mix(in srgb, var(--c) 80%, var(--text));
  font-size: 0.8rem; font-weight: 600; white-space: nowrap;
}
.st-idea { --c: var(--st-idea); }
.st-buy { --c: var(--st-buy); }
.st-purchased { --c: var(--st-purchased); }
.st-received { --c: var(--st-received); }
.st-wrapped { --c: var(--st-wrapped); }

/* ---------- Page header & stats ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head p { color: var(--muted); margin: 6px 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.back { display: inline-flex; gap: 4px; margin-bottom: 10px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.9rem; }
.back:hover { color: var(--text); }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 28px; }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* Home page: six figures in one row on wide screens, three per row on tablets. */
.stats-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1000px) { .stats-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .stats-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { padding: 14px 16px; }
.stat-label { color: var(--muted); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 1.45rem; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }

/* ---------- Budget bar ---------- */
.budget { display: grid; gap: 6px; }
.budget-bar { position: relative; display: flex; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.budget-bar span { height: 100%; }
.budget-bar .spent { background: var(--st-wrapped); }
.budget-bar .planned { background: repeating-linear-gradient(45deg, var(--st-buy), var(--st-buy) 4px, color-mix(in srgb, var(--st-buy) 60%, transparent) 4px, color-mix(in srgb, var(--st-buy) 60%, transparent) 8px); }
.budget.over .budget-bar .spent { background: var(--danger); }
.budget-legend { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.budget-legend strong { color: var(--text); }
.budget.over .remaining { color: var(--danger); font-weight: 700; }

/* ---------- People grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.person-card {
  display: grid; gap: 14px; padding: 18px; align-content: start;
  color: inherit; text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.person-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.person-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  flex: none; display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
  color: #fff; font-weight: 800; letter-spacing: 0.02em;
}
.avatar-lg { width: 56px; height: 56px; font-size: 1.2rem; }
.person-name { font-weight: 700; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-sub { color: var(--muted); font-size: 0.85rem; }
.status-counts { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px; }

.add-card {
  display: grid; place-items: center; gap: 6px; min-height: 170px; padding: 18px;
  border: 2px dashed var(--border); border-radius: var(--radius);
  background: transparent; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer;
}
.add-card:hover { border-color: var(--accent); color: var(--accent-strong); background: var(--accent-soft); }
.add-card .plus { font-size: 2rem; line-height: 1; }

.empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.empty .big { font-size: 3rem; }
.empty h2 { color: var(--text); margin: 8px 0 6px; }

/* ---------- Person detail ---------- */
.person-header { display: grid; gap: 18px; padding: 20px; margin-bottom: 24px; }
.person-header-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.person-header .notes { color: var(--muted); white-space: pre-wrap; margin: 0; }

.add-gift { padding: 18px; margin-bottom: 24px; }
.add-gift h2 { margin-bottom: 12px; }
.add-gift form { display: grid; grid-template-columns: 2fr 2fr 1fr auto; gap: 10px; align-items: end; }
@media (max-width: 820px) { .add-gift form { grid-template-columns: 1fr 1fr; } .add-gift form .field-name, .add-gift form .field-url { grid-column: 1 / -1; } }
.add-gift .form-error { grid-column: 1 / -1; min-height: 0; }

.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; scrollbar-width: thin; }
.filters button {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
}
.filters button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.filters .count { font-variant-numeric: tabular-nums; opacity: 0.7; }

.gift-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.gift-card { display: flex; flex-direction: column; overflow: hidden; }
.gift-image { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); }
.gift-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gift-image.product img { object-fit: contain; background: #fff; }
.gift-image .pill { position: absolute; top: 10px; left: 10px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(4px); }
.gift-image.loading::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.35), transparent);
  animation: shimmer 1.1s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.gift-body { display: grid; gap: 10px; padding: 14px; flex: 1; align-content: start; }
.gift-title-row { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.gift-name { font-weight: 700; overflow-wrap: anywhere; }
.gift-price { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gift-link { font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gift-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 14px 14px; }
.gift-foot .btn { flex: 1; }

/* Status stepper */
.stepper { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 0; padding: 0; list-style: none; }
.stepper button {
  display: grid; justify-items: center; gap: 3px; width: 100%;
  padding: 4px 0; border: 0; background: none; color: var(--muted);
  font: inherit; font-size: 0.66rem; font-weight: 600; cursor: pointer; border-radius: 8px;
}
.stepper button:hover { background: var(--surface-2); color: var(--text); }
.stepper .bar { width: 100%; height: 6px; border-radius: 999px; background: var(--surface-2); }
.stepper .done .bar { background: var(--c); }
.stepper .current { color: var(--text); }
.stepper .current .bar { box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 35%, transparent); }

/* Card menu */
.menu { position: relative; }
.menu-list {
  position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 5;
  display: grid; min-width: 190px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.menu-list[hidden] { display: none; }
.menu-list button {
  text-align: left; padding: 8px 10px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font: inherit; font-size: 0.9rem; cursor: pointer;
}
.menu-list button:hover { background: var(--surface-2); }
.menu-list .danger { color: var(--danger); }

/* ---------- Modal ---------- */
.modal {
  width: min(480px, calc(100vw - 32px)); padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgb(0 0 0 / 0.3);
}
.modal::backdrop { background: rgb(20 14 18 / 0.5); backdrop-filter: blur(2px); }
.modal form { display: grid; gap: 14px; padding: 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.modal p { margin: 0; color: var(--muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 10px 18px; border-radius: 999px;
  background: var(--text); color: var(--bg); font-weight: 600; box-shadow: var(--shadow);
}

.loading-page { padding: 80px 0; text-align: center; color: var(--muted); }

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

/* ---------- Plans & account ---------- */
.muted { color: var(--muted); margin: 6px 0 0; }
.link-button {
  justify-self: center; padding: 4px; border: 0; background: none;
  color: var(--accent-strong); font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
}
.link-button:hover { text-decoration: underline; }
.pricing-note { margin-top: 18px; font-size: 1rem; }
.pricing-note strong { color: var(--text); }

.plan-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); font-size: 0.8rem; font-weight: 700;
  white-space: nowrap; text-decoration: none;
}
.plan-chip.premium { background: color-mix(in srgb, var(--gold) 22%, transparent); color: color-mix(in srgb, var(--gold) 45%, var(--text)); }
.btn-upgrade { background: var(--gold); color: #3a2a00; }
.btn-upgrade:hover { background: color-mix(in srgb, var(--gold) 85%, #000); }

.account-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 760px) { .account-grid { grid-template-columns: 1fr; } }
.plan-card { display: grid; gap: 14px; padding: 20px; }
.plan-card p { margin: 0; color: var(--muted); }
.plan-card.premium { border-color: color-mix(in srgb, var(--gold) 55%, var(--border)); }
.plan-title { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.meter { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.inline-form { display: grid; gap: 10px; }
.inline-form .btn { justify-self: start; }

.upgrade-pitch { display: grid; gap: 10px; }
.perks { display: grid; gap: 8px; margin: 0; padding: 14px 16px; list-style: none; background: var(--surface-2); border-radius: 12px; }
.add-card-note { font-size: 0.8rem; font-weight: 500; color: var(--muted); }
.plan-card > .btn { justify-self: start; }
.btn { white-space: nowrap; }

/* Read-only people after Premium lapses */
.person-card.locked { opacity: 0.75; }
.person-card.locked:hover { opacity: 1; }
.locked-notice {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px;
  padding: 18px; margin-bottom: 24px;
  border-color: color-mix(in srgb, var(--gold) 55%, var(--border));
  background: color-mix(in srgb, var(--gold) 8%, var(--surface));
}
.locked-notice > div { flex: 1 1 320px; }
.locked-notice p { margin: 6px 0 0; color: var(--muted); }
.stepper button:disabled { cursor: default; }
.stepper button:disabled:hover { background: none; color: var(--muted); }
.stepper .current button:disabled:hover { color: var(--text); }
.locked-chip { margin-left: 8px; padding: 1px 8px; font-size: 0.75rem; }

/* ---------- Legal pages & footer ---------- */
.site-footer {
  max-width: 1120px; margin: 0 auto; padding: 0 16px 32px;
  color: var(--muted); font-size: 0.85rem; text-align: center;
}
.site-footer a { color: inherit; }
.fine-print { margin: 0; color: var(--muted); font-size: 0.85rem; text-align: center; }
.upgrade-pitch .fine-print { text-align: left; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.danger-zone .btn { justify-self: start; }

.legal { max-width: 760px; line-height: 1.65; }
.legal h1 { margin-bottom: 4px; }
.legal h2 { margin: 32px 0 8px; font-size: 1.15rem; }
.legal .updated { color: var(--muted); margin-top: 0; }
.legal ul { padding-left: 22px; }
.legal li { margin: 6px 0; }
.legal code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }

/* ---------- Past gifts ---------- */
.past-gifts { display: grid; gap: 14px; margin-top: 36px; }
.past-gifts > h2 { font-size: 1.3rem; }
.past-hint { color: var(--muted); font-size: 0.9rem; text-align: center; padding: 8px 16px; }
.past-hint strong { color: var(--text); }
.past-locked {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; padding: 18px;
}
.past-locked > div { flex: 1 1 260px; }
.past-locked p { margin: 6px 0 0; color: var(--muted); }
.past-group { padding: 16px 18px; }
.past-group-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-bottom: 8px; }
.past-group-head h3 { font-size: 1.05rem; }
.past-list { display: grid; margin: 0; padding: 0; list-style: none; }
.past-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.past-list li:first-child { border-top: 0; }
.past-list img { flex: none; width: 56px; height: 42px; object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.past-list img.product { object-fit: contain; background: #fff; }
.past-info { flex: 1; min-width: 0; }
.past-info .gift-name { font-weight: 600; overflow-wrap: anywhere; }
.past-info a { color: inherit; }
.past-actions { display: flex; gap: 6px; flex: none; }

@media (max-width: 560px) {
  .topbar { gap: 8px; }
  .account { gap: 6px; }
  .brand { font-size: 1.05rem; }
  .account .btn-sm { padding: 4px 10px; }
}
.field-note { margin: -4px 0 0; color: var(--muted); font-size: 0.85rem; }
.field-note strong { color: var(--text); }
@media (min-width: 761px) {
  /* Profile on the right; plan and delete stacked on the left. */
  .account-grid { grid-template-rows: auto 1fr; }
  .account-grid > :nth-child(2) { grid-column: 2; grid-row: 1 / span 2; }
}
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; opacity: 0; }

/* ---------- Admin ---------- */
.stat-note { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
.admin-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; align-items: start; }
@media (max-width: 900px) { .admin-grid { grid-template-columns: 1fr; } }
.admin-card { padding: 18px; }
.admin-card h2 { margin-bottom: 10px; font-size: 1.05rem; }
.admin-list { display: grid; margin: 0; padding: 0; list-style: none; }
.admin-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 0.92rem; }
.admin-list li:first-child { border-top: 0; }
.admin-list strong { font-variant-numeric: tabular-nums; }
.weeks li span:first-child { flex: none; width: 9.5em; color: var(--muted); }
.week-bar { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.week-bar span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.plan-chip.warn { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.admin-users-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.admin-users-head h2 { margin: 0; }
.admin-users-head input { max-width: 280px; min-height: 36px; }
.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.admin-table th { text-align: left; color: var(--muted); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.admin-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.admin-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.admin-table .cell-strong { font-weight: 600; }
.admin-table .empty-cell { text-align: center; color: var(--muted); padding: 24px; }
#admin-link[hidden] { display: none; }
@media (max-width: 560px) { #admin-link { padding: 4px 8px; } }

/* ---------- Cards / List toggle ---------- */
.gift-toolbar { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.gift-toolbar .filters { flex: 1; min-width: 0; margin-bottom: 0; }
.view-toggle { flex: none; display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.view-toggle button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 4px 12px;
  border: 0; border-radius: 999px; background: none; color: var(--muted);
  font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.view-toggle button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
@media (max-width: 560px) { .view-label { display: none; } .view-toggle button { padding: 4px 10px; } }

/* ---------- List view ---------- */
.gift-grid.list { grid-template-columns: 1fr; gap: 8px; }
.gift-row {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) auto 150px auto;
  align-items: center; gap: 14px; padding: 8px 12px 8px 8px;
}
.gift-thumb { position: relative; width: 64px; height: 48px; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.gift-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gift-thumb.product img { object-fit: contain; background: #fff; }
.gift-thumb.loading::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.35), transparent);
  animation: shimmer 1.1s infinite;
}
.gift-row-main { min-width: 0; }
.gift-row-main .gift-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gift-row-meta { font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gift-row .gift-price { text-align: right; }
.status-select {
  min-height: 34px; padding: 4px 8px; font-size: 0.85rem; font-weight: 600;
  border-color: color-mix(in srgb, var(--c) 45%, var(--border));
  background: color-mix(in srgb, var(--c) 10%, var(--surface));
}
.status-select:disabled { opacity: 1; cursor: default; }
.gift-row-actions { display: flex; align-items: center; gap: 6px; justify-content: flex-end; min-width: 150px; }
.gift-row-actions .ready { padding: 0 8px; font-size: 1.1rem; }
/* Short rows: open the menu downwards so it isn't clipped. */
.gift-row .menu-list { bottom: auto; top: calc(100% + 6px); }
@media (max-width: 720px) {
  .gift-row {
    grid-template-columns: 56px minmax(0, 1fr) auto;
    grid-template-areas: "thumb main price" "thumb status actions";
    gap: 6px 12px;
  }
  .gift-row .gift-thumb { grid-area: thumb; width: 56px; height: 56px; align-self: start; }
  .gift-row-main { grid-area: main; }
  .gift-row .gift-price { grid-area: price; }
  .gift-row .status-select { grid-area: status; width: 100%; min-width: 0; }
  .gift-row-actions { grid-area: actions; min-width: 0; }
  /* Room is tight: let names use two lines, and show just the icon on the move button. */
  .gift-row-main .gift-name {
    white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere;
  }
}
@media (max-width: 720px) { .gift-row-actions .move-label { display: none; } }

/* ---------- Celebrations ---------- */
.stat.complete {
  border-color: color-mix(in srgb, var(--st-wrapped) 55%, var(--border));
  background: color-mix(in srgb, var(--st-wrapped) 10%, var(--surface));
}
.stat.complete .stat-label,
.stat.complete .stat-value { color: var(--st-wrapped); }
.firework { display: inline-block; animation: pop 0.6s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes pop { from { transform: scale(0) rotate(-30deg); opacity: 0; } to { transform: none; opacity: 1; } }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 100; }

/* ---------- Overall budget ---------- */
.overall-panel { display: grid; gap: 14px; padding: 18px 20px; margin: -8px 0 24px; }
.overall-panel h2 { font-size: 1.1rem; }
.overall-panel p { margin: 6px 0 0; color: var(--muted); }
.overall-panel p strong { color: var(--text); }
.empty-overall { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; }
.empty-overall > div { flex: 1 1 280px; }
.overall-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; }
.overall-head > div { flex: 1 1 280px; }
.over-text, .allocation-summary.over { color: var(--danger); font-weight: 600; }
.allocation-bar { display: flex; height: 12px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.allocation-bar span { height: 100%; border-right: 2px solid var(--surface); }
.allocation-bar span:last-child { border-right: 0; }
.overall-panel.over .allocation-bar { box-shadow: 0 0 0 2px color-mix(in srgb, var(--danger) 45%, transparent); }

.modal { max-height: calc(100vh - 32px); overflow: auto; }
.allocation-list { display: grid; gap: 4px; max-height: 45vh; overflow: auto; padding-right: 2px; }
.allocation-row { display: grid; grid-template-columns: auto minmax(0, 1fr) 110px; align-items: center; gap: 12px; padding: 6px 0; border-top: 1px solid var(--border); }
.allocation-row:first-child { border-top: 0; }
.allocation-row .avatar { width: 34px; height: 34px; font-size: 0.8rem; }
.allocation-name { display: grid; min-width: 0; font-weight: 600; }
.allocation-name > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.allocation-row input { text-align: right; }
.allocation-summary { margin: 0; color: var(--muted); }
.allocation-summary strong { color: var(--text); }
.split-btn { justify-self: start; }

.celebration-banner {
  position: fixed; left: 50%; bottom: 24px; z-index: 101; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  width: max-content; max-width: calc(100vw - 32px);
  padding: 16px 20px; border-radius: 16px;
  background: var(--st-wrapped); color: #fff;
  font-size: 1.1rem; font-weight: 700; line-height: 1.35;
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.25);
  animation: banner-in 0.5s cubic-bezier(.2, 1.4, .4, 1) both;
}
.celebration-banner.leaving { animation: banner-out 0.4s ease both; }
.celebration-icon { font-size: 1.6rem; }
.celebration-close {
  flex: none; width: 30px; height: 30px; margin-left: 4px; border: 0; border-radius: 50%;
  background: rgb(255 255 255 / 0.2); color: #fff; font-size: 1.2rem; line-height: 1; cursor: pointer;
}
.celebration-close:hover { background: rgb(255 255 255 / 0.35); }
@keyframes banner-in { from { opacity: 0; transform: translate(-50%, 40px) scale(0.9); } to { opacity: 1; transform: translateX(-50%); } }
@keyframes banner-out { to { opacity: 0; transform: translate(-50%, 20px); } }
@media (max-width: 560px) { .celebration-banner { font-size: 1rem; padding: 14px 16px; } }
.optional-tag {
  display: inline-block; vertical-align: middle; margin-left: 4px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
}
.stepper button { white-space: nowrap; }
