/* Photo report UI — mobile-first. One accent (brand blue #005a9c), calm slate neutrals. */
:root {
  --bg: #f3f5f6;
  --surface: #ffffff;
  --surface-2: #f0f3f4;
  --surface-3: #e4e9eb;
  --text: #17212a;
  --muted: #56636e;
  --faint: #5f6b74;
  --border: #dce2e5;
  --border-strong: #c3cdd2;
  --accent: #005a9c;
  --accent-strong: #004576;
  --accent-weak: #e4eef8;
  --on-accent: #ffffff;
  --ok: #17794a;
  --ok-weak: #e3f4ea;
  --warn: #8a5300;
  --warn-weak: #fdf1dc;
  --danger: #b3261e;
  --danger-weak: #fbe9e7;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(18, 28, 34, .06), 0 8px 24px rgba(18, 28, 34, .06);
  --nav-h: 56px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, Ubuntu, sans-serif;
  overflow-x: hidden;
}
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; }
h1 { font-size: 20px; }
h2 { font-size: 20px; }
h3 { font-size: 15px; }
p { margin: 0 0 8px; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; }
small { color: var(--muted); font-size: 12px; }
[hidden], .hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.hint { color: var(--muted); font-size: 13px; }
.optional { color: var(--faint); font-weight: 400; font-size: 12px; margin-left: 4px; }
.eyebrow { display: block; color: var(--faint); font-size: 11px; letter-spacing: .08em; font-weight: 700; text-transform: uppercase; }
.empty { margin: 0; padding: 22px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.notice { margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--accent-weak); color: var(--text); font-size: 14px; }
.notice.warn, .warn { color: var(--warn); }
.notice.warn { background: var(--warn-weak); }
p.warn { margin: 8px 0 0; font-size: 13px; }

/* ---------- topbar / navigation ---------- */
.topbar { position: sticky; top: 0; z-index: 40; background: var(--surface); border-bottom: 1px solid var(--border); padding-top: env(safe-area-inset-top); }
.topbar-inner { position: relative; display: flex; align-items: center; gap: 12px; max-width: 1180px; margin: 0 auto; padding: 0 12px; min-height: var(--nav-h); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; min-width: 0; margin-right: auto; }
/* Genuine logo stays unaltered on a white plate in both themes. */
.brand-plate { display: inline-flex; align-items: center; justify-content: center; flex: none; background: #ffffff; border-radius: 8px; padding: 5px 9px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .07); }
.brand-logo { display: block; height: 20px; width: auto; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-weight: 500; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) { .brand-sub { display: none; } }
.badge { display: inline-block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; vertical-align: middle; }
.badge.on { background: var(--ok-weak); color: var(--ok); }
.badge.off { background: var(--danger-weak); color: var(--danger); }
.badge.warn { background: var(--warn-weak); color: var(--warn); }

.navbtn {
  border: 0; background: none; color: var(--muted); border-radius: var(--radius-sm);
  padding: 9px 12px; min-height: 44px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; text-align: left;
}
.navbtn:hover { background: var(--surface-2); color: var(--text); }
.navbtn.is-active { color: var(--accent-strong); background: var(--accent-weak); }
.navbtn.subtle { font-weight: 500; }
.iconbtn { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: var(--radius-sm); min-height: 44px; padding: 0 14px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.iconbtn:hover { background: var(--surface-2); }

/* mobile: sections live in a drop-down panel under the bar */
.mainnav { display: none; position: absolute; left: 0; right: 0; top: 100%; flex-direction: column; gap: 2px; padding: 8px 12px 12px; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow); }
body.mobile-menu-open .mainnav { display: flex; }
.nav-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--border); }
.nav-foot .badge { margin: 0 6px 0 12px; }

@media (min-width: 900px) {
  .only-mobile { display: none; }
  .brand { margin-right: 12px; }
  .mainnav { display: flex; position: static; flex: 1; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 2px; padding: 0; border: 0; box-shadow: none; background: none; min-width: 0; }
  .mainnav::-webkit-scrollbar { display: none; }
  .nav-foot { margin: 0 0 0 auto; padding: 0; border: 0; flex-wrap: wrap; }
  .nav-foot .badge { margin: 0 6px 0 0; }
}

