/* Indigo Real Estate Management - resident reports
   Primary colour: deep indigo #3d3a8f. Mobile-first. */

:root {
  --indigo: #3d3a8f;
  --indigo-dark: #2c2a6b;
  --indigo-light: #ecebf7;
  --indigo-tint: #f6f6fc;
  --accent: #7938b3;        /* Indigo logo purple - used as an accent */
  --ink: #1f2033;
  --muted: #5f6076;
  --line: #e0e0ea;
  --white: #ffffff;
  --danger: #b4232a;
  --danger-bg: #fdecec;
  --warn: #8a5a00;
  --warn-bg: #fdf3e0;
  --ok: #1d6a3a;
  --ok-bg: #e8f6ec;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(31, 32, 51, 0.12);
}

* { box-sizing: border-box; }

html {
  overflow-x: hidden;               /* iOS: html can scroll even if body can't */
  overscroll-behavior-x: none;      /* no sideways rubber-band of the whole page */
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--indigo-tint);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;               /* never scroll sideways on mobile */
  overscroll-behavior-x: none;
  -webkit-text-size-adjust: 100%;   /* stop iOS auto-inflating text */
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; }
main { flex: 1 0 auto; min-width: 0; }   /* flex item must be allowed to shrink to the viewport */

/* Per-development background: a soft, fixed photo behind the resident app. */
body.has-dev-bg {
  background: var(--indigo-tint);
}
body.has-dev-bg::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: var(--dev-bg);
  background-size: cover;
  background-position: center;
  opacity: 0.14;
  pointer-events: none;
}

/* Built-in gradient themes (used when a development has no uploaded photo).
   Applied to the whole page as a gentle, always-legible wash. */
