/* ============================================================
   Wedding Planner — Design System
   Aesthetic: Editorial, warm, refined. Chinese heritage meets
   modern minimalism. Display serif + clean sans. Cream + burgundy + gold.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Manrope:wght@300;400;500;600;700&display=swap');

:root {
  /* Colors */
  --cream: #FAF4EC;
  --cream-deep: #F3E9D8;
  --surface: #FFFFFF;
  --ink: #1A1614;
  --ink-soft: #4A4239;
  --ink-faint: #8B8378;
  --burgundy: #8B1A1A;
  --burgundy-deep: #5C0F0F;
  --gold: #B8935E;
  --gold-soft: #D4A574;
  --sage: #7A8471;
  --amber: #C9824A;
  --danger: #9E3C2D;
  --line: #E8DDC9;
  --line-soft: #F0E6D5;

  /* Type */
  --font-serif: 'Cormorant Garamond', 'Times New Roman', serif;
  --font-sans: 'Manrope', -apple-system, sans-serif;

  /* Shadow */
  --shadow-xs: 0 1px 2px rgba(26, 22, 20, 0.04);
  --shadow-sm: 0 2px 8px rgba(26, 22, 20, 0.06);
  --shadow-md: 0 8px 24px rgba(26, 22, 20, 0.08);
  --shadow-lg: 0 16px 48px rgba(26, 22, 20, 0.12);

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 24px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

body {
  padding-bottom: 88px; /* space for bottom nav */
}

a { color: var(--burgundy); text-decoration: none; }

h1, h2, h3, h4 { font-family: var(--font-serif); font-weight: 600; letter-spacing: -0.015em; line-height: 1.15; color: var(--ink); }
h1 { font-size: 2.25rem; font-weight: 700; }
h2 { font-size: 1.75rem; font-weight: 600; }
h3 { font-size: 1.375rem; font-weight: 600; }
h4 { font-size: 1.125rem; font-weight: 600; font-family: var(--font-sans); letter-spacing: 0; }

button { font-family: inherit; cursor: pointer; border: none; background: none; }

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
textarea, select {
  font-family: inherit; font-size: 15px;
  width: 100%;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):focus,
textarea:focus, select:focus {
  outline: none;
  border-color: var(--burgundy);
  box-shadow: 0 0 0 3px rgba(139, 26, 26, 0.08);
}
input[type="checkbox"], input[type="radio"] {
  width: 18px; height: 18px;
  accent-color: var(--burgundy);
  cursor: pointer;
  vertical-align: middle;
  margin: 0;
  flex-shrink: 0;
}
input[type="file"] {
  font-size: 13px; padding: 8px 0;
  color: var(--ink-soft);
}
input[type="file"]::file-selector-button {
  padding: 8px 14px; margin-right: 10px;
  background: var(--cream-deep); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--cream); border-color: var(--gold); }
label { display: block; font-size: 13px; font-weight: 500; color: var(--ink-soft); margin-bottom: 6px; letter-spacing: 0.01em; }
/* Labels that contain a checkbox inline (rendered via h() with inline style="display:flex") get zero margin */
label:has(input[type="checkbox"]), label:has(input[type="radio"]) {
  display: flex; align-items: center; gap: 8px; margin-bottom: 0; font-weight: 400; color: var(--ink); cursor: pointer;
}

/* ============ Layout ============ */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.page { padding: 24px 20px 20px; max-width: 720px; margin: 0 auto; width: 100%; }
.page.narrow { max-width: 480px; }

/* ============ Top Bar ============ */
.topbar {
  background: var(--cream);
  border-bottom: 1px solid var(--line-soft);
  padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(8px);
}
.topbar .brand {
  font-family: var(--font-serif); font-size: 22px; font-style: italic;
  color: var(--burgundy); letter-spacing: 0.02em;
}
.topbar .brand b { font-style: normal; font-weight: 600; color: var(--ink); }
.topbar .user { font-size: 13px; color: var(--ink-soft); }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px;
  font-weight: 500; font-size: 14px; letter-spacing: 0.01em;
  border-radius: var(--r-md);
  transition: all 0.15s;
  line-height: 1;
  min-height: 44px;
}
.btn-primary { background: var(--burgundy); color: #fff; }
.btn-primary:hover { background: var(--burgundy-deep); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--cream-deep); color: var(--ink); }
.btn-secondary:hover { background: var(--line); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--cream-deep); color: var(--ink); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: var(--gold-soft); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-sm { padding: 8px 14px; font-size: 13px; min-height: 36px; }
.btn-xs { padding: 6px 10px; font-size: 12px; min-height: 30px; }
.btn-block { width: 100%; }

