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

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

.top-bar {
  background: #f6f0e7;
  padding: 12px 16px 4px;
}

.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 {
  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;
}

.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;
  opacity: 1;
}

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

.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-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-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-section { margin-top: 10px; }
.warehouse-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.warehouse-controls button,
.add-option-btn {
  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: 6px; }

.warehouse-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.warehouse-table th,
.warehouse-table td {
  padding: 4px 4px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: middle;
}
.warehouse-table-tight th,
.warehouse-table-tight td { padding: 2px 4px; }
.warehouse-table th {
  text-align: left;
  font-size: 13px;
  color: #4b5563;
}
.warehouse-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  flex-wrap: wrap;
  align-items: center;
}
.warehouse-actions button {
  border-radius: 999px;
  border: none;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
}
.warehouse-actions .edit { background: #1f2937; color: #f9fafb; }
.warehouse-actions .delete { background: #fef2f2; color: #b91c1c; }

.drag-name {
  cursor: grab;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 7px;
  line-height: 1.15;
  touch-action: none;
}
.drag-name:active { cursor: grabbing; }
.drag-handle {
  display: inline-flex;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #efe3d3;
  color: #4b5563;
  font-size: 12px;
  flex: 0 0 auto;
}
.draggable-row.dragging { opacity: 0.45; }
.draggable-row.drag-over { outline: 2px dashed #1f2937; outline-offset: -2px; background: #fff7ed; }

.options-warehouse {
  background: #fbf7f0;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  padding: 12px;
}
.option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
}
.option-box {
  background: #fffaf2;
  border: 1px solid #eadfce;
  border-radius: 16px;
  padding: 10px;
}
.option-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.option-head h4 { margin: 0; font-size: 14px; }
.add-option-btn { font-size: 12px; padding: 6px 10px; }
.compact-table td { padding: 3px 4px; font-size: 13px; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.modal.hidden { display: none; }
.modal-content {
  background: #f9fafb;
  border-radius: 18px;
  padding: 16px 16px 12px;
  width: min(520px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-content-wide { width: min(760px, 96vw); }
.modal-content h2 { margin-top: 0; margin-bottom: 8px; }
.modal-title-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.x-close {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: none;
  background: #e5e7eb;
  color: #111827;
  font-size: 22px;
  cursor: pointer;
}

.form-section {
  background: #fffaf2;
  border: 1px solid #eadfce;
  border-radius: 16px;
  padding: 12px;
  margin: 10px 0;
}
.form-section h3 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 900;
  color: #111827;
}

#ceremonyForm label,
#warehouseForm label,
#setForm label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  margin-bottom: 8px;
}
#ceremonyForm input,
#ceremonyForm select,
#ceremonyForm textarea,
#warehouseForm input,
#setForm input,
#setForm select {
  border-radius: 10px;
  border: 1px solid #d1d5db;
  padding: 8px 10px;
  font-size: 14px;
  background: #fff;
}
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.modal-actions button {
  border-radius: 999px;
  border: none;
  padding: 7px 14px;
  font-size: 14px;
  cursor: pointer;
}
.sticky-actions {
  position: sticky;
  bottom: 0;
  background: #f9fafb;
  padding-top: 10px;
  border-top: 1px solid #e5e7eb;
}
#cancelModalBtn,
#cancelWarehouseBtn,
#cancelSetBtn { background: #e5e7eb; }
#saveCeremonyBtn,
#saveWarehouseBtn,
#saveSetBtn { background: #111827; color: #f9fafb; }

.grave-row { display: flex; gap: 12px; align-items: center; margin: 4px 0 6px; }
.grave-option { display: flex !important; flex-direction: row !important; align-items: center; gap: 4px; font-size: 13px; }
.grave-fields { display: flex; gap: 8px; margin-bottom: 8px; }
.grave-fields input,
.grave-fields select { flex: 1; }
.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; }

.history-card-clickable { cursor: pointer; }
.history-card-clickable:hover { border-color: #c7b899; }
.history-mini { font-size: 12px; color: #6b7280; margin-top: 6px; }
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat-card { background: #fbf7f0; border: 1px solid #e5e7eb; border-radius: 16px; padding: 12px; margin: 10px 0; }
.stat-title { font-weight: 900; margin-bottom: 8px; }
.stat-line { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 3px 0; border-bottom: 1px solid rgba(229,231,235,.7); }
.stat-line:last-child { border-bottom: none; }
.stat-pill { background: #e3d7c5; border-radius: 999px; padding: 6px 10px; font-size: 13px; }

.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 12px;
  text-align: center;
  font-size: 12px;
  background: #111827;
  color: #e5e7eb;
}

@media (max-width: 760px) {
  .option-grid,
  .stats-grid { grid-template-columns: 1fr; }
}

@media (max-width: 460px) {
  .form-grid-2 { grid-template-columns: 1fr; }
  .ceremony-header { flex-direction: column; align-items: flex-start; }
  .ceremony-date { white-space: normal; }
  .new-ceremony { margin-left: 0; width: 100%; }
  .grave-fields { flex-direction: column; }
}
