:root {
  --color-bg: #faf6f2;
  --color-surface: #ffffff;
  --color-surface-alt: #fdf9f6;
  --color-primary: #b8798f;
  --color-primary-dark: #96586e;
  --color-primary-light: #f3dde3;
  --color-accent: #c9a961;
  --color-accent-light: #f2e8d0;
  --color-accent-dark: #6b551c;
  --color-sage: #7f9574;
  --color-sage-light: #e6ecdf;
  --color-sage-dark: #45592f;
  --color-danger: #c0564f;
  --color-danger-light: #f5dedd;
  --color-text: #382f33;
  --color-text-muted: #8a7c81;
  --color-border: #ecdfe1;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 4px 20px rgba(90, 50, 65, 0.08);
  --shadow-lg: 0 16px 44px rgba(90, 50, 65, 0.18);
  --sidebar-width: 250px;
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

:root[data-theme="dark"] {
  --color-bg: #1c1518;
  --color-surface: #262023;
  --color-surface-alt: #211b1e;
  --color-primary: #d98fa8;
  --color-primary-dark: #e7a9be;
  --color-primary-light: #3a2530;
  --color-accent: #d8b56f;
  --color-accent-light: #3a3020;
  --color-accent-dark: #e9c988;
  --color-sage: #9db38f;
  --color-sage-light: #263124;
  --color-sage-dark: #b6cca8;
  --color-danger: #e08079;
  --color-danger-light: #3a2422;
  --color-text: #f2e9ec;
  --color-text-muted: #ab9ba1;
  --color-border: #3a2f34;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 16px 44px rgba(0, 0, 0, 0.45);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #1c1518;
    --color-surface: #262023;
    --color-surface-alt: #211b1e;
    --color-primary: #d98fa8;
    --color-primary-dark: #e7a9be;
    --color-primary-light: #3a2530;
    --color-accent: #d8b56f;
    --color-accent-light: #3a3020;
    --color-accent-dark: #e9c988;
    --color-sage: #9db38f;
    --color-sage-light: #263124;
    --color-sage-dark: #b6cca8;
    --color-danger: #e08079;
    --color-danger-light: #3a2422;
    --color-text: #f2e9ec;
    --color-text-muted: #ab9ba1;
    --color-border: #3a2f34;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.28);
    --shadow-lg: 0 16px 44px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}

h1, h2, h3, h4 {
  font-family: var(--font-sans);
  font-weight: 700;
  margin: 0 0 4px 0;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }

svg { display: block; }

.app { display: flex; min-height: 100vh; }

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulseCheck { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }

.fade-in { animation: fadeIn 0.28s ease; }
.pop-in { animation: scaleIn 0.18s cubic-bezier(.22,.85,.34,1); }
.toast-anim { animation: toastIn 0.25s ease; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--color-surface), var(--color-surface-alt));
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 20;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 20px 8px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 14px;
}
.brand-icon { font-size: 28px; }
.brand-title { font-size: 17px; font-weight: 700; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12px; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text { flex: 1; min-width: 0; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: left;
  background: transparent;
  border: none;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  color: var(--color-text);
  transition: background 0.15s, color 0.15s, transform 0.1s;
  white-space: nowrap;
}
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--color-primary-light); transform: translateX(1px); }
.nav-item.active { background: var(--color-primary); color: #fff; font-weight: 600; }

.sidebar-footer {
  font-size: 11.5px;
  color: var(--color-text-muted);
  text-align: center;
  padding-top: 14px;
  border-top: 1px solid var(--color-border);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
}

.icon-btn.sidebar-collapse-btn { flex-shrink: 0; width: 28px; height: 28px; }
.sidebar-collapse-btn svg { width: 13px; height: 13px; }

/* Collapsed sidebar: icon rail only (desktop widths only — mobile keeps the full drawer) */
@media (min-width: 761px) {
  .sidebar.collapsed { width: 72px; }
  .sidebar.collapsed .brand { justify-content: center; }
  .sidebar.collapsed .brand-text,
  .sidebar.collapsed .nav-label,
  .sidebar.collapsed .sidebar-footer { display: none; }
  .sidebar.collapsed .nav-item { justify-content: center; padding: 11px 0; }
}
@media (max-width: 760px) {
  .icon-btn.sidebar-collapse-btn { display: none; }
}

.sidebar-scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 15; }