/* ============ Cards ============ */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line-soft);
}
.card-flat { background: var(--surface); border-radius: var(--r-lg); padding: 20px; border: 1px solid var(--line-soft); }
.card-title { font-family: var(--font-serif); font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.card-subtitle { font-size: 13px; color: var(--ink-faint); margin-bottom: 14px; }

/* ============ Countdown Hero ============ */
.hero-countdown {
  background: linear-gradient(145deg, var(--burgundy) 0%, var(--burgundy-deep) 100%);
  color: #fff;
  padding: 32px 28px;
  border-radius: var(--r-xl);
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.hero-countdown::before {
  content: '';
  position: absolute; top: -40px; right: -40px;
  width: 180px; height: 180px;
  border: 1.5px solid rgba(212, 165, 116, 0.2);
  border-radius: 50%;
}
.hero-countdown::after {
  content: '';
  position: absolute; bottom: -60px; left: -60px;
  width: 220px; height: 220px;
  border: 1.5px solid rgba(212, 165, 116, 0.15);
  border-radius: 50%;
}
.hero-countdown .couple {
  font-family: var(--font-serif); font-style: italic; font-size: 18px;
  color: var(--gold-soft); margin-bottom: 8px; letter-spacing: 0.04em;
}
.hero-countdown .days {
  font-family: var(--font-serif); font-size: 72px; font-weight: 500;
  line-height: 1; letter-spacing: -0.02em;
  position: relative; z-index: 1;
}
.hero-countdown .days-label {
  font-size: 13px; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--gold-soft); margin-top: 8px;
}
.hero-countdown .date {
  font-family: var(--font-serif); font-size: 20px; font-style: italic;
  margin-top: 16px; color: rgba(255,255,255,0.85);
}
.hero-countdown .trad-badge {
  display: inline-block;
  margin-top: 14px; padding: 4px 12px;
  border: 1px solid rgba(212, 165, 116, 0.4);
  border-radius: 100px; font-size: 11px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--gold-soft);
}

/* ============ Stat Grid ============ */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 20px 0; }
.stat-card {
  background: var(--surface); padding: 16px; border-radius: var(--r-md);
  border: 1px solid var(--line-soft);
}
.stat-card .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-faint); margin-bottom: 6px; font-weight: 600; }
.stat-card .value { font-family: var(--font-serif); font-size: 26px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }
.stat-card .value.accent { color: var(--burgundy); }
.stat-card .sub { font-size: 12px; color: var(--ink-faint); margin-top: 4px; font-weight: 500; }

/* ============ Progress ============ */
.progress-bar { height: 4px; background: var(--line-soft); border-radius: 2px; overflow: hidden; }
.progress-bar .fill { height: 100%; background: var(--burgundy); transition: width 0.4s; }
.progress-bar .fill.gold { background: var(--gold); }
.progress-bar .fill.sage { background: var(--sage); }

/* ============ Section ============ */
.section { margin: 28px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; }
.section-head h3 { font-family: var(--font-serif); font-size: 22px; font-weight: 500; }
.section-head .act { font-size: 13px; color: var(--burgundy); font-weight: 500; }

/* ============ Bottom Nav ============ */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding: 8px 2px 22px;
  z-index: 100;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.03);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 3px; padding: 6px 1px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.02em;
  color: var(--ink-faint); text-transform: uppercase;
  transition: color 0.2s;
  min-width: 0;
}
.bottom-nav a.active { color: var(--burgundy); }
.bottom-nav a .icon { font-size: 20px; }
.bottom-nav a.active .icon { transform: translateY(-1px); }

/* ============ Timeline ============ */
.phase-group { margin-bottom: 28px; }
.phase-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}
.phase-header .name { font-family: var(--font-serif); font-size: 20px; font-weight: 500; flex: 1; }
.phase-header .count { font-size: 12px; color: var(--ink-faint); }

