:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #334155;
  --accent: #38bdf8;
  --accent2: #818cf8;
  --text: #f1f5f9;
  --text2: #94a3b8;
  --green: #4ade80;
  --red: #f87171;
  --orange: #fb923c;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding-top: var(--safe-top);
  padding-bottom: calc(70px + var(--safe-bottom));
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Calendar ─────────────────────────────────── */
#calendar {
  background: var(--surface);
  border-radius: var(--radius);
  margin: 8px;
  overflow: hidden;
}

.fc {
  --fc-bg-event-opacity: 0.2;
  --fc-today-bg-color: rgba(56, 189, 248, 0.1);
  --fc-page-bg-color: transparent;
  --fc-border-color: var(--surface2);
  --fc-button-bg-color: transparent;
  --fc-button-border-color: transparent;
  --fc-button-hover-bg-color: var(--surface2);
  --fc-button-active-bg-color: var(--accent);
  --fc-button-active-border-color: var(--accent);
  --fc-event-bg-color: var(--accent);
  --fc-today-bg-color: rgba(56,189,248,0.08);
}

.fc .fc-toolbar-title { font-size: 1.1em; }
.fc .fc-button { font-size: 0.85em; padding: 4px 10px; border-radius: 8px; }
.fc .fc-daygrid-day { padding: 2px; }
.fc .fc-daygrid-day-number { font-size: 0.85em; padding: 4px; }
.fc .fc-col-header-cell { font-size: 0.75em; padding: 6px 0; }

/* Multi-day event bar spanning months */
.fc .fc-event { border-radius: 6px; padding: 1px 4px; font-size: 0.75em; cursor: pointer; }

.fc .fc-daygrid-day.fc-day-today { background: rgba(56,189,248,0.08); }

/* ── Stats Bar ────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 2px;
  margin: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.stats-bar::-webkit-scrollbar { display: none; }

.stat-chip {
  flex-shrink: 0;
  background: var(--surface);
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 100px;
  text-align: center;
}
.stat-chip .num { font-size: 1.4em; font-weight: 700; color: var(--accent); }
.stat-chip .label { font-size: 0.7em; color: var(--text2); margin-top: 2px; }

/* ── Bottom Nav ───────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(60px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--surface2);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
}
.nav-btn {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 0.7em;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 16px;
  cursor: pointer;
}
.nav-btn.active { color: var(--accent); }
.nav-btn svg { width: 22px; height: 22px; }

/* ── Panels ───────────────────────────────────── */
.panel {
  display: none;
  padding: 8px;
}
.panel.active { display: block; }