/* Main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--color-bg) 88%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--color-border);
}
.topbar-title { font-size: 19px; font-weight: 700; flex: 1; }
.menu-toggle { display: none; }
.icon-btn {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--color-text);
  transition: background 0.15s, transform 0.15s;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--color-primary-light); }
.theme-toggle svg { transition: transform 0.3s ease; }
.theme-toggle:active svg { transform: rotate(20deg); }
.countdown {
  background: var(--color-accent-light);
  color: var(--color-accent-dark);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.content { padding: 22px 26px 60px 26px; max-width: 1180px; width: 100%; margin: 0 auto; }

/* Cards / grid */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.stat-card { position: relative; overflow: hidden; }
.stat-label { font-size: 12.5px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 6px; }
.stat-sub { font-size: 12.5px; color: var(--color-text-muted); margin-top: 4px; }

.progress-bar { width: 100%; height: 9px; background: var(--color-border); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.progress-bar > div { height: 100%; background: var(--color-primary); border-radius: 999px; transition: width 0.4s cubic-bezier(.2,.8,.3,1); }
.progress-bar.sage > div { background: var(--color-sage); }
.progress-bar.gold > div { background: var(--color-accent); }
.progress-bar.danger > div { background: var(--color-danger); }

.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 10px; flex-wrap: wrap; }
.section-header h2 { font-size: 22px; }
.section-header .muted { color: var(--color-text-muted); font-size: 13px; margin-top: 2px; }
.muted { color: var(--color-text-muted); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.1s, box-shadow 0.1s, background 0.15s;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-outline { background: transparent; }
.btn-danger { background: var(--color-danger); border-color: var(--color-danger); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-icon { padding: 6px; width: 30px; height: 30px; justify-content: center; }
.btn-icon svg { width: 15px; height: 15px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-toggle-group { display: inline-flex; border: 1px solid var(--color-border); border-radius: var(--radius-sm); overflow: hidden; }
.btn-toggle-group button { border: none; border-radius: 0; background: var(--color-surface); padding: 9px 16px; font-size: 13.5px; font-weight: 600; color: var(--color-text-muted); display: inline-flex; align-items: center; gap: 6px; }
.btn-toggle-group button.active { background: var(--color-primary); color: #fff; }
.btn-toggle-group button svg { width: 15px; height: 15px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
label { font-size: 12.5px; font-weight: 700; color: var(--color-text-muted); display: block; margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.checkbox-field { display: flex; align-items: center; gap: 8px; }
.checkbox-field input { width: auto; }
.checkbox-field label { margin: 0; }

.checkbox-group { display: flex; flex-wrap: wrap; gap: 8px; }
.checkbox-group-item {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.checkbox-group-item input { width: auto; margin: 0; accent-color: var(--color-primary); }
.checkbox-group-item:has(input:checked) { background: var(--color-primary-light); border-color: var(--color-primary); }

/* Table */
.table-wrap { overflow-x: auto; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
thead th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--color-text-muted); padding: 12px 14px; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--color-border); font-size: 14px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: var(--color-surface-alt); }
.empty-row td { text-align: center; color: var(--color-text-muted); padding: 30px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge-yes { background: var(--color-sage-light); color: var(--color-sage-dark); }
.badge-no { background: var(--color-danger-light); color: var(--color-danger); }
.badge-pending { background: var(--color-accent-light); color: var(--color-accent-dark); }
.badge-neutral { background: var(--color-border); color: var(--color-text-muted); }
.badge-primary { background: var(--color-primary-light); color: var(--color-primary-dark); }
.badge-gold { background: var(--color-accent-light); color: var(--color-accent-dark); }
.badge-sage { background: var(--color-sage-light); color: var(--color-sage-dark); }
.badge-sm { padding: 2px 8px; font-size: 11px; }

.row-actions { display: flex; gap: 6px; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--color-text-muted); }
.empty-state .emoji { font-size: 40px; margin-bottom: 10px; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(20, 14, 17, 0.5); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: var(--color-surface); border-radius: var(--radius-lg); padding: 24px; width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal h3 { margin-bottom: 16px; font-size: 19px; }
.modal-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 18px; border-top: 1px solid var(--color-border); padding-top: 16px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--color-text); color: var(--color-bg);
  padding: 11px 20px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  z-index: 200; box-shadow: var(--shadow-lg);
}

/* Checklist */
.task-group { margin-bottom: 22px; }
.task-group h4 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--color-text-muted); margin-bottom: 8px; }
.task-item { display: flex; align-items: flex-start; gap: 12px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 8px; transition: opacity 0.2s, background 0.2s; }
.task-item.done { opacity: 0.55; }
.task-item.done .task-title { text-decoration: line-through; }
.task-checkbox { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; accent-color: var(--color-primary); }
.task-checkbox:checked { animation: pulseCheck 0.25s ease; }
.task-title { font-weight: 600; font-size: 14.5px; }
.task-meta { font-size: 12px; color: var(--color-text-muted); margin-top: 3px; }
.task-body { flex: 1; min-width: 0; }
.priority-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.priority-high { background: var(--color-danger); }
.priority-medium { background: var(--color-accent); }
.priority-low { background: var(--color-sage); }

/* Schedule timeline */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--color-border); }
.timeline-item { position: relative; margin-bottom: 18px; }
.timeline-item::before { content: ""; position: absolute; left: -26px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--color-primary); border: 2px solid var(--color-surface); box-shadow: 0 0 0 1px var(--color-primary); }
.timeline-time { font-weight: 700; color: var(--color-primary-dark); font-size: 13px; }
.timeline-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 10px 14px; margin-top: 4px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }

