/* Quattro - Municipal Property Tax Console
 * YCharts-inspired light, dense, professional UI.
 * Designed to live under piaindustries.com today and graduate to its own domain.
 *
 * SPACING SCALE  (φ ≈ 1.618, Fibonacci-derived, compact-biased for dense data)
 *   --q-sp-1:  4px   micro — icon gap, tag padding
 *   --q-sp-2:  7px   tight — kv-table row, filter-row, stat sub-line
 *   --q-sp-3: 11px   inner — panel body, card padding, filter rows container
 *   --q-sp-4: 18px   section — panel margin-bottom, stats-grid gap, title-row gap
 *   --q-sp-5: 29px   major — main left/right padding, page-header padding
 *   --q-sp-6: 47px   page bottom
 *
 * TYPE SCALE  (minor-third modular, base 13px)
 *   --q-fs-xs:   10.5px  labels, badges, meta chips
 *   --q-fs-sm:   12px    secondary text, filter counts, subtabs
 *   --q-fs-base: 13px    body, table cells, kv rows
 *   --q-fs-md:   15px    panel headers (h3), section labels
 *   --q-fs-lg:   19px    stat values
 *   --q-fs-xl:   24px    page title
 *
 * The stat card achieves a ~1:1.618 label-to-value visual weight ratio using
 * --q-fs-xs for the label and --q-fs-lg for the value.
 */