/* ---------- views / layout ---------- */
.view { width: 100%; max-width: 760px; margin: 0 auto; padding: 14px 12px 40px; }
.view.wide { max-width: 980px; }
#view-report { padding-bottom: 150px; }
.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 6px 2px 14px; }
.view-head .hint { display: block; margin-top: 2px; }

.step, .admin-card, fieldset {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px;
}
.step { box-shadow: var(--shadow); }
.step-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.step-head .hint { margin: 3px 0 0; }
.pill { padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.block { padding-top: 14px; margin-top: 14px; border-top: 1px solid var(--border); }
.block:first-of-type { padding-top: 0; margin-top: 0; border-top: 0; }
.block > h3 { margin-bottom: 10px; font-size: 16px; }

/* ---------- stepper ---------- */
.stepper { display: flex; margin: 0 0 14px; }
.stepper-item { flex: 1 1 0; min-width: 0; position: relative; }
.stepper-item + .stepper-item::before { content: ""; position: absolute; z-index: 0; top: 17px; right: 50%; width: 100%; height: 2px; background: var(--border-strong); }
.stepper-item.is-active::before, .stepper-item.is-done::before { background: var(--accent); }
.stepper-btn {
  position: relative; z-index: 1; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 0; background: none; color: var(--muted); padding: 2px 4px; min-height: 56px;
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; border-radius: var(--radius-sm);
}
.stepper-num { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); color: var(--muted); font-size: 14px; }
.stepper-item.is-active .stepper-btn { color: var(--text); }
.stepper-item.is-active .stepper-num { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.stepper-item.is-done .stepper-num { background: var(--accent-weak); border-color: var(--accent); color: var(--accent-strong); }

/* ---------- brand filmstrips (authenticated report view only) ---------- */
/* One shared grid: the top strip and the side rails start on the same line as the form column. */
.brand-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; margin: 0 0 14px; }
.brand-strip img, .brand-rail img { display: block; width: 100%; object-fit: cover; background: var(--surface-3); }
.brand-strip img { height: 64px; }
.brand-strip img:first-of-type { border-radius: var(--radius) 0 0 var(--radius); }
.brand-strip img:last-of-type { border-radius: 0 var(--radius) var(--radius) 0; }
.brand-strip figcaption { grid-column: 1 / -1; margin-top: 3px; font-size: 11px; color: var(--faint); text-align: right; }
.brand-rail { display: none; }
@media (min-width: 480px) { .brand-strip img { height: 96px; } }
@media (min-width: 760px) { .brand-strip img { height: 150px; } }
@media (min-width: 1240px) {
  /* The rails take every pixel the form does not need, up to the window edges. */
  .view#view-report { max-width: none; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 760px) minmax(0, 1fr); align-items: start; column-gap: 20px; }
  /* A rail always fills the visible height of the window and stays in place while the form scrolls. */
  .brand-rail { display: grid; grid-auto-rows: minmax(0, 1fr); gap: 3px; position: sticky; top: calc(var(--nav-h) + 22px); height: calc(100vh - var(--nav-h) - 44px); min-height: 420px; border-radius: var(--radius); overflow: hidden; }
  .brand-rail img { width: 100%; height: 100%; min-height: 0; }
  .brand-rail .brand-extra { display: none; }
}
@media (min-width: 1800px) {
  .brand-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brand-rail .brand-extra { display: block; }
}

/* ---------- wizard nav ---------- */
.wizard-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -6px 18px rgba(18, 28, 34, .06);
}
.wizard-buttons { display: flex; gap: 10px; }
.wizard-buttons .btn { min-height: 48px; gap: 8px; }
#btn-back::before { content: "\2190"; }
#btn-next::after { content: "\2192"; }
.wizard-buttons .btn.primary { flex: 1 1 auto; }
.step-error { margin: 0 0 10px; padding: 9px 12px; border-radius: var(--radius-sm); background: var(--danger-weak); color: var(--danger); font-size: 13px; font-weight: 600; }