/* ── Stay Card ────────────────────────────────── */
.stay-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  border-left: 4px solid var(--accent);
  cursor: pointer;
  transition: transform 0.1s;
}
.stay-card:active { transform: scale(0.98); }
.stay-card .city-date {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.stay-card .city { font-weight: 700; font-size: 1.05em; }
.stay-card .dates { font-size: 0.8em; color: var(--text2); }
.stay-card .tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag {
  background: var(--surface2);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.72em;
  display: flex;
  align-items: center;
  gap: 3px;
}
.tag.water { color: #38bdf8; }
.tag.power { color: #facc15; }
.tag.shower { color: #4ade80; }
.tag.price { color: #fb923c; }
.stay-card .stay-configs { margin-top: 6px; }
.stay-person {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(56,189,248,0.1);
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 0.72em;
  margin: 2px;
}
.stay-person.dog { background: rgba(251,146,60,0.1); }
.stay-person.hotel { background: rgba(129,140,248,0.1); }
/* ── Member Rows ───────────────────────────────── */
.member-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--surface2);
}
.member-row:last-child { border-bottom: none; }
.member-label {
  font-size: 0.88em;
  font-weight: 600;
  min-width: 64px;
  flex-shrink: 0;
}
.member-options {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.member-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--surface2);
  font-size: 0.75em;
  cursor: pointer;
  transition: all 0.12s;
  user-select: none;
}
.member-chip input { display: none; }
.member-chip:has(input:checked) {
  border-color: var(--accent);
  background: rgba(56,189,248,0.15);
  color: var(--accent);
}
.member-chip:active { transform: scale(0.95); }
.stay-card .notes {
  margin-top: 6px;
  font-size: 0.82em;
  color: var(--text2);
  white-space: pre-line;
}
.stay-card .rating { color: #fbbf24; font-size: 0.85em; }

/* ── Form Modal ───────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal-sheet {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 92dvh;
  overflow-y: auto;
  padding: 20px 16px calc(20px + var(--safe-bottom));
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-header h2 { font-size: 1.1em; }
.modal-close {
  background: var(--surface2);
  border: none;
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.1em;
  cursor: pointer;
}

.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 0.78em;
  color: var(--text2);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-row {
  display: flex;
  gap: 8px;
}
.form-row > .form-group { flex: 1; }

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.95em;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 60px; }

.toggle-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--surface2);
  background: transparent;
  color: var(--text2);
  font-size: 0.85em;
  cursor: pointer;
  transition: all 0.15s;
}
.toggle-btn.on {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(56,189,248,0.1);
}

/* ── Stay Config Builder ──────────────────────── */
.config-builder {
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 10px;
}
.config-builder .config-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.config-builder .config-header h4 {
  font-size: 0.82em;
  color: var(--text2);
}
.add-config-btn {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 0.78em;
  font-weight: 600;
  cursor: pointer;
}

.config-item {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.config-item input,
.config-item select {
  flex: 1;
  min-width: 60px;
  padding: 7px 8px;
  font-size: 0.85em;
}
.config-item .remove-config {
  background: rgba(248,113,113,0.15);
  color: var(--red);
  border: none;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  font-size: 1em;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Rating Stars ─────────────────────────────── */
.rating-stars {
  display: flex;
  gap: 4px;
}
.rating-stars .star {
  font-size: 1.6em;
  cursor: pointer;
  color: var(--surface2);
  transition: color 0.1s;
}
.rating-stars .star.filled { color: #fbbf24; }

/* ── Buttons ──────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 0.95em;
  font-weight: 700;
  width: 100%;
  cursor: pointer;
  margin-top: 6px;
}
.btn-primary:active { opacity: 0.8; }

.btn-danger {
  background: rgba(248,113,113,0.15);
  color: var(--red);
  border: 1px solid rgba(248,113,113,0.3);
  border-radius: 10px;
  padding: 10px;
  font-size: 0.88em;
  width: 100%;
  cursor: pointer;
  margin-top: 6px;
}

/* ── FAB ──────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  border: none;
  font-size: 2em;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(56,189,248,0.3);
  z-index: 50;
  transition: transform 0.15s;
}
.fab:active { transform: scale(0.92); }

/* ── Quick Add Mini ───────────────────────────── */
.quick-section {
  border: 1px dashed var(--surface2);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}
.quick-section h3 {
  font-size: 0.82em;
  color: var(--text2);
  margin-bottom: 8px;
}

/* ── Detail View ──────────────────────────────── */
.detail-header {
  text-align: center;
  padding: 16px 0;
}
.detail-header h2 { font-size: 1.3em; }
.detail-header .sub { color: var(--text2); font-size: 0.85em; margin-top: 4px; }

.detail-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}
.detail-section h3 {
  font-size: 0.78em;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--surface2);
  font-size: 0.9em;
}
.detail-row:last-child { border-bottom: none; }
.detail-row .key { color: var(--text2); }
.detail-row .val { font-weight: 600; }

.detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.detail-actions button {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: none;
  font-size: 0.9em;
  font-weight: 600;
  cursor: pointer;
}
.btn-edit {
  background: var(--surface2);
  color: var(--text);
}
.btn-del {
  background: rgba(248,113,113,0.15);
  color: var(--red);
}

/* ── Empty state ──────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text2);
}
.empty-state .icon { font-size: 3em; margin-bottom: 12px; }
.empty-state p { font-size: 0.9em; }

/* ── Fallback .fc styles ──────────────────────── */
/* Pure-CSS calendar fallback (no JS) */
.cal-fallback { display: none; }
#calendar.no-fc .cal-fallback { display: block; }
#calendar.no-fc .fc { display: none; }

.cal-fallback-month {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px;
}
.cal-fallback-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.cal-fallback-header button {
  background: var(--surface2);
  border: none;
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 1.1em;
  cursor: pointer;
}
.cal-fallback-header .month-label { font-weight: 700; font-size: 1.05em; }
.cal-fallback-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.72em;
  color: var(--text2);
  margin-bottom: 4px;
}
.cal-fallback-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-fallback-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.82em;
  cursor: pointer;
  position: relative;
}
.cal-fallback-day.today { background: rgba(56,189,248,0.15); font-weight: 700; }
.cal-fallback-day.has-stay::after {
  content: '';
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 50%;
  position: absolute;
  bottom: 3px;
}
.cal-fallback-day.other-month { color: var(--surface2); }
.cal-fallback-day:active { background: var(--surface2); }

/* ── Utilities ────────────────────────────────── */
.text-muted { color: var(--text2); }
.text-accent { color: var(--accent); }
.mt-8 { margin-top: 8px; }
.mb-8 { margin-bottom: 8px; }
