* {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

body {
  margin: 0;
  background: #f6f0e7;
  color: #1f2430;
}

/* ==================== TOP BAR ==================== */
.top-bar {
  background: #f6f0e7;
  padding: 12px 16px 4px;
  padding-top: max(12px, env(safe-area-inset-top));
}

.brand-pill {
  display: inline-block;
  background: #1f2430;
  color: #f6f0e7;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.08em;
  font-size: 13px;
}

.top-links {
  margin-top: 4px;
  font-size: 13px;
  color: #6b7280;
}
.top-links span + span::before { content: " · "; }

/* ==================== TABS NAV ==================== */
.tabs {
  display: flex;
  gap: 8px;
  padding: 8px 12px 4px;
  align-items: center;
  flex-wrap: wrap;
}

.tab-button {
  flex: 0 0 auto;
  border-radius: 999px;
  border: none;
  padding: 8px 18px;
  background: #e3d7c5;
  color: #1f2430;
  font-weight: 500;
  cursor: pointer;
  font-size: 14px;
}
.tab-button.active {
  background: #1f2430;
  color: #f6f0e7;
}

.new-ceremony {
  margin-left: auto;
  border-radius: 999px;
  border: none;
  padding: 8px 18px;
  background: #111827;
  color: #f6f0e7;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
}

/* ==================== MAIN / TABS ==================== */
main {
  padding: 8px 12px 80px;
}

.tab { display: none; }
.tab.active { display: block; }
h2 { margin-top: 8px; }

/* ==================== HISTORY SEARCH ==================== */
.history-search { margin: 8px 0 10px; }
.history-search input {
  width: 100%;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  padding: 10px 12px;
  font-size: 14px;
  background: #fbf7f0;
}

/* ==================== WEEK DIVIDERS ==================== */
.week-divider,
.day-divider {
  margin: 10px 0 8px;
  padding: 8px 12px;
  border-radius: 14px;
  background: #efe3d3;
  color: #1f2430;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.04em;
}

/* ==================== CEREMONY CARDS ==================== */
.ceremony-card {
  background: #fbf7f0;
  border-radius: 18px;
  padding: 14px 14px 12px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(15,23,42,0.08);
  border: 2px solid transparent;
}
.ceremony-card.green-frame { border-color: #16a34a; }

.ceremony-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
  gap: 10px;
}
.ceremony-name { font-weight: 800; font-size: 18px; line-height: 1.15; }
.ceremony-date { font-size: 13px; color: #4b5563; white-space: nowrap; }
.ceremony-place { font-size: 14px; color: #4b5563; margin-bottom: 6px; }
.ceremony-row { font-size: 13px; margin-bottom: 2px; }
.ceremony-label { font-weight: 700; }

.card-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 10px;
}
.card-buttons button {
  border-radius: 999px;
  padding: 6px 14px;
  border: none;
  font-size: 13px;
  cursor: pointer;
}
.card-buttons .edit  { background: #1f2937; color: #f9fafb; }
.card-buttons .delete { background: #fef2f2; color: #b91c1c; }

/* ==================== WAREHOUSE ==================== */
.warehouse-section { margin-top: 14px; }
.warehouse-controls { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.warehouse-controls button {
  border-radius: 999px;
  border: none;
  padding: 8px 14px;
  background: #1f2937;
  color: #f9fafb;
  font-size: 14px;
  cursor: pointer;
}
.warehouse-hint { font-size: 12px; color: #6b7280; margin-top: 8px; }

.warehouse-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.warehouse-table th,
.warehouse-table td {
  padding: 6px 4px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: middle;
}
.warehouse-table th { text-align: left; font-size: 13px; color: #4b5563; }

.warehouse-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
  align-items: center;
}
.warehouse-actions button {
  border-radius: 999px;
  border: none;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.warehouse-actions .edit  { background: #1f2937; color: #f9fafb; }
.warehouse-actions .delete { background: #fef2f2; color: #b91c1c; }

/* ==================== MODAL — BOTTOM SHEET (iPhone) ==================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  display: flex;
  align-items: flex-end;   /* ανεβαίνει από κάτω στο iPhone */
  justify-content: center;
  z-index: 20;
}
.modal.hidden { display: none; }

.modal-content {
  background: #f9fafb;
  border-radius: 22px 22px 0 0;
  padding: 20px 16px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  width: 100%;
  max-width: 560px;
  max-height: 93vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Desktop: κανονικό centered modal */
@media (min-width: 600px) {
  .modal { align-items: center; }
  .modal-content {
    border-radius: 18px;
    padding: 22px 22px 20px;
    max-height: 88vh;
  }
}

/* ==================== MODAL HEADER ==================== */
.modal-header { margin-bottom: 14px; }

.modal-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.modal-title-row h2 { margin: 0; font-size: 20px; }

.close-x {
  background: #e5e7eb;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #374151;
  flex-shrink: 0;
}

/* ==================== STEP INDICATOR (dots) ==================== */
.step-indicator {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
}
.step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d1d5db;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.2s;
}
.step-dot.active { background: #111827; transform: scale(1.25); }
.step-dot.done   { background: #9ca3af; }
.step-line { flex: 1; height: 2px; background: #e5e7eb; margin: 0 5px; }
.step-label { font-size: 12px; color: #6b7280; font-weight: 500; }

/* ==================== FORM STEPS ==================== */
.form-step { display: none; }
.form-step.active {
  display: block;
  animation: fadeUp 0.18s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ==================== LABELS & INPUTS ==================== */
#ceremonyForm label,
#warehouseForm label,
#setForm label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 10px;
}

#ceremonyForm input,
#ceremonyForm select,
#ceremonyForm textarea,
#warehouseForm input,
#warehouseForm select,
#setForm input,
#setForm select {
  border-radius: 12px;
  border: 1.5px solid #e5e7eb;
  padding: 11px 12px;
  font-size: 16px;        /* 16px = iOS δεν κάνει auto-zoom */
  background: #fff;
  color: #1f2430;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s;
}

#ceremonyForm input:focus,
#ceremonyForm select:focus,
#ceremonyForm textarea:focus {
  outline: none;
  border-color: #111827;
  box-shadow: 0 0 0 3px rgba(17,24,39,0.08);
}

#ceremonyForm textarea {
  resize: vertical;
  min-height: 80px;
  font-size: 15px;
  line-height: 1.5;
}

/* ==================== SEGMENTED CONTROL ==================== */
.segmented-control {
  display: flex;
  background: #e5e7eb;
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
  margin-top: 2px;
}
.seg-btn {
  flex: 1;
  border: none;
  border-radius: 10px;
  padding: 10px 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: #6b7280;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  line-height: 1.2;
}
.seg-btn.active {
  background: #111827;
  color: #f9fafb;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}

/* ==================== STEP NAVIGATION ==================== */
.step-navigation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  gap: 8px;
}

.step-counter {
  font-size: 13px;
  color: #9ca3af;
  font-weight: 600;
  min-width: 36px;
  text-align: center;
}

.step-nav-btn {
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.step-nav-btn.prev { background: #e5e7eb; color: #1f2430; }
.step-nav-btn.next { background: #111827; color: #f9fafb; }
.step-nav-btn.save { background: #16a34a; color: #fff; }
.step-nav-btn:active { opacity: 0.75; }

/* ==================== GRID ==================== */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 360px) {
  .form-grid-2 { grid-template-columns: 1fr; }
}

/* ==================== MODAL ACTIONS (αποθήκη/ΣΕΤ modals) ==================== */
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}
.modal-actions button {
  border-radius: 999px;
  border: none;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
#cancelModalBtn.modal-actions,
#cancelWarehouseBtn { background: #e5e7eb; color: #1f2430; }
#cancelSetBtn       { background: #e5e7eb; color: #1f2430; }
#saveWarehouseBtn   { background: #111827; color: #f9fafb; }
#saveSetBtn         { background: #111827; color: #f9fafb; }

/* ==================== GRAVE FIELDS ==================== */
.grave-fields {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.grave-fields input,
.grave-fields select {
  flex: 1;
  border-radius: 12px;
  border: 1.5px solid #e5e7eb;
  padding: 10px 10px;
  font-size: 15px;
  background: #fff;
  -webkit-appearance: none;
  appearance: none;
}

/* ==================== HINT BOX (αποτεφρωση) ==================== */
.hint-box {
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  border-radius: 14px;
  padding: 10px;
  margin-bottom: 10px;
}
.mini-muted { margin: 6px 0 0; font-size: 12px; color: #6b7280; }

/* ==================== HIDDEN UTILITY ==================== */
.hidden { display: none !important; }

/* ==================== FOOTER ==================== */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 12px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  text-align: center;
  font-size: 12px;
  background: #111827;
  color: #e5e7eb;
}