.task-item {
  display: flex; gap: 12px; padding: 14px 16px;
  background: var(--surface); border-radius: var(--r-md);
  border: 1px solid var(--line-soft);
  margin-bottom: 8px;
  transition: all 0.15s;
}
.task-item.done { background: var(--cream-deep); opacity: 0.7; }
.task-item.done .task-title { text-decoration: line-through; color: var(--ink-faint); }
.task-item.overdue { border-left: 3px solid var(--danger); }
.task-checkbox {
  width: 22px; height: 22px; min-width: 22px;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; margin-top: 2px;
  transition: all 0.15s;
}
.task-checkbox.checked { background: var(--burgundy); border-color: var(--burgundy); color: #fff; }
.task-content { flex: 1; min-width: 0; }
.task-title { font-size: 14px; font-weight: 500; margin-bottom: 4px; word-wrap: break-word; }
.task-meta { font-size: 12px; color: var(--ink-faint); display: flex; gap: 8px; flex-wrap: wrap; }
.task-meta .tag { display: inline-block; padding: 1px 6px; background: var(--cream-deep); border-radius: 4px; font-size: 11px; }
.task-meta .tag.priority-high { background: rgba(158, 60, 45, 0.12); color: var(--danger); }
.task-meta .tag.priority-medium { background: rgba(184, 147, 94, 0.15); color: var(--gold); }

/* ============ Vendor Cards ============ */
.vendor-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 640px) { .vendor-grid { grid-template-columns: 1fr 1fr; } }