body.bg-theme { background-attachment: fixed; }
body.bg-theme-indigo    { background: linear-gradient(160deg, #eef0fb 0%, #dfe3f5 100%); }
body.bg-theme-sage      { background: linear-gradient(160deg, #eef4ee 0%, #dde9df 100%); }
body.bg-theme-slate     { background: linear-gradient(160deg, #eef1f4 0%, #dfe5ea 100%); }
body.bg-theme-champagne { background: linear-gradient(160deg, #f7f2ea 0%, #ede2d0 100%); }
body.bg-theme-coastal   { background: linear-gradient(160deg, #ecf3f6 0%, #d8e7ee 100%); }

/* Theme picker on the staff Branding page. */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.6rem;
  margin-top: 0.4rem;
}
.theme-opt {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border, #d9d8ee);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 500;
}
.theme-opt:has(input:checked) {
  border-color: var(--indigo, #3d3a8f);
  box-shadow: 0 0 0 2px rgba(61, 58, 143, 0.18);
}
.theme-opt input { margin: 0; }
.theme-swatch {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  flex: 0 0 auto;
}
.theme-name { font-size: 0.88rem; }

/* Floating bottom tab bar for the resident app (phone-first, works on desktop).
   Only shown when a resident is signed in (body.resident-view). */
.rtabs { display: none; }
body.resident-view .rtabs {
  display: flex;
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  justify-content: space-around;
  gap: 2px;
  padding: 8px max(10px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left));
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border, #e2e1f0);
  box-shadow: 0 -6px 24px -12px rgba(30, 28, 80, 0.35);
  z-index: 50;
}
@media (min-width: 600px) {
  body.resident-view .rtabs {
    bottom: 16px;
    border: 1px solid var(--border, #e2e1f0);
    border-radius: 20px;
    box-shadow: 0 18px 40px -16px rgba(30, 28, 80, 0.45);
  }
}
.rtab {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  text-decoration: none;
  color: var(--muted, #6b6a8a);
  font-size: 0.68rem;
  font-weight: 600;
  border-radius: 12px;
}
.rtab svg {
  width: 24px; height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.rtab.active { color: var(--indigo, #3d3a8f); }
.rtab:focus-visible { outline: 2px solid var(--indigo, #3d3a8f); outline-offset: 2px; }
.rtab-icon { position: relative; display: inline-flex; }
.rtab-dot {
  position: absolute; top: -2px; right: -4px;
  width: 9px; height: 9px; border-radius: 50%;
  background: #e5484d; border: 2px solid #fff;
}

/* Keep content and footer clear of the fixed tab bar. */
body.resident-view main { padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }
body.resident-view .sitefoot { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }

/* Preview mode banner (staff previewing a development's resident view). */
.preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  position: relative;
  z-index: 60;
  background: #1b1836;
  color: #fff;
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
}
.preview-bar .btn { flex: 0 0 auto; }

/* Slim branded header strip at the top of inner resident screens. */
.screen-head {
  background: linear-gradient(150deg, #12b3a8 0%, #2a2a72 88%);
  color: #fff;
  border-radius: 18px;
  padding: 0.85rem 1.15rem;
  margin: 0.75rem 0 1.1rem;
  box-shadow: 0 16px 34px -22px rgba(20, 20, 60, 0.5);
}
.screen-head h1 { margin: 0; font-size: 1.4rem; line-height: 1.15; }

/* Compact footer for the resident / public interface. */
.sitefoot-min { font-size: 0.72rem; }
.sitefoot-min .foot-min { display: flex; flex-direction: column; gap: 0.15rem; }
.sitefoot-min .foot-min strong { font-size: 0.8rem; }

/* ---- Resident front page (home) --------------------------------------- */
.rhome-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.rhome .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--indigo, #3d3a8f);
  opacity: 0.85;
}
.rhome-title {
  font-size: 2rem;
  line-height: 1.08;
  margin: 0.2rem 0 0;
  padding-left: 0.7rem;
  border-left: 4px solid #d8b877;
}
.rhome-bell {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border, #e2e1f0);
  background: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 4px 12px -6px rgba(30, 28, 80, 0.35);
}

/* Swipeable action pills on the resident home. A CSS grid carousel: each column
   is exactly the container width, so it can never force the page wider than the
   screen (unlike flex items with min-width, which can on mobile Safari). */
.pill-pager {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 100%;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;   /* swiping pills must NOT drag the page */
  scrollbar-width: none;
  margin-top: 1.1rem;
  padding-bottom: 4px;
  max-width: 100%;
}
.pill-pager::-webkit-scrollbar { display: none; }
.pill {
  position: relative;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  min-width: 0;
  min-height: 164px;
  border-radius: 22px;
  color: #fff;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 1.4rem;
  box-shadow: 0 22px 44px -22px rgba(20, 20, 60, 0.55);
}
.pill svg {
  width: 42px; height: 42px;
  fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.pill-title { font-size: 1.55rem; font-weight: 800; letter-spacing: -0.01em; }
.pill-report   { background: linear-gradient(150deg, #12b3a8 0%, #2a2a72 90%); }
.pill-messages { background: linear-gradient(150deg, #6d5be0 0%, #2a2a72 90%); }
.pill-account  { background: linear-gradient(150deg, #2f7bf0 0%, #17b0a6 92%); }
.pill-badge {
  position: absolute; top: 14px; right: 16px;
  background: #e5484d; color: #fff;
  font-weight: 800; font-size: 0.8rem;
  border-radius: 999px; padding: 2px 10px;
  box-shadow: 0 4px 10px -4px rgba(0, 0, 0, 0.5);
}
.pill-dots { display: flex; justify-content: center; gap: 7px; margin: 0.85rem 0 0.2rem; }
.pill-dots .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(60, 58, 143, 0.28); transition: all 0.2s ease;
}
.pill-dots .dot.active { background: var(--indigo, #3d3a8f); width: 20px; border-radius: 999px; }

.hero-card {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  margin-top: 1.1rem;
  min-height: 210px;
  color: #fff;
  background: linear-gradient(150deg, #12b3a8 0%, #2a2a72 88%);
  box-shadow: 0 22px 44px -22px rgba(20, 20, 60, 0.55);
}
.hero-card.has-photo {
  background-image:
    linear-gradient(150deg, rgba(10, 60, 90, 0.45) 0%, rgba(20, 18, 54, 0.86) 92%),
    var(--hero-bg);
  background-size: cover;
  background-position: center;
}
.hero-skyline {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  width: 100%; height: 58%;
}
.hero-inner {
  position: relative;
  z-index: 1;
  padding: 1.3rem 1.4rem 1.4rem;
  display: flex;
  flex-direction: column;
  min-height: 210px;
}
.hero-brand {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  opacity: 0.92;
}
.hero-name {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin: 0.55rem 0 0.35rem;
}
.hero-sub {
  font-size: 0.9rem;
  line-height: 1.4;
  opacity: 0.9;
  max-width: 30ch;
  margin-bottom: 1.1rem;
}
.hero-cta {
  align-self: flex-start;
  margin-top: auto;
  background: #fff;
  color: #1b1836;
  font-weight: 700;
  padding: 0.7rem 1.25rem;
  border-radius: 999px;
  text-decoration: none;
  box-shadow: 0 10px 22px -10px rgba(0, 0, 0, 0.5);
}
.hero-cta:hover { background: #f3f1ff; }

.rhome-h2 {
  font-size: 1.15rem;
  margin: 1.5rem 0 0.7rem;
}
.rhome-alert {
  display: block;
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: #eef0fb;
  border: 1px solid #d7dbf3;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.92rem;
}

.rlist { display: flex; flex-direction: column; gap: 0.6rem; }

.anncard {
  background: #fff;
  border: 1px solid var(--border, #ecebf5);
  border-left: 4px solid var(--indigo, #3d3a8f);
  border-radius: 16px;
  padding: 0.9rem 1rem;
  box-shadow: 0 10px 24px -18px rgba(30, 28, 80, 0.4);
}
.anncard-title { font-weight: 700; }
.anncard-body { margin-top: 0.4rem; white-space: pre-line; }

.rcard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
  background: #fff;
  border: 1px solid var(--border, #ecebf5);
  border-radius: 16px;
  padding: 0.85rem 1rem;
  box-shadow: 0 10px 24px -18px rgba(30, 28, 80, 0.4);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.rcard:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px -18px rgba(30, 28, 80, 0.5);
}
.rcard-main { flex: 1; min-width: 0; }   /* allow long text to wrap instead of pushing the badge off */
.rcard-ref { font-weight: 800; color: var(--indigo, #3d3a8f); font-size: 1.02rem; }
.rcard-meta { font-size: 0.9rem; margin-top: 0.12rem; overflow-wrap: anywhere; }
.rcard-date { color: var(--muted, #6b6a8a); font-size: 0.78rem; margin-top: 0.15rem; }
.rcard .badge { flex-shrink: 0; }

/* Property switcher (residents with more than one property). */
.prop-switch { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.9rem; }
.prop-switch-label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.14em;
  font-weight: 700; color: var(--muted, #6b6a8a); flex: 0 0 auto;
}
.prop-switch select { flex: 1; min-width: 0; }
.prop-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.prop-item {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.7rem 0.85rem; border: 1px solid var(--border, #ecebf5); border-radius: 12px;
}
.prop-item form { margin: 0; }

/* A read-only value shown where a field is fixed (e.g. locked development). */
.locked-field {
  padding: 0.6rem 0.75rem;
  background: var(--indigo-tint);
  border: 1px solid var(--border, #d9d8ee);
  border-radius: 8px;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

a { color: var(--indigo); }

/* ---------- Top bar (staff) ---------- */
.topbar {
  background: var(--indigo);
  color: var(--white);
  padding-top: env(safe-area-inset-top, 0px);   /* clear the notch when installed */
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.6rem max(1rem, env(safe-area-inset-right)) 0.6rem max(1rem, env(safe-area-inset-left));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
}
.brand {
  color: var(--white);
  font-weight: 700;
  text-decoration: none;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.brand-logo { height: 30px; width: auto; display: block; }
.brand-sub {
  color: #dfdefa;
  font-weight: 600;
  font-size: 0.85rem;
  border-left: 1px solid rgba(255,255,255,0.35);
  padding-left: 0.6rem;
}
.mainnav { display: flex; gap: 1rem; flex: 1; flex-wrap: wrap; }
.mainnav a {
  color: #dfdefa;
  text-decoration: none;
  font-size: 0.95rem;
  padding: 0.2rem 0;
  border-bottom: 2px solid transparent;
}
.mainnav a:hover { color: #fff; border-bottom-color: rgba(255,255,255,0.6); }
.signout { display: flex; align-items: center; gap: 0.6rem; }
.who { color: #dfdefa; font-size: 0.85rem; }

/* ---------- Layout ---------- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem max(1rem, env(safe-area-inset-right)) 3rem max(1rem, env(safe-area-inset-left));
}
.narrow { max-width: 640px; }
h1 { font-size: 1.5rem; margin: 0.2rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.6rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-block;
  border: 1px solid var(--indigo);
  background: var(--indigo);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover { background: var(--indigo-dark); border-color: var(--indigo-dark); }
.btn-block { display: block; width: 100%; text-align: center; }
.btn-ghost {
  background: transparent;
  border-color: rgba(255,255,255,0.6);
  color: #fff;
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
}
.btn-ghost:hover { background: rgba(255,255,255,0.15); }
.btn-secondary { background: #fff; color: var(--indigo); }
.btn-secondary:hover { background: var(--indigo-light); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 0.35rem 0.6rem; font-size: 0.85rem; }
.btn[disabled], .btn.disabled { opacity: 0.5; cursor: not-allowed; }

label { display: block; font-weight: 600; margin: 0.9rem 0 0.3rem; }
input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=date], input[type=month], select, textarea {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
}
textarea { min-height: 120px; resize: vertical; }
.field-hint { font-weight: 400; color: var(--muted); font-size: 0.85rem; }
.checkbox-row { display: flex; align-items: center; gap: 0.5rem; margin-top: 1rem; }
.checkbox-row label { margin: 0; font-weight: 600; }
.checkbox-row input { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.5rem 1rem 1rem; }
.inline-form { display: inline; }
.form-row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end; }
.form-row > div { flex: 1; min-width: 160px; }

/* ---------- Cards ---------- */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

/* ---------- Public form ---------- */
.public-shell { max-width: 560px; margin: 0 auto; padding: 1rem; }

/* Full-screen photo background for the sign-up / sign-in pages. */
body.auth-photo::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  /* Per-development background when the sign-up link carries a development
     (--auth-bg); otherwise the shared default photo. */
  background-image: var(--auth-bg, url('/static/img/community-bg.jpg'));
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
}
body.auth-photo::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(16, 22, 45, 0.42) 0%, rgba(16, 22, 45, 0.72) 100%);
}
body.auth-photo .public-header {
  background: transparent;
  padding: 0.5rem 0.25rem 0;
  margin-bottom: 1rem;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.45);
}
/* Glass form: transparent card so the photo shows through, with light text. */
body.auth-photo .card {
  background: rgba(17, 22, 42, 0.34);
  backdrop-filter: blur(18px) saturate(120%);
  -webkit-backdrop-filter: blur(18px) saturate(120%);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.7);
  color: #fff;
}
body.auth-photo .card label { color: #fff; }
body.auth-photo .card .field-hint { color: rgba(255, 255, 255, 0.72); }
body.auth-photo .card input,
body.auth-photo .card select,
body.auth-photo .card textarea {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.38);
  color: #fff;
}
body.auth-photo .card input::placeholder,
body.auth-photo .card textarea::placeholder { color: rgba(255, 255, 255, 0.6); }
body.auth-photo .card input:focus,
body.auth-photo .card select:focus,
body.auth-photo .card textarea:focus {
  border-color: rgba(255, 255, 255, 0.85);
  outline: none;
}
/* Native dropdown list stays readable (dark text on the browser's white menu). */
body.auth-photo .card select option { color: #1b1836; }
body.auth-photo .card .locked-field {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
}
body.auth-photo .card .privacy,
body.auth-photo .card .small,
body.auth-photo .card .checkbox-row label { color: rgba(255, 255, 255, 0.85); }
body.auth-photo .card a { color: #cdd6ff; }
/* Keep autofilled fields on-theme instead of the browser's solid white. */
body.auth-photo .card input:-webkit-autofill {
  -webkit-text-fill-color: #fff;
  -webkit-box-shadow: 0 0 0 1000px rgba(70, 78, 120, 0.55) inset;
  transition: background-color 9999s ease-in-out 0s;
}
/* Let the photo show through the footer too, on the auth pages. */
body.auth-photo .sitefoot {
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.55);
}
.public-header {
  background: var(--indigo);
  color: #fff;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.public-header h1 { margin: 0; font-size: 1.3rem; }
.public-header .loc { color: #dfdefa; margin-top: 0.25rem; }
.pub-logo { height: 28px; width: auto; display: block; margin-bottom: 0.6rem; }
.emergency {
  background: var(--danger-bg);
  border: 2px solid var(--danger);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
}
.emergency strong { color: var(--danger); }
.emergency .phone {
  display: inline-block;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--danger);
  text-decoration: none;
  margin-top: 0.25rem;
}
.privacy {
  font-size: 0.82rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  margin-top: 1.5rem;
  padding-top: 1rem;
}
.confirm-ref {
  font-size: 2rem;
  font-weight: 800;
  color: var(--indigo);
  letter-spacing: 0.03em;
  background: var(--indigo-light);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  margin: 1rem 0;
}

/* ---------- Summary cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--indigo);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
}
.stat .n { font-size: 1.9rem; font-weight: 800; color: var(--indigo); }
.stat .l { color: var(--muted); font-size: 0.85rem; }
.stat.alert { border-left-color: var(--danger); }
.stat.alert .n { color: var(--danger); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--indigo-tint); color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
tbody tr:hover { background: var(--indigo-tint); }
td.ref a { font-weight: 700; text-decoration: none; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.badge-new { background: var(--indigo-light); color: var(--indigo-dark); }
.badge-progress { background: var(--warn-bg); color: var(--warn); }
.badge-closed { background: var(--ok-bg); color: var(--ok); }
.badge-overdue { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }
.badge-dup { background: #eee6fb; color: #5a2ea6; }
.badge-expired { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }
.badge-suggested { background: var(--ok-bg); color: var(--ok); }

.filters { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filters label { margin: 0 0 0.25rem; }
.filters > div { min-width: 180px; }

.detail-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 780px) { .detail-grid { grid-template-columns: 2fr 1fr; } }
.kv { margin: 0; }
.kv dt { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.02em; margin-top: 0.6rem; }
.kv dd { margin: 0.1rem 0 0; }
.photo-thumb { max-width: 100%; border-radius: var(--radius); border: 1px solid var(--line); margin-top: 0.5rem; }
.photo-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.photo-grid .photo-thumb { width: 104px; height: 104px; object-fit: cover; margin-top: 0; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 2px solid var(--indigo-light); padding: 0 0 0.9rem 0.9rem; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--indigo); }
.timeline .when { color: var(--muted); font-size: 0.8rem; }

.flashes { margin-bottom: 1rem; }
.flash { padding: 0.7rem 1rem; border-radius: var(--radius); margin-bottom: 0.5rem; }
.flash-success { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--danger-bg); color: var(--danger); }
.flash-info { background: var(--indigo-light); color: var(--indigo-dark); }

.emailbox { background: var(--indigo-tint); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; white-space: pre-wrap; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 0.9rem; }

/* ---------- Conversation thread ---------- */
.thread { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 0.5rem; }
.msg { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.6rem 0.8rem; max-width: 90%; }
.msg-staff { background: var(--indigo-light); align-self: flex-start; }
.msg-resident { background: var(--indigo-tint); align-self: flex-end; border-color: var(--indigo-light); }
.msg-meta { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.25rem; }
.msg .photo-thumb { max-width: 220px; margin-top: 0.4rem; }

/* ---------- Site footer ---------- */
.sitefoot { flex-shrink: 0; background: var(--indigo-dark); color: #d9d8f0; font-size: 0.8rem; overflow-wrap: anywhere; }
.sitefoot-inner { max-width: 1100px; margin: 0 auto; padding: 1rem max(1rem, env(safe-area-inset-right)) 1rem max(1rem, env(safe-area-inset-left)); display: flex; flex-wrap: wrap; gap: 0.75rem 2rem; justify-content: space-between; }
.sitefoot a { color: #fff; }
.sitefoot .muted { color: #b7b6dd; }
.foot-meta { display: flex; flex-direction: column; gap: 0.15rem; text-align: right; }
@media (max-width: 600px) { .foot-meta { text-align: left; } }

/* ---------- Logo panel (for light/print backgrounds) ---------- */
.logo-panel { background: var(--indigo); border-radius: var(--radius); padding: 0.9rem 1rem; text-align: center; }
.logo-panel img { height: 34px; width: auto; }

/* ---------- Login ---------- */
.login-wrap { max-width: 380px; margin: 3rem auto; }
.login-wrap .brand-big { text-align: center; color: var(--indigo); font-weight: 800; font-size: 1.4rem; margin-bottom: 1.25rem; }

/* ---------- QR poster (A4 print) ---------- */
.poster {
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  background: #fff;
  padding: 24mm 20mm;
  text-align: center;
  color: var(--ink);
}
.poster .p-brand { color: var(--indigo); font-weight: 800; font-size: 1.4rem; letter-spacing: 0.02em; }
.poster h1 { font-size: 2.4rem; margin: 1rem 0 0.3rem; }
.poster .p-loc { font-size: 1.3rem; color: var(--muted); margin-bottom: 1.5rem; }
.poster .qr { width: 90mm; height: 90mm; margin: 0.5rem auto 1rem; }
.poster .p-steps { font-size: 1.3rem; text-align: left; max-width: 130mm; margin: 1rem auto; }
.poster .p-steps li { margin-bottom: 0.6rem; }
.poster .p-emergency { border: 3px solid var(--danger); border-radius: 12px; padding: 1rem; margin: 1.5rem auto 0; max-width: 150mm; }
.poster .p-emergency .lbl { color: var(--danger); font-weight: 800; font-size: 1.2rem; }
.poster .p-emergency .num { font-size: 2rem; font-weight: 800; color: var(--danger); }
.print-toolbar { text-align: center; padding: 1rem; background: var(--indigo-tint); }
@media print {
  .print-toolbar { display: none; }
  body { background: #fff; }
  .poster { margin: 0; }
  @page { size: A4; margin: 0; }
}