/* Events / Calendar */
.event-card { display: flex; flex-direction: column; gap: 10px; }
.event-card-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.event-detail-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--color-text); }
.event-detail-row svg { width: 15px; height: 15px; color: var(--color-text-muted); flex-shrink: 0; }
.event-detail-row a { color: var(--color-primary-dark); text-decoration: none; font-weight: 600; }
.event-detail-row a:hover { text-decoration: underline; }
.event-vendor-list { border-top: 1px dashed var(--color-border); padding-top: 10px; margin-top: 2px; }
.event-vendor-row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }

.calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; flex-wrap: wrap; }
.calendar-nav { display: flex; align-items: center; gap: 6px; }
.calendar-title { font-size: 17px; font-weight: 700; min-width: 170px; text-align: center; }
.calendar-legend { display: flex; gap: 14px; font-size: 12px; color: var(--color-text-muted); flex-wrap: wrap; }
.calendar-legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-weekday { text-align: center; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--color-text-muted); padding-bottom: 4px; }
.cal-cell {
  min-height: 92px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.cal-cell:hover { background: var(--color-primary-light); }
.cal-cell.muted { opacity: 0.4; cursor: default; }
.cal-cell.muted:hover { background: var(--color-surface); }
.cal-cell.today { border-color: var(--color-primary); border-width: 2px; }
.cal-daynum { font-size: 12px; font-weight: 700; margin-bottom: 4px; }
.cal-events { display: flex; flex-direction: column; gap: 3px; }
.cal-event-pill {
  font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-left: 3px solid var(--color-primary);
  background: var(--color-primary-light); color: var(--color-primary-dark);
}
.cal-event-pill.side-partner1 { border-left-color: var(--color-primary); background: var(--color-primary-light); color: var(--color-primary-dark); }
.cal-event-pill.side-partner2 { border-left-color: var(--color-accent); background: var(--color-accent-light); color: var(--color-accent-dark); }
.cal-event-pill.side-both { border-left-color: var(--color-sage); background: var(--color-sage-light); color: var(--color-sage-dark); }

/* Settings */
.settings-section { margin-bottom: 26px; }
.settings-section h3 { font-size: 15px; margin-bottom: 12px; }
.danger-zone { border: 1px solid var(--color-danger-light); background: var(--color-danger-light); border-radius: var(--radius); padding: 16px; }
.invite-code-box { display: flex; align-items: center; gap: 10px; background: var(--color-surface-alt); border: 1px dashed var(--color-border); border-radius: var(--radius-sm); padding: 12px 16px; }
.invite-code-value { font-size: 22px; font-weight: 700; letter-spacing: 0.15em; }

/* Auth screen */
.auth-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--color-primary-light), var(--color-bg) 55%);
  padding: 20px;
  position: relative;
}
.auth-theme-toggle { position: absolute; top: 20px; right: 20px; }
.auth-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 34px 30px;
  width: 100%;
  max-width: 380px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; justify-content: center; }
.auth-brand-icon { font-size: 26px; }
.auth-tagline { text-align: center; color: var(--color-text-muted); font-size: 13.5px; margin: 8px 0 22px 0; }
.auth-tabs { display: flex; border: 1px solid var(--color-border); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 20px; }
.auth-tab { flex: 1; padding: 10px; background: var(--color-surface-alt); font-weight: 700; font-size: 13.5px; color: var(--color-text-muted); border: none; }
.auth-tab.active { background: var(--color-primary); color: #fff; }
.auth-form.hidden { display: none; }
.auth-error { background: var(--color-danger-light); color: var(--color-danger); padding: 9px 12px; border-radius: var(--radius-sm); font-size: 12.5px; margin-bottom: 14px; }
.auth-footnote { text-align: center; font-size: 11.5px; color: var(--color-text-muted); margin-top: 18px; }

@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
  .content { padding: 16px 14px 50px 14px; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .field-row { flex-direction: column; gap: 0; }
  .topbar { padding: 12px 14px; }
  .topbar-title { font-size: 16px; }
  .cal-grid { gap: 3px; }
  .cal-cell { min-height: 64px; padding: 4px; }
  .cal-event-pill { font-size: 9px; }
  .calendar-title { min-width: 0; }
}
