/* ==========================================================================
   Munitown styles. One file, no build step. Light theme only.
   Sections: tokens, base, layout (resident), layout (admin), components,
   resident pages, admin pages, utilities, motion, print.
   Contrast notes (WCAG): ratios are against the background they sit on.
   ========================================================================== */

/* --- Tokens --------------------------------------------------------------- */
:root {
  color-scheme: light;

  /* Neutrals (slate) */
  --page: #f7f7f5;          /* warm off-white page */
  --surface: #ffffff;       /* cards */
  --surface-sunken: #f1f5f9;
  --text: #0f172a;          /* 16.6:1 on --page */
  --text-muted: #475569;    /* 7.1:1 on --page, 7.6:1 on white */
  --border: #e2e8f0;        /* decorative card edges */
  --border-strong: #64748b; /* form controls: 4.8:1 on white (>=3:1 UI) */

  /* Brand. A city's brand colour overrides these five from an inline <style> (src/brand.ts brandTheme),
     which keeps primary >=4.5:1 on white, --page and --primary-soft, and hover >=4.5:1 on soft and tint.
     Use the tokens for anything brand-coloured; never hard-code a blue. */
  --primary: #1d4ed8;       /* 6.7:1 on white; white text on it 6.7:1 */
  --primary-hover: #1e40af; /* 8.7:1 on white */
  --primary-soft: #eff6ff;
  --primary-tint: #dbeafe;
  --on-primary: #ffffff;

  /* Feedback: text colour / tinted background pairs */
  --success: #166534;  --success-bg: #f0fdf4;  --success-border: #86efac; /* 6.8:1 on bg */
  --warning: #92400e;  --warning-bg: #fffbeb;  --warning-border: #fcd34d; /* 6.8:1 on bg */
  --danger: #b91c1c;   --danger-bg: #fef2f2;   --danger-border: #fca5a5;  /* 5.9:1 on bg */
  --info: #1e40af;     --info-bg: #eff6ff;     --info-border: #93c5fd;    /* 8.0:1 on bg */

  /* Focus: dark ring plus yellow halo, visible on any background */

  /* Shape and depth */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / 0.06);
  --shadow-md: 0 1px 2px rgb(15 23 42 / 0.06), 0 4px 12px rgb(15 23 42 / 0.06);
  --shadow-lg: 0 2px 4px rgb(15 23 42 / 0.06), 0 12px 32px rgb(15 23 42 / 0.10);

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --tap: 48px;
}

/* --- Base ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--text);
  background: var(--page);
  font-family: var(--font);
  font-size: 1.25rem; /* 20px resident base */
  line-height: 1.5;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}
body.admin { font-size: 1.0625rem; display: block; }

main { width: 100%; max-width: 46rem; margin: 0 auto; padding: var(--space-5) var(--space-4) var(--space-7); flex: 1; }
main:focus { outline: none; }

h1, h2, h3 { color: var(--text); letter-spacing: -0.01em; }
h1 { font-size: 2rem; line-height: 1.2; margin: 0 0 var(--space-4); font-weight: 750; }
h2 { font-size: 1.5rem; line-height: 1.25; margin: var(--space-6) 0 var(--space-3); font-weight: 700; }
h3 { font-size: 1.25rem; line-height: 1.3; margin: var(--space-5) 0 var(--space-2); }
p { margin: 0 0 var(--space-4); }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
/* Links inside a sentence need more than color to stand out from the text around them (WCAG 1.4.1),
   so they keep a faint underline that darkens on hover. Navigation, buttons and controls have none. */
:is(.legal, .form-legal, .notice, .muted, .hint, .page-header p, .message-card p, .address-credit) a:not(.button) {
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
}
:is(.legal, .form-legal, .notice, .muted, .hint, .page-header p, .message-card p, .address-credit) a:not(.button):hover { text-decoration-color: currentColor; }

:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.skip-link {
  position: absolute; left: var(--space-2); top: -10rem; z-index: 100;
  padding: var(--space-3) var(--space-4);
  background: var(--text); color: #fff; border-radius: var(--radius-sm);
}
.skip-link:focus { top: var(--space-2); }

/* Only on the public demo (src/demo.ts), above every page. */
.demo-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--space-1) var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: var(--surface-sunken); border-bottom: 1px solid var(--border);
  color: var(--text-muted); font-size: 0.9375rem; text-align: center;
}
.demo-bar p { margin: 0; }
.demo-bar-links { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-1) var(--space-4); font-weight: 600; }

.svg-icon { width: 1.25em; height: 1.25em; flex: none; display: block; }

/* --- Layout: resident ----------------------------------------------------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.site-header-inner { max-width: 46rem; margin: 0 auto; padding: var(--space-3) var(--space-4); display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.header-link { font-size: 1rem; font-weight: 600; color: var(--text); text-decoration: none; }
.header-link:hover { color: var(--primary); }
.header-nav { display: flex; align-items: center; gap: var(--space-5); }
@media (max-width: 40rem) { .header-nav .header-link { display: none; } }
.brand {
  display: inline-flex; align-items: center; gap: var(--space-3);
  min-height: var(--tap);
  color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.375rem;
}
.brand:hover { color: var(--text); }

.monogram {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 2.5rem; height: 2.5rem;
  border-radius: var(--radius-sm);
  background: var(--primary); color: var(--on-primary);
  font-weight: 800; font-size: 1.25rem; line-height: 1;
  box-shadow: inset 0 -2px 0 rgb(0 0 0 / 0.15);
}
.monogram .svg-icon { width: 1.4rem; height: 1.4rem; }
.monogram-sm { width: 2rem; height: 2rem; font-size: 1rem; border-radius: 7px; }
.monogram-lg { width: 3.5rem; height: 3.5rem; font-size: 1.75rem; border-radius: var(--radius-md); }

/* An uploaded logo takes the monogram's place. Height is fixed, width follows the logo up to a cap. */
.logo { display: block; flex: none; height: 2.5rem; width: auto; max-width: 10rem; object-fit: contain; object-position: left center; }
.logo-sm { height: 2rem; max-width: 7rem; }
.logo-lg { height: 3.5rem; max-width: 7rem; }
.tile > .logo { grid-row: span 2; }

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 1rem;
  text-align: center;
  padding: var(--space-5) var(--space-4);
}
.site-footer p { margin: 0 0 var(--space-1); }
.site-footer strong { color: var(--text); }