/* ---------- buttons / forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent);
  border-radius: var(--radius-sm); padding: 9px 18px; font: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; min-height: 44px; text-align: center;
}
.btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.ghost { background: var(--surface); color: var(--accent-strong); border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--accent-weak); border-color: var(--accent); }
.btn.ghost.danger { color: var(--danger); }
.btn.ghost.danger:hover { background: var(--danger-weak); border-color: var(--danger); }
.btn.small { padding: 6px 14px; font-size: 14px; white-space: nowrap; flex: none; }
.textbtn { border: 0; background: none; color: var(--accent-strong); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; padding: 6px 8px; min-height: 44px; border-radius: var(--radius-sm); }
.textbtn:hover { background: var(--accent-weak); }
.textbtn:disabled { color: var(--faint); cursor: default; background: none; }
.textbtn.danger { color: var(--danger); }
.textbtn.danger:hover { background: var(--danger-weak); }
.textbtn.inline { padding: 0; min-height: 0; text-decoration: underline; }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: rgba(16, 24, 30, .62); color: #fff; cursor: pointer; }
.icon-btn:hover { background: rgba(16, 24, 30, .85); }
.icon-btn:disabled { opacity: .35; cursor: default; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; min-width: 0; }
.field > label, .field > span:first-child, .control-label { font-size: 13px; color: var(--muted); font-weight: 600; }
input[type="text"], input[type="email"], input[type="number"], input[type="password"], select, textarea {
  width: 100%; min-height: 44px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 9px 11px; font: inherit; font-size: 16px; color: inherit; background: var(--surface);
}
textarea { resize: vertical; min-height: 72px; }
/* Sensible widths for single-column form fields. */
.field > input[type="text"], .field > input[type="email"] { max-width: 560px; }
.step .field > input[type="text"], .step .field > input[type="email"], .step .field > select, .step .field > textarea { max-width: 100%; }
.field > input[type="number"], .field > input[type="password"] { max-width: 280px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, summary:focus-visible, .dropzone:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px;
}
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); }
input[readonly] { background: var(--surface-2); }
/* Own slider drawing: the browser default differs too much between Chrome, Opera, Firefox and Safari. */
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; margin: 0; padding: 0; border: 0; background: transparent; cursor: pointer; --fill: 50%; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: linear-gradient(to right, var(--accent) var(--fill), var(--surface-3) var(--fill)); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%; border: 2px solid var(--accent); background: var(--surface); box-shadow: 0 1px 3px rgba(18, 28, 34, .28); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 999px; background: var(--surface-3); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--accent); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--accent); background: var(--surface); box-shadow: 0 1px 3px rgba(18, 28, 34, .28); }
input[type="checkbox"] { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.range-legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--faint); }

.check { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; min-height: 44px; }
.check small { display: block; }
.check-col { display: flex; flex-direction: column; }

.grid2, .grid3 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 12px; }
@media (min-width: 620px) {
  .grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.grid2.tight { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }

fieldset { margin: 0 0 14px; min-width: 0; }
legend { padding: 0 6px; font-weight: 650; font-size: 15px; }

.disclosure { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); padding: 0 12px; margin: 0 0 12px; }
.disclosure > summary { cursor: pointer; font-weight: 600; color: var(--accent-strong); padding: 10px 0; min-height: 44px; display: flex; align-items: center; gap: 8px; list-style: none; }
.disclosure > summary::-webkit-details-marker, .fold > summary::-webkit-details-marker { display: none; }
.disclosure > summary::before, .fold > summary::before { content: ""; width: 7px; height: 7px; flex: none; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s ease-out; }
.disclosure[open] > summary::before, .fold[open] > summary::before { transform: rotate(45deg); }
.disclosure[open] { padding-bottom: 12px; }
.disclosure[open] > summary { margin-bottom: 6px; }

