:root {
  --bg: #ffffff;
  --card: #ffffff;
  --ink: #1c1c1a;           /* near-black */
  --muted: #6d6b65;         /* warm gray, 5:1 on white: readable on a phone in daylight */
  --accent: #1c1c1a;
  --accent-soft: #f2f2f0;
  --accent-ink: #ffffff;
  --heart: #d92b2b;         /* red — the only selection marker */
  --danger: #b0433f;
  --ok: #3f7d4e;
  --border: #e9e8e4;
  --radius: 0;
}

* { box-sizing: border-box; }
:root {
  --font-display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-body: "EB Garamond", Georgia, "Times New Roman", serif;
}
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  background: var(--bg);
  color: var(--ink);
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: 0.02em;
}
h2 { font-size: 1.45rem; }

.container { max-width: none; margin: 0 auto; padding: 1rem 1.5rem; }
.container.narrow { max-width: 560px; }
.container.wide { max-width: none; }
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.login-card { width: min(360px, 92vw); text-align: center; }
.login-card input { width: 100%; margin: 0.75rem 0; }
.sso-btn { display: block; width: 100%; margin-top: 1rem; padding: 0.8rem; }
.login-fallback { margin-top: 1.2rem; }
.login-fallback summary { cursor: pointer; font-size: 0.85rem; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.75rem 1.25rem; background: var(--card); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.25rem; margin: 0; letter-spacing: 0.06em; }
.topbar-actions { display: flex; gap: 0.5rem; align-items: center; }

.btn {
  display: inline-block; padding: 0.55rem 1.1rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--card); color: var(--ink);
  font-size: 0.82rem; cursor: pointer;
  font-family: var(--font-body);
  text-transform: uppercase; letter-spacing: 0.14em;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; margin-top: 0.75rem; }
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }

input, select, textarea {
  padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 1rem; background: #fff; color: var(--ink); font-family: var(--font-body);
}
.form label { display: block; margin-bottom: 0.9rem; font-size: 0.92rem; color: var(--muted); }
.form label input, .form label select, .form label textarea { display: block; width: 100%; margin-top: 0.3rem; color: var(--ink); }
.form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  column-gap: 1rem; align-items: end;
}
.form .checkbox { display: flex; gap: 0.5rem; align-items: center; color: var(--ink); }
.form .checkbox input { width: auto; margin: 0; }

.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--danger); }