/* --- Layout: admin app shell ---------------------------------------------- */
.app-shell { min-height: 100vh; }
.sidebar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: var(--space-3) var(--space-4) 0;
}
.sidebar-brand {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: 44px; margin-bottom: var(--space-2);
  color: var(--text); text-decoration: none; font-weight: 700;
}
.sidebar-brand:hover { color: var(--text); }
.sidebar-brand small { display: block; font-weight: 500; font-size: 0.8125rem; color: var(--text-muted); }
.side-nav ul {
  list-style: none; margin: 0; padding: 0 0 var(--space-2);
  display: flex; gap: var(--space-1);
  overflow-x: auto; scrollbar-width: thin;
}
.side-nav a {
  display: flex; align-items: center; gap: var(--space-2);
  min-height: 44px; padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted); text-decoration: none; font-weight: 600; white-space: nowrap;
}
.side-nav a:hover { background: var(--surface-sunken); color: var(--text); }
.side-nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary-hover); }
.side-nav .nav-sep { display: none; }
.app-body { min-width: 0; }
/* Who is signed in, and Sign out: the foot of the sidebar on wide screens, the foot of the Menu panel on phones. */
.account { display: grid; gap: var(--space-2); font-size: 0.875rem; color: var(--text-muted); }
.account-row { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.account-avatar {
  flex: none; display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary-hover); font-weight: 700;
}
.account-who { margin: 0; flex: 1; min-width: 0; line-height: 1.3; }
.who-email { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 600; }
.account-role { display: block; font-size: 0.8125rem; }
.account .sign-out { margin: 0; }
.account-sign-out {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--text-muted); cursor: pointer;
}
.account-sign-out:hover { background: var(--surface-sunken); color: var(--text); }
.dev-badge { font-size: 0.8125rem; font-weight: 600; color: var(--text-muted); }
.legal h2 { font-size: 1.25rem; margin: var(--space-5) 0 var(--space-2); }
.legal ul { padding-left: 1.25rem; }
.legal li { margin-bottom: var(--space-2); }
.form-legal { margin: var(--space-3) 0 0; color: var(--text-muted); font-size: 1rem; }
.sign-in-card form + .form-legal, .sign-in-card form + form .form-legal { margin-top: var(--space-4); }
/* A form's submit button that reads as a link inside a sentence, with the same faint underline as links there. */
.link-button {
  display: inline; padding: 0; border: 0; background: none; font: inherit; color: var(--primary); cursor: pointer;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
}
.link-button:hover { color: var(--primary-hover); text-decoration-color: currentColor; }
.card.sign-in-card { max-width: 32rem; margin: var(--space-6) auto; }
.sign-in-account {
  display: flex; flex-direction: column; gap: 0.125rem; margin: 0 0 var(--space-5); padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-sunken); overflow-wrap: anywhere;
}
.sign-in-account-label { color: var(--text-muted); font-size: 0.875rem; }
body.admin main { max-width: 76rem; padding: var(--space-5) var(--space-4) var(--space-7); }

@media (min-width: 64rem) {
  .app-shell { display: grid; grid-template-columns: 16rem minmax(0, 1fr); }
  .sidebar {
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    border-bottom: 0; border-right: 1px solid var(--border);
    padding: var(--space-4) var(--space-3);
  }
  .sidebar-brand { margin: 0 var(--space-2) var(--space-5); }
  .side-nav ul { flex-direction: column; overflow: visible; padding: 0; }
  .side-nav .nav-sep { display: block; height: 1px; background: var(--border); margin: var(--space-3) var(--space-2); }
  .sidebar { display: flex; flex-direction: column; }
  .nav-menu, .nav-panel { display: flex; flex-direction: column; flex: 1; }
  .account { margin-top: auto; padding: var(--space-3) var(--space-2) 0; border-top: 1px solid var(--border); }
  body.admin main { padding: var(--space-6); margin: 0; }
}

/* --- Components: buttons -------------------------------------------------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--tap); min-width: var(--tap);
  padding: 0.5rem 1.25rem;
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--primary); color: var(--on-primary);
  font: inherit; font-weight: 700; line-height: 1.2;
  text-align: center; text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.button:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); text-decoration: none; }
.button:focus-visible { background: var(--primary-hover); color: var(--on-primary); }
.button-secondary { background: var(--surface); color: var(--primary); border-color: var(--primary); }
.button-secondary:hover, .button-secondary:focus-visible { background: var(--primary-soft); color: var(--primary-hover); }
.button-danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.button-danger:hover, .button-danger:focus-visible { background: var(--danger); color: #fff; border-color: var(--danger); }
.button-ghost { background: transparent; color: var(--primary); border-color: transparent; box-shadow: none; }
.button-ghost:hover, .button-ghost:focus-visible { background: var(--primary-soft); color: var(--primary-hover); border-color: transparent; }
.button-large { width: 100%; min-height: 72px; font-size: 1.375rem; border-radius: var(--radius-md); }
.button-block { width: 100%; }
.button-small { padding: 0.35rem 1rem; font-size: 1rem; box-shadow: none; }
.button-danger-solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.button-danger-solid:hover, .button-danger-solid:focus-visible { background: #991b1b; border-color: #991b1b; color: #fff; }
.button:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.button-danger-solid:disabled:hover { background: var(--danger); border-color: var(--danger); }
body.admin .button { min-height: 44px; padding: 0.4rem 1rem; font-size: 0.9375rem; }
.button-row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.center-row { justify-content: center; }

/* --- Components: cards ---------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-5);
  margin: 0 0 var(--space-5);
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card-title { font-size: 1.25rem; margin: 0 0 var(--space-3); }
body.admin .card { padding: var(--space-5); border-radius: var(--radius-md); }
body.admin .card-title { font-size: 1.125rem; }
.card-footer { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border); }

.icon-tile {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 3.25rem; height: 3.25rem;
  border-radius: var(--radius-md);
  background: var(--primary-tint); color: var(--primary-hover);
}
.icon-tile .svg-icon { width: 1.75rem; height: 1.75rem; }
.icon-tile-sm { width: 2.25rem; height: 2.25rem; border-radius: var(--radius-sm); }
.icon-tile-sm .svg-icon { width: 1.25rem; height: 1.25rem; }

/* Icon picker: radio buttons shown as labeled icon tiles. The radio stays in the page for keyboards and screen readers. */
.icon-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); gap: var(--space-2); }
.icon-option {
  position: relative; display: flex; align-items: center; gap: var(--space-2); margin: 0;
  padding: var(--space-2); border: 2px solid var(--border); border-radius: var(--radius-md);
  font-weight: 500; cursor: pointer; min-height: var(--tap);
}
.icon-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.icon-option:hover { border-color: var(--primary); }
.icon-option:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); font-weight: 700; }
.icon-option:has(input:focus-visible) { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent); }