/* ---------- step 1: photos ---------- */
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  padding: 26px 12px; text-align: center; color: var(--muted); cursor: pointer; background: var(--surface-2);
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-weak); color: var(--text); }
.dropzone strong { display: block; margin-top: 6px; font-size: 16px; color: var(--text); }
.drop-subtitle { display: block; margin: 3px 0 14px; font-size: 13px; }
.drop-icon { margin: 0 auto; width: 52px; height: 52px; display: grid; place-items: center; border-radius: 16px; background: var(--surface); color: var(--accent); border: 1px solid var(--border); }
.drop-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 0; }
.drop-actions .btn { padding-left: 14px; padding-right: 14px; white-space: nowrap; }
@media (min-width: 480px) { .drop-actions .btn { flex: 0 1 200px; } }
body.has-photos .dropzone { padding: 10px; border-width: 1px; }
body.has-photos .drop-actions .btn:not(.ghost) { background: var(--surface); color: var(--accent-strong); border-color: var(--border-strong); }
body.has-photos .drop-actions .btn:not(.ghost):hover { background: var(--accent-weak); border-color: var(--accent); }
body.has-photos .drop-icon, body.has-photos .dropzone > strong, body.has-photos .drop-subtitle { display: none; }
body:not(.has-photos) .with-photos { display: none; }