.badge {
  display: inline-block; padding: 0.2rem 0.6rem; border-radius: 0; font-size: 0.8rem;
}
.badge.done { background: #e7f2ea; color: var(--ok); }
.badge.expired { background: #f7e7e6; color: var(--danger); }
.badge.unpaid { background: #f7e7e6; color: var(--danger); }
.badge.paid { background: #e7f2ea; color: var(--ok); }
.badge.active { background: var(--accent-soft); color: var(--accent); }

.project-list { display: flex; flex-direction: column; gap: 0.5rem; }
.project-row {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  color: var(--ink); padding: 0.9rem 1.25rem;
}
.project-row.is-offline { opacity: 0.65; }
.project-main { color: var(--ink); flex: 1; min-width: 0; }
.project-title .muted { margin-inline-start: 0.6rem; }
.project-sub { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.85rem; margin-top: 0.25rem; }
.project-sub .due { color: var(--danger); font-weight: 600; }
.project-side { display: flex; gap: 0.6rem; align-items: center; flex-shrink: 0; }
.btn.small { padding: 0.35rem 0.75rem; font-size: 0.85rem; }
.badge.offline { background: #ececec; color: #666; }
.badge.st-draft { background: #ececec; color: #666; }
.badge.st-sent { background: #e4edf5; color: #3b6d96; }
.badge.st-viewed { background: #f5efdd; color: #8a6d1f; }
.badge.st-selecting { background: #f1e4f5; color: #7b4d96; }
.badge.st-submitted { background: #e7f2ea; color: var(--ok); }

.notif-wrap { position: relative; }
#notif-bell { position: relative; }
.notif-count {
  position: absolute; top: -6px; right: -6px;
  background: var(--danger); color: #fff; font-size: 0.7rem; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 0;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.notif-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 40;
  width: 320px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 6px 22px rgba(20, 40, 50, 0.16);
  max-height: 60vh; overflow-y: auto;
}
.notif-empty { padding: 1rem; text-align: center; margin: 0; }
.notif-item {
  display: block; padding: 0.7rem 1rem; color: var(--ink); font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--accent-soft); }
.notif-item .muted { display: block; font-size: 0.78rem; }
.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-state .btn { margin-top: 0.75rem; }

.link-row { display: flex; gap: 0.5rem; }
.link-row input { flex: 1; font-family: monospace; font-size: 0.85rem; }

.selection-grid { margin-bottom: 0.9rem; }
.selection-grid .admin-thumb { cursor: default; }

/* ---------- dashboard table ---------- */

.table-wrap { overflow-x: auto; padding: 0.5rem; }
.gallery-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.gallery-table th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.6rem 0.5rem; border-bottom: 2px solid var(--border);
}
.gallery-table td { padding: 0.35rem 0.4rem; border-bottom: 1px solid var(--border); }
.gallery-table tr:last-child td { border-bottom: none; }
.gallery-table tr.is-offline td { opacity: 0.55; }
.gallery-table .num, .gallery-table input.num { text-align: right; }
.gallery-table .nowrap { white-space: nowrap; }
.gallery-table input.inline {
  border: 1px solid transparent; background: transparent; border-radius: 0;
  padding: 0.35rem 0.4rem; width: 100%; min-width: 60px; font-size: 0.92rem;
}
.gallery-table input.inline:hover { border-color: var(--border); }
.gallery-table input.inline:focus { border-color: var(--accent); background: #fff; outline: none; }
.gallery-table input.inline.saved { border-color: var(--ok); background: #eef7f0; }
.gallery-table input.inline.save-error { border-color: var(--danger); background: #fbeeee; }
.gallery-table input.inline.num { min-width: 60px; }
.gallery-table input.inline[type="date"] { min-width: 0; width: 8.2rem; }
.btn.small { padding: 0.3rem 0.55rem; }
.row-actions { gap: 0.25rem; }
.row-actions { display: flex; gap: 0.35rem; align-items: center; }
.thumb-cell { width: 64px; }
.row-thumb {
  display: block; width: 56px; height: 42px; object-fit: cover;
  border-radius: 0; box-shadow: 0 1px 3px rgba(20, 40, 50, 0.2);
}
.row-thumb.empty {
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); font-size: 1.1rem;
}
.inline-form { display: inline; }
.ok-text { color: var(--ok); }
.due-text { color: var(--danger); font-weight: 600; }

.invoice-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.invoice-table th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.6rem 0.5rem; border-bottom: 2px solid var(--border);
}
.invoice-table td { padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--border); }
.invoice-table tr:last-child td { border-bottom: none; }
.invoice-table .num { text-align: right; }
.invoice-table input.inline, .invoice-table select.inline {
  border: 1px solid transparent; background: transparent;
  padding: 0.35rem 0.45rem; width: 100%; min-width: 90px; font-size: 0.92rem;
}
.invoice-table input.inline:hover, .invoice-table select.inline:hover { border-color: var(--border); }
.invoice-table input.inline:focus, .invoice-table select.inline:focus { border-color: var(--accent); background: #fff; outline: none; }
.invoice-table input.inline.saved, .invoice-table select.inline.saved { border-color: var(--ok); background: #eef7f0; }
.invoice-table input.inline.num { min-width: 80px; }
.billing-summary { font-size: 0.95rem; }
.billing-summary .ok { color: var(--ok); }
.billing-summary .due { color: var(--danger); }

/* ---------- correspondence log (mini-CRM) ---------- */

.email-log { margin-top: 1rem; }
.email-item {
  border: 1px solid var(--border); margin-bottom: 0.5rem;
}
.email-item summary {
  cursor: pointer; padding: 0.55rem 0.8rem;
  display: flex; gap: 0.7rem; align-items: center; flex-wrap: wrap;
}
.email-item summary strong { font-weight: 500; }
.email-item summary .email-addr { font-size: 0.78rem; }
.email-item summary .email-when { margin-inline-start: auto; font-size: 0.8rem; white-space: nowrap; }
.email-item[open] summary { border-bottom: 1px solid var(--border); }
.email-body {
  white-space: pre-wrap; word-break: break-word; font-family: var(--font-body);
  font-size: 0.95rem; margin: 0; padding: 0.8rem; background: #fbfbfa;
  max-height: 320px; overflow-y: auto;
}
.email-meta { padding: 0.4rem 0.8rem; margin: 0; }

/* ---------- customer payment pages ---------- */

.pay-card-box { width: min(460px, 94vw); text-align: center; padding: 1.75rem; }
.pay-amount { font-family: var(--font-display); font-size: 2.2rem; margin: 0.6rem 0; }
.pay-amount.ok { color: var(--ok); font-size: 1.4rem; }
.pay-option {
  display: block; text-align: start; border: 1px solid var(--border);
  padding: 0.9rem 1rem; margin: 0.7rem 0; color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.pay-option:hover { border-color: var(--ink); background: #fbfbfa; }
.pay-option-title { display: block; font-size: 1.05rem; margin-bottom: 0.2rem; }
.bank-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; text-align: start; margin: 0.8rem 0; }
.bank-table td { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); text-align: start; }
.bank-table td:first-child { color: var(--muted); white-space: nowrap; }
.bank-table tr:last-child td { border-bottom: none; }

.totals-bar {
  position: sticky; bottom: 0.5rem; z-index: 10;
  display: flex; flex-wrap: wrap; gap: 1.5rem; justify-content: center;
  padding: 0.8rem 1.25rem; font-size: 0.95rem;
  box-shadow: 0 -2px 12px rgba(20, 40, 50, 0.08);
}
.totals-bar strong { margin-inline-start: 0.3rem; }
.totals-bar .ok { color: var(--ok); }
.totals-bar .due { color: var(--danger); }

/* Two lists on the dashboard: the active list on top, the Done list beneath a
   clear divider. Only the active list keeps the sticky totals bar. */
.sessions-divider { border: none; border-top: 2px dashed var(--border); margin: 2.75rem 0 1.25rem; }
.sessions-heading { margin: 0 0 0.75rem; font-size: 1.15rem; color: var(--muted); letter-spacing: 0.02em; }
.sessions-group[data-scope="done"] .totals-bar {
  position: static; box-shadow: none; border-top: 1px solid var(--border);
}

/* ---------- email template editor ---------- */

.email-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
@media (max-width: 900px) { .email-editor { grid-template-columns: 1fr; } }
.var-table { border-collapse: collapse; font-size: 0.9rem; }
.var-table td { padding: 0.25rem 0.8rem 0.25rem 0; vertical-align: top; }
.var-table code {
  background: var(--accent-soft); color: var(--accent);
  padding: 0.1rem 0.4rem; border-radius: 0; font-size: 0.85rem;
}
.preview-card { position: sticky; top: 1rem; }
.email-preview {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; background: #fdfdfc;
}
.preview-subject { border-bottom: 1px solid var(--border); padding-bottom: 0.6rem; }
.email-preview pre {
  white-space: pre-wrap; word-break: break-word;
  font-family: inherit; font-size: 0.92rem; margin: 0;
}
.pv-html { font-size: 0.95rem; line-height: 1.6; word-break: break-word; }

.admin-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.6rem;
}
.admin-thumb { margin: 0; position: relative; cursor: grab; }
.admin-thumb.dragging { opacity: 0.4; }
.admin-thumb img { width: 100%; border-radius: 0; display: block; }
.admin-thumb figcaption { font-size: 0.72rem; color: var(--muted); word-break: break-all; }
.admin-thumb .sel-heart { color: var(--heart); }

/* ---------- client gallery (flat, white, full-width — no rounded corners) ---------- */

.gallery-page {
  -webkit-user-select: none; user-select: none;
  --g-bg: #ffffff;
  --g-tile: #fbfbfa;   /* very gentle, very bright gray */
  --g-ink: #1c1c1a;
  --g-muted: #8f8d87;
  --g-line: #e9e8e4;
  --g-heart: #d92b2b;  /* red — the only selection marker */
  --g-gold: #c99a2e;   /* gold — marks the free bonus photo */
  background: var(--g-bg);
  color: var(--g-ink);
}
.gallery-page .btn,
.gallery-page .card,
.gallery-page input,
.gallery-page .modal-box,
.gallery-page .toast { border-radius: 0; }
.gallery-page .btn.primary { background: var(--g-ink); border-color: var(--g-ink); color: #fff; }

.gallery-header {
  text-align: center;
  padding: 2rem 1.5rem 0.8rem;
}
.studio-name {
  margin: 0; font-size: 0.95rem; letter-spacing: 0.42em; text-transform: uppercase;
  color: var(--g-ink); font-weight: 500;
  font-family: var(--font-display);
}
.gallery-title {
  margin: 0.7rem 0 0.15rem; font-size: 2rem; font-weight: 500;
  font-family: var(--font-display);
  text-transform: uppercase; letter-spacing: 0.1em;
}
.shoot-name { margin: 0; color: var(--g-muted); font-style: italic; }
.instructions { margin-top: 0.7rem; color: var(--g-muted); font-size: 0.95rem; }

.selection-bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.7rem 1.1rem;
  padding: 0.65rem 1.5rem;
  background: color-mix(in srgb, var(--g-bg) 94%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--g-line);
}
.sel-info { display: flex; align-items: center; gap: 0.35rem; font-size: 0.95rem; }
.heart-mini { color: var(--g-heart); }
.sel-options { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.4rem 0.85rem; cursor: pointer;
  border: 1px solid var(--g-line); background: var(--g-bg);
  font-size: 0.9rem; transition: all 0.15s ease;
}
.chip input { accent-color: var(--g-ink); margin: 0; cursor: pointer; }
.chip:has(input:checked) {
  border-color: var(--g-ink); background: var(--g-ink); color: #fff;
}
.chip:has(input:checked) input { accent-color: #fff; }
.chip:has(input:disabled) { opacity: 0.55; cursor: default; }

/* Bonus offer: a longer, review-linked label; goes gold (not ink) when claimed. */
.chip-bonus .review-link { color: inherit; text-decoration: underline; font-weight: 600; }
.chip-bonus:has(input:checked) {
  border-color: var(--g-gold); background: var(--g-gold); color: #3a2c07;
}
.chip-bonus:has(input:checked) input { accent-color: #3a2c07; }

.done-btn { display: inline-flex; align-items: center; gap: 0.4rem; }
.btn-heart { font-size: 0.9em; }

.photo-grid {
  margin: 1.2rem 0; padding: 0 1.5rem;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.3rem;
}
.photo-tile {
  position: relative; overflow: hidden; cursor: pointer;
  background: var(--g-tile);
  aspect-ratio: 1 / 1;
  transition: background 0.15s ease;
}
.photo-tile:hover { background: #f5f5f3; }
.photo-tile img {
  width: 100%; height: 100%; object-fit: contain; display: block;
  padding: 7%; box-sizing: border-box;
  -webkit-user-drag: none; pointer-events: none;
}

.photo-tile .heart {
  position: absolute; bottom: 10px; inset-inline-end: 10px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.18s ease;
}
.photo-tile .heart svg { width: 24px; height: 24px; }
.photo-tile .heart svg path {
  fill: none; stroke: #b3b1ab; stroke-width: 1.8;
  transition: all 0.18s ease;
}
.photo-tile:hover .heart svg path { stroke: var(--g-heart); }
/* Selection is marked ONLY by the red heart — no outline, no frame. */
.photo-tile.is-selected .heart svg path { fill: var(--g-heart); stroke: var(--g-heart); }
.photo-tile.pop .heart { animation: heart-pop 0.35s ease; }
@keyframes heart-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.35); }
  100% { transform: scale(1); }
}


/* The free bonus photo (the last one chosen past the base limit): a gold ring
   plus a corner flag, so it reads clearly apart from the red selection heart. */
.photo-tile.is-bonus { box-shadow: inset 0 0 0 3px var(--g-gold); background: #fdfaf0; }
.bonus-flag {
  position: absolute; top: 10px; inset-inline-start: 10px;
  display: none; align-items: center; gap: 0.2rem;
  padding: 0.2rem 0.5rem; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
  background: var(--g-gold); color: #3a2c07;
}
.photo-tile.is-bonus .bonus-flag { display: inline-flex; }

.photo-tile.is-locked { cursor: default; }

/* ---------- full-gallery offer ("I want it all") ---------- */
.all-offer {
  margin: 1.2rem 1.5rem 0.4rem;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem 2rem;
  padding: 1.4rem 1.6rem;
  border: 1px solid var(--g-line); border-top: 3px solid var(--g-gold);
  background: linear-gradient(180deg, #fffdf8, #fbf6ea);
}
.all-offer-copy { flex: 1 1 22rem; }
.all-offer-kicker {
  margin: 0 0 0.3rem; font-size: 0.72rem; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--g-gold);
}
.all-offer-title { margin: 0 0 0.35rem; font-size: 1.45rem; font-weight: 500; letter-spacing: 0.01em; color: var(--g-ink); }
.all-offer-text { margin: 0; color: var(--g-muted); font-size: 0.98rem; }
.all-offer-action { flex: 0 1 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 0.45rem; text-align: right; }
.all-offer-price { margin: 0; font-size: 1.6rem; line-height: 1.1; color: var(--g-ink); }
.all-offer-price span { display: block; font-size: 0.75rem; color: var(--g-muted); letter-spacing: 0.04em; }
.all-offer-taxnote { margin: -0.2rem 0 0.1rem; font-size: 0.78rem; font-style: italic; color: var(--g-muted); }
.all-offer-toggle {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.75rem 1.5rem; cursor: pointer;
  font-size: 0.95rem; letter-spacing: 0.1em; text-transform: uppercase;
  background: var(--g-ink); color: #fff; border: 1px solid var(--g-ink);
  transition: background 0.15s ease, color 0.15s ease;
}
.all-offer-toggle:hover { background: #33322e; }
.all-offer-toggle:focus-within { outline: 2px solid var(--g-gold); outline-offset: 2px; }
/* Keep the real checkbox for keyboard + screen readers, but hide the box. */
.all-offer-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.all-offer-hint { margin: 0; font-size: 0.85rem; color: #6b5313; }
.all-offer .when-on { display: none; }
.all-offer.is-on .when-on { display: inline; }
.all-offer.is-on p.when-on { display: block; }
.all-offer.is-on .when-off { display: none; }
.all-offer.is-on { border-color: var(--g-gold); background: #fbf3de; }
.all-offer.is-on .all-offer-toggle { background: var(--g-gold); border-color: var(--g-gold); color: #3a2c07; }
.all-offer.is-final .all-offer-title { font-size: 1.3rem; }
@media (max-width: 640px) {
  .all-offer { margin: 0.9rem 0.7rem 0.3rem; padding: 1.1rem; }
  .all-offer-title { font-size: 1.25rem; }
  .all-offer-action { width: 100%; align-items: stretch; text-align: left; }
}

.zoom-btn {
  position: absolute; top: 10px; inset-inline-end: 10px;
  width: 30px; height: 30px; border: none; border-radius: 0;
  background: rgba(28, 28, 26, 0.5); color: #fff; cursor: pointer; font-size: 0.9rem;
  opacity: 0; transition: opacity 0.15s ease;
}
.photo-tile:hover .zoom-btn { opacity: 1; }
@media (hover: none) { .zoom-btn { opacity: 1; } }

.protect-note { text-align: center; color: var(--g-muted); font-size: 0.8rem; padding: 1rem 1rem 2rem; }

.modal { position: fixed; inset: 0; z-index: 50; background: rgba(10, 25, 32, 0.5);
  display: flex; align-items: center; justify-content: center; }
.modal-box { background: var(--card); border-radius: var(--radius); padding: 1.5rem;
  width: min(400px, 90vw); text-align: center; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: center; margin-top: 1rem; }

.email-modal-box { width: min(640px, 94vw); text-align: left; max-height: 92vh; overflow-y: auto; }
.email-modal-box h2 { margin-top: 0; }
.em-label { display: block; margin-bottom: 0.8rem; font-size: 0.92rem; color: var(--muted); }
.em-label input, .em-label textarea { display: block; width: 100%; margin-top: 0.3rem; color: var(--ink); }
.em-hint code { background: var(--accent-soft); color: var(--accent); padding: 0.05rem 0.3rem; border-radius: 0; }
.em-actions { justify-content: flex-end; flex-wrap: wrap; }

.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(8, 14, 18, 0.95);
  display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 92vw; max-height: 92vh; -webkit-user-drag: none; }
.lb-close, .lb-nav {
  position: absolute; background: rgba(255,255,255,0.12); color: #fff; border: none;
  cursor: pointer; border-radius: 0; font-size: 1.4rem; width: 44px; height: 44px;
}
.lb-close { top: 14px; inset-inline-end: 14px; }
.lb-prev { inset-inline-start: 14px; top: 50%; transform: translateY(-50%); }
.lb-next { inset-inline-end: 14px; top: 50%; transform: translateY(-50%); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 70;
  background: var(--ink); color: #fff; padding: 0.7rem 1.2rem; border-radius: 0;
  font-size: 0.92rem; max-width: 90vw; text-align: center;
}
.hidden { display: none !important; }

@media print { body { display: none !important; } }

/* ---------- save feedback (admin) ---------- */

.admin-toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 90;
  background: var(--ink); color: #fff; padding: 0.6rem 1rem;
  font-size: 0.9rem; max-width: 420px; line-height: 1.4;
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.admin-toast.show { opacity: 1; transform: translateY(0); }
.admin-toast.error { background: var(--danger); }
.save-state { font-size: 0.78rem; font-weight: 400; margin-inline-start: 0.6rem; }
.save-state.unsaved { color: var(--danger); }
.save-state.saved-ok { color: var(--ok); }

/* ---------- Templates area ---------- */

.tpl-tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.8rem 0 1rem; }
.tpl-tab {
  border: 1px solid var(--border); background: var(--card); color: var(--ink);
  padding: 0.5rem 1rem; cursor: pointer; font-family: var(--font-body);
  font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.12em;
}
.tpl-tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.tpl-dot { color: var(--heart); }
.tpl-tab.active .tpl-dot { color: #fff; }

/* Admin notice: something the photographer should read once, e.g. a gallery
   that was reopened because its photo limit went up. */
.notice {
  border-left: 3px solid var(--accent, #c0392b);
  padding: 0.9rem 1.1rem;
  margin-bottom: 1rem;
}

/* ---------- stages: the four steps a session moves through ---------- */

.stage-chips { display: inline-flex; gap: 0.3rem; align-items: center; }
.stage-chip {
  display: inline-block; padding: 0.22rem 0.55rem; font-size: 0.78rem; letter-spacing: 0.02em;
  border: 1px solid var(--border); background: #fff; color: var(--muted); white-space: nowrap;
}
.stage-chip.done { background: #e7f2ea; color: var(--ok); border-color: #d3e6d8; }
.stage-chip.active { background: #f5efdd; color: #8a6d1f; border-color: #eadfb8; }
.stage-chip.todo { opacity: 0.55; }
.stage-chip.is-current { border-color: var(--accent); color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); opacity: 1; }
.stage-chip:hover { border-color: var(--accent); opacity: 1; }
.sessions-table input.inline { min-width: 90px; }

.summary-strip { display: flex; flex-wrap: wrap; gap: 1rem 2.25rem; align-items: baseline; }
.summary-strip .item { display: flex; flex-direction: column; gap: 0.15rem; }
.summary-strip .label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.summary-strip .value { font-size: 1.1rem; }
.summary-strip .value.num { font-variant-numeric: tabular-nums; }

.stage-nav { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 1rem; }
.stage-tab {
  flex: 1; padding: 0.75rem 1rem 0.65rem; margin-bottom: -2px;
  border-bottom: 3px solid transparent; color: var(--muted);
  display: flex; flex-direction: column; gap: 0.15rem;
}
.stage-tab .t { font-family: var(--font-display); font-size: 1.15rem; letter-spacing: 0.03em; color: var(--ink); }
.stage-tab .h { font-size: 0.78rem; }
.stage-tab .s { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; margin-top: 0.15rem; }
.stage-tab.done .s { color: var(--ok); }
.stage-tab.active .s { color: #8a6d1f; }
.stage-tab.todo .s { color: var(--muted); }
.stage-tab.is-current { border-bottom-color: var(--accent); }
.stage-tab:hover { background: var(--accent-soft); }
.stage-num {
  display: inline-block; width: 1.45rem; height: 1.45rem; line-height: 1.4rem; text-align: center;
  border: 1px solid currentColor; font-size: 0.75rem; margin-inline-end: 0.45rem; font-family: var(--font-body);
}
.stage-tab.done .stage-num { background: var(--ok); border-color: var(--ok); color: #fff; }
.stage-tab.is-current .stage-num { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- dashboard: filter + sortable table ---------- */
.table-toolbar { display: flex; gap: 0.6rem; align-items: center; margin-bottom: 0.6rem; flex-wrap: wrap; }
.table-toolbar input[type="search"] { padding: 0.45rem 0.6rem; border: 1px solid var(--border); background: #fff; min-width: 16rem; font-size: 0.95rem; }
.table-toolbar select { padding: 0.45rem 0.6rem; border: 1px solid var(--border); background: #fff; font-size: 0.95rem; }
.filter-count { font-size: 0.85rem; }
.gallery-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.gallery-table th.sortable:hover { color: var(--accent); }
.gallery-table th.sortable::after { content: '↕'; opacity: 0.3; margin-inline-start: 0.3rem; font-size: 0.75rem; }
.gallery-table th.sortable.sort-asc::after { content: '↑'; opacity: 0.9; }
.gallery-table th.sortable.sort-desc::after { content: '↓'; opacity: 0.9; }

/* ---------- customer invoice / statement on the pay page ---------- */
.pay-statement { text-align: left; margin: 1rem 0; border: 1px solid var(--border); }
.pay-statement .line { display: flex; justify-content: space-between; gap: 1rem; padding: 0.5rem 0.8rem; border-bottom: 1px solid var(--border); }
.pay-statement .line:last-child { border-bottom: none; }
.pay-statement .line.paid { color: var(--ok); }
.pay-statement .line.bal { font-weight: 700; font-size: 1.1rem; background: var(--accent-soft); }

/* ---------- Done stage checklist ---------- */
.done-checklist { list-style: none; padding: 0; margin: 0.8rem 0; }
.done-checklist li { padding: 0.35rem 0; color: var(--muted); }
.done-checklist li.ok { color: var(--ink); }

/* ---------- billing: installments form ---------- */
.installments-form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; margin-top: 0.4rem; }
.installments-form label { display: flex; flex-direction: column; font-size: 0.8rem; color: var(--muted); gap: 0.2rem; }
.installments-form input { padding: 0.4rem 0.5rem; border: 1px solid var(--border); background: #fff; font-size: 0.95rem; }
.installments-form input[name="payments"] { width: 4.5rem; }
.installments-form input[type="number"] { width: 9rem; }

/* ============================================================
   Mobile admin — phones such as the iPhone 16e (~390px wide).
   The dense sessions list becomes tap-friendly cards; the topbar
   wraps; wide financial tables keep their own horizontal scroll.
   ============================================================ */

/* Tablet / small laptop: let the topbar wrap and tighten padding. */
@media (max-width: 820px) {
  .topbar { flex-direction: column; align-items: stretch; gap: 0.6rem; }
  .topbar-actions { flex-wrap: wrap; justify-content: center; gap: 0.4rem; }
  .container { padding: 0.85rem 1rem; }
}

/* Phones. */
@media (max-width: 640px) {
  .topbar { padding: 0.7rem 0.9rem; }
  .topbar h1 { font-size: 1.05rem; text-align: center; }
  .topbar-actions .btn,
  .topbar-actions form { flex: 1 1 8rem; }
  .topbar-actions form { display: flex; }
  .topbar-actions form > .btn { width: 100%; }
  /* Comfortable touch targets everywhere. */
  .btn { padding: 0.65rem 0.9rem; font-size: 0.88rem; min-height: 42px; line-height: 1.2; }
  .container { padding: 0.7rem 0.7rem; }
  .card { padding: 0.9rem; }

  /* Per-list filter/sort controls stack full width. */
  .table-toolbar { flex-direction: column; align-items: stretch; }
  .table-toolbar .table-filter,
  .table-toolbar .stage-filter { width: 100%; box-sizing: border-box; }

  /* --- Sessions list -> stacked cards (dashboard + Done list) --- */
  .sessions-group .table-wrap {
    overflow-x: visible; padding: 0; border: none; background: transparent; box-shadow: none;
  }
  .sessions-table thead { display: none; }
  .sessions-table, .sessions-table tbody, .sessions-table tr, .sessions-table td { display: block; width: 100%; }
  .sessions-table tr {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    margin-bottom: 0.7rem; padding: 0.55rem 0.8rem; box-sizing: border-box;
  }
  .sessions-table td {
    display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
    padding: 0.4rem 0; border: none; text-align: right; min-height: 2.2rem;
  }
  .sessions-table td::before {
    content: attr(data-label); font-weight: 600; color: var(--muted);
    font-size: 0.78rem; text-align: left; flex: 0 0 auto; white-space: nowrap;
  }
  /* Numbers Yoav rarely needs on a phone glance stay off the card. */
  .sessions-table td.mobile-hide, .sessions-table th.mobile-hide { display: none; }
  .sessions-table input.inline { text-align: right; max-width: 62%; }
  .sessions-table input.inline[type="date"] { width: auto; }
  /* Photo sits on top of each card as a big tap target into the session. */
  .sessions-table .thumb-cell { justify-content: center; padding-bottom: 0.2rem; }
  .sessions-table .thumb-cell::before { content: none; }
  .sessions-table .thumb-cell a { display: block; width: 100%; }
  .sessions-table .row-thumb { width: 100%; height: auto; max-height: 190px; aspect-ratio: 3 / 2; object-fit: cover; }
  .sessions-table .row-thumb.empty { display: flex; align-items: center; justify-content: center; font-size: 2rem; aspect-ratio: 3 / 2; background: var(--card); border: 1px dashed var(--border); }
  .sessions-table .stage-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; justify-content: flex-end; }
  .sessions-table td.nowrap { white-space: normal; }

  /* Totals bar: stop it floating over the cards; make it a plain panel. */
  .totals-bar {
    position: static; box-shadow: none; border: 1px solid var(--border);
    gap: 0.4rem 1rem; justify-content: space-between; font-size: 0.85rem;
  }

  /* Wide financial tables (billing, ledger) keep horizontal scroll with a nudge. */
  .invoice-table { font-size: 0.85rem; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
}

/* ---------- gallery settings: three tidy groups ---------- */
.settings-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 1rem; margin: 0.4rem 0 1rem; }
.settings-group { border: 1px solid var(--border); padding: 0.9rem 1rem 0.3rem; background: #fdfcfa; }
.settings-group h3 { margin: 0 0 0.8rem; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.settings-group .checkbox { margin-bottom: 0.75rem; align-items: flex-start; line-height: 1.35; }
.settings-group .checkbox input { margin-top: 0.2rem; }
.settings-indent { margin-left: 1.6rem; max-width: 9rem; }
.settings-note { margin: -0.4rem 0 0.75rem; font-size: 0.8rem; line-height: 1.4; }
.settings-reopen { color: var(--danger) !important; }

/* Booked stage: per-customer automatic email switches */
.email-switches { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0.4rem 1.2rem; }
.email-switches .checkbox { align-items: flex-start; line-height: 1.35; }
.email-switches .checkbox input { margin-top: 0.25rem; }
.email-switches .muted { font-size: 0.82rem; }

/* Booked stage: "Coming up for <client>" — the emails queued for this customer */
.coming-list { list-style: none; margin: 0.4rem 0 0; padding: 0; }
.coming-item { display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; padding: 0.7rem 0; border-top: 1px solid var(--line, rgba(0, 0, 0, 0.08)); }
.coming-item:first-child { border-top: 0; }
.coming-item .muted { font-size: 0.85rem; }
.coming-item .badge { margin-left: 0.4rem; }
.coming-item .btn { flex: none; }

/* Dashboard: customer + session type open the session */
.row-link { color: var(--ink); text-decoration: none; border-bottom: 1px dotted transparent; }
.row-link:hover { border-bottom-color: currentColor; }
.row-link-name { font-weight: 600; }
.edit-email-link { font-size: 0.78rem; font-weight: 400; margin-left: 0.35rem; color: var(--accent); }

/* Session number YYMMDD-NN — the cross-reference link in every admin table. */
.sess-no { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.82em; letter-spacing: 0.02em; white-space: nowrap; }

/* Search everything (top bar) and per-list tools (public/js/lists.js). */
.global-search input { width: 15rem; max-width: 42vw; padding: 0.42rem 0.6rem; font-size: 0.85rem; }
.list-tools { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin: 0.3rem 0 0.5rem; position: relative; }
.list-search { width: 15rem; max-width: 100%; padding: 0.35rem 0.55rem; font-size: 0.85rem; }
.list-count { font-size: 0.8rem; }
.table-toolbar { position: relative; }
.list-cols-panel { position: absolute; z-index: 30; top: 100%; right: 0; background: #fff; border: 1px solid var(--border); box-shadow: 0 6px 24px rgba(0,0,0,0.12); padding: 0.6rem 0.7rem; min-width: 16rem; max-height: 60vh; overflow: auto; }
.list-cols-row { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; padding: 0.15rem 0; font-size: 0.85rem; }
.list-cols-row label { display: flex; gap: 0.35rem; align-items: center; cursor: pointer; }
.list-cols-row .btn.small { padding: 0.1rem 0.4rem; }
.search-group { margin-bottom: 1rem; }
.search-group h2 { font-size: 1.05rem; margin: 0 0 0.4rem; }
.search-hit { padding: 0.45rem 0; border-bottom: 1px solid var(--border); }
.search-hit:last-child { border-bottom: none; }
.search-hit .meta { font-size: 0.8rem; color: var(--muted); }
.search-hit mark { background: #fbeec2; padding: 0 1px; }

/* ============================================================
   Accessibility (all screens)
   ============================================================ */
a:focus-visible, button:focus-visible, .btn:focus-visible, summary:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--ink); outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
/* The search box sits in the header next to the page's buttons. */
.topbar { gap: 0.6rem 0.75rem; flex-wrap: wrap; }
.topbar h1 { flex: 1 1 16rem; min-width: 0; }
.topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
.topbar .global-search { flex: 0 1 auto; }

/* The phone tab bar and menu (public/js/admin-mobile.js) — phones only. */
.m-tabbar, .m-sheet, .m-shade { display: none; }
.m-label { display: none; }

/* ============================================================
   Phones — Yoav's Android and Meital's iPhone (v1.65)
   ============================================================ */
@media (max-width: 640px) {
  html { -webkit-text-size-adjust: 100%; }
  body {
    font-size: 16px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.06);
    padding-bottom: calc(68px + env(safe-area-inset-bottom));
  }
  /* 16px stops iPhone Safari zooming in on every field you tap. */
  input, select, textarea,
  .gallery-table input.inline, .invoice-table input.inline, .invoice-table select.inline,
  .list-search, .table-toolbar input[type="search"], .table-toolbar select { font-size: 16px; }
  input:not([type="checkbox"]):not([type="radio"]), select { min-height: 44px; }

  /* Header: back link / title, then the search box. The page's buttons are in Menu. */
  .topbar {
    position: sticky; top: 0; z-index: 30;
    flex-direction: column; align-items: stretch; gap: 0.5rem;
    padding: calc(0.6rem + env(safe-area-inset-top)) calc(0.9rem + env(safe-area-inset-right)) 0.6rem calc(0.9rem + env(safe-area-inset-left));
    background: #fff;
  }
  .topbar h1 { font-size: 1.12rem; text-align: left; line-height: 1.3; letter-spacing: 0.03em; }
  .topbar h1 a { display: inline-block; padding: 0.35rem 0; }
  .topbar > .topbar-actions { flex-wrap: wrap; justify-content: flex-start; }
  .topbar .global-search { width: 100%; }
  .global-search input { width: 100%; max-width: none; padding: 0.55rem 0.8rem; border-radius: 10px; background: #f6f5f2; border-color: #f6f5f2; }

  .container, .container.narrow { padding: 0.75rem calc(0.75rem + env(safe-area-inset-left)) 1rem; max-width: none; }
  .card { padding: 0.95rem; border-radius: 12px; }
  h2 { font-size: 1.3rem; margin: 0.2rem 0 0.6rem; }
  .btn { padding: 0.7rem 1rem; min-height: 44px; font-size: 0.85rem; letter-spacing: 0.08em; border-radius: 10px; }
  .btn.small { min-height: 38px; padding: 0.45rem 0.75rem; font-size: 0.8rem; }
  .admin-toast { left: 12px; right: 12px; max-width: none; bottom: calc(80px + env(safe-area-inset-bottom)); border-radius: 10px; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .notice { border-radius: 12px; }

  /* ---- bottom tab bar ---- */
  .m-tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: #fff;
    border-top: 1px solid var(--border);
    padding: 0.3rem env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  .m-tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.15rem;
    min-height: 56px; padding: 0.25rem 0; color: var(--muted); background: none; border: 0;
    font: 500 0.7rem/1.1 var(--font-body); letter-spacing: 0.03em; cursor: pointer;
  }
  .m-tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .m-tab.is-on, .m-tab[aria-expanded="true"] { color: var(--ink); }
  .m-tab.is-on span { font-weight: 700; }
  .m-tab.is-add svg { width: 34px; height: 34px; padding: 6px; border-radius: 50%; background: var(--ink); color: #fff; stroke-width: 2.2; }

  /* ---- menu sheet ---- */
  .m-shade:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 70; background: rgba(20, 20, 18, 0.35); }
  .m-sheet:not([hidden]) {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
    max-height: 86vh; overflow-y: auto; overscroll-behavior: contain;
    background: #fff; border-radius: 18px 18px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.18);
    padding: 0.4rem calc(1rem + env(safe-area-inset-right)) calc(1rem + env(safe-area-inset-bottom)) calc(1rem + env(safe-area-inset-left));
    animation: m-up 0.2s ease-out;
  }
  @keyframes m-up { from { transform: translateY(30px); opacity: 0.6; } to { transform: none; opacity: 1; } }
  html.m-sheet-open, html.m-sheet-open body { overflow: hidden; }
  .m-sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0 0.4rem; position: sticky; top: -0.4rem; background: #fff; z-index: 1; }
  .m-sheet-head strong { font-family: var(--font-display); font-size: 1.3rem; font-weight: 500; }
  .m-sheet-close { width: 44px; height: 44px; border: 0; border-radius: 50%; background: #f3f2ef; font-size: 1.05rem; cursor: pointer; color: var(--ink); }
  .m-sheet-title { margin: 0.9rem 0 0.3rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
  .m-sheet .topbar-actions { display: flex; flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .m-sheet .topbar-actions > .btn, .m-sheet .topbar-actions > form, .m-sheet .topbar-actions > .notif-wrap { width: 100%; flex: none; }
  .m-sheet .topbar-actions .btn { width: 100%; text-align: center; }
  .m-sheet .topbar-actions form { display: block; }
  .m-sheet .m-dup { display: none !important; }
  .m-sheet .m-label { display: inline; margin-inline-start: 0.5rem; }
  .m-sheet-actions .m-sheet-title { margin-top: 0.2rem; }
  .m-sheet .notif-dropdown { position: static; width: auto; box-shadow: none; margin-top: 0.4rem; }
  .m-sheet .notif-count { top: 6px; right: 10px; border-radius: 9px; }
  .m-sheet-links { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
  .m-sheet-link { display: flex; align-items: center; justify-content: space-between; min-height: 50px; padding: 0 1rem; color: var(--ink); border-bottom: 1px solid var(--border); font-size: 1.02rem; }
  .m-sheet-link:last-child { border-bottom: 0; }
  .m-sheet-link::after { content: '›'; color: var(--muted); font-size: 1.3rem; }
  .m-sheet-link[aria-current="page"] { font-weight: 700; background: #f8f7f4; }
  .m-sheet-logout { margin-top: 0.9rem; }
  .m-sheet-logout .btn { width: 100%; }

  /* ---- sessions list: one compact card per session ---- */
  .table-toolbar { flex-direction: row; flex-wrap: wrap; gap: 0.5rem; }
  .table-toolbar .table-filter { flex: 1 1 100%; min-width: 0; border-radius: 10px; }
  .table-toolbar .stage-filter { flex: 1 1 auto; width: auto; border-radius: 10px; }
  .table-toolbar .list-cols-btn { flex: 0 0 auto; }
  .table-toolbar .filter-count { flex-basis: 100%; order: 10; }
  .table-toolbar .filter-count:empty { display: none; }
  .sessions-table tr {
    display: grid; grid-template-columns: 60px minmax(0, 1fr) auto; column-gap: 0.75rem; row-gap: 0.2rem;
    align-items: center; padding: 0.75rem 0.8rem; margin-bottom: 0.6rem; border-radius: 12px;
  }
  .sessions-table td { display: block; padding: 0; min-height: 0; text-align: left; width: auto; }
  .sessions-table td::before { content: none; }
  .sessions-table .thumb-cell { grid-column: 1; grid-row: 1 / span 2; padding: 0; align-self: start; }
  .sessions-table .row-thumb, .sessions-table .row-thumb.empty {
    width: 60px; height: 60px; max-height: none; aspect-ratio: auto; border-radius: 10px; box-shadow: none; font-size: 1.3rem;
  }
  .sessions-table .c-name { grid-column: 2; grid-row: 1; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sessions-table .c-no { grid-column: 3; grid-row: 1; text-align: right; font-size: 0.85rem; }
  .sessions-table .c-type { grid-column: 2 / span 2; grid-row: 2; font-size: 0.9rem; }
  .sessions-table .c-type a { color: var(--muted); }
  .sessions-table .c-date { grid-column: 1 / span 3; grid-row: 3; display: flex; gap: 0.4rem; margin-top: 0.45rem; }
  .sessions-table .c-date input.inline { flex: 1 1 auto; width: auto !important; max-width: none; min-width: 0; text-align: left; border: 1px solid var(--border); border-radius: 8px; min-height: 40px; }
  .sessions-table .c-date input[type="time"] { flex: 0 0 7.5rem; }
  .sessions-table .c-col, .sessions-table .c-due { grid-row: 4; display: flex; justify-content: flex-start; align-items: baseline; gap: 0.35rem; margin-top: 0.35rem; font-size: 0.95rem; }
  .sessions-table .c-col { grid-column: 1 / span 2; }
  .sessions-table .c-due { grid-column: 3; justify-content: flex-end; }
  .sessions-table .c-col::before, .sessions-table .c-due::before { content: attr(data-label); font-size: 0.75rem; color: var(--muted); font-weight: 400; }
  .sessions-table .c-stage { grid-column: 1 / span 3; grid-row: 5; margin-top: 0.45rem; }
  .sessions-table .stage-chips { justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -0.8rem; padding: 0 0.8rem; }
  .sessions-table .stage-chips::-webkit-scrollbar { display: none; }
  .sessions-table .stage-chip { padding: 0.35rem 0.6rem; font-size: 0.78rem; border-radius: 999px; }
  .sessions-table td.mobile-hide { display: none; }
  .totals-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem 1rem; border-radius: 12px; }
  .totals-bar span { display: flex; justify-content: space-between; }

  /* ---- every other list: cards, each value labelled ---- */
  .table-wrap { padding: 0; border: 0; background: transparent; overflow: visible; }
  table.m-cards, table.m-cards tbody, table.m-cards tfoot, table.m-cards tr { display: block; width: 100%; }
  table.m-cards thead { display: none; }
  table.m-cards tbody tr, table.m-cards tfoot tr {
    background: var(--card); border: 1px solid var(--border); border-radius: 12px;
    padding: 0.55rem 0.85rem; margin-bottom: 0.6rem;
  }
  table.m-cards td {
    display: flex; justify-content: space-between; align-items: center; gap: 0.9rem;
    padding: 0.4rem 0; border: 0; border-bottom: 1px solid #f1f0ec; text-align: right; min-width: 0;
    overflow-wrap: anywhere;
  }
  table.m-cards td:last-child { border-bottom: 0; }
  table.m-cards td:empty { display: none; }
  table.m-cards td[data-label]::before {
    content: attr(data-label); flex: 0 0 auto; max-width: 42%;
    text-align: left; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
  }
  table.m-cards td:not([data-label]) { justify-content: flex-start; text-align: left; }
  table.m-cards td > form, table.m-cards td > details { max-width: 100%; }
  table.m-cards td input.inline, table.m-cards td select.inline, table.m-cards td select {
    max-width: 62%; min-width: 0; border: 1px solid var(--border); border-radius: 8px; text-align: right;
  }
  table.m-cards td.num { font-variant-numeric: tabular-nums; }
  table.m-cards .m-val { display: block; min-width: 0; text-align: right; }
  table.m-cards td:not([data-label]) .m-val { flex: 1; text-align: left; }
  table.m-cards .m-val select, table.m-cards .m-val input.inline { max-width: 100%; }
  /* A note row under a payment ("⚠ …") reads as part of the card above it. */
  table.m-cards tbody tr:has(> td[colspan]) { margin-top: -0.65rem; border-top: 0; border-radius: 0 0 12px 12px; padding-top: 0; }
  table.m-cards td[colspan] { display: block; text-align: left; }
  .list-tools { gap: 0.5rem; }
  .list-tools .list-search { flex: 1 1 auto; width: auto; min-height: 44px; border-radius: 10px; }
  .list-cols-panel { left: 0; right: 0; min-width: 0; border-radius: 12px; }
  .list-cols-row { min-height: 44px; }

  /* ---- one session: summary + the four stages ---- */
  .summary-strip { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem 1rem; }
  .summary-strip .value { font-size: 1rem; overflow-wrap: anywhere; }
  .stage-nav { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; gap: 0.2rem; scroll-snap-type: x proximity; }
  .stage-nav::-webkit-scrollbar { display: none; }
  .stage-tab { flex: 0 0 auto; min-width: 7.2rem; padding: 0.6rem 0.75rem 0.55rem; scroll-snap-align: start; }
  .stage-tab .t { font-size: 1.02rem; white-space: nowrap; }
  .stage-tab .h { display: none; }
  .email-item summary { min-height: 44px; }
  .email-item summary .email-when { margin-inline-start: 0; }
  .admin-grid { grid-template-columns: repeat(3, 1fr); gap: 0.35rem; }
  .settings-groups, .email-switches { grid-template-columns: 1fr; }
  .coming-item { flex-direction: column; gap: 0.5rem; }
  .coming-item .btn { width: 100%; }
  .installments-form label, .installments-form input[type="number"] { width: 100%; }
  .link-row { flex-direction: column; }
  .modal-box { border-radius: 14px; }
  .email-modal-box { width: 100vw; max-height: 100dvh; border-radius: 0; padding-bottom: calc(1.5rem + env(safe-area-inset-bottom)); }
  .modal-actions .btn { flex: 1; }
  .fin-tile { border-radius: 12px; }
  .search-hit { padding: 0.7rem 0; }
}

/* Phones, round 2 (v1.66.1, Yoav 2026-10-11): use the whole screen.
   The desktop title's 16rem flex-basis became 250px of empty height in the
   stacked phone header; the header no longer sticks; sessions are denser. */
@media (max-width: 640px) {
  .topbar { position: static; gap: 0.45rem; padding-top: calc(0.5rem + env(safe-area-inset-top)); padding-bottom: 0.5rem; }
  .topbar h1 { flex: none; font-size: 1.05rem; }
  .topbar h1 a { padding: 0.15rem 0; }
  .global-search input { min-height: 40px; padding: 0.4rem 0.75rem; }
  .container, .container.narrow { padding-top: 0.5rem; }

  /* Filter + stage on one line, Columns as a compact button beside them. */
  .table-toolbar { flex-wrap: nowrap; gap: 0.4rem; margin-bottom: 0.5rem; }
  .table-toolbar .table-filter, .table-toolbar input[type="search"] { flex: 1 1 auto; min-width: 0; width: auto; min-height: 40px; }
  .table-toolbar .stage-filter { flex: 0 0 7.5rem; min-height: 40px; padding-right: 0.3rem; }
  .table-toolbar .list-cols-btn { min-height: 40px; padding: 0.3rem 0.55rem; font-size: 0; letter-spacing: 0; }
  .table-toolbar .list-cols-btn::before { content: '⚙'; font-size: 1.1rem; }
  .table-toolbar .list-cols-panel { top: calc(100% + 4px); }

  /* Session card: tighter, and no empty photo box when there are no photos. */
  .sessions-table tr { padding: 0.6rem 0.75rem; margin-bottom: 0.5rem; row-gap: 0.1rem; grid-template-columns: 48px minmax(0, 1fr) auto; }
  .sessions-table .row-thumb { width: 48px; height: 48px; }
  .sessions-table tr:has(.row-thumb.empty) .thumb-cell { display: none; }
  .sessions-table tr:has(.row-thumb.empty) .c-name { grid-column: 1 / span 2; }
  .sessions-table tr:has(.row-thumb.empty) .c-type { grid-column: 1 / span 3; }
  .sessions-table .c-name { font-size: 1.02rem; line-height: 1.25; }
  .sessions-table .c-type { font-size: 0.86rem; line-height: 1.2; }
  .sessions-table .c-date { margin-top: 0.35rem; }
  .sessions-table .c-date input.inline { min-height: 36px; padding: 0.2rem 0.5rem; }
  .sessions-table .c-col, .sessions-table .c-due { margin-top: 0.25rem; }
  .sessions-table .c-stage { margin-top: 0.3rem; }
  .sessions-table .stage-chip { padding: 0.25rem 0.55rem; }

  .m-tab { min-height: 52px; }
}

/* Drag a column title (or a Columns-panel row) to move the column — v1.67. */
th.col-draggable { cursor: grab; }
th.col-draggable:active { cursor: grabbing; }
.gallery-table th.sortable.col-draggable { cursor: pointer; }
th.col-dragging, .list-cols-row.col-dragging { opacity: 0.4; }
th.col-drop-before { box-shadow: inset 3px 0 0 var(--ink); }
th.col-drop-after { box-shadow: inset -3px 0 0 var(--ink); }
.list-cols-row { cursor: grab; }
.list-cols-row .grip { color: var(--muted); margin-right: 0.15rem; font-size: 1rem; line-height: 1; }
.list-cols-row.col-drop-before { box-shadow: inset 0 2px 0 var(--ink); }
.list-cols-row.col-drop-after { box-shadow: inset 0 -2px 0 var(--ink); }

/* Phones, round 3 (v1.66.2, Yoav 2026-10-11): a session card shows only the
   customer's photo, name, session type, shooting date, what was paid and the
   balance. The whole card opens the session; the number and stages are on it. */
.m-only { display: none; }
@media (max-width: 640px) {
  .m-only { display: inline; }
  .d-only { display: none; }
  .sessions-table tr {
    position: relative;
    grid-template-columns: 56px minmax(0, 1fr) auto; column-gap: 0.85rem; row-gap: 0.15rem;
    padding: 0.75rem 0.85rem;
  }
  .sessions-table .c-no, .sessions-table .c-stage, .sessions-table .c-date input { display: none; }
  .sessions-table .thumb-cell,
  .sessions-table tr:has(.row-thumb.empty) .thumb-cell { display: block; grid-column: 1; grid-row: 1 / span 4; align-self: center; }
  .sessions-table .row-thumb, .sessions-table .row-thumb.empty { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; }
  .sessions-table .row-thumb.empty { font-size: 0; border: 0; background: #efece6; display: flex; align-items: center; justify-content: center; }
  .sessions-table .row-thumb.empty::after { content: attr(data-initials); font-size: 1.05rem; letter-spacing: 0.04em; color: #5b5852; font-family: var(--font-display); }
  .sessions-table .c-name,
  .sessions-table tr:has(.row-thumb.empty) .c-name { grid-column: 2 / span 2; grid-row: 1; font-size: 1.08rem; }
  .sessions-table .c-name a::after { content: ''; position: absolute; inset: 0; }   /* the whole card is the link */
  .sessions-table .c-type,
  .sessions-table tr:has(.row-thumb.empty) .c-type { grid-column: 2 / span 2; grid-row: 2; }
  .sessions-table .c-date { grid-column: 2 / span 2; grid-row: 3; display: block; margin: 0; font-size: 0.9rem; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sessions-table .c-col, .sessions-table .c-due { grid-row: 4; margin-top: 0.3rem; font-size: 0.92rem; }
  .sessions-table .c-col { grid-column: 2; color: var(--ok); }
  .sessions-table .c-due { grid-column: 3; text-align: right; }
  .sessions-table .c-col::before, .sessions-table .c-due::before { content: none; }
  .sessions-table .c-col .m-only, .sessions-table .c-due .m-only { color: var(--muted); font-weight: 400; }
  .sessions-table .c-col strong { color: var(--ok); font-weight: 600; }
  .sessions-table .c-due strong { color: var(--danger); font-weight: 700; }
  .sessions-table .c-due.is-clear .m-only { color: var(--ok); }
  .sessions-table tr:active { background: #f8f7f4; }
}

/* Audit log + release notes (v1.68). */
.audit-filters { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.audit-filters label { display: flex; gap: 0.35rem; align-items: center; font-size: 0.85rem; color: var(--muted); }
.audit-filters input[type="search"] { flex: 1 1 14rem; min-width: 0; }
.audit-table td { vertical-align: top; }
.audit-table tr.is-reconstructed td { color: #55534e; }
.audit-changes { margin: 0.3rem 0 0; padding-left: 1rem; }
.audit-changes li { margin: 0.1rem 0; overflow-wrap: anywhere; }
.audit-kind { font-size: 0.72rem; margin-right: 0.2rem; }
.audit-projects { background: #e4edf5; color: #3b6d96; }
.audit-invoices { background: #f5efdd; color: #8a6d1f; }
.audit-payments { background: #e7f2ea; color: var(--ok); }
.audit-agreements { background: #f1e4f5; color: #7b4d96; }
.audit-emails { background: #ececec; color: #555; }
.release h2 { margin: 0; font-size: 1.25rem; }
.release-v { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85em; margin-right: 0.35rem; }
.release-date { margin: 0.15rem 0 0.4rem; font-size: 0.82rem; }
.release ul { margin: 0; padding-left: 1.15rem; line-height: 1.5; }
.release li { margin: 0.25rem 0; }
@media (max-width: 640px) {
  .audit-filters > * { flex: 1 1 100%; }
  .audit-filters label input { flex: 1; }
}

/* Price adjustments + split bill (v1.69). */
.badge.credit { background: #f5efdd; color: #8a6d1f; }
.badge.upgrade { background: #e4edf5; color: #3b6d96; font-size: 0.7rem; }
.invoice-table tr.credit-row td { background: #fdfaf2; }
.invoice-table tr.credit-row.is-void td { opacity: 0.55; text-decoration: line-through; }
.invoice-table tr.credit-row.is-void td:last-child, .invoice-table tr.credit-row.is-void td:nth-last-child(2) { text-decoration: none; }
.credit-text { color: #8a6d1f; font-weight: 600; }
.billing-tools { display: grid; gap: 0.6rem; margin: 0.8rem 0 0.4rem; }
.billing-tool { border: 1px solid var(--border); padding: 0.6rem 0.9rem; background: #fdfcfa; }
.billing-tool > summary { cursor: pointer; padding: 0.2rem 0; }
.billing-tool[open] > summary { margin-bottom: 0.5rem; }
.adjust-kind { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; flex-basis: 100%; }
.adjust-kind .checkbox, .adjust-type { display: flex; gap: 0.4rem; align-items: center; flex-direction: row !important; color: var(--ink) !important; font-size: 0.92rem !important; }
.adjust-form .adjust-reason { flex: 1 1 16rem; }
.adjust-form .adjust-reason input { width: 100%; }
@media (max-width: 640px) {
  .adjust-form label, .adjust-form .adjust-reason { width: 100%; }
  .adjust-form input:not([type="radio"]):not([type="checkbox"]), .billing-tool select { width: 100%; }
}

/* Session price history (v1.70). */
.price-history { border: 1px solid var(--border); background: #fdfcfa; padding: 0.55rem 0.9rem; margin: 0.6rem 0; font-size: 0.9rem; }
.price-history ul { margin: 0.3rem 0 0; padding-left: 1.1rem; }
.price-history li { margin: 0.25rem 0; }
.price-history .inline-form { margin-left: 0.4rem; }
.pkg-other[hidden] { display: none !important; }

/* Audit trail: integrity + per-item history (v1.71). */
.audit-integrity { margin: 0.2rem 0 0.6rem; font-size: 0.86rem; padding: 0.35rem 0.6rem; display: inline-block; }
.audit-integrity.ok { background: #e7f2ea; color: var(--ok); }
.audit-integrity.broken { background: #f7e7e6; color: var(--danger); font-weight: 600; }
.hist-link { font-size: 0.72rem; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; margin-left: 0.25rem; white-space: nowrap; }
.hist-link:hover { color: var(--ink); }
.audit-photos { background: #f1e4f5; color: #7b4d96; }
.audit-settings, .audit-auth { background: #ececec; color: #555; }