/* --- Components: callouts and flash messages ------------------------------ */
.callout {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-4);
  border: 1px solid var(--info-border);
  border-radius: var(--radius-md);
  background: var(--info-bg); color: var(--text);
  margin: 0 0 var(--space-5);
}
.callout > .svg-icon { width: 1.75rem; height: 1.75rem; margin-top: 0.1rem; color: var(--info); }
.callout p { margin: 0; }
.callout-danger { border-color: var(--danger-border); background: var(--danger-bg); }
.callout-danger > .svg-icon { color: var(--danger); }
.callout-warning, .notice { border-color: var(--warning-border); background: var(--warning-bg); }
.callout-warning > .svg-icon { color: var(--warning); }
.notice { border: 1px solid var(--warning-border); border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4); }

.flash {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  margin: 0 0 var(--space-5);
  border-radius: var(--radius-md);
  border: 1px solid;
  box-shadow: var(--shadow-md);
  font-weight: 600;
}
.flash .svg-icon { width: 1.5rem; height: 1.5rem; }
.flash-ok { border-color: var(--success-border); background: var(--success-bg); color: var(--success); }
.flash-error { border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger); }

/* --- Components: forms ---------------------------------------------------- */
label, legend { display: block; font-weight: 700; margin: 0 0 var(--space-1); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; }
.field { margin-bottom: var(--space-5); }
.field:last-child { margin-bottom: 0; }
.hint { color: var(--text-muted); margin: 0 0 var(--space-2); }
.req { font-weight: 500; color: var(--text-muted); }

input[type="text"], input[type="email"], input[type="tel"], input[type="number"], input[type="search"], input:not([type]), textarea, select {
  display: block; width: 100%;
  min-height: var(--tap);
  padding: 0.6rem 0.85rem;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff; color: var(--text);
  font: inherit;
  transition: border-color 0.15s;
}
input:hover, textarea:hover, select:hover { border-color: var(--text); }
:is(input, textarea, select):focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent);
}
textarea { min-height: 8rem; resize: vertical; }
select { appearance: none; padding-right: 2.5rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230f172a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.75rem center; background-size: 1.1rem; }
body.admin input[type="text"], body.admin input[type="email"], body.admin input[type="tel"], body.admin input[type="number"], body.admin input[type="search"],
body.admin input:not([type]), body.admin textarea, body.admin select { min-height: 44px; padding: 0.45rem 0.75rem; }
body.admin select { padding-right: 2.25rem; }
body.admin label { font-size: 0.9375rem; }

.checkbox { display: flex; align-items: center; gap: var(--space-3); font-weight: 500; min-height: var(--tap); cursor: pointer; }
.checkbox input { width: 24px; height: 24px; flex: none; margin: 0; accent-color: var(--primary); }

.field-error { color: var(--danger); font-weight: 700; margin: 0 0 var(--space-2); }
[aria-invalid="true"] { border-color: var(--danger) !important; border-width: 3px; }

.error-summary {
  border: 4px solid var(--danger);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: var(--space-4) var(--space-5);
  margin: 0 0 var(--space-5);
}
/* app.js focuses the summary on load so screen readers announce it; it can't be tabbed to, and its border already marks it. */
.error-summary:focus { outline: none; }
.error-summary h2 { margin: 0 0 var(--space-2); font-size: 1.375rem; }
.error-summary ul { margin: 0; padding-left: 1.25rem; }
.error-summary a { color: var(--danger); font-weight: 700; }

.form-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); margin-bottom: var(--space-4); }
.form-grid > div { min-width: 0; }
.form-grid .span-all { grid-column: 1 / -1; }
.form-grid input + .hint { margin: var(--space-1) 0 0; }

/* Sign-in code: app.js draws boxes under the one real input, which stays on top, invisible, to take taps, paste and autofill. */
.code-boxes { position: relative; }
.code-boxes.is-enhanced input {
  position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; min-height: 0;
  opacity: 0; font-size: 16px; cursor: text;
}
.code-box-row { display: flex; gap: var(--space-2); }
.code-box {
  display: flex; align-items: center; justify-content: center;
  flex: 1; min-width: 0; max-width: 3.5rem; aspect-ratio: 7 / 8;
  border: 2px solid var(--border-strong); border-radius: var(--radius-sm);
  background: #fff; color: var(--text);
  font-size: clamp(1.25rem, 6vw, 1.75rem); font-weight: 700; font-variant-numeric: tabular-nums;
  transition: border-color 0.15s;
}
.code-box:nth-child(3) { margin-right: var(--space-2); }
.code-boxes:hover .code-box { border-color: var(--text); }
.code-boxes .code-box.is-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent);
}
.code-box.is-active:not(.is-filled)::after {
  content: ""; width: 2px; height: 1em; background: var(--text);
  animation: code-caret 1s step-end infinite;
}
@keyframes code-caret { 50% { opacity: 0; } }
.code-boxes + .hint { margin: var(--space-2) 0 0; font-size: 0.9375rem; }
.code-boxes:has([aria-invalid="true"]) .code-box { border-color: var(--danger) !important; border-width: 3px; }