.summary { margin-top: 12px; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.progress-wrap { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.progress { flex: 1; height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .2s ease-out; }
#progress-text { font-size: 12px; color: var(--muted); white-space: nowrap; }
.totals { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 6px 14px; }
.total span { display: block; font-size: 12px; color: var(--muted); }
.total b { font-size: 18px; line-height: 1.2; }
.total.accent { margin-left: auto; text-align: right; }
.total.accent b { color: var(--ok); }
.total.accent b.warn { color: var(--warn); }
.total-arrow { color: var(--faint); padding-bottom: 2px; }
.meter-row { margin-top: 10px; }
.meter { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin-bottom: 5px; }
.meter-bar { height: 100%; width: 0; background: var(--ok); border-radius: 999px; transition: width .2s ease-out; }
.meter-bar.over { background: #d28a12; }

.list-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; margin: 12px 0 8px; }
.list-actions { display: flex; gap: 2px; margin-left: auto; }
.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.seg { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: var(--radius-sm); padding: 8px 14px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; min-height: 44px; }
.seg:hover { background: var(--surface-2); }
.seg.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.segmented.mini { gap: 0; }
.segmented.mini .seg { border-radius: 0; margin-left: -1px; }
.segmented.mini .seg:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.segmented.mini .seg:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.file-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 8px; }
.file-item { position: relative; display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.file-item.is-error { border-color: var(--danger); background: var(--danger-weak); }
.thumb { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--surface-3); }
.file-meta { padding: 7px 9px 9px; min-width: 0; }
.file-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-sizes { font-size: 12px; color: var(--muted); }
.file-status { font-size: 12px; color: var(--muted); }
.file-status.ok { color: var(--ok); }
.file-status.error { color: var(--danger); font-weight: 600; }
.file-status.busy { color: var(--warn); }
.file-actions { position: absolute; top: 6px; right: 6px; z-index: 2; display: flex; gap: 6px; }

.compression-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 8px 8px 14px; border-radius: var(--radius-sm); margin: 14px 0 0; background: var(--surface-2); }
.compression-main { min-width: 0; }
.compression-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compression-summary { display: flex; align-items: center; gap: 6px; font-size: 13px; flex-wrap: wrap; justify-content: flex-end; }
.compression-summary span { padding: 3px 8px; background: var(--surface); border-radius: 6px; white-space: nowrap; color: var(--muted); }
.controls { display: flex; flex-direction: column; gap: 18px; margin-top: 8px; padding: 16px 14px 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.controls .disclosure { margin: 0; padding: 0; border: 0; border-top: 1px solid var(--border); border-radius: 0; background: none; }
.controls .control-label b { color: var(--text); font-size: 14px; }
/* Width presets: one joined control on wide screens, an even grid on a phone. */
#width-presets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
#width-presets .seg { position: relative; padding-left: 6px; padding-right: 6px; }
@media (min-width: 620px) {
  #width-presets { display: flex; flex-wrap: nowrap; gap: 0; }
  #width-presets .seg { flex: 1 1 auto; border-radius: 0; margin-left: -1px; }
  #width-presets .seg:first-child { margin-left: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
  #width-presets .seg:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
  #width-presets .seg.active { z-index: 1; }
}
.controls.collapsed { display: none; }
.controls .grid2 .field { margin-bottom: 0; }
.controls .grid2 { row-gap: 12px; }
.control-group { display: flex; flex-direction: column; gap: 6px; }
.num { max-width: 180px; }
.input-narrow { max-width: 420px; }

/* ---------- step 2: recipients ---------- */
.recipients { display: flex; flex-direction: column; gap: 8px; margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.mail-subject-field { margin-bottom: 8px; }
.mail-zip-option { margin: 0 0 8px; }
.mail-advanced { margin-top: 8px; }
.group-members { margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.group-members-title { margin: 0 0 2px; font-weight: 650; }
.group-selected-count { color: var(--muted); font-size: 12px; font-weight: 500; }
.group-member-checks { display: grid; gap: 4px; margin-top: 8px; }
.group-member-check { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 7px 10px; cursor: pointer; border: 1px solid transparent; border-radius: 10px; background: var(--surface); transition: background .15s ease-out, border-color .15s ease-out; }
.group-member-check:hover { border-color: var(--border-strong); background: var(--accent-weak); }
.group-member-check input { margin: 0; }
.group-member-check input:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.group-member-check span { display: flex; flex-direction: column; min-width: 0; }
.group-member-check small { color: var(--muted); overflow-wrap: anywhere; }
.group-others { margin: 8px 0 0; background: transparent; }
.saved-addresses { margin-top: 10px; }
.saved-addresses-title { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.chip-add { border: 0; background: none; padding: 0; min-height: 44px; font: inherit; font-size: 13px; color: var(--accent-strong); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recipient-help { margin: 0 0 8px; }
.recipients > .hint { margin: 0; }
.rcpt { display: flex; gap: 8px; align-items: flex-start; min-width: 0; }
.rcpt.empty-recipient { display: none; }
.rcpt-label { font-size: 12px; color: var(--muted); width: 62px; flex: none; padding-top: 8px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 2px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px; padding: 0 2px 0 12px; font-size: 13px; max-width: 100%; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-x { border: 0; background: transparent; cursor: pointer; font-size: 18px; line-height: 1; color: var(--muted); min-width: 44px; min-height: 44px; border-radius: 50%; }
.chip-x:hover { color: var(--danger); background: var(--danger-weak); }

.search-row { display: flex; gap: 8px; align-items: stretch; }
.search-row > input { flex: 1 1 160px; min-width: 0; }
.search-row > select { width: auto; flex: 0 0 auto; }
.search-row > .btn { flex: 0 0 auto; }
.suggest { margin: 6px 0 0; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); max-height: 240px; overflow: auto; box-shadow: var(--shadow); }
.suggest-item { display: flex; justify-content: space-between; gap: 10px; padding: 9px 10px; border-radius: 6px; cursor: pointer; min-height: 44px; align-items: center; }
.suggest-item:hover { background: var(--accent-weak); }
.suggest-item span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- step 3: the letter ---------- */
.letter { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; border-top: 4px solid var(--accent); }
.review-line { display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; align-items: center; gap: 4px 10px; padding: 6px 6px 6px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.review-line:last-child { border-bottom: 0; }
.review-label { color: var(--muted); font-size: 13px; }
.review-value { word-break: break-word; font-weight: 600; }
.letter .notice { margin: 10px 12px; }
.preview, .status { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; background: var(--surface); font-size: 13px; word-break: break-word; }
.preview { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); background: var(--ok-weak); }
.status.ok { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); background: var(--ok-weak); }
.status.error { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); background: var(--danger-weak); color: var(--danger); }
.preview-head, .status-head { font-weight: 650; font-size: 15px; }
.preview-head::before, .status.ok .status-head::before { content: "✓ "; color: var(--ok); }
.preview-meta { color: var(--muted); margin-bottom: 6px; }
.preview-list, .status-list { margin-top: 6px; }
.preview-list li, .status-list li { margin-bottom: 4px; }
.preview-part { font-weight: 600; }
.preview-files { color: var(--muted); font-size: 12px; max-height: 5.4em; overflow: auto; }
.status .hint { margin: 2px 0 0; }

/* ---------- tabs / admin ---------- */
.tabs { display: flex; gap: 4px; margin: 0 -12px 12px; padding: 0 12px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--muted); padding: 10px 10px 9px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; min-height: 44px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-strong); border-bottom-color: var(--accent); }
.tab-intro { margin: 0 2px 12px; }

.admin-body, .card-stack { display: flex; flex-direction: column; gap: 10px; }
.admin-body { scroll-margin-top: calc(var(--nav-h) + 12px); }
.list-title { margin: 8px 2px 0; color: var(--muted); font-size: 13px; font-weight: 600; }
.admin-status { margin: 10px 2px 0; }
.admin-status.error { color: var(--danger); font-weight: 600; }
.admin-status.ok { color: var(--ok); font-weight: 600; }
.admin-card { padding: 12px; }
.admin-card.add-card { background: var(--surface-2); border-style: dashed; border-color: var(--border-strong); }
.admin-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; min-width: 0; }
.admin-card-head b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-card-head .hint, .admin-card-head .badge { margin-left: auto; flex: none; }
.admin-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.admin-status-line { font-size: 13px; color: var(--muted); }
.admin-status-line:not(:empty) { margin-top: 8px; }
.admin-status-line.error { color: var(--danger); font-weight: 600; }
.admin-status-line.ok { color: var(--ok); }
.admin-status-line .btn { margin-left: 8px; }
.fold > summary { cursor: pointer; list-style: none; margin: -12px; padding: 12px; min-height: 48px; }
.fold[open] > summary { margin-bottom: 0; }
.invite-card > .hint { margin-bottom: 10px; }
.invite-link { margin-bottom: 6px; }
.invite-menu { margin: 4px 0 0; }
.login-journal { margin: 0 0 12px; }
.login-row { padding: 4px 0; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.login-row:last-child { border-bottom: 0; }
.invite-menu > .admin-card-actions { margin-top: 8px; }
#people-grant .admin-card-head .btn { margin-left: auto; }
#people-grant .member-list { max-height: 420px; }
.grant-row .btn { flex: none; }
/* Invite cards wrap so a long name + status badge never overflow at 320/375. */
.invite-card .admin-card-head { flex-wrap: wrap; row-gap: 4px; }
.invite-card .admin-card-head b { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
.invite-card .admin-card-head .badge { overflow-wrap: anywhere; }

@media (min-width: 700px) {
  .contact-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) auto; gap: 0 10px; align-items: center; padding: 8px 10px; }
  .contact-row .field { margin: 0; }
  .contact-row .field > span:first-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .contact-row .admin-card-actions { margin: 0; flex-wrap: nowrap; }
  .contact-row .admin-status-line { grid-column: 1 / -1; }
}

