:root {
  --bg: #f5f2ec;
  --surface: #fff;
  --surface-2: #faf8f4;
  --ink: #1d2c28;
  --muted: #74817d;
  --brand: #315f55;
  --brand-dark: #244c44;
  --brand-2: #dfeae6;
  --brand-3: #edf4f1;
  --line: #e7e2da;
  --danger: #a94d4d;
  --danger-bg: #fbecec;
  --warning: #96601d;
  --warning-bg: #fff2dd;
  --ok: #2f725b;
  --ok-bg: #e6f3ed;
  --reserved: #8462a8;
  --reserved-bg: #f1eaf8;
  --shadow: 0 14px 38px rgba(40, 55, 50, .09);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, textarea { font: inherit; }
button, a.btn { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.shell { width: min(1180px, 100%); margin: 0 auto; padding-inline: 18px; }
.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; }

.hero {
  color: #fff;
  padding: 28px 0 30px;
  border-radius: 0 0 30px 30px;
  background: radial-gradient(circle at top right, rgba(255,255,255,.25), transparent 28%), linear-gradient(135deg, #315f55, #47796d);
  box-shadow: var(--shadow);
}
.topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.kicker { font-size: 13px; letter-spacing: .12em; text-transform: uppercase; opacity: .8; font-weight: 800; }
h1 { font-size: clamp(31px, 6vw, 50px); letter-spacing: -.04em; margin: 4px 0 6px; }
.hero p { margin: 0; opacity: .88; max-width: 700px; line-height: 1.5; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 20px; }
.user-area { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; }
.avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,.7); }
.user-copy { display: grid; text-align: right; }
.user-copy strong { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-copy small { opacity: .75; }

.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  min-height: 44px;
  border-radius: 13px;
  padding: 10px 14px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: #fff; color: var(--brand); border-color: #fff; }
.btn-brand { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-danger { color: var(--danger); background: var(--danger-bg); border-color: #f0caca; }
.btn-google { width: 100%; margin-top: 8px; box-shadow: 0 5px 14px rgba(0,0,0,.07); }
.google-mark { color: #4285f4; font-size: 20px; font-weight: 900; }
.icon-btn {
  width: 42px; height: 42px; padding: 0; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; display: inline-grid; place-items: center; font-size: 20px; color: var(--ink);
}
.icon-on-dark { color: #fff; border-color: rgba(255,255,255,.32); background: rgba(255,255,255,.12); }

.center-view { min-height: 55vh; display: grid; place-items: center; padding-block: 48px; text-align: center; }
.center-view > p { color: var(--muted); }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--brand-2); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.welcome-card { width: min(440px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 24px; background: #fff; box-shadow: var(--shadow); }
.welcome-card h2 { margin: 4px 0 8px; font-size: 26px; }
.welcome-card p { color: var(--muted); line-height: 1.55; margin: 0 0 18px; }
.welcome-icon { font-size: 38px; }
.login-overlay { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 24px 18px; overflow: auto; background: rgba(20,29,26,.48); backdrop-filter: blur(5px); }
.login-overlay .welcome-card { text-align: left; }
.login-overlay .welcome-icon { text-align: center; }
.dev-logins { margin-top: 24px; padding-top: 18px; border-top: 1px dashed var(--line); display: grid; gap: 8px; }
.dev-logins small { color: var(--warning); font-weight: 800; }

.dashboard { margin-top: -10px; padding-bottom: 8px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.metric, .progress-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); }
.metric { min-width: 0; }
.metric small { display: block; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.metric strong { font-size: 30px; letter-spacing: -.03em; }
.progress-card { margin-top: 12px; }
.progress-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.progress-track { height: 12px; border-radius: 999px; background: #ebe7e0; overflow: hidden; display: flex; }
.progress-segment { height: 100%; width: 0; transition: width .25s ease; }
.progress-have { background: var(--brand); }
.progress-reserved { background: var(--reserved); }
.progress-legend { display: flex; justify-content: flex-end; gap: 14px; margin-top: 9px; color: var(--muted); font-size: 12px; font-weight: 700; }
.dot { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; }
.dot-have { background: var(--brand); }
.dot-reserved { background: var(--reserved); }

.controls { position: sticky; top: 0; z-index: 20; background: rgba(245,242,236,.92); backdrop-filter: blur(14px); padding: 14px 0 10px; }
.control-row { display: flex; gap: 10px; align-items: center; }
.search { flex: 1; min-width: 0; position: relative; }
.search input { width: 100%; height: 48px; border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: 0 14px 0 42px; outline: none; color: var(--ink); }
.search input:focus, .field input:focus, .field textarea:focus { border-color: #91afa5; box-shadow: 0 0 0 3px rgba(49,95,85,.1); }
.search > span:first-child { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); opacity: .55; }
.chips { display: flex; gap: 8px; overflow: auto; padding: 8px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px; padding: 9px 13px; font-weight: 800; white-space: nowrap; }
.chip.active { background: var(--brand-2); border-color: #b9cfc7; color: var(--brand); }

.category { margin: 14px 0 22px; }
.category-title { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin: 0 2px 10px; }
.category-title h2 { font-size: 19px; margin: 0; }
.category-title small { color: var(--muted); font-weight: 700; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.item-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: 0 8px 24px rgba(35,49,44,.05); display: flex; flex-direction: column; gap: 13px; transition: .18s ease; }
.item-card.complete { border-color: #c8ddd5; background: linear-gradient(180deg,#fff,#fbfefd); }
.item-card.mine { box-shadow: 0 0 0 2px rgba(132,98,168,.18), 0 8px 24px rgba(35,49,44,.05); }
.item-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.item-name { font-weight: 850; font-size: 17px; line-height: 1.28; }
.item-meta { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.badge { display: inline-flex; align-items: center; padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 900; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.partial { background: var(--warning-bg); color: var(--warning); }
.badge.missing { background: var(--danger-bg); color: var(--danger); }
.badge.reserved { background: var(--reserved-bg); color: var(--reserved); }
.note { color: var(--muted); font-size: 12px; margin-top: 7px; line-height: 1.45; }
.quantities { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.quantity { background: var(--surface-2); border-radius: 11px; padding: 8px; text-align: center; }
.quantity small { display: block; color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .03em; }
.quantity strong { display: block; margin-top: 2px; font-size: 17px; }
.item-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: auto; }
.item-actions .btn { min-height: 38px; padding: 7px 10px; font-size: 12px; }
.item-actions .gift-button { flex: 1; }
.reorder-actions { display: flex; gap: 4px; margin-right: auto; }
.reorder-btn { width: 35px; height: 35px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--brand); font-size: 16px; }
.reservation-list { border-top: 1px solid var(--line); padding-top: 10px; display: grid; gap: 7px; }
.reservation-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.reservation-row > div { min-width: 0; flex: 1; }
.reservation-row strong, .reservation-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reservation-row small { color: var(--muted); }
.mini-button { border: 0; background: var(--brand-3); color: var(--brand); border-radius: 8px; padding: 6px 8px; font-weight: 800; font-size: 11px; }
.mini-button.danger { color: var(--danger); background: var(--danger-bg); }
.empty { background: #fff; border: 1px dashed #cfc8bd; border-radius: 18px; padding: 32px; text-align: center; color: var(--muted); }
.section-foot { display: flex; justify-content: center; padding-block: 18px 70px; color: var(--muted); font-size: 13px; }

.modal { width: min(620px, calc(100% - 28px)); max-height: min(90vh, 800px); padding: 20px; border: 0; border-radius: 24px; color: var(--ink); box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.modal::backdrop { background: rgba(20,29,26,.5); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 22px; }
.modal-head small { color: var(--muted); font-weight: 800; }
.modal-copy { color: var(--muted); line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 800; }
.field input, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; outline: none; background: #fff; color: var(--ink); }
.field textarea { min-height: 90px; resize: vertical; }
.field-help { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.gift-list { display: grid; gap: 9px; }
.gift-row { display: flex; justify-content: space-between; gap: 14px; padding: 12px; background: var(--surface-2); border-radius: 13px; }
.gift-row span { color: var(--reserved); font-weight: 850; white-space: nowrap; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translate(-50%, 25px); max-width: min(480px, calc(100% - 28px)); padding: 12px 16px; background: var(--ink); color: #fff; border-radius: 12px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #762f2f; }

@media (max-width: 800px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { grid-template-columns: 1fr; }
  .hero { border-radius: 0 0 24px 24px; }
  .topline { display: block; }
  .user-area { margin-top: 18px; }
  .user-copy { text-align: left; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
}
@media (max-width: 480px) {
  .hero-actions .btn { flex: 1 1 auto; }
  .welcome-card { padding: 24px 18px; }
  .metric strong { font-size: 25px; }
  .modal { padding: 17px; }
}
@media print {
  body { background: #fff; }
  .hero { background: #fff; color: #000; box-shadow: none; padding: 0 0 15px; border-radius: 0; }
  .hero p { color: #444; }
  .hero-actions, .user-area, .controls, .item-actions, .reservation-list, .section-foot { display: none !important; }
  .shell { max-width: none; padding: 0; }
  .dashboard { margin: 0; }
  .metrics { grid-template-columns: repeat(4, 1fr); }
  .metric, .progress-card, .item-card { box-shadow: none; }
  .grid { grid-template-columns: 1fr 1fr; }
}