.honeypot { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.cf-turnstile { margin: var(--space-5) 0; }

/* --- Components: status pills (one map, keyed by Status) ------------------ */
.status {
  display: inline-flex; align-items: center; gap: 0.4em;
  padding: 0.15em 0.7em 0.15em 0.55em;
  border: 1px solid var(--pill-border);
  border-radius: var(--radius-pill);
  background: var(--pill-bg); color: var(--pill-fg);
  font-weight: 700; font-size: 0.875em; line-height: 1.4; white-space: nowrap; vertical-align: middle;
}
.status-dot { width: 0.55em; height: 0.55em; border-radius: 50%; background: currentColor; flex: none; }
/* Text on pill background: submitted 7.4:1, acknowledged 7.2:1, in_progress 6.4:1, resolved 6.5:1, closed 8.4:1 */
.status-submitted    { --pill-fg: #6b21a8; --pill-bg: #f3e8ff; --pill-border: #d8b4fe; }
.status-acknowledged { --pill-fg: #1e40af; --pill-bg: #dbeafe; --pill-border: #93c5fd; }
.status-in_progress  { --pill-fg: #92400e; --pill-bg: #fef3c7; --pill-border: #fcd34d; }
.status-resolved     { --pill-fg: #166534; --pill-bg: #dcfce7; --pill-border: #86efac; }
.status-closed       { --pill-fg: #334155; --pill-bg: #e2e8f0; --pill-border: #cbd5e1; }
.status-closed .status-dot { border-radius: 2px; }

/* --- Components: timeline ------------------------------------------------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline > li { position: relative; padding: 0 0 var(--space-5) 2.25rem; }
.timeline > li::before { /* rail */
  content: ""; position: absolute; left: 0.6rem; top: 1.4rem; bottom: 0;
  width: 2px; background: var(--border);
}
.timeline > li:last-child { padding-bottom: 0; }
.timeline > li:last-child::before { display: none; }
.timeline > li::after { /* node */
  content: ""; position: absolute; left: 0.2rem; top: 0.45rem;
  width: 0.9rem; height: 0.9rem; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--primary);
}
.event-date { display: block; color: var(--text-muted); font-size: 0.875em; font-weight: 600; }
.event-message {
  margin: var(--space-2) 0 0; white-space: pre-wrap;
  background: var(--surface-sunken); border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
}

/* --- Components: definition list ----------------------------------------- */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-3) var(--space-5); margin: 0; }
.facts dt { font-weight: 700; color: var(--text-muted); }
.facts dd { margin: 0; min-width: 0; }
.pre { white-space: pre-wrap; }
@media (max-width: 30rem) {
  .facts { grid-template-columns: 1fr; gap: 0; }
  .facts dd { margin-bottom: var(--space-3); }
}

/* --- Resident: home ------------------------------------------------------- */
.hero { padding: var(--space-6) var(--space-5); }
.hero h1 { font-size: clamp(1.875rem, 6vw, 2.5rem); }
.hero-lead { font-size: 1.375rem; color: var(--text-muted); }
.action-list { list-style: none; padding: 0; margin: var(--space-5) 0 0; display: grid; gap: var(--space-3); }
.action-list .svg-icon { width: 1.6rem; height: 1.6rem; }

.contact-card {
  display: flex; align-items: center; gap: var(--space-4);
  min-height: 72px; padding: var(--space-4) var(--space-5);
  color: var(--text); text-decoration: none;
}
.contact-card:hover { color: var(--text); border-color: var(--primary); }
.contact-card .icon-round { color: var(--primary-hover); background: var(--primary-tint); }
.contact-label { display: block; color: var(--text-muted); }
.contact-number { display: block; font-size: 1.5rem; font-weight: 750; color: var(--primary); }
.icon-round {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 3rem; height: 3rem; border-radius: 50%;
}
.icon-round .svg-icon { width: 1.5rem; height: 1.5rem; }

.how-it-works { list-style: none; padding: 0; margin: var(--space-4) 0 var(--space-5); display: grid; gap: var(--space-3); }
.how-it-works li {
  display: flex; align-items: center; gap: var(--space-3);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}
.how-num {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 2.25rem; height: 2.25rem; border-radius: 50%;
  background: var(--primary); color: var(--on-primary); font-weight: 800;
}
@media (min-width: 40rem) {
  .how-it-works { grid-template-columns: repeat(3, 1fr); }
  .how-it-works li { flex-direction: column; text-align: center; padding: var(--space-4); }
}
.section-label { font-size: 1.25rem; margin: var(--space-6) 0 0; }

/* --- Marketing landing page ----------------------------------------------- */
body.marketing main, body.marketing .site-header-inner { max-width: 68rem; }
/* The hero's tinted band runs edge to edge while its content stays in the page column. */
.mkt-hero {
  display: grid; gap: var(--space-6); align-items: center;
  margin: calc(-1 * var(--space-5)) 0 var(--space-6); padding: var(--space-7) 0;
  background: var(--primary-soft); box-shadow: 0 0 0 100vmax var(--primary-soft); clip-path: inset(0 -100vmax);
}
.mkt-hero h1 { font-size: clamp(2.25rem, 5.5vw, 3.25rem); line-height: 1.08; letter-spacing: -0.02em; }
.mkt-hero .hero-lead { color: var(--text); max-width: 34rem; }
.mkt-hero-note { margin: var(--space-4) 0 0; color: var(--text-muted); font-weight: 600; }
.mkt-preview { box-shadow: var(--shadow-lg); border-radius: var(--radius-lg); }
.mkt-preview-city { display: flex; align-items: center; gap: var(--space-2); font-weight: 700; padding-bottom: var(--space-3); margin: 0 0 var(--space-3); border-bottom: 1px solid var(--border); }
.mkt-preview-title { font-weight: 700; }
.mkt-section-lead { color: var(--text-muted); font-size: 1.1875rem; margin-top: 0; }
.mkt-pricing { margin: var(--space-7) 0; scroll-margin-top: var(--space-5); }
#how { scroll-margin-top: var(--space-5); }
.mkt-pricing-grid { display: grid; gap: var(--space-4); align-items: stretch; }
.price-card { margin: 0; padding: var(--space-6); }
.price-card h3 { margin: 0 0 var(--space-3); font-size: 1.25rem; }
.price { margin: 0; color: var(--text-muted); font-weight: 600; }
.price-amount { font-size: 3rem; font-weight: 800; color: var(--text); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.price-alt { margin: 0 0 var(--space-2); color: var(--text-muted); }
.price-card .price { margin-bottom: var(--space-5); }
.price-included { margin: var(--space-4) 0 0; padding: var(--space-5) var(--space-6); }
.price-included h3 { margin: 0 0 var(--space-3); font-size: 1.125rem; }
.price-included .check-list { margin: 0; }
.price-card-quiet { background: var(--surface-sunken); box-shadow: none; }
.price-card-quiet p { color: var(--text-muted); }
.check-list { list-style: none; padding: 0; margin: 0 0 var(--space-5); display: grid; gap: var(--space-2); }
.check-list li { display: flex; align-items: flex-start; gap: var(--space-2); }
.check-list .svg-icon { color: var(--success); margin-top: 0.2em; }
/* Phones: a shorter hero, so how it works and pricing are closer to the top. */
@media (max-width: 40rem) {
  .mkt-hero .hero-lead { font-size: 1.1875rem; }
  .mkt-preview li:nth-child(n + 3) { display: none; }
}
.mkt-preview ul { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-2); }
.mkt-preview li {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius-md);
}
.mkt-features { list-style: none; padding: 0; margin: var(--space-4) 0 var(--space-6); display: grid; gap: var(--space-4); }
.mkt-features .card { margin: 0; }
.mkt-features h3 { margin: var(--space-3) 0 var(--space-2); }
.mkt-features p { color: var(--text-muted); font-size: 1.0625rem; }
.mkt-features .icon-round { color: var(--primary-hover); background: var(--primary-tint); }
.mkt-cta { text-align: center; background: var(--primary-soft); border-color: var(--primary-tint); }
.mkt-eyebrow { margin: 0 0 var(--space-3); color: var(--primary-hover); font-size: 0.9375rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.mkt-faq { margin: var(--space-7) 0; }
.mkt-faq .card { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.mkt-faq details + details { border-top: 1px solid var(--border); }
.mkt-faq summary { padding: var(--space-4) 0; font-size: 1.125rem; font-weight: 700; cursor: pointer; }
.mkt-faq details p { margin: 0 0 var(--space-4); color: var(--text-muted); font-size: 1.0625rem; max-width: 46rem; }
.card.start-card { max-width: 36rem; margin: var(--space-6) auto; }
.request-list { list-style: none; padding: 0; margin: var(--space-4) 0 var(--space-6); display: grid; gap: var(--space-4); }
.request-list .card { margin: 0; }
.request-card { display: grid; gap: var(--space-5); }
@media (min-width: 52rem) { .request-card { grid-template-columns: minmax(14rem, 18rem) minmax(0, 34rem); gap: var(--space-6); } }
.request-who h3 { margin: 0 0 var(--space-2); font-size: 1.125rem; }
.request-who p { margin: 0 0 var(--space-1); overflow-wrap: anywhere; }
.request-card .field { margin-bottom: var(--space-4); }
.input-suffix { display: flex; }
.input-suffix input { min-width: 0; flex: 1; }
.input-suffix input:has(+ span) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-suffix span { display: flex; align-items: center; padding: 0 var(--space-3); border: 2px solid var(--border-strong); border-left: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--surface-sunken); color: var(--text-muted); white-space: nowrap; }
.input-suffix [aria-invalid="true"] + span { border-color: var(--danger); border-width: 3px; border-left: 0; }
.mkt-resident-note { text-align: center; color: var(--text-muted); font-size: 1.0625rem; }
@media (min-width: 52rem) {
  .mkt-hero { grid-template-columns: 1.4fr 1fr; }
  .mkt-pricing-grid { grid-template-columns: repeat(3, 1fr); }
  .price-included .check-list { grid-template-columns: repeat(2, 1fr); }
  .mkt-features { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* --- Resident: city picker and category grid ------------------------------ */
.card-grid { list-style: none; padding: 0; margin: var(--space-5) 0; display: grid; gap: var(--space-3); }
@media (min-width: 40rem) { .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); } }
.card-grid > li { display: flex; }

.tile {
  flex: 1;
  display: grid; grid-template-columns: auto 1fr auto; column-gap: var(--space-4); align-items: center;
  min-height: 88px; padding: var(--space-4);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  color: var(--text); text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.tile:hover { border-color: var(--primary); box-shadow: var(--shadow-lg); color: var(--text); transform: translateY(-1px); }
.tile:focus-visible { border-color: var(--primary); background: var(--surface); color: var(--text); border-radius: var(--radius-lg); }
.tile > .icon-tile, .tile > .monogram { grid-row: span 2; }
.tile-text { grid-row: span 2; min-width: 0; }
.tile-name { display: block; font-weight: 700; font-size: 1.25rem; line-height: 1.3; color: var(--primary); }
.tile-description { display: block; color: var(--text-muted); line-height: 1.4; margin-top: 0.15rem; }
.tile-chevron { grid-row: span 2; color: var(--text-muted); }
.tile:hover .tile-chevron { color: var(--primary); }

/* --- Resident: report form ------------------------------------------------ */
.chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin: 0 0 var(--space-4); }
.chip {
  display: inline-flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-4) var(--space-2) var(--space-2);
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  background: var(--surface); box-shadow: var(--shadow-sm);
  font-weight: 700;
}
.chip .icon-tile { border-radius: 50%; }
.chip-row a { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--space-2); font-weight: 600; }