.vendor-card {
  background: var(--surface); border-radius: var(--r-lg);
  padding: 20px; border: 1px solid var(--line-soft);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-xs);
}
.vendor-card .cat {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--gold); font-weight: 700; margin-bottom: 8px;
}
.vendor-card .name { font-family: var(--font-serif); font-size: 23px; font-weight: 700; margin-bottom: 6px; letter-spacing: -0.01em; color: var(--ink); line-height: 1.2; }
.vendor-card .loc { font-size: 13px; color: var(--ink-soft); margin-bottom: 12px; font-weight: 500; }
.vendor-card .pkg-count { font-size: 12px; color: var(--ink-soft); font-weight: 500; }
.vendor-card .rep-badge {
  display: inline-block; padding: 4px 11px; border-radius: 100px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  background: var(--cream-deep); color: var(--ink-soft);
  margin-top: 10px;
}
.vendor-card .rep-badge.high { background: rgba(122, 132, 113, 0.2); color: var(--sage); }
.vendor-card .rep-badge.low { background: rgba(158, 60, 45, 0.1); color: var(--danger); }
.vendor-card .cats-row { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.vendor-card .cats-row .mini-chip { font-size: 10px; padding: 2px 8px; border-radius: 100px; background: var(--cream-deep); color: var(--ink-soft); font-weight: 600; letter-spacing: 0.02em; }

/* ============ Package row ============ */
.pkg-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--cream); border-radius: var(--r-md);
  margin-bottom: 8px;
  border: 1px solid var(--line-soft);
}
.pkg-row.selected { border-color: var(--burgundy); background: rgba(139, 26, 26, 0.03); }
.pkg-row .name { flex: 1; font-weight: 500; font-size: 14px; }
.pkg-row .price { font-family: var(--font-serif); font-size: 18px; font-weight: 600; color: var(--burgundy); }
.pkg-row .status-draft { font-size: 10px; background: var(--amber); color: #fff; padding: 2px 6px; border-radius: 3px; text-transform: uppercase; letter-spacing: 0.05em; }

/* ============ Modal ============ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(26, 22, 20, 0.5);
  z-index: 200;
  display: flex; align-items: flex-end;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.15s;
}
.modal {
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  width: 100%; max-height: 92vh; overflow-y: auto;
  padding: 24px 20px 32px;
  animation: slideUp 0.2s ease-out;
}
.modal .head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal .title { font-family: var(--font-serif); font-size: 24px; font-weight: 500; }
.modal .close { font-size: 22px; color: var(--ink-faint); padding: 6px; line-height: 1; }
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; justify-content: center; }
  .modal { max-width: 520px; border-radius: var(--r-xl); margin: 20px; }
}

@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.fade-in { animation: fadeInUp 0.3s ease-out; }

/* ============ Forms ============ */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ============ Toast ============ */
.toast-host { position: fixed; top: 16px; left: 16px; right: 16px; z-index: 300; pointer-events: none; }
.toast {
  background: var(--ink); color: var(--cream);
  padding: 14px 16px; border-radius: var(--r-md);
  font-size: 14px; margin-bottom: 8px;
  box-shadow: var(--shadow-lg);
  animation: slideDown 0.2s;
  pointer-events: auto;
  max-width: 480px; margin-left: auto; margin-right: auto;
}
.toast.success { background: var(--sage); }
.toast.error { background: var(--danger); }
@keyframes slideDown { from { transform: translateY(-30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ============ Login ============ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(180deg, var(--cream) 0%, var(--cream-deep) 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 40px 32px;
  width: 100%; max-width: 400px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--line-soft);
}
.login-card h1 {
  font-family: var(--font-serif); font-size: 36px; font-style: italic;
  color: var(--burgundy); text-align: center; margin-bottom: 4px;
}
.login-card .tag { text-align: center; color: var(--ink-faint); font-size: 13px; letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 28px; }

/* ============ Onboarding ============ */
.onboarding-step {
  background: var(--surface); border-radius: var(--r-xl);
  padding: 28px 24px; max-width: 520px; margin: 20px auto;
  border: 1px solid var(--line-soft); box-shadow: var(--shadow-sm);
}
.onboarding-step .step-num {
  font-family: var(--font-serif); font-size: 14px; font-style: italic;
  color: var(--gold); letter-spacing: 0.1em;
}
.onboarding-step h2 { margin: 6px 0 20px; }
.template-option {
  display: block; padding: 16px; border: 1.5px solid var(--line);
  border-radius: var(--r-md); margin-bottom: 10px; cursor: pointer;
  transition: all 0.15s;
}
.template-option:hover { border-color: var(--gold); background: var(--cream); }
.template-option.selected { border-color: var(--burgundy); background: rgba(139, 26, 26, 0.04); }
.template-option .tname { font-family: var(--font-serif); font-size: 18px; font-weight: 500; }
.template-option .tdesc { font-size: 13px; color: var(--ink-faint); margin-top: 4px; }

/* ============ Transaction list ============ */
.tx-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-bottom: 1px solid var(--line-soft);
}
.tx-row:last-child { border-bottom: none; }
.tx-row .icon {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.tx-row .icon.in { background: rgba(122, 132, 113, 0.15); color: var(--sage); }
.tx-row .icon.out { background: rgba(139, 26, 26, 0.08); color: var(--burgundy); }
.tx-row .desc { flex: 1; min-width: 0; }
.tx-row .desc .d1 { font-weight: 500; font-size: 14px; }
.tx-row .desc .d2 { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.tx-row .amt { font-family: var(--font-serif); font-weight: 600; font-size: 16px; }
.tx-row .amt.in { color: var(--sage); }
.tx-row .amt.out { color: var(--burgundy); }

/* ============ Empty state ============ */
.empty {
  text-align: center; padding: 48px 20px;
  color: var(--ink-faint);
}
.empty .icon { font-size: 40px; margin-bottom: 12px; opacity: 0.5; }
.empty .msg { font-family: var(--font-serif); font-size: 18px; font-style: italic; }

/* ============ Spinner ============ */
.spinner {
  width: 20px; height: 20px; border: 2px solid var(--line);
  border-top-color: var(--burgundy); border-radius: 50%;
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  position: fixed; inset: 0; background: rgba(250, 244, 236, 0.85);
  z-index: 150; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px;
  backdrop-filter: blur(2px);
}
.loading-overlay .spinner { width: 40px; height: 40px; border-width: 3px; }
.loading-overlay .msg { font-family: var(--font-serif); font-style: italic; color: var(--ink-soft); }

/* ============ Compare View ============ */
.compare-card {
  padding: 20px; background: var(--surface); border-radius: var(--r-lg);
  border: 1px solid var(--line-soft); margin-bottom: 14px;
}
.compare-card.winner { border-color: var(--gold); background: linear-gradient(180deg, rgba(184, 147, 94, 0.06) 0%, var(--surface) 100%); position: relative; }
.compare-card.winner::before {
  content: 'PILIHAN TERBAIK'; position: absolute; top: -10px; left: 20px;
  background: var(--gold); color: #fff; padding: 3px 10px; border-radius: 100px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.15em;
}
.compare-score {
  font-family: var(--font-serif); font-size: 42px; font-weight: 600;
  color: var(--burgundy); line-height: 1;
}
.compare-score small { font-size: 14px; color: var(--ink-faint); }

/* ============ Utilities ============ */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 13px; } .text-xs { font-size: 11px; }
.text-faint { color: var(--ink-faint); }
.text-soft { color: var(--ink-soft); }
.text-accent { color: var(--burgundy); }
.text-gold { color: var(--gold); }
.serif { font-family: var(--font-serif); }
.italic { font-style: italic; }
.center { text-align: center; }
.w-full { width: 100%; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.divider { border-top: 1px solid var(--line-soft); margin: 16px 0; }
.chip {
  display: inline-block; padding: 4px 10px; border-radius: 100px;
  font-size: 12px; background: var(--cream-deep); color: var(--ink-soft);
  margin: 2px;
}
.chip.active { background: var(--burgundy); color: #fff; }