.member-group { margin-bottom: 12px; }
.member-list { margin-top: 5px; max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px 10px; background: var(--surface); }
.member-list > .hint { margin: 10px 0; }
.member-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.member-row:last-child { border-bottom: 0; }
.member-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 14px; color: var(--muted); }
.member-name small { display: block; overflow: hidden; text-overflow: ellipsis; }
.member-row.is-on .member-name { color: var(--text); font-weight: 600; }
.member-row select { width: auto; flex: none; min-height: 44px; font-size: 14px; padding: 6px 8px; }

.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 720px) { .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; background: var(--surface); }
.stat-card b { display: block; font-size: 22px; line-height: 1.2; }
.stat-card span { color: var(--muted); font-size: 12px; }
.stat-table-wrap { overflow-x: auto; margin-top: 12px; background: var(--surface); border-radius: var(--radius-sm); }
.stat-table { width: 100%; min-width: 480px; border-collapse: collapse; font-size: 13px; background: var(--surface); }
.stat-table th, .stat-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.stat-table th { color: var(--muted); font-weight: 600; }

/* ---------- history ---------- */
.history-body { min-height: 80px; }
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-list li { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--surface); }
.history-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.history-head b { min-width: 0; word-break: break-word; }
.history-head .badge { flex: none; max-width: 60%; }
.history-meta { font-size: 13px; color: var(--muted); margin: 2px 0; }
.history-rcpt { font-size: 13px; word-break: break-word; margin-bottom: 10px; }