.form-card { padding: var(--space-5); }
@media (min-width: 40rem) { .form-card { padding: var(--space-6); } }
.form-section { padding: var(--space-5) 0; border-top: 1px solid var(--border); }
.form-section:first-of-type { border-top: 0; padding-top: 0; }
.section-heading { display: flex; align-items: center; gap: var(--space-3); font-size: 1.375rem; margin: 0 0 var(--space-2); }
.section-heading label { margin: 0; font-size: inherit; }
.step-num {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 2.25rem; height: 2.25rem; border-radius: 50%;
  background: var(--primary); color: var(--on-primary);
  font-size: 1.125rem; font-weight: 800;
}
.form-section .button-secondary { margin-top: var(--space-3); }
.location-status:empty { display: none; }
.location-status { color: var(--text-muted); margin: var(--space-3) 0 0; }
.location-added { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); min-height: var(--tap); margin: var(--space-2) 0 0; font-weight: 600; }
.location-added[hidden] { display: none; }
.location-added > .svg-icon { color: var(--success); }
/* A button that reads as a link: it sits in a line of text, so it keeps the in-sentence underline. */
.text-button {
  appearance: none; background: none; border: 0; padding: var(--space-2) var(--space-1); margin: 0;
  font: inherit; color: var(--primary); cursor: pointer;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
}
.text-button:hover { color: var(--primary-hover); text-decoration-color: currentColor; }
.address-credit { flex-basis: 100%; font-size: 0.875rem; font-weight: 400; color: var(--text-muted); }
.address-credit[hidden] { display: none; }

.dropzone {
  position: relative;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-2);
  padding: var(--space-5) var(--space-4);
  border: 3px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-sunken);
  transition: border-color 0.15s, background-color 0.15s;
}
.dropzone:hover { border-color: var(--primary); background: var(--primary-soft); }
.dropzone:focus-within { border-color: var(--primary); border-style: solid; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent); }
.dropzone.has-file { border-style: solid; border-color: var(--success); background: var(--success-bg); }
.dropzone-icon { color: var(--primary); }
.dropzone-icon .svg-icon { width: 2.5rem; height: 2.5rem; }
.dropzone-label { margin: 0; font-size: 1.25rem; font-weight: 700; color: var(--primary); cursor: pointer; }
/* Make the whole drop zone a click target for the label. */
.dropzone-label::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.dropzone input[type="file"] { position: relative; z-index: 1; max-width: 100%; font: inherit; font-size: 1.125rem; }
.dropzone input[type="file"]:focus-visible { box-shadow: none; outline: none; }
.dropzone input[type="file"]::file-selector-button {
  font: inherit; font-weight: 700; min-height: var(--tap); padding: 0.5rem 1.25rem; margin-right: var(--space-3);
  border: 2px solid var(--primary); border-radius: var(--radius-sm); background: var(--surface); color: var(--primary); cursor: pointer;
}
/* With app.js showing the chosen file below, hide the browser's own "No file chosen" text, which gets cut off on phones. */
.dropzone.is-enhanced input[type="file"] { font-size: 0; }
.dropzone.is-enhanced input[type="file"]::file-selector-button { font-size: 1.125rem; margin-right: 0; }
.file-name { margin: 0; font-weight: 700; color: var(--success); display: flex; align-items: center; gap: var(--space-2); }

/* --- Resident: thanks and tracking ---------------------------------------- */
.success-mark {
  display: flex; align-items: center; justify-content: center;
  width: 4.5rem; height: 4.5rem; margin: 0 auto var(--space-4);
  border-radius: 50%; background: var(--success-bg); color: var(--success);
  border: 3px solid var(--success-border);
}
.success-mark .svg-icon { width: 2.5rem; height: 2.5rem; stroke-width: 2.5; }
.center { text-align: center; }