:root {
  /* ---------- colour ----------
     2026-07-20: retoned onto the shared civic-ledger palette
     (/css/civic-ledger.css — royal navy / gold / paper, serif throughout).
     Variable NAMES are unchanged so every rule below and every page that
     already consumes var(--q-*) repaints automatically; only the values
     now alias the --ms-* / --cl-* tokens. Requires civic-ledger.css to be
     linked before this file resolves (see each page's <head>). */
  --q-bg: var(--ms-bg, #f4f6f8);
  --q-surface: var(--ms-surface, #ffffff);
  --q-surface-alt: var(--ms-surface-2, #f8faf9);
  --q-border: var(--ms-border, #e2e6ea);
  --q-border-strong: var(--ms-border-2, #c8ced6);
  --q-text: var(--ms-text, #1e2630);
  --q-text-muted: var(--ms-muted, #5a6575);
  --q-text-faint: color-mix(in srgb, var(--ms-muted, #5a6575) 65%, var(--ms-bg, #fff));
  --q-link: var(--ms-brand-2, #1f5fb3);
  --q-link-hover: var(--ms-brand, #154884);

  --q-nav-bg: var(--cl-navy-ink, #161b22);
  --q-nav-text: var(--cl-white, #ffffff);
  --q-nav-text-muted: rgba(255,255,255,.58);
  --q-nav-accent: var(--cl-gold, #d4a017);
  --q-nav-accent-2: var(--cl-gold-2, #f3c14a);

  --q-positive: var(--ms-good, #1c8a3a);
  --q-negative: var(--ms-crit, #c2392b);
  --q-warning: var(--ms-warn, #b97a00);
  /* five-point rating scale (Scout/reval ranking) — distinct vocabulary from
     the good/warn/crit status tokens above; left as-is, see restyle report */
  --q-attractive: #2196F3;
  --q-neutral: #9e9e9e;
  --q-avoid: #e53935;
  --q-unrated: #607d8b;

  --q-row-hover: color-mix(in srgb, var(--cl-navy, #1e4470) 6%, var(--ms-surface, #fff));
  --q-row-stripe: color-mix(in srgb, var(--ms-surface-2, #f3f1ec) 45%, var(--ms-surface, #fff));
  --q-focus: var(--ms-gold, #8a6206);

  /* accent (civic green — same semantic as --q-positive) */
  --q-accent: var(--ms-good, #1f7a4d);
  --q-accent-soft: color-mix(in srgb, var(--ms-good, #1f7a4d) 12%, var(--ms-surface, #fff));
  --q-accent-muted: color-mix(in srgb, var(--ms-good, #1f7a4d) 22%, var(--ms-surface, #fff));

  /* ---------- elevation (navy-tinted, was green-black) ---------- */
  --q-shadow-sm: 0 1px 3px rgba(13, 31, 51, 0.08), 0 1px 2px rgba(13, 31, 51, 0.05);
  --q-shadow-md: 0 3px 8px rgba(13, 31, 51, 0.09), 0 1px 3px rgba(13, 31, 51, 0.06);
  --q-shadow-lg: 0 12px 32px rgba(13, 31, 51, 0.14), 0 3px 8px rgba(13, 31, 51, 0.08);

  /* ---------- geometry ---------- */
  --q-radius:    var(--ms-radius, 8px);
  --q-radius-lg: 12px;
  --q-radius-xl: 16px;

  /* ---------- φ-based spacing scale (layout — untouched) ---------- */
  --q-sp-1:  4px;
  --q-sp-2:  7px;
  --q-sp-3: 11px;
  --q-sp-4: 18px;
  --q-sp-5: 29px;
  --q-sp-6: 47px;

  /* ---------- modular type scale (layout — untouched) ---------- */
  --q-fs-xs:   10.5px;
  --q-fs-sm:   12px;
  --q-fs-base: 13px;
  --q-fs-md:   15px;
  --q-fs-lg:   19px;
  --q-fs-xl:   24px;

  /* ---------- typography ----------
     civic-ledger is serif in every slot, including "sans" and "mono" —
     deliberate, see civic-ledger.css header comment. */
  --q-font: var(--ms-serif, 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif);
  --q-mono: var(--ms-mono, 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace);

  /* ---------- bill palette (civic green/cream) ----------
     Printable tax-bill facsimile (.q-bill-*, ~line 1170+) — deliberately its
     own green-ledger print identity, kept OUT of the navy/gold reskin (same
     exception class as the GIS viewers). Not touched by this pass. */
  --bill-ink:        #1d2b22;
  --bill-green:      #19392a;
  --bill-green-soft: #2c5a41;
  --bill-cream:      #faf7ef;
  --bill-line:       #c9cfc7;
  --bill-rule:       #7d8a7f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--q-bg);
  color: var(--q-text);
  font-family: var(--q-font);
  font-size: var(--q-fs-base);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: linear-gradient(180deg, var(--ms-surface-2, #ecf1ee) 0%, var(--q-bg) 220px);
}

a { color: var(--q-link); text-decoration: none; }
a:hover { color: var(--q-link-hover); text-decoration: underline; }

/* ============================================================
   TOP NAVIGATION
   ============================================================ */
.q-topbar {
  background: var(--q-nav-bg);
  color: var(--q-nav-text);
  padding: 0 var(--q-sp-5);
  /* height:auto + wrap: on narrow/scaled displays (1080p projector mirrored
     from a 150%-scaled laptop = 1280px logical; Surface at 150% = ~1536px)
     the user block used to run ~400px off-screen. At >=1687px this renders
     identically to the old fixed 50px single row. */
  height: auto;
  min-height: 50px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--q-sp-4);
  row-gap: 4px;
  border-bottom: 1px solid rgba(0,0,0,.35);
  box-shadow: 0 1px 0 rgba(255,255,255,.04);
}
.q-brand {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--q-nav-accent);
  display: flex;
  align-items: center;
  gap: var(--q-sp-2);
}
.q-brand .q-brand-mark {
  display: inline-block;
  width: 26px; height: 26px;
  border-radius: var(--q-sp-1);
  background: linear-gradient(135deg, var(--q-nav-accent) 0%, var(--q-nav-accent-2) 100%);
  color: var(--cl-navy-ink, #1c1c1c);
  font-size: var(--q-fs-base);
  font-weight: 900;
  text-align: center;
  line-height: 26px;
}
.q-collaboration-divider {
  width: 1px;
  height: 22px;
  background: rgba(255,255,255,.22);
  flex: 0 0 auto;
}
.q-collaboration-seal {
  display: block;
  width: auto;
  height: 30px;
  object-fit: contain;
  flex: 0 0 auto;
}
@media (max-width: 720px) {
  .q-collaboration-seal { height: 26px; }
  .q-collaboration-divider { height: 19px; }
}
.q-nav-links {
  display: flex; gap: 20px; align-items: center;
  flex: 1 1 auto;
  flex-wrap: wrap;      /* extra links drop to a second row instead of pushing */
  min-width: 0;         /* the user block off the right edge on narrow displays */
  row-gap: 2px;
}
.q-nav-links a {
  color: var(--q-nav-text);
  font-size: var(--q-fs-sm);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  padding: var(--q-sp-1) 0;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.q-nav-links a:hover { color: var(--q-nav-accent); }
.q-nav-links a.active {
  color: #fff;
  border-bottom-color: var(--q-nav-accent);
}
.q-nav-search {
  background: var(--cl-navy-3, #22282f);
  border: 1px solid var(--cl-navy-4, #363d47);
  color: #eee;
  border-radius: var(--q-radius);
  padding: var(--q-sp-2) var(--q-sp-3);
  font-size: var(--q-fs-base);
  width: clamp(150px, 15vw, 260px);  /* shrinks gradually on narrow displays */
  outline: none;
  transition: border-color .15s;
}
.q-nav-search:focus { border-color: var(--q-nav-accent); }
.q-nav-search::placeholder { color: rgba(255,255,255,.42); }
.q-nav-user {
  display: flex; align-items: center; gap: var(--q-sp-2);
  font-size: var(--q-fs-sm);
  color: var(--q-nav-text-muted);
  margin-left: auto;   /* keeps right alignment when the links row wraps */
  min-width: 0;
}
.q-source-cue {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
}
.q-source-cue[hidden] { display: none; }
.q-source-cue svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.q-source-cue.is-live { color: #4ade80; }
.q-source-cue.is-fallback { color: #fbbf24; }
.q-source-cue__warning { display: none; }
.q-source-cue.is-fallback .q-source-cue__check { display: none; }
.q-source-cue.is-fallback .q-source-cue__warning { display: inline; }
/* On narrow/scaled displays the full email is the widest rigid item —
   tighten its ellipsis budget so the row fits before wrapping is needed. */
@media (max-width: 1700px) {
  .pia-rolebadge__user { max-width: clamp(90px, 11vw, 200px); }
}

/* ── Role badge (signed-in role pill + username) ─────────────────────────────
   Shared with piai-shell + the Quattro Workbench. Solid colored pill, white
   text — reads on the dark q-topbar (--q-nav-bg). */
.pia-rolebadge__pill {
  display:inline-block; padding:3px 10px; border-radius:999px;
  font-size:10px; font-weight:800; text-transform:uppercase; letter-spacing:.05em;
  color:#fff; white-space:nowrap; line-height:1.45;
}
.pia-rolebadge__user {
  font-size:12px; font-weight:600; color:#cbd5e1; white-space:nowrap;
  max-width:200px; overflow:hidden; text-overflow:ellipsis;
}
.pia-rolebadge__pill.founder, .pia-rolebadge__pill.ceo     { background:#c89b1e; }
.pia-rolebadge__pill.admin, .pia-rolebadge__pill.superuser { background:#7c3aed; }
.pia-rolebadge__pill.town_manager                          { background:#0ea5e9; }
.pia-rolebadge__pill.assessor                              { background:#16a34a; }
.pia-rolebadge__pill.deputy_assessor                       { background:#1f9a55; }
.pia-rolebadge__pill.editor                                { background:#d97706; }
.pia-rolebadge__pill.treasurer                             { background:#b07d10; }
.pia-rolebadge__pill.collector                             { background:#dc2626; }
.pia-rolebadge__pill.clerk                                 { background:#0891b2; }
.pia-rolebadge__pill.select_board                          { background:#6366f1; }
.pia-rolebadge__pill.viewer, .pia-rolebadge__pill.user     { background:#64748b; }
@media (max-width: 640px) { .pia-rolebadge__user { display:none; } }
.q-nav-user .q-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--q-nav-accent);
  color: var(--cl-navy-ink, #1c1c1c);
  display: grid; place-items: center;
  font-weight: 800;
  font-size: var(--q-fs-sm);
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.q-page-header {
  background: linear-gradient(180deg, var(--ms-surface, #ffffff) 0%, var(--ms-surface-2, #fafcfb) 100%);
  border-bottom: 1px solid var(--q-border);
  padding: var(--q-sp-4) var(--q-sp-5) 0;
  box-shadow: var(--q-shadow-sm);
}
.q-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--q-sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--q-sp-3);
}
.q-title {
  margin: 0;
  font-size: var(--q-fs-xl);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--q-text);
  line-height: 1.2;
}
.q-subtitle { color: var(--q-text-muted); font-size: var(--q-fs-sm); margin-top: 3px; }
.q-quick-meta {
  display: flex; gap: var(--q-sp-3); align-items: center; flex-wrap: wrap;
  font-size: var(--q-fs-sm); color: var(--q-text-muted);
}
.q-quick-meta strong { color: var(--q-text); font-weight: 700; }
.q-positive { color: var(--q-positive); font-weight: 600; }
.q-negative { color: var(--q-negative); font-weight: 600; }

/* Tab nav */
.q-tabs {
  display: flex;
  gap: 20px;
  border-bottom: 1px solid var(--q-border);
  margin: 0 calc(-1 * var(--q-sp-5));
  padding: 0 var(--q-sp-5);
  overflow-x: auto;
}
.q-tabs a {
  padding: var(--q-sp-3) 0;
  font-size: var(--q-fs-base);
  font-weight: 600;
  color: var(--q-text-muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  text-decoration: none;
  transition: color .15s, border-color .15s;
}
.q-tabs a:hover { color: var(--q-text); }
.q-tabs a.active {
  color: var(--q-accent);
  border-bottom-color: var(--q-accent);
}

/* Subtabs */
.q-subtabs {
  display: flex; gap: var(--q-sp-4);
  padding: var(--q-sp-2) var(--q-sp-5);
  background: var(--q-surface);
  border-bottom: 1px solid var(--q-border);
  font-size: var(--q-fs-sm);
}
.q-subtabs a {
  color: var(--q-text-muted);
  text-decoration: none;
  font-weight: 500;
}
.q-subtabs a.active { color: var(--q-accent); font-weight: 700; }

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.q-main { padding: var(--q-sp-4) var(--q-sp-5) var(--q-sp-6); }

.q-section-title {
  font-size: var(--q-fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--q-text-muted);
  margin: 0 0 var(--q-sp-2);
}
.q-h2 {
  font-size: var(--q-fs-md); font-weight: 700; margin: 0 0 var(--q-sp-2);
  color: var(--q-text);
}

/* ============================================================
   PANELS / CARDS
   ============================================================ */
.q-panel {
  background: var(--q-surface);
  border: 1px solid var(--q-border);
  border-radius: var(--q-radius-lg);
  margin-bottom: var(--q-sp-4);
  overflow: hidden;
  box-shadow: var(--q-shadow-sm);
}
.q-panel-h {
  background: linear-gradient(180deg, #fbfcfc 0%, #f7f9f8 100%);
  border-bottom: 1px solid var(--q-border);
  padding: var(--q-sp-2) var(--q-sp-3);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--q-sp-3);
  flex-wrap: wrap;
  border-radius: var(--q-radius-lg) var(--q-radius-lg) 0 0;
}
.q-panel-h h3 {
  margin: 0;
  font-size: var(--q-fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--q-text);
  display: flex;
  align-items: center;
  gap: var(--q-sp-2);
}
/* Accent dot before every panel heading */
.q-panel-h h3::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--q-accent);
  flex-shrink: 0;
}
.q-panel-h .q-panel-meta { color: var(--q-text-faint); font-size: var(--q-fs-xs); }
.q-panel-body { padding: var(--q-sp-3); }
.q-panel-body.is-flush { padding: 0; }

/* ============================================================
   STATS GRID (top-of-dashboard headline cards)
   ============================================================ */
.q-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: var(--q-sp-3);
  margin-bottom: var(--q-sp-3);
}
.q-stat {
  background: var(--q-surface);
  border: 1px solid var(--q-border);
  border-radius: var(--q-radius-lg);
  /* φ-derived pad: 11px top/bottom (--sp-3), 13px sides (between sp-3 and sp-4) */
  padding: var(--q-sp-3) 13px var(--q-sp-3);
  position: relative;
  overflow: hidden;
  box-shadow: var(--q-shadow-sm);
  transition: box-shadow .16s ease, transform .16s ease, border-color .16s ease;
}
/* Left accent bar — the φ relationship: bar width 3px : card ≈1:40 */
.q-stat::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--q-border-strong);
  transition: background .16s;
}
.q-stat:hover {
  box-shadow: var(--q-shadow-md);
  transform: translateY(-1px);
  border-color: var(--q-accent-muted);
}
.q-stat:hover::before { background: var(--q-accent); }

/* Label: --q-fs-xs (10.5px). Value: --q-fs-lg (19px). Ratio ≈ 1:1.81, close to φ. */
.q-stat .q-stat-label {
  font-size: var(--q-fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--q-text-faint);
  font-weight: 700;
  line-height: 1.3;
}
.q-stat .q-stat-value {
  font-family: var(--q-mono);
  font-size: var(--q-fs-lg);
  font-weight: 800;
  color: var(--q-text);
  margin-top: var(--q-sp-1);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.q-stat .q-stat-sub {
  font-size: var(--q-fs-xs);
  color: var(--q-text-faint);
  margin-top: var(--q-sp-1);
  line-height: 1.3;
}
/* Positive stat card */
.q-stat.is-positive {
  background: linear-gradient(160deg, #f0f8f3 0%, #ffffff 60%);
  border-color: #c8e4d4;
}
.q-stat.is-positive::before { background: var(--q-positive); }
.q-stat.is-positive .q-stat-value { color: var(--q-positive); }
/* Negative stat card */
.q-stat.is-negative {
  background: linear-gradient(160deg, #fdf1f0 0%, #ffffff 60%);
  border-color: #f0c8c4;
}
.q-stat.is-negative::before { background: var(--q-negative); }
.q-stat.is-negative .q-stat-value { color: var(--q-negative); }

/* ============================================================
   KEY-VALUE TABLES (YCharts Key Stats look)
   ============================================================ */
.q-kv-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.q-kv-table tr { border-bottom: 1px solid var(--q-border); }
.q-kv-table tr:last-child { border-bottom: 0; }
/* Compact row: 7px vertical (--sp-2), 14px horizontal */
.q-kv-table td {
  padding: var(--q-sp-2) 14px;
  font-size: var(--q-fs-base);
  line-height: 1.35;
}
.q-kv-table td.q-kv-label {
  color: var(--q-link);
  width: 60%;
  cursor: default;
  text-decoration: underline dotted #c1c8d3;
}
.q-kv-table td.q-kv-value {
  text-align: right;
  font-family: var(--q-mono);
  color: var(--q-text);
  font-weight: 500;
  white-space: nowrap;
}
.q-kv-table.is-input td.q-kv-value input,
.q-kv-table.is-input td.q-kv-value select {
  width: 100%;
  text-align: right;
  font-family: var(--q-mono);
  border: 1px solid transparent;
  background: transparent;
  padding: var(--q-sp-1) var(--q-sp-2);
  font-size: var(--q-fs-base);
  border-radius: var(--q-sp-1);
}
.q-kv-table.is-input td.q-kv-value input:hover,
.q-kv-table.is-input td.q-kv-value select:hover {
  border-color: var(--q-border); background: #fff;
}
.q-kv-table.is-input td.q-kv-value input:focus,
.q-kv-table.is-input td.q-kv-value select:focus {
  border-color: var(--q-focus);
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(138, 98, 6, 0.18);
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.q-filter-bar {
  background: var(--q-surface);
  border: 1px solid var(--q-border);
  border-radius: var(--q-radius-lg);
  margin-bottom: var(--q-sp-3);
  box-shadow: var(--q-shadow-sm);
}
.q-filter-h {
  padding: var(--q-sp-2) var(--q-sp-3);
  display: flex; align-items: center; gap: var(--q-sp-3);
  flex-wrap: wrap;   /* Reset All / search wrap on phones instead of widening the page */
  border-bottom: 1px solid var(--q-border);
  background: var(--q-surface-alt);
  border-radius: var(--q-radius-lg) var(--q-radius-lg) 0 0;
}
.q-filter-h .q-chev {
  cursor: pointer;
  color: var(--q-text-muted);
  font-size: var(--q-fs-sm);
}
.q-filter-h h4 {
  margin: 0;
  font-size: var(--q-fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.q-filter-h .q-pill-btn {
  padding: var(--q-sp-1) var(--q-sp-3);
  border-radius: 12px;
  font-size: var(--q-fs-sm);
  font-weight: 600;
  background: var(--q-surface);
  border: 1px solid var(--q-border-strong);
  color: var(--q-text);
  cursor: pointer;
  transition: background .12s;
}
.q-filter-h .q-pill-btn:hover { background: var(--q-accent-soft); border-color: var(--q-accent); color: var(--q-accent); }
.q-filter-rows { padding: 0 var(--q-sp-3); }
.q-filter-row {
  display: flex; gap: var(--q-sp-3); align-items: center;
  padding: var(--q-sp-2) 0;
  border-bottom: 1px dashed var(--q-border);
  font-size: var(--q-fs-base);
}
.q-filter-row:last-child { border-bottom: 0; }
.q-filter-row .q-fr-label { flex: 1; color: var(--q-text); }
.q-filter-row .q-fr-count { color: var(--q-text-muted); font-size: var(--q-fs-sm); }
.q-filter-row .q-fr-x {
  color: var(--q-text-faint);
  cursor: pointer;
  width: 18px; text-align: center;
}
.q-filter-row .q-fr-x:hover { color: var(--q-negative); }

.q-rating-row {
  display: flex;
  gap: var(--q-sp-4);
  align-items: center;
  padding: var(--q-sp-2) var(--q-sp-3);
  font-size: var(--q-fs-sm);
  color: var(--q-text-muted);
  background: var(--q-surface-alt);
  border-top: 1px solid var(--q-border);
  flex-wrap: wrap;
}
.q-rating-row label {
  display: inline-flex;
  align-items: center;
  gap: var(--q-sp-2);
  cursor: pointer;
  font-weight: 600;
}
.q-rating-row .q-rating-attractive { color: var(--q-attractive); }
.q-rating-row .q-rating-neutral    { color: var(--q-neutral); }
.q-rating-row .q-rating-avoid      { color: var(--q-avoid); }
.q-rating-row .q-rating-unrated    { color: var(--q-unrated); }

/* ============================================================
   BUTTONS
   ============================================================ */
.q-btn {
  display: inline-flex; align-items: center; gap: var(--q-sp-2);
  border: 1px solid var(--q-border-strong);
  background: var(--q-surface);
  color: var(--q-text);
  padding: var(--q-sp-2) var(--q-sp-3);
  font-size: var(--q-fs-sm);
  font-weight: 600;
  border-radius: var(--q-radius);
  cursor: pointer;
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: background .14s ease, border-color .14s ease, color .14s ease, box-shadow .14s ease;
}
.q-btn:hover {
  background: var(--q-accent-soft);
  border-color: var(--q-accent);
  color: var(--q-accent);
  text-decoration: none;
}
.q-btn.is-primary {
  background: var(--q-accent);
  color: #fff;
  border-color: var(--q-accent);
  box-shadow: 0 1px 3px rgba(31, 122, 77, .25);
}
.q-btn.is-primary:hover {
  background: #176038;
  border-color: #176038;
  color: #fff;
  box-shadow: 0 2px 6px rgba(31, 122, 77, .3);
}
.q-btn.is-ghost { border-color: transparent; background: transparent; color: var(--q-link); }
.q-btn.is-ghost:hover { background: rgba(31, 95, 179, 0.08); border-color: transparent; }
.q-btn.is-danger { color: var(--q-negative); border-color: #f0c8c4; background: #fdf3f2; }
.q-btn.is-danger:hover { background: #fbe4e1; border-color: var(--q-negative); }
.q-btn-row { display: flex; gap: var(--q-sp-2); flex-wrap: wrap; align-items: center; }

/* ============================================================
   DATA TABLE (YCharts results table)
   ============================================================ */
.q-table-wrap {
  overflow-x: auto;
  background: var(--q-surface);
  border: 1px solid var(--q-border);
  border-radius: var(--q-radius-lg);
  box-shadow: var(--q-shadow-sm);
}
.q-table-h {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--q-sp-2) var(--q-sp-3);
  border-bottom: 1px solid var(--q-border);
  background: var(--q-surface-alt);
  flex-wrap: wrap;
  gap: var(--q-sp-2);
  border-radius: var(--q-radius-lg) var(--q-radius-lg) 0 0;
}
.q-table-h h4 {
  margin: 0; font-size: var(--q-fs-base); font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.q-table-h .q-table-meta { color: var(--q-text-muted); font-size: var(--q-fs-sm); }
.q-table-h .q-pager { display: flex; align-items: center; gap: var(--q-sp-1); font-size: var(--q-fs-sm); }
.q-table-h .q-pager button {
  background: transparent; border: 0; color: var(--q-text-muted);
  font-size: var(--q-fs-sm); padding: 2px var(--q-sp-2); cursor: pointer; font-weight: 700;
}
.q-table-h .q-pager button.is-active { color: var(--q-link); }
.q-table-h .q-pager button:disabled { color: var(--q-text-faint); cursor: not-allowed; }

table.q-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--q-fs-base);
  font-variant-numeric: tabular-nums; /* aligns figure columns */
}
table.q-table thead th {
  position: sticky; top: 0;
  background: var(--q-surface-alt);
  text-align: right;
  font-size: var(--q-fs-xs);
  font-weight: 700;
  text-transform: none;
  color: var(--q-text-muted);
  letter-spacing: 0;
  padding: var(--q-sp-2) var(--q-sp-3);
  border-bottom: 1px solid var(--q-border);
  white-space: normal;
  vertical-align: bottom;
  line-height: 1.25;
}
table.q-table thead th:first-child,
table.q-table thead th.q-th-left { text-align: left; }
table.q-table thead th.q-sortable { cursor: pointer; user-select: none; }
table.q-table thead th.q-sortable:hover { color: var(--q-text); }
table.q-table thead th.q-sorted { color: var(--q-link); }

table.q-table tbody td {
  padding: var(--q-sp-2) var(--q-sp-3);
  border-bottom: 1px solid var(--q-border);
  font-family: var(--q-mono);
  text-align: right;
  white-space: nowrap;
  color: var(--q-text);
}
table.q-table tbody td:first-child,
table.q-table tbody td.q-td-left {
  text-align: left;
  font-family: var(--q-font);
}
table.q-table tbody tr:nth-child(even) td { background: var(--q-row-stripe); }
table.q-table tbody tr:hover td { background: var(--q-row-hover); cursor: pointer; }
table.q-table tbody tr.is-selected td { background: #e4eef9; }
table.q-table .q-symbol {
  color: var(--q-link);
  font-weight: 700;
}

/* ============================================================
   FORM CONTROLS
   ============================================================ */
input[type="text"], input[type="number"], input[type="search"], input[type="email"],
select, textarea {
  font-family: var(--q-font);
  font-size: var(--q-fs-base);
  padding: var(--q-sp-2) var(--q-sp-3);
  border: 1px solid var(--q-border-strong);
  border-radius: var(--q-radius);
  background: var(--q-surface);
  color: var(--q-text);
  transition: border-color .14s, box-shadow .14s;
}
input[type="text"]:focus, input[type="number"]:focus, input[type="search"]:focus,
select:focus, textarea:focus {
  outline: none;
  border-color: var(--q-focus);
  box-shadow: 0 0 0 2px rgba(138, 98, 6, 0.18);
}
.q-field {
  display: flex; flex-direction: column; gap: var(--q-sp-1); margin-bottom: var(--q-sp-3);
}
.q-field label {
  font-size: var(--q-fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--q-text-muted);
}
.q-field input, .q-field select, .q-field textarea { width: 100%; }
.q-field-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--q-sp-3); }

/* ============================================================
   THREE COLUMN DETAIL LAYOUT
   ============================================================ */
.q-cols {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--q-sp-4);
}
@media (max-width: 1100px) { .q-cols { grid-template-columns: 1fr; } }

/* ============================================================
   PHOTO STRIP
   ============================================================ */
.q-photos {
  display: flex; gap: var(--q-sp-2); flex-wrap: wrap;
  padding: var(--q-sp-3) 14px;
  border-top: 1px solid var(--q-border);
}
.q-photo {
  width: 96px; height: 72px;
  border-radius: var(--q-sp-1);
  background: #eef0f3 50% 50% / cover no-repeat;
  border: 1px solid var(--q-border);
  position: relative;
}
.q-photo .q-photo-x {
  position: absolute; top: 2px; right: 2px;
  background: rgba(0,0,0,0.55);
  color: #fff; font-size: 10px;
  border-radius: 2px;
  padding: 1px var(--q-sp-1);
  cursor: pointer;
  display: none;
}
.q-photo:hover .q-photo-x { display: block; }
.q-photo-add {
  width: 96px; height: 72px;
  border-radius: var(--q-sp-1);
  border: 1px dashed var(--q-border-strong);
  display: grid; place-items: center;
  font-size: var(--q-fs-sm); font-weight: 700;
  color: var(--q-text-muted);
  cursor: pointer;
  transition: border-color .14s, color .14s;
}
.q-photo-add:hover { border-color: var(--q-link); color: var(--q-link); }

/* ============================================================
   APPLY-INCREASE INLINE TOOL
   ============================================================ */
.q-apply-tool {
  background: #fff8e1;
  border: 1px solid #f1d97a;
  border-radius: var(--q-radius);
  padding: var(--q-sp-3);
  margin-top: var(--q-sp-3);
  font-size: var(--q-fs-base);
}
.q-apply-tool h5 {
  margin: 0 0 var(--q-sp-2);
  font-size: var(--q-fs-xs);
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0.07em;
  color: #6b5400;
}
.q-apply-tool .q-apply-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: var(--q-sp-2); margin-bottom: var(--q-sp-2);
}

/* ============================================================
   STATEMENT (printable)
   ============================================================ */
.q-statement {
  background: #fff;
  border: 1px solid var(--q-border);
  border-radius: var(--q-radius);
  padding: 28px;
  max-width: 720px;
  margin: 0 auto var(--q-sp-4);
  box-shadow: var(--q-shadow-md);
  font-size: var(--q-fs-base);
}
.q-statement h2 {
  margin: 0 0 var(--q-sp-1); font-size: 18px; letter-spacing: 0.02em; text-transform: uppercase;
}
.q-statement .q-statement-meta {
  display: flex; justify-content: space-between; gap: var(--q-sp-3);
  border-bottom: 2px solid #000; padding-bottom: var(--q-sp-2); margin-bottom: var(--q-sp-4);
}
.q-statement table { width: 100%; border-collapse: collapse; margin: var(--q-sp-3) 0; }
.q-statement table th, .q-statement table td {
  border-bottom: 1px solid var(--q-border);
  padding: var(--q-sp-2) var(--q-sp-2); text-align: left; font-size: var(--q-fs-base);
}
.q-statement table td.q-amt { text-align: right; font-family: var(--q-mono); }
.q-statement .q-payment-stub {
  border: 2px dashed #888;
  padding: 14px;
  margin-top: 18px;
  font-size: var(--q-fs-sm);
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--q-sp-2);
}

@media print {
  .q-topbar, .q-tabs, .q-subtabs, .q-page-header .q-quick-meta,
  .q-btn, .q-btn-row, .q-no-print { display: none !important; }
  body { background: #fff; }
  .q-main { padding: 0; }
  .q-statement {
    box-shadow: none; border: 0; max-width: 100%; margin: 0;
    padding: 14px; page-break-after: always;
  }
  .q-statement:last-child { page-break-after: auto; }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.q-flex { display: flex; gap: var(--q-sp-2); align-items: center; }
.q-flex-between { display: flex; justify-content: space-between; align-items: center; gap: var(--q-sp-3); flex-wrap: wrap; }
.q-mr-auto { margin-right: auto; }
.q-mt-2 { margin-top: var(--q-sp-2); }
.q-mt-3 { margin-top: var(--q-sp-3); }
.q-mb-2 { margin-bottom: var(--q-sp-2); }
.q-mb-3 { margin-bottom: var(--q-sp-3); }
.q-w-full { width: 100%; }
.q-tag {
  display: inline-block;
  padding: 1px var(--q-sp-2);
  font-size: var(--q-fs-xs);
  font-weight: 700;
  border-radius: 10px;
  background: #eef0f3;
  color: var(--q-text-muted);
}
.q-tag.is-positive { background: #dff0e7; color: var(--q-positive); }
.q-tag.is-negative { background: #fbe4e1; color: var(--q-negative); }
.q-tag.is-warning  { background: #fdf0d4; color: var(--q-warning); }
.q-divider { height: 1px; background: var(--q-border); margin: var(--q-sp-3) 0; }
.q-empty {
  padding: var(--q-sp-5) var(--q-sp-3);
  text-align: center;
  color: var(--q-text-muted);
  font-size: var(--q-fs-base);
}

/* ============================================================
   MODAL
   ============================================================ */
.q-modal-bg {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none; align-items: center; justify-content: center;
  z-index: 1000;
}
.q-modal-bg.is-open { display: flex; }
.q-modal {
  background: #fff;
  border-radius: var(--q-radius-lg);
  width: min(560px, 92vw);
  box-shadow: var(--q-shadow-lg);
  overflow: hidden;
}
.q-modal-h {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--q-sp-3) var(--q-sp-4);
  border-bottom: 1px solid var(--q-border);
  background: var(--q-surface-alt);
}
.q-modal-h h3 { margin: 0; font-size: var(--q-fs-md); font-weight: 800; }
.q-modal-h .q-x {
  cursor: pointer; color: var(--q-text-muted); font-size: 20px; line-height: 1;
  transition: color .14s;
}
.q-modal-h .q-x:hover { color: var(--q-negative); }
.q-modal-body { padding: var(--q-sp-4); max-height: 70vh; overflow-y: auto; }
.q-modal-footer {
  display: flex; justify-content: flex-end; gap: var(--q-sp-2);
  padding: var(--q-sp-3) var(--q-sp-4);
  border-top: 1px solid var(--q-border);
  background: var(--q-surface-alt);
}

/* ============================================================
   TOASTS
   ============================================================ */
.q-toast-wrap {
  position: fixed; right: var(--q-sp-4); bottom: var(--q-sp-4); z-index: 9999;
  display: flex; flex-direction: column; gap: var(--q-sp-2);
  max-width: 360px;
}
.q-toast {
  background: #fff; border: 1px solid var(--q-border);
  border-left: 4px solid var(--q-link);
  border-radius: var(--q-radius);
  padding: var(--q-sp-2) var(--q-sp-3);
  box-shadow: var(--q-shadow-md);
  font-size: var(--q-fs-base);
  animation: q-toast-in .18s ease-out;
}
.q-toast.is-success { border-left-color: var(--q-positive); }
.q-toast.is-error   { border-left-color: var(--q-negative); }
.q-toast .q-toast-title { font-weight: 800; margin-bottom: 2px; }
.q-toast .q-toast-msg  { color: var(--q-text-muted); }
@keyframes q-toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   PROVENANCE BADGES + POPOVER
   ============================================================ */
.q-prov {
  display: inline-flex;
  align-items: center;
  margin-left: var(--q-sp-2);
  padding: 0 5px;
  height: 15px;
  border-radius: 3px;
  font-family: var(--q-mono);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 15px;
  vertical-align: middle;
  cursor: help;
  border: 1px solid transparent;
  user-select: none;
  white-space: nowrap;
  transition: filter 120ms ease, transform 120ms ease;
}
.q-prov:hover, .q-prov:focus { filter: brightness(1.08); transform: translateY(-1px); }
.q-prov[data-kind="pdf"]     { background: #fef0d6; color: #8a5400; border-color: #f3d8a3; }
.q-prov[data-kind="vgsi"]    { background: #ece4fb; color: #5a2fbc; border-color: #d3c5f3; }
.q-prov[data-kind="derived"] { background: #eef0f3; color: #4a5360; border-color: #d6dae0; }
.q-prov[data-kind="user"]    { background: #def5e3; color: #176b2c; border-color: #b8e6c3; }
.q-prov[data-kind="cfg"]     { background: #dceaff; color: #18437f; border-color: #b6cdf2; }
.q-prov[data-kind="unknown"] { background: #fbe2e2; color: #8a1f1f; border-color: #f0b5b5; }

/* Provenance chips are retired for official-data towns; belt-and-suspenders hide. */
.q-prov, .q-prov-pop { display: none !important; }

.q-prov-pop {
  position: absolute;
  z-index: 1000;
  min-width: 260px; max-width: 360px;
  background: #ffffff;
  border: 1px solid var(--q-border-strong);
  border-radius: var(--q-radius-lg);
  box-shadow: var(--q-shadow-lg);
  padding: var(--q-sp-3) 14px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--q-text);
  pointer-events: auto;
}
.q-prov-pop .q-prov-pop-h {
  display: flex; align-items: center; gap: var(--q-sp-2);
  font-weight: 800; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--q-text-muted);
  margin-bottom: var(--q-sp-2);
}
.q-prov-pop .q-prov-pop-doc   { font-weight: 700; color: var(--q-text); margin-bottom: var(--q-sp-1); }
.q-prov-pop .q-prov-pop-formula {
  background: var(--q-surface-alt); border: 1px solid var(--q-border);
  border-radius: var(--q-radius); padding: var(--q-sp-2) var(--q-sp-2);
  font-family: var(--q-mono); font-size: 11.5px;
  margin: var(--q-sp-2) 0; color: var(--q-text);
  white-space: pre-wrap; word-break: break-word;
}
.q-prov-pop .q-prov-pop-note { color: var(--q-text-muted); font-size: 11.5px; margin-top: var(--q-sp-1); }
.q-prov-pop .q-prov-pop-link {
  display: inline-block; margin-top: var(--q-sp-2); font-size: 11.5px;
  font-weight: 700; color: var(--q-link);
}
.q-prov-pop .q-prov-pop-link:hover { color: var(--q-link-hover); text-decoration: underline; }
.q-prov-pop .q-prov-pop-meta {
  margin-top: var(--q-sp-2); padding-top: var(--q-sp-2);
  border-top: 1px solid var(--q-border);
  font-size: 11px; color: var(--q-text-faint);
}

/* ============================================================
   SECTION ACCENT PALETTE
   Each major dashboard section gets its own hue — applied as a
   3 px left border on .q-panel-h, a matching dot (h3::before),
   and a feather-light tint behind the header band.
   All values are CSS custom properties so tweaks stay in one spot.
   ============================================================ */

:root {
  /* Muted categorical set — one per section */
  --q-sec-budget:      #4f6bbd;   /* indigo      — Budget */
  --q-sec-budget-bg:   #f0f3fb;
  --q-sec-commit:      #1a7f7a;   /* teal        — Commitment */
  --q-sec-commit-bg:   #edf7f7;
  --q-sec-coll:        #b06a00;   /* amber       — Collections */
  --q-sec-coll-bg:     #fdf5e6;
  --q-sec-cert:        #7052a3;   /* violet      — Certificate of Assessment */
  --q-sec-cert-bg:     #f4f0fa;
  --q-sec-rec:         #a0394d;   /* rose        — Taxes Receivable */
  --q-sec-rec-bg:      #fdf0f2;
  --q-sec-tif:         #3a6b8a;   /* steel-blue  — TIF */
  --q-sec-tif-bg:      #eef4f8;
  --q-sec-orphans:     #5c6b42;   /* olive-slate — Orphans (no geometry) */
  --q-sec-orphans-bg:  #f3f5ee;
  --q-sec-block:       #2c6e49;   /* forest      — By Block */
  --q-sec-block-bg:    #edf6f1;
}

/* ---- Budget (1st panel in .q-cols) ---- */
.q-cols > .q-panel:nth-of-type(1) > .q-panel-h {
  background: linear-gradient(180deg, var(--q-sec-budget-bg) 0%, #f8f9fd 100%);
  border-left: 3px solid var(--q-sec-budget);
}
.q-cols > .q-panel:nth-of-type(1) > .q-panel-h h3::before {
  background: var(--q-sec-budget);
}

/* ---- Commitment (2nd panel in .q-cols) ---- */
.q-cols > .q-panel:nth-of-type(2) > .q-panel-h {
  background: linear-gradient(180deg, var(--q-sec-commit-bg) 0%, #f7fafb 100%);
  border-left: 3px solid var(--q-sec-commit);
}
.q-cols > .q-panel:nth-of-type(2) > .q-panel-h h3::before {
  background: var(--q-sec-commit);
}

/* ---- Collections (3rd panel in .q-cols) ---- */
.q-cols > .q-panel:nth-of-type(3) > .q-panel-h {
  background: linear-gradient(180deg, var(--q-sec-coll-bg) 0%, #fdfaf5 100%);
  border-left: 3px solid var(--q-sec-coll);
}
.q-cols > .q-panel:nth-of-type(3) > .q-panel-h h3::before {
  background: var(--q-sec-coll);
}

/* ---- Certificate of Assessment ---- */
#cert-panel > .q-panel-h {
  background: linear-gradient(180deg, var(--q-sec-cert-bg) 0%, #f9f7fd 100%);
  border-left: 3px solid var(--q-sec-cert);
}
#cert-panel > .q-panel-h h3::before {
  background: var(--q-sec-cert);
}

/* ---- Taxes Receivable & Uncollected ---- */
#receivable-panel > .q-panel-h {
  background: linear-gradient(180deg, var(--q-sec-rec-bg) 0%, #fdf9fa 100%);
  border-left: 3px solid var(--q-sec-rec);
}
#receivable-panel > .q-panel-h h3::before {
  background: var(--q-sec-rec);
}

/* ---- TIF Calculator ---- */
#tif-panel > .q-panel-h {
  background: linear-gradient(180deg, var(--q-sec-tif-bg) 0%, #f6fafd 100%);
  border-left: 3px solid var(--q-sec-tif);
}
#tif-panel > .q-panel-h h3::before {
  background: var(--q-sec-tif);
}

/* ---- Orphans (parcels without geometry) ---- */
#orphans-panel > .q-panel-h {
  background: linear-gradient(180deg, var(--q-sec-orphans-bg) 0%, #f8f9f6 100%);
  border-left: 3px solid var(--q-sec-orphans);
}
#orphans-panel > .q-panel-h h3::before {
  background: var(--q-sec-orphans);
}

/* ---- By Block ---- */
#by-block > .q-panel-h {
  background: linear-gradient(180deg, var(--q-sec-block-bg) 0%, #f7fbf8 100%);
  border-left: 3px solid var(--q-sec-block);
}
#by-block > .q-panel-h h3::before {
  background: var(--q-sec-block);
}

/* Compensate the left border so the panel header still aligns with the
   existing border-radius on the top-left corner. The .q-panel's own
   border-radius clips the top-left neatly; no layout shift occurs. */
.q-cols > .q-panel:nth-of-type(1) > .q-panel-h,
.q-cols > .q-panel:nth-of-type(2) > .q-panel-h,
.q-cols > .q-panel:nth-of-type(3) > .q-panel-h,
#cert-panel      > .q-panel-h,
#receivable-panel > .q-panel-h,
#tif-panel       > .q-panel-h,
#orphans-panel   > .q-panel-h,
#by-block        > .q-panel-h {
  /* The 3 px left border is inside the existing 1 px panel border; nudge
     padding-left down by 3 px to keep text flush with the non-accented state. */
  padding-left: calc(var(--q-sp-3) - 3px);
}

/* ============================================================
   MILL-RATE RECONCILIATION BLOCK
   ============================================================ */
.q-mill-recon {
  margin-top: var(--q-sp-2);
  margin-bottom: var(--q-sp-3);
  padding: var(--q-sp-2) var(--q-sp-3);
  background: var(--ms-gold-dim, #fffbf0);
  border: 1px solid rgba(201, 169, 98, 0.4);
  border-left: 3px solid var(--q-nav-accent);
  border-radius: var(--q-radius);
  font-size: var(--q-fs-sm);
}
.q-mill-recon h5 {
  margin: 0 0 var(--q-sp-2); font-size: var(--q-fs-xs); font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--ms-warn, #8a5400);
}
.q-mill-recon table { width: 100%; border-collapse: collapse; }
.q-mill-recon td {
  padding: 3px var(--q-sp-2); vertical-align: top;
  border-bottom: 1px solid rgba(201, 169, 98, 0.18);
}
.q-mill-recon tr:last-child td { border-bottom: 0; }
.q-mill-recon .q-mill-recon-rate {
  font-family: var(--q-mono); font-weight: 800;
  text-align: right; width: 60px;
}

/* ============================================================
   OFFICIAL MAINE TAX BILL  (.q-bill)
   ============================================================ */
.q-bill {
  background: #fff; border: 1px solid var(--bill-line);
  border-radius: var(--q-radius-lg);
  box-shadow: var(--q-shadow-md);
  padding: 20px 22px; margin: 0 0 var(--q-sp-4);
  max-width: 860px; color: var(--bill-ink);
  font-size: 11px; line-height: 1.34;
}
/* Top band: left column + billing table */
.q-bill-top { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
.q-bill-left { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.q-bill-head { display: grid; grid-template-columns: 60px 1fr; gap: 12px; align-items: center; }
.q-seal { width: 60px; height: 60px; }
.q-seal-svg, .q-seal-img { width: 60px; height: 60px; display: block; }
.q-seal-img { object-fit: contain; }
.q-bill-town { text-align: center; }
.q-bill-town-name { font-weight: 800; font-size: 14px; letter-spacing: .02em; color: var(--bill-green); }
.q-bill-town div { font-size: 10.5px; }
.q-bill-web { color: var(--q-link); font-size: 10px; }
.q-bill-only { margin-top: 5px; font-weight: 800; font-size: 11px; letter-spacing: .02em; }
.q-bill-info { border: 1.5px solid var(--bill-green); border-radius: 8px; overflow: hidden; }
.q-bill-info-title { background: var(--bill-green); color: #fff; font-weight: 800; text-align: center; padding: 5px 8px; font-size: 11px; letter-spacing: .02em; }
.q-bill-info-sub { background: #eef2ec; color: var(--bill-green); font-weight: 700; text-align: center; padding: 3px 8px; font-size: 9.5px; letter-spacing: .05em; border-bottom: 1px solid var(--bill-line); }
.q-bill-info-tbl { width: 100%; border-collapse: collapse; }
.q-bill-info-tbl td { padding: 2px 9px; font-size: 10px; }
.q-bill-info-tbl td:first-child { color: #46514a; letter-spacing: .02em; }
.q-bill-info-tbl td.q-amt { text-align: right; font-family: var(--q-mono); }
.q-bill-info-tbl tr.has-rule td { border-bottom: 1px solid var(--bill-line); }
.q-bill-info-tbl tr.is-strong td { background: #f3f6f1; font-weight: 800; font-size: 11px; border-top: 2px solid var(--bill-green); }

.q-bill-parties { display: grid; grid-template-columns: 1.25fr 1fr 132px; gap: 14px; align-items: start; }
.q-bill-mailto { line-height: 1.42; }
.q-bill-mailto-h { font-size: 9px; font-weight: 800; letter-spacing: .06em; color: var(--q-text-faint); text-transform: uppercase; margin-bottom: 2px; }
.q-bill-acct-tbl { width: 100%; border-collapse: collapse; }
.q-bill-acct-tbl td { padding: 1.5px 7px; font-size: 9.5px; border-bottom: 1px solid #edefe9; }
.q-bill-acct-tbl td:first-child { color: #46514a; font-weight: 600; letter-spacing: .02em; width: 38%; }
.q-bill-acct-tbl td:last-child { font-family: var(--q-mono); }
.q-bill-acct-tbl tr.is-strong td { font-weight: 800; background: #f3f6f1; border-bottom: 0; }
.q-bill-shape { border: 1px solid var(--bill-line); border-radius: 8px; padding: 6px; background: #fcfdfb; }
.q-bill-shape svg { display: block; width: 100%; height: auto; }

.q-bill-notice { margin-top: 14px; border: 1px solid var(--bill-line); border-radius: 8px; padding: 9px 13px; background: var(--bill-cream); }
.q-bill-notice-h { text-align: center; font-weight: 800; letter-spacing: .06em; font-size: 11px; color: var(--bill-green); margin-bottom: 5px; }
.q-bill-notice p { margin: 0 0 5px; font-size: 10px; line-height: 1.4; }
.q-bill-notice p:last-child { margin-bottom: 0; }

.q-bill-prior { margin-top: 12px; border: 1px solid #e4c98f; background: #fdf7e8; border-radius: 8px; padding: 9px 13px; }
.q-bill-prior-h { font-weight: 800; font-size: 10.5px; letter-spacing: .03em; color: #8a5a00; text-transform: uppercase; }
.q-bill-prior-rows { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 5px; font-size: 12px; }
.q-bill-prior-total { margin-left: auto; }

.q-bill-cols { display: grid; grid-template-columns: 1fr 1.25fr; gap: 16px; margin-top: 16px; }
.q-bill-col-h { font-weight: 800; letter-spacing: .05em; font-size: 11px; text-align: center; color: #fff; background: var(--bill-green-soft); padding: 4px; border-radius: 6px 6px 0 0; }
.q-bill-dist, .q-bill-remit { border: 1px solid var(--bill-line); border-radius: 8px; overflow: hidden; }
.q-bill-dist table { width: 100%; border-collapse: collapse; }
.q-bill-dist td { padding: 4px 12px; font-size: 12px; border-bottom: 1px solid #edefe9; }
.q-bill-dist td.q-amt { text-align: right; font-family: var(--q-mono); }
.q-bill-dist tr.is-strong td { font-weight: 800; background: #f3f6f1; border-bottom: 0; }
.q-bill-remit { padding: 0 0 10px; }
.q-bill-remit p { margin: 8px 12px 6px; font-size: 11.5px; }
.q-bill-remit-addr { margin: 0 12px; font-family: var(--q-mono); font-size: 11px; line-height: 1.5; }
.q-bill-remit-contact { margin: 6px 12px 0; font-size: 11.5px; font-weight: 600; }
.q-bill-pay { font-size: 10.5px !important; color: var(--q-text-muted); border-top: 1px dashed var(--bill-line); padding-top: 6px; }

.q-bill-stub { display: grid; grid-template-columns: 1fr 300px; gap: 16px; margin-top: 16px; border-top: 2px dashed var(--bill-rule); padding-top: 12px; }
.q-bill-stub-l div { font-size: 11px; line-height: 1.45; }
.q-bill-stub-title { font-weight: 800 !important; font-size: 12px !important; letter-spacing: .02em; }
.q-bill-stub-remit { margin-top: 6px; color: var(--q-text-muted); }
.q-bill-stub-banner { background: var(--bill-green); color: #fff; font-weight: 800; text-align: center; padding: 4px; border-radius: 6px; font-size: 11px; letter-spacing: .03em; }
.q-bill-stub-tbl { width: 100%; border-collapse: collapse; margin-top: 6px; }
.q-bill-stub-tbl th { font-size: 9.5px; letter-spacing: .04em; color: #46514a; border-bottom: 1px solid var(--bill-line); padding: 3px 6px; }
.q-bill-stub-tbl td { font-family: var(--q-mono); font-size: 11px; text-align: center; padding: 5px 6px; border-bottom: 1px solid var(--bill-line); }
.q-bill-stub-foot { text-align: center; font-size: 9.5px; letter-spacing: .04em; color: var(--q-text-muted); margin-top: 6px; }

/* ============================================================
   PRINT — compress tax bill to one Letter page
   ============================================================ */
@media print {
  @page { size: letter portrait; margin: 0.32in; }
  html, body { background: #fff; }
  .q-main { padding: 0; }

  .q-bill {
    font-size: 9px; line-height: 1.2; color: #111;
    border: none; box-shadow: none; border-radius: 0;
    padding: 0; margin: 0; max-width: 100%;
    page-break-after: always; break-after: page; break-inside: avoid;
  }
  .q-bill:last-child { page-break-after: auto; break-after: auto; }
  .q-bill-top, .q-bill-parties, .q-bill-notice, .q-bill-cols, .q-bill-stub, .q-bill-prior { break-inside: avoid; }
  .q-bill-notice, .q-bill-cols, .q-bill-prior { margin-top: 7px; }
  .q-bill-stub { margin-top: 7px; padding-top: 7px; }

  .q-bill-top { grid-template-columns: 1fr 250px; gap: 12px; }
  .q-bill-left { gap: 7px; }
  .q-bill-head { grid-template-columns: 50px 1fr; gap: 8px; }
  .q-seal, .q-seal-svg, .q-seal-img { width: 50px; height: 50px; }
  .q-bill-town-name { font-size: 11.5px; }
  .q-bill-town div { font-size: 8.6px; }
  .q-bill-web { font-size: 8.4px; }
  .q-bill-only { margin-top: 3px; font-size: 9.5px; }
  .q-bill-info-title { font-size: 10px; padding: 3px; }
  .q-bill-info-sub { font-size: 8px; padding: 2px; }
  .q-bill-info-tbl td { padding: 0.9px 8px; font-size: 8.3px; }
  .q-bill-info-tbl tr.is-strong td { font-size: 9.6px; }

  .q-bill-parties { grid-template-columns: 1.2fr 1fr 116px; gap: 10px; }
  .q-bill-mailto { padding-top: 0; font-size: 9px; }
  .q-bill-mailto-h { font-size: 7.6px; }
  .q-bill-acct-tbl td { padding: 0.7px 7px; font-size: 8.2px; }
  .q-bill-shape { padding: 3px; }
  .q-bill-shape svg { max-height: 80px; }

  .q-bill-notice { padding: 6px 11px; }
  .q-bill-notice-h { font-size: 9.5px; margin-bottom: 3px; }
  .q-bill-notice p { font-size: 7.8px; line-height: 1.18; margin-bottom: 2.4px; }

  .q-bill-prior { padding: 5px 10px; }
  .q-bill-prior-h { font-size: 8px; }
  .q-bill-prior-rows { font-size: 9px; margin-top: 3px; }

  .q-bill-cols { gap: 10px; }
  .q-bill-col-h { font-size: 9px; padding: 3px; }
  .q-bill-dist td { padding: 1.6px 10px; font-size: 9px; }
  .q-bill-remit p { margin: 5px 11px 4px; font-size: 8.8px; }
  .q-bill-remit-addr { font-size: 8.6px; line-height: 1.35; }
  .q-bill-remit-contact { font-size: 8.8px; margin-top: 4px; }
  .q-bill-pay { font-size: 7.8px !important; padding-top: 4px; }

  .q-bill-stub { grid-template-columns: 1fr 270px; gap: 12px; }
  .q-bill-stub-l div { font-size: 8.6px; }
  .q-bill-stub-title { font-size: 9.5px !important; }
  .q-bill-stub-banner { font-size: 9px; padding: 3px; }
  .q-bill-stub-tbl th { font-size: 8px; padding: 2px 6px; }
  .q-bill-stub-tbl td { font-size: 9px; padding: 3px 6px; }
  .q-bill-stub-foot { font-size: 8px; margin-top: 4px; }

  .q-topbar, .q-tabs, .q-subtabs, .q-page-header .q-quick-meta,
  .q-btn, .q-btn-row, .q-no-print { display: none !important; }
  .q-statement { break-inside: avoid; }
}

@media (max-width: 720px) {
  .q-bill-top, .q-bill-parties, .q-bill-cols, .q-bill-stub { grid-template-columns: 1fr; }
  .q-seal { margin: 0 auto; }
}

/* ===== Parties & account↔parcel links (lot detail) ===================== */
/* The parsed ownership model: each party gets a role chip, plus badges for
   the parcel↔account fan-out (multi-account parcels, combined billing). */
.q-parties { margin-top: 10px; }
.q-parties-h {
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--q-text-faint); margin: 4px 0 6px;
}
.q-party-row {
  display: flex; align-items: baseline; gap: 8px;
  padding: 4px 0; border-top: 1px dashed var(--q-border);
  font-size: 13px; color: var(--q-text);
}
.q-party-row:first-of-type { border-top: 0; }
.q-party-name { flex: 1 1 auto; min-width: 0; }
.q-party-interest { color: var(--q-text-faint); font-size: 10.5px; }
.q-role-chip {
  flex: 0 0 auto; font-size: 9.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap;
}
.q-role-chip.is-owner    { background: var(--q-accent-soft); color: var(--q-accent); border-color: var(--q-accent-muted); }
.q-role-chip.is-co_owner { background: #eef4fb; color: var(--q-link); border-color: #d6e4f5; }
.q-role-chip.is-trustee  { background: #f3eefb; color: #6b3fb0; border-color: #e2d6f5; }
.q-role-chip.is-careof   { background: #fbf3e6; color: var(--q-warning); border-color: #f0e0c0; }
.q-link-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.q-link-badge {
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: var(--q-radius);
  border: 1px solid var(--q-border-strong); background: var(--q-surface-alt); color: var(--q-text-muted);
}
.q-link-badge a { color: var(--q-link); text-decoration: none; }
.q-link-badge a:hover { text-decoration: underline; }
.q-link-badge.is-multi    { background: #fff6e9; border-color: #f0d9b0; color: var(--q-warning); }
.q-link-badge.is-combined { background: #eef4fb; border-color: #cfe0f3; color: var(--q-link); }
.q-link-badge.is-units    { background: #f3eefb; border-color: #e2d6f5; color: #6b3fb0; }
/* "et al." marker used in tables/lists. */
.q-etal { color: var(--q-text-faint); font-style: italic; }

/* ===== Mobile / narrow viewports ======================================== */
/* The Quattro portal pages (index/dashboard, lots, statements, pay) share this
   topbar + .q-main but historically had no phone handling, so wide data tables
   stretched the whole document (~1100px of horizontal overflow) and the 50px
   flex topbar ran off-screen. Scoped to <=768px so the desktop layout is
   untouched; finance.html's own inline rules still win where they overlap. */
@media (max-width: 768px) {
  /* Topbar wraps: brand + user on the first row, nav links on their own
     horizontally-scrollable row instead of forcing document width. */
  .q-topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 8px var(--q-sp-3);
    gap: var(--q-sp-2);
    row-gap: 6px;
  }
  .q-nav-links {
    order: 3;
    flex-basis: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 14px;
    white-space: nowrap;
    padding-bottom: 2px;
  }
  .q-nav-links a { flex: 0 0 auto; }
  /* The fixed 260px search box forces horizontal width — hide it on phones. */
  .q-nav-search { display: none; }
  .q-nav-user { margin-left: auto; }

  /* Data tables scroll within the content column rather than widening the page
     (the primary source of overflow on lots/statements/index). */
  .q-main { padding: var(--q-sp-3) var(--q-sp-3) var(--q-sp-5); }
  .q-main table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* Any remaining multi-column grid collapses to a single column. */
  .q-cols { grid-template-columns: 1fr; }
}

/* Wide data tables (the lots table is ~1515px at min-content) also overflow
   the 769–1600px range — 1080p projectors mirrored from 150%-scaled laptops
   (1280px logical) and Surface displays at 150% (~1536px). Same treatment:
   the table scrolls inside the content column instead of widening the page. */
@media (min-width: 769px) and (max-width: 1600px) {
  .q-main table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}