/* ---------- settings ---------- */
.settings-form { max-width: 760px; margin: 0 auto; }
.preset-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 12px; }
.status-line { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.status-line.error { color: var(--danger); font-weight: 600; }
.status-line.ok { color: var(--ok); font-weight: 600; }
.form-actions { position: sticky; bottom: 0; margin: 0 -12px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--border); }
.form-actions .status-line { margin: 0; }

/* ---------- overlay / toast ---------- */
.overlay { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 60; }
.dialog { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: min(420px, 100%); max-height: 88vh; overflow: auto; box-shadow: var(--shadow); text-align: center; }
.dialog .brand-plate { margin: 0 auto 12px; padding: 8px 12px; border-radius: 10px; }
.dialog .brand-plate .brand-logo { height: 28px; }
.dialog .brand-sub-line { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.dialog h1 { margin-bottom: 8px; }
.dialog .btn { margin-top: 8px; }
.gate-email { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 12px; text-align: left; }
.gate-email label { font-size: 13px; font-weight: 600; color: var(--muted); }
.gate-email .btn { margin-top: 4px; }
.gate-email .status-line { margin: 0; min-height: 0; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: #18232a; color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); font-size: 14px; z-index: 80; width: max-content; max-width: min(92vw, 560px); box-shadow: var(--shadow); }

/* ---------- wider screens ---------- */
@media (min-width: 760px) {
  .view { padding: 22px 20px 48px; }
  #view-report { padding-bottom: 48px; }
  .step, fieldset { padding: 24px; }
  .wizard-nav { position: static; background: none; border: 0; box-shadow: none; padding: 14px 0 0; }
  .wizard-buttons { justify-content: space-between; }
  .wizard-buttons .btn, .wizard-buttons .btn.primary { flex: 0 0 auto; min-width: 176px; }
  .file-list { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .stepper-btn { font-size: 14px; }
  input[type="text"], input[type="email"], input[type="number"], input[type="password"], select, textarea { font-size: 15px; }
  .tabs { margin: 0 0 12px; padding: 0; }
  .form-actions { margin: 0; padding: 12px 0; }
  .toast { bottom: 32px; }
}
@media (max-width: 479px) {
  .drop-actions .btn { font-size: 14px; }
  .compression-bar { flex-direction: column; align-items: stretch; gap: 4px; }
  .compression-summary { justify-content: flex-start; }
  .compression-summary .textbtn { margin-left: auto; }
  .search-row { flex-wrap: wrap; }
  .search-row > select { flex: 1 1 auto; }
  .review-line { grid-template-columns: minmax(0, 1fr) auto; }
  .review-label { grid-column: 1 / -1; margin-bottom: -4px; }
  .member-row { flex-wrap: wrap; }
  .member-row select { width: 100%; }
}
@media (max-width: 759px) {
  #view-report { padding-bottom: 40px; scroll-padding-bottom: 24px; }
  .wizard-nav { position: static; margin-top: 16px; padding: 0; background: transparent; border: 0; box-shadow: none; }
}
@media (max-width: 360px) {
  .topbar-inner { gap: 8px; }
  .brand-plate { padding: 3px 6px; }
  .brand-logo { height: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .progress-bar, .meter-bar, .disclosure > summary::before, .fold > summary::before { transition: none; }
}

/* ---------- dark theme ---------- */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1419;
  --surface: #17212a;
  --surface-2: #1d2a34;
  --surface-3: #293841;
  --text: #e9eef2;
  --muted: #a6b3bd;
  --faint: #8090a0;
  --border: #2b3a45;
  --border-strong: #3d505d;
  --accent: #4fa6dd;
  --accent-strong: #8ec8ee;
  --accent-weak: #0f2f47;
  --on-accent: #06202f;
  --ok: #4cc983;
  --ok-weak: #15301f;
  --warn: #e6b566;
  --warn-weak: #3a2c12;
  --danger: #f08a80;
  --danger-weak: #3a1f1d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
}
html[data-theme="dark"] .toast { background: #e9eef2; color: #131c23; }