.ticket {
  position: relative;
  margin: var(--space-4) 0 var(--space-5);
  padding: var(--space-4) var(--space-4) var(--space-3);
  border: 3px dashed var(--text);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: center;
}
.ticket-label { margin: 0; color: var(--text-muted); font-weight: 600; }
.tracking-code {
  font-family: var(--mono);
  font-size: clamp(2.5rem, 14vw, 4.5rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  line-height: 1.15;
  margin: var(--space-2) 0;
  color: var(--text);
}

.status-card h2 { margin-top: 0; }
.code-inline { font-family: var(--mono); letter-spacing: 0.05em; }
.status-text { font-size: 1.375rem; margin: var(--space-4) 0 0; }

.stepper { list-style: none; margin: var(--space-5) 0 0; padding: 0; display: grid; gap: var(--space-2); }
.step { position: relative; display: flex; align-items: center; gap: var(--space-3); min-height: 3rem; color: var(--text-muted); }
.step-marker {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 2.5rem; height: 2.5rem; border-radius: 50%;
  border: 2px solid var(--border-strong); background: var(--surface);
  font-weight: 800; color: var(--text-muted);
}
.step-marker .svg-icon { width: 1.4rem; height: 1.4rem; stroke-width: 2.5; }
.step-done { color: var(--text); }
.step-done .step-marker { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.step-current { color: var(--text); font-weight: 700; }
.step-current .step-marker { background: var(--surface); border: 3px solid var(--primary); color: var(--primary); box-shadow: 0 0 0 4px var(--primary-tint); }
.step-closed.step-current .step-marker { border-color: #334155; color: #334155; box-shadow: 0 0 0 4px #e2e8f0; }
.step-now {
  margin-left: auto; padding: 0.05rem 0.6rem; border-radius: var(--radius-pill);
  background: var(--primary); color: var(--on-primary); font-size: 0.875rem; font-weight: 700;
}
@media (min-width: 40rem) {
  .stepper { grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; }
  .step { flex-direction: column; text-align: center; gap: var(--space-2); padding: 0 var(--space-1); }
  .step::before { /* connector to the previous step */
    content: ""; position: absolute; top: 1.25rem; right: 50%; width: 100%; height: 3px;
    background: var(--border); z-index: 0;
  }
  .step:first-child::before { display: none; }
  .step-done::before, .step-current::before { background: var(--primary); }
  .step-marker { position: relative; z-index: 1; }
  .step-label { font-size: 1.25rem; line-height: 1.3; }
  .step-now { margin-left: 0; }
}

/* --- Message page --------------------------------------------------------- */
.message-card { text-align: center; padding: var(--space-6) var(--space-5); }
.message-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 3.5rem; height: 3.5rem; border-radius: 50%;
  background: var(--primary-tint); color: var(--primary-hover); margin-bottom: var(--space-4);
}
.message-icon .svg-icon { width: 1.75rem; height: 1.75rem; }
/* --- Archiving ------------------------------------------------------------ */
.archived-banner, .billing-banner { margin-bottom: var(--space-5); }
.archived-banner form { margin-top: var(--space-3); }
fieldset.read-only { border: 0; margin: 0; padding: 0; min-width: 0; }
.danger-zone { border-color: var(--danger-border); }
.archive-effects { padding-left: 1.25rem; margin: 0 0 var(--space-4); }
.archive-effects li { margin-bottom: var(--space-1); }
.archive-form input { margin-bottom: var(--space-4); }
.dialog {
  width: min(32rem, calc(100vw - 2rem)); padding: var(--space-5);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  color: var(--text); background: var(--surface);
}
.dialog::backdrop { background: rgb(15 23 42 / 0.5); }
.dialog h2 { margin-top: 0; }

.message-links { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2) var(--space-5); margin: var(--space-2) 0 0; }

/* --- Admin: page header and stats ---------------------------------------- */
body.admin h1 { font-size: 1.75rem; margin: 0; }
body.admin h2 { font-size: 1.25rem; }
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-3) var(--space-4); margin: 0 0 var(--space-5); }
.page-header p { margin: var(--space-1) 0 0; color: var(--text-muted); }
.page-header .eyebrow { margin: 0 0 var(--space-1); }
.eyebrow { display: inline-flex; align-items: center; gap: var(--space-1); font-size: 0.9375rem; font-weight: 600; }
.back-link { margin: 0 0 var(--space-3); }
.back-link a { min-height: 44px; }
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }

.stats { list-style: none; padding: 0; margin: 0 0 var(--space-5); display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); }
.stat {
  display: block; height: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm); padding: var(--space-4);
  color: var(--text); text-decoration: none;
}
a.stat:hover { border-color: var(--primary); color: var(--text); box-shadow: var(--shadow-md); }
.stat-label { display: flex; align-items: center; gap: var(--space-2); color: var(--text-muted); font-size: 0.9375rem; font-weight: 600; }
.stat-value { display: block; font-size: 2rem; font-weight: 750; line-height: 1.15; margin-top: var(--space-1); font-variant-numeric: tabular-nums; }
.stat .status-dot { color: var(--pill-fg); width: 0.6rem; height: 0.6rem; }
/* The tile for the current filter is the filled one; on-primary is the pair that follows the brand colour. */
.stat[aria-current] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.stat[aria-current] :is(.stat-label, .status-dot) { color: var(--on-primary); }
a.stat[aria-current]:hover { color: var(--on-primary); background: var(--primary-hover); }

/* --- Admin: toolbar and table -------------------------------------------- */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4); margin: 0 0 var(--space-4); box-shadow: var(--shadow-sm);
}
.toolbar-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); }
.toolbar-form > div { min-width: 11rem; flex: 1 1 11rem; max-width: 18rem; }
.toolbar-form[role="search"] { flex-wrap: nowrap; }
.toolbar-form > .toolbar-search { flex: 1 1 11rem; max-width: 15rem; }
.toolbar label { margin-bottom: var(--space-1); }
/* Same height as the controls, so the count sits on their line rather than floating above it. */
.toolbar .result-count { margin: 0 0 0 auto; min-height: 44px; display: flex; align-items: center; color: var(--text-muted); font-size: 0.9375rem; }

/* Newer, the page number and Older keep their columns when one of the links is missing on the first or last page. */
.pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--space-3); margin-top: var(--space-4); }
.pager-newer { grid-column: 1; justify-self: start; }
.pager-status { grid-column: 2; margin: 0; color: var(--text-muted); font-size: 0.9375rem; white-space: nowrap; }
.pager-older { grid-column: 3; justify-self: end; }
@media (max-width: 30rem) {
  .pager { grid-template-columns: 1fr 1fr; }
  .pager-status { grid-column: 1 / -1; grid-row: 1; justify-self: center; }
  .pager-older { grid-column: 2; }
}

