/* ═══════════════════════════════════════════
   ΣΤΑΥΡΑΚΑΚΗ — Unified App CSS
   Mobile-first, iOS-optimized
═══════════════════════════════════════════ */

:root {
  --bg: #f0ebe2;
  --card: #faf7f2;
  --ink: #1a1f2e;
  --ink2: #3d4559;
  --muted: #6b7588;
  --line: rgba(26,31,46,0.1);
  --accent: #1a1f2e;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --blue: #2563eb;
  --radius: 18px;
  --shadow: 0 2px 12px rgba(26,31,46,0.08);
  --shadow-lg: 0 12px 40px rgba(26,31,46,0.16);
  --topbar-h: 56px;
  --bottomnav-h: 70px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ── TOPBAR ── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--ink);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  padding-top: env(safe-area-inset-top);
  z-index: 100;
  gap: 10px;
}

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

.brand {
  font-weight: 900;
  font-size: 15px;
  letter-spacing: 0.12em;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand svg, .brand span:first-child {
  color: rgba(255,255,255,0.5);
  font-size: 12px;
}

.topbar__date {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  font-weight: 500;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar__action {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.topbar__action:active { opacity: 0.7; }

.operator-select {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  max-width: 110px;
  appearance: none;
  -webkit-appearance: none;
}

.operator-select option { background: var(--ink); color: #fff; }

/* ── MAIN ── */
.main {
  margin-top: var(--topbar-h);
  margin-bottom: var(--bottomnav-h);
  padding: 10px 12px 0;
  min-height: calc(100vh - var(--topbar-h) - var(--bottomnav-h));
}

/* ── PANELS ── */
.panel { display: none; }
.panel.active { display: block; }

/* ── DASHBOARD STRIP ── */
.dash-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.dash-pill {
  background: var(--card);
  border-radius: 14px;
  padding: 10px 8px;
  text-align: center;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.dash-pill b {
  display: block;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  color: var(--ink);
}

.dash-pill span {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
  font-weight: 600;
}

.dash-pill--warn { border-color: rgba(217,119,6,0.3); }
.dash-pill--warn b { color: var(--amber); }
.dash-pill--red { border-color: rgba(220,38,38,0.3); }
.dash-pill--red b { color: var(--red); }

/* ── SUBTABS ── */
.subtabs {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.stab {
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 7px 14px;
  background: var(--card);
  color: var(--ink2);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.stab.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.stab-new {
  margin-left: auto;
  border-radius: 999px;
  border: none;
  padding: 7px 16px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
}

.stab-new:active { opacity: 0.8; }

/* ── SUBPANELS ── */
.subpanel { display: none; padding-bottom: 20px; }
.subpanel.active { display: block; }

/* ── CEREMONY CARDS ── */
.ceremony-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  border: 2px solid transparent;
  box-shadow: var(--shadow);
}

.ceremony-card.today { border-color: var(--green); }
.ceremony-card.green-frame { border-color: #22c55e; }

.cer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}

.cer-name {
  font-weight: 800;
  font-size: 17px;
  line-height: 1.2;
  flex: 1;
}

.cer-date {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  text-align: right;
}

.cer-today-badge {
  display: inline-block;
  background: var(--green);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  border-radius: 999px;
  padding: 2px 7px;
  margin-left: 6px;
}

.cer-place {
  font-size: 13px;
  color: var(--ink2);
  margin-bottom: 6px;
}

.cer-row {
  font-size: 12px;
  margin-bottom: 2px;
  color: var(--ink2);
}

.cer-row b { font-weight: 700; color: var(--ink); }

.cer-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-top: 10px;
}

/* ── WEEK DIVIDERS ── */
.week-divider {
  background: rgba(26,31,46,0.07);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: 0.06em;
  margin: 12px 0 8px;
  text-transform: uppercase;
}

/* ── WAREHOUSE ── */
.wh-section {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}

.wh-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.wh-head h3 { font-size: 14px; font-weight: 800; }

.wh-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.wh-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(26,31,46,0.03);
}

.wh-table td {
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}

.wh-table tr:hover td { background: rgba(26,31,46,0.02); }

.wh-qty {
  font-weight: 800;
  font-size: 15px;
}

.wh-qty.low { color: var(--red); }

.wh-hint {
  padding: 8px 14px 12px;
  font-size: 11px;
  color: var(--muted);
}

.wh-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

/* ── STATS ── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.stat-box {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 16px;
  text-align: center;
}

.stat-box__n {
  font-size: 32px;
  font-weight: 900;
  line-height: 1;
  color: var(--ink);
}

.stat-box__l {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 600;
}

/* ── HISTORY SEARCH ── */
.search-box {
  width: 100%;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 10px 16px;
  font-size: 14px;
  background: var(--card);
  margin-bottom: 10px;
}

.search-box:focus { outline: none; border-color: var(--ink); }

/* ── ORDERS: FILTER ROW ── */
.filter-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 10px;
}

.fbtn {
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  background: var(--card);
  color: var(--ink2);
  cursor: pointer;
}

.fbtn.active {
  background: var(--amber);
  color: var(--ink);
  border-color: var(--amber);
}

.fbtn--toggle {
  font-weight: 900;
  border-color: var(--ink);
}

.fbtn--toggle.on {
  background: var(--ink);
  color: #fff;
}

/* ── WREATH CARDS ── */
.wreath-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 13px 14px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.wreath-ceremony-title {
  font-weight: 800;
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 4px;
}

.wreath-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.wreath-type { font-size: 13px; color: var(--ink2); flex: 1; }

.badge {
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 800;
}

.badge--paid { background: #dcfce7; color: #14532d; }
.badge--unpaid { background: #fee2e2; color: #7f1d1d; }
.badge--draft { background: #f3f4f6; color: #374151; }
.badge--checked { background: #dcfce7; color: #14532d; border: 1px solid #86efac; }
.badge--ordered { background: #dbeafe; color: #1e3a8a; border: 1px solid #93c5fd; }
.badge--delivered { background: #ede9fe; color: #4c1d95; border: 1px solid #c4b5fd; }
.badge--cancelled { background: #fee2e2; color: #7f1d1d; }

.wreath-msg { font-size: 13px; color: var(--ink2); margin: 4px 0; }
.wreath-amount { font-size: 14px; font-weight: 900; color: var(--amber); }

.wreath-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-top: 8px;
}

/* Ceremony totals box */
.cer-totals {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 2px solid var(--line);
  background: rgba(255,255,255,0.6);
}

.cer-totals.has-unpaid { border-color: var(--red); }
.cer-totals.all-paid { border-color: var(--green); }

.totals-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 900;
}

.totals-row { font-size: 13px; font-weight: 800; margin-bottom: 2px; }
.totals-row.unpaid { color: #7f1d1d; }
.totals-row.paid { color: #14532d; }

/* ── ARCHIVE ── */
.archive-hero {
  text-align: center;
  padding: 30px 20px 20px;
}

.archive-icon { font-size: 48px; margin-bottom: 10px; }
.archive-hero h2 { font-size: 20px; font-weight: 900; margin-bottom: 6px; }
.archive-hero p { font-size: 14px; color: var(--muted); line-height: 1.5; }

.archive-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.archive-pick, .archive-refresh {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius);
  border: 1.5px solid var(--ink);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  background: var(--card);
  color: var(--ink);
}

.archive-pick { background: var(--ink); color: #fff; }
.archive-pick:active, .archive-refresh:active { opacity: 0.8; }

.archive-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--card);
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink2);
  margin-bottom: 16px;
  font-weight: 600;
}

.archive-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.archive-dot.connected { background: var(--green); }

/* Archive tree */
.archive-folder {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  margin-bottom: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.archive-folder-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
}

.archive-folder-head:active { background: rgba(0,0,0,0.03); }

.archive-folder-head .fold-icon { font-size: 16px; }

.archive-files {
  border-top: 1px solid var(--line);
  padding: 8px 0;
  display: none;
}

.archive-files.open { display: block; }

.archive-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--ink2);
  cursor: pointer;
  text-decoration: none;
}

.archive-file:hover { background: rgba(0,0,0,0.03); }
.archive-file-icon { font-size: 16px; }

/* ── BOTTOM NAV ── */
.bottomnav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottomnav-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  box-shadow: 0 -4px 20px rgba(26,31,46,0.08);
}

.bnav {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
}

.bnav.active { color: var(--ink); }

.bnav.active svg { stroke: var(--ink); }
.bnav svg { stroke: var(--muted); }

.nbadge {
  position: absolute;
  top: 4px;
  right: calc(50% - 22px);
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  border-radius: 999px;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
}

.nbadge.hidden { display: none; }

/* ── MODALS ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
}

.modal.hidden { display: none; }

.modal-bd {
  position: absolute;
  inset: 0;
  background: rgba(26,31,46,0.45);
  backdrop-filter: blur(2px);
}

.modal-sheet {
  position: relative;
  background: var(--card);
  border-radius: 22px 22px 0 0;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-sheet--sm { max-height: 60vh; }

.modal-pill {
  width: 36px; height: 4px;
  background: rgba(26,31,46,0.15);
  border-radius: 999px;
  margin: 10px auto 0;
  flex-shrink: 0;
}

.modal-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 10px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
}

.modal-hd h2 { font-size: 16px; font-weight: 900; }

.modal-x {
  background: rgba(26,31,46,0.08);
  border: none;
  border-radius: 999px;
  width: 28px; height: 28px;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  -webkit-overflow-scrolling: touch;
}

.modal-ft {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
  gap: 8px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

.modal-ft-r {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ── FORM ELEMENTS ── */
.fl {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 10px;
}

.fl-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  display: block;
  margin-bottom: 5px;
}

.fl input, .fl select, .fl textarea,
.f2 input, .f2 select {
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}

.fl input:focus, .fl select:focus, .fl textarea:focus,
.f2 input:focus, .f2 select:focus {
  outline: none;
  border-color: var(--ink);
}

.f2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

@media (max-width: 360px) { .f2 { grid-template-columns: 1fr; } }

.hint-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.hint-box.hidden { display: none; }

.radio-row {
  display: flex;
  gap: 14px;
  margin: 4px 0;
}

.radio-opt {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink2);
  cursor: pointer;
}

.locked-hint {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  color: #92400e;
  margin-bottom: 12px;
}

.locked-hint.hidden { display: none; }

/* ── BUTTONS ── */
.btn-primary {
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 9px 20px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.btn-primary:active { opacity: 0.8; }

.btn-secondary {
  background: rgba(26,31,46,0.08);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.btn-ghost {
  background: none;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-link {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 4px;
}

.btn-xs {
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

/* Card action buttons */
.cbtn {
  border-radius: 999px;
  border: none;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.cbtn--edit { background: var(--ink); color: #fff; }
.cbtn--delete { background: #fee2e2; color: #7f1d1d; }
.cbtn--wa { background: #22c55e; color: #fff; }
.cbtn--share { background: #e5e7eb; color: var(--ink); }
.cbtn--paid { background: #dcfce7; color: #14532d; }
.cbtn--unpaid { background: #fee2e2; color: #7f1d1d; }
.cbtn--link { background: #dbeafe; color: #1e3a8a; }

.hidden { display: none; }

/* ── TOAST ── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottomnav-h) + 10px);
  transform: translateX(-50%) translateY(10px);
  background: rgba(26,31,46,0.92);
  color: #fff;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 999;
  max-width: 90vw;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── RESPONSIVE ── */
@media (min-width: 600px) {
  .modal { align-items: center; justify-content: center; }
  .modal-sheet { border-radius: 22px; max-width: 540px; max-height: 85vh; }
}