/* clip, not hidden: it rounds the table's corners without becoming a scroll container, so the headings still stick to the window. */
body.admin .table-card { padding: 0; overflow: clip; }
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); }
@media (min-width: 64rem) { .table-wrap { overflow: visible; } }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 0.9375rem; }
th, td { text-align: left; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-sunken); color: var(--text-muted);
  font-size: 0.875rem; font-weight: 700; white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f8fafc; }
.code-link { font-family: var(--mono); font-weight: 700; letter-spacing: 0.03em; white-space: nowrap; }
.cell-muted { color: var(--text-muted); white-space: nowrap; }
.cell-location { max-width: 22rem; }
/* Phones: each report is a stacked card (code and status, problem, location, department and age) instead of a scrolling row. */
@media (max-width: 40rem) {
  .report-table, .report-table tbody { display: block; }
  .report-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .report-table tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-1) var(--space-3); align-items: center;
    grid-template-areas: "code status" "problem problem" "location location" "dept age";
    padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border);
  }
  .report-table tbody tr:last-child { border-bottom: 0; }
  .report-table td { display: block; padding: 0; border: 0; }
  .report-table tbody tr:hover, .report-table tbody tr:hover td { background: none; }
  .report-table .cell-code { grid-area: code; }
  .report-table .cell-status { grid-area: status; justify-self: end; }
  .report-table .cell-problem { grid-area: problem; }
  .report-table .cell-location { grid-area: location; max-width: none; color: var(--text-muted); }
  .report-table .cell-dept { grid-area: dept; color: var(--text-muted); }
  .report-table .cell-age { grid-area: age; justify-self: end; }
}

.empty-state { text-align: center; padding: var(--space-7) var(--space-5); }
.empty-state .icon-round { width: 4rem; height: 4rem; background: var(--surface-sunken); color: var(--text-muted); margin-bottom: var(--space-3); }
.empty-state .icon-round .svg-icon { width: 2rem; height: 2rem; }
.empty-state h2 { margin: 0 0 var(--space-2); }
.empty-state p { color: var(--text-muted); }

/* --- Admin: report detail ------------------------------------------------- */
.detail-grid { display: grid; gap: var(--space-5); }
@media (min-width: 64rem) { .detail-grid { grid-template-columns: minmax(0, 1fr) 22rem; align-items: start; } }
.detail-side { display: grid; gap: var(--space-4); }
.detail-side .card { margin: 0; }
@media (min-width: 64rem) { .detail-side { position: sticky; top: 4.5rem; } }
.problem-line { display: flex; align-items: center; gap: var(--space-2); }
.photo { display: inline-block; }
.photo img { display: block; max-width: 100%; max-height: 20rem; width: auto; height: auto; border-radius: var(--radius-md); border: 1px solid var(--border); }
.visibility {
  display: inline-flex; align-items: center; padding: 0 0.5rem; margin-left: var(--space-1);
  font-size: 0.8125rem; font-weight: 700; border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong); color: #334155; background: var(--surface-sunken);
}
.visibility.is-public { border-color: var(--success-border); color: var(--success); background: var(--success-bg); }
.actor { font-weight: 600; }

/* --- Admin: lists, cities, settings -------------------------------------- */
.city-grid { list-style: none; padding: 0; margin: 0 0 var(--space-5); display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); }
.city-grid > li { display: flex; }
.city-grid .tile { min-height: 84px; border-width: 1px; border-radius: var(--radius-md); }
.city-grid .tile-name { font-size: 1.125rem; }
.city-grid .tile-description { font-size: 0.9375rem; font-family: var(--mono); }
.count-badge {
  display: inline-flex; align-items: center; gap: var(--space-1); margin-top: var(--space-1);
  font-size: 0.8125rem; font-weight: 700; color: var(--text-muted);
}

details.disclosure > summary { list-style: none; display: inline-flex; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure[open] > summary { margin-bottom: var(--space-4); }

.item-list { list-style: none; margin: 0; padding: 0; }
.item-list > li { border-bottom: 1px solid var(--border); }
.item-list > li:last-child { border-bottom: 0; }
.category-row { display: flex; align-items: flex-start; gap: var(--space-2); }
.category-row { scroll-margin-top: 30vh; }
/* After a move the page lands on #row-<id>; flash that row so it is easy to spot, then let it fade.
   A plain :target background would stay until the URL changes. */
.category-row:target { border-radius: var(--radius-sm); animation: row-moved 1.5s ease-out; }
@keyframes row-moved { from { background: var(--primary-soft); } to { background: transparent; } }
.category-row > details { flex: 1; min-width: 0; }
.move-buttons { display: flex; gap: var(--space-1); padding-top: var(--space-2); }
.button-icon { min-width: 48px; padding-inline: 0; }
.button-icon:disabled { opacity: 0.35; cursor: default; background: transparent; }
.item-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) 0; }
.item-main { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 2.25rem; height: 2.25rem; border-radius: 50%;
  background: var(--surface-sunken); color: #334155; font-weight: 700; text-transform: uppercase;
}

/* Category editors are <details> rows; the summary is the clickable row. */
.category-item > summary {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) 0; cursor: pointer; list-style: none; border-radius: var(--radius-sm);
}
.category-item > summary::-webkit-details-marker { display: none; }
.category-item > summary:hover .summary-name { color: var(--primary-hover); }
.summary-text { flex: 1; min-width: 0; }
.summary-name { display: block; font-weight: 700; color: var(--primary); }
.summary-meta { display: block; color: var(--text-muted); font-size: 0.875rem; }
.summary-chevron { color: var(--text-muted); transition: transform 0.15s; }
.category-item[open] > summary .summary-chevron { transform: rotate(90deg); }
.category-item > form { padding: 0 0 var(--space-4); }
.category-item.inactive .icon-tile { background: var(--surface-sunken); color: var(--text-muted); }
.tag { display: inline-flex; padding: 0 0.5rem; border-radius: var(--radius-pill); background: var(--surface-sunken); color: #334155; font-size: 0.8125rem; font-weight: 700; border: 1px solid #cbd5e1; }

/* Branding card on Settings */
.brand-preview { border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; margin: 0 0 var(--space-5); background: var(--page); }
.brand-preview-header { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); background: var(--surface); border-bottom: 1px solid var(--border); font-weight: 700; }
.brand-preview-body { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4); padding: var(--space-4); }
.brand-preview-link { color: var(--primary); font-weight: 600; }
.color-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-4); margin-bottom: var(--space-4); }
.color-row > div { min-width: 0; }
input[type="color"] { display: block; width: 5rem; height: 44px; padding: 2px; border: 2px solid var(--border-strong); border-radius: var(--radius-sm); background: #fff; cursor: pointer; }
.hex-input { max-width: 10rem; font-family: var(--mono); }
.current-logo { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4); margin: 0 0 var(--space-4); }
.current-logo img { display: block; max-height: 4rem; max-width: 14rem; object-fit: contain; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-2); }
.branding-actions, .billing-actions { margin-top: var(--space-4); }
.billing-actions + .hint { margin-top: var(--space-2); }
.billing-choices { margin-top: var(--space-5); padding-top: var(--space-5); border-top: 1px solid var(--border); }
.billing-choices h3 { margin: 0 0 var(--space-2); font-size: 1.125rem; }
.billing-choice-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); margin-top: var(--space-4); }
.billing-choice { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-md); min-width: 0; }
.billing-choice h4 { margin: 0; font-size: 1rem; }
.billing-choice .hint { flex: 1; margin: 0; }
.billing-choices + :is(form, fieldset), .billing-actions + .hint + :is(form, fieldset) { margin-top: var(--space-5); padding-top: var(--space-5); border-top: 1px solid var(--border); }
.branding-section + .branding-section { margin-top: var(--space-5); padding-top: var(--space-5); border-top: 1px solid var(--border); }

/* --- Utilities ------------------------------------------------------------ */
.muted { color: var(--text-muted); }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap;
}
.stack > * + * { margin-top: var(--space-4); }

/* --- Motion --------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .tile:hover { transform: none; }
}

/* --- Print ---------------------------------------------------------------- */
@media print {
  body { background: #fff; display: block; }
  .site-header, .site-footer, .sidebar, .button, form, .skip-link, .demo-bar { display: none !important; }
  .card { box-shadow: none; border-color: #000; }
  .ticket { border-color: #000; }
  .success-mark { border-color: #000; }
  /* A page with a slip prints only the slip. A zero page margin also drops the browser's date and title lines. */
  @page { margin: 0; }
  body:has(.print-slip) main > :not(.print-slip) { display: none !important; }
  body:has(.print-slip) :is(.app-body, main) { max-width: none; padding: 0; margin: 0; }
  .print-slip { display: block; padding: 0.75in; color: #000; font-size: 11pt; line-height: 1.4; }
  .slip-header { display: flex; align-items: center; gap: 12pt; padding-bottom: 12pt; border-bottom: 2pt solid #000; }
  .slip-header :is(.logo, .monogram) { width: 44pt; height: 44pt; }
  .slip-city { margin: 0; font-size: 18pt; font-weight: 700; }
  .slip-title, .slip-label { margin: 0; font-size: 9pt; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: #444; }
  .slip-code { margin: 24pt 0; padding: 14pt 18pt; border: 1pt solid #000; }
  .slip-code-value { margin: 4pt 0 0; font-family: var(--mono); font-size: 30pt; font-weight: 700; letter-spacing: 0.08em; }
  .slip-facts { display: grid; grid-template-columns: 8rem 1fr; margin: 0; border-top: 0.5pt solid #999; }
  .slip-facts :is(dt, dd) { margin: 0; padding: 8pt 0; border-bottom: 0.5pt solid #999; }
  .slip-facts dt { font-weight: 700; color: #444; }
  .slip-facts dd { white-space: pre-wrap; overflow-wrap: anywhere; }
  .slip-footer { margin: 24pt 0 0; font-size: 10pt; }
}
@media screen { .print-slip { display: none; } }

/* Local dev "View as" switch */
.dev-view-as { font-size: 0.875rem; }
.dev-view-as > summary { cursor: pointer; color: var(--text-muted); padding: var(--space-1) var(--space-2); border: 1px dashed var(--border-strong, #64748b); border-radius: var(--radius-sm); }
.dev-view-as-panel { margin-top: var(--space-2); display: grid; gap: var(--space-3); }
.dev-view-as form { display: grid; gap: var(--space-2); }
.dev-view-as form .button { justify-self: start; }
.item-note { margin: 0 0 var(--space-4); padding-top: var(--space-3); border-top: 1px solid var(--border); }
.facts + .item-note { margin-top: var(--space-5); }

/* --- Launch QA fixes: tap targets, long words on narrow screens ----------- */
.site-footer a { display: inline-block; padding: 0.625rem 0.375rem; }
.send-status:empty { display: none; }
.send-status { margin: var(--space-3) 0 0; color: var(--text-muted); }
.mkt-preview-label { margin: 0 0 var(--space-2); color: var(--text-muted); font-size: 0.875rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.tracking-code { white-space: nowrap; font-size: clamp(2rem, 11vw, 4.5rem); }
.city-grid .tile-text { min-width: 0; }
.city-grid .tile-description { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The whole inbox row opens the report; the code stays the one real link for keyboards and screen readers. */
.report-table tbody tr { position: relative; cursor: pointer; }
.report-table .code-link::after { content: ""; position: absolute; inset: 0; }
/* Phones and tablets: the admin tabs sit behind a Menu button next to the city name, opening as a panel over the page.
   A scrolling row hid tabs off-screen and a wrapped one took a third of a phone screen (#72). */
@media (max-width: 63.99rem) {
  .sidebar { position: relative; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding-bottom: var(--space-2); }
  .sidebar-brand { margin-bottom: 0; min-width: 0; }
  .sidebar-brand > span { min-width: 0; overflow-wrap: break-word; }
  .nav-menu { flex-shrink: 0; }
  .nav-menu > summary {
    display: flex; align-items: center; gap: var(--space-2);
    min-height: 44px; padding: 0 var(--space-3);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text); font-weight: 600; cursor: pointer; list-style: none;
  }
  .nav-menu > summary::-webkit-details-marker { display: none; }
  .nav-menu[open] > summary { background: var(--surface-sunken); }
  .nav-panel {
    position: absolute; top: 100%; left: var(--space-4); right: var(--space-4); z-index: 20;
    max-height: calc(100vh - 5rem); overflow-y: auto; padding: var(--space-2);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgb(15 23 42 / 0.12);
  }
  .nav-panel .side-nav ul { flex-direction: column; overflow: visible; padding: 0; }
  .nav-panel .nav-sep { display: block; height: 1px; background: var(--border); margin: var(--space-1) var(--space-2); }
  .account { margin-top: var(--space-2); padding: var(--space-3) var(--space-3) var(--space-2); border-top: 1px solid var(--border); }
}
/* Wide screens: the list is always shown in the sidebar. A browser without ::details-content keeps the Menu button. */
@media (min-width: 64rem) {
  @supports selector(::details-content) {
    .nav-menu > summary { display: none; }
    .nav-menu::details-content { content-visibility: visible; display: contents; }
  }
}
@media (max-width: 40rem) {
  .move-buttons { flex-direction: column; gap: 0; padding-top: 0; }
}
/* Turnstile's box, once drawn, would otherwise push Send down under a second tap. */
.cf-turnstile { min-height: 65px; }
/* Admin forms send once (app.js); this shows the tap was taken. */
form[aria-busy="true"] button[type="submit"] { opacity: 0.6; cursor: progress; }
