:root {
  --pico-spacing: 0.75rem;
  --pico-form-element-spacing-vertical: 0.35rem;
  --pico-form-element-spacing-horizontal: 0.55rem;
  --pico-typography-spacing-vertical: 0.6rem;
  --pico-block-spacing-vertical: 0.6rem;
  --pico-block-spacing-horizontal: 0.75rem;
  --pico-line-height: 1.4;
  --pico-font-size: 95%;
}
body > header.container,
body > main.container {
  padding: 0.4rem 0.75rem;
  max-width: none;
}
h1, h2, h3, h4 { margin-bottom: 0.4rem; }
article { padding: 0.75rem 1rem; margin-bottom: 0.75rem; }
fieldset { padding: 0.4rem 0.6rem 0.2rem; margin-bottom: 0.6rem; }
label { margin-bottom: 0.25rem; }
input, select, textarea { margin-bottom: 0.35rem; }
.grid { gap: 0.4rem; }
.topbar { display: flex; gap: 1rem; align-items: center; justify-content: space-between; padding: 0.25rem 0; }
/* Dev-environment menubar tint (APP_ENV=dev) — unmistakably not prod */
header.dev { background: #ffe6cc; }

/* Address as a Google Maps link: pin glyph beside the lines, so the street
   and city/state/zip lines left-align with each other (glyph in its own column). */
.addr-block { display: inline-flex; align-items: flex-start; gap: 0.4rem; text-decoration: none; color: inherit; }
.addr-block .fa-map-marker { color: #c0392b; margin-top: 0.15rem; flex: 0 0 auto; }
.addr-block:hover .addr-lines { text-decoration: underline; }
.topbar nav ul { display: flex; gap: 1rem; list-style: none; margin: 0; padding: 0; align-items: center; }
.muted { color: var(--pico-muted-color); font-size: 0.85rem; }
.badge { display: inline-block; padding: 0.05rem 0.45rem; border-radius: 0; font-size: 0.72rem; background: var(--pico-secondary-background); color: var(--pico-secondary-inverse); }
/* Admin elevation — compact chip in the menu bar (between name and Log out) */
.admin-mode { display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.admin-mode-label { color: #946200; font-size: 0.8rem; font-weight: 600; }
.admin-mode-label .fa-unlock-alt { color: #d4a017; }
.admin-mode-step {
  width: auto; margin: 0; padding: 0.05rem 0.5rem; font-size: 0.7rem;
  border-radius: 999px; background: transparent; color: #946200;
  border: 1px solid #d4a017; cursor: pointer; white-space: nowrap;
}
@media (max-width: 768px) { .admin-mode-label { display: none; } }
.nav-elevate { display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap; }
.nav-elevate .btn-narrow { padding: 0.1rem 0.6rem; font-size: 0.8rem; }
.badge-passkey { color: #2c8a3e; font-weight: 600; white-space: nowrap; }
.footer-elevate #elevate-pw-form input { font-size: 0.85rem; padding: 0.15rem 0.4rem; }

/* Enroll/Regen buttons. Element prefixes give specificity over Pico's
   `[type=submit] { width: 100% }` rule so the button fits its text. */
button.invite-btn,
[type="submit"].invite-btn {
  display: inline-block;
  padding: 0.05rem 0.55rem; font-size: 0.72rem; border-radius: 999px;
  background: transparent; color: var(--pico-primary); border: 1px solid var(--pico-primary);
  cursor: pointer; width: auto; margin: 0; white-space: nowrap;
}
.invite-btn.pending { color: #946200; border-color: #d4a017; background: #fdf3d7; }
.invite-btn.drop { color: #b71c1c; border-color: #b71c1c; }

/* Car photo strips (show page + expando) */
.car-photos { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin: 0.3rem 0 0.6rem; }
.car-photo { position: relative; display: inline-block; }
.car-photo img { height: 110px; width: auto; border-radius: 0.35rem; display: block; box-shadow: 0 1px 3px rgba(0,0,0,0.25); }
.car-photo .photo-del {
  position: absolute; bottom: 0.3rem; right: 0.3rem;
  width: 1.4rem; height: 1.4rem; line-height: 1; padding: 0; margin: 0;
  border-radius: 50%; border: 1px solid #9a9a9a; color: #000;
  background: #d9d9d9; cursor: pointer; font-size: 0.9rem;
}
.photo-add { margin: 0; }
.photo-add input[type="file"] { display: none; }
.photo-add-label {
  display: inline-block; padding: 0.15rem 0.6rem; font-size: 0.8rem;
  border: 1px dashed var(--pico-primary); border-radius: 0.4rem;
  color: var(--pico-primary); cursor: pointer;
}
.photo-hint { font-size: 0.75rem; margin-left: 0.4rem; }
tr.car-photos-row td { border-bottom: 1px solid var(--pico-muted-border-color); }

/* Pill-style nav buttons (My household, Elevate to admin) */
.pill-btn {
  display: inline-block; padding: 0.2rem 0.8rem; border-radius: 999px;
  border: 1px solid var(--pico-primary); color: var(--pico-primary);
  text-decoration: none; font-size: 0.85rem; white-space: nowrap;
}
.pill-btn:hover { background: var(--pico-primary); color: #fff; }
button.pill-btn { background: transparent; width: auto; margin: 0; cursor: pointer; }
button.pill-btn:hover { background: var(--pico-primary); color: #fff; }

/* Household page footer: Add a car + Edit record side by side */
.show-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* Inline confirmation (replaces browser confirm() dialogs — see confirm.js) */
.confirm-inline {
  display: inline-flex; align-items: center; gap: 0.45rem;
  background: #fdf3d7; border: 1px solid #d4a017; border-radius: 0.4rem;
  padding: 0.15rem 0.55rem; font-size: 0.8rem; line-height: 1.3;
}
.confirm-inline button { width: auto; margin: 0; padding: 0.05rem 0.65rem; font-size: 0.75rem; border-radius: 999px; line-height: 1.4; }
.confirm-inline .ci-yes { background: #b71c1c; border: 1px solid #b71c1c; color: #fff; cursor: pointer; }
.confirm-inline .ci-no { background: #fff; border: 1px solid #8a8f98; color: #1a1a1a; cursor: pointer; }
/* Over a photo: a floating box sized to its content (the thumbnail is too
   narrow to contain it), centered on the photo with its own solid backdrop. */
.car-photo .confirm-inline {
  position: absolute; left: 50%; bottom: 0.3rem; transform: translateX(-50%);
  width: max-content; max-width: 18rem; flex-wrap: wrap; justify-content: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4); z-index: 10;
}

/* Car list on the household page: two lines per car + photo strip, inline editing */
.car-list { margin-top: 0.75rem; }
.car-item { margin-bottom: 0.9rem; }
.car-line1 { margin: 0; font-weight: 600; }
.car-line2 { margin: 0 0 0.2rem; font-size: 0.9rem; }
.car-edit-btn {
  display: inline-block; width: auto; margin: 0 0 0 0.4rem; padding: 0 0.45rem;
  background: transparent; border: 1px solid var(--pico-muted-border-color);
  border-radius: 0.35rem; color: var(--pico-primary); cursor: pointer; font-size: 0.8rem;
}
.car-editing { border: 1px solid var(--pico-muted-border-color); border-radius: 0.4rem; padding: 0.6rem; }
.car-editing form { margin: 0; }
/* One field per line — matches the mobile-friendly editing style */
.car-form-grid { display: grid; grid-template-columns: 1fr; gap: 0.45rem; max-width: 28rem; }
.car-form-grid label { margin: 0; font-size: 0.8rem; }
.car-form-grid input, .car-form-grid select, .car-form-grid textarea { margin-bottom: 0; padding: 0.25rem 0.4rem; }
.car-form-actions { display: flex; gap: 0.5rem; margin-top: 0.6rem; align-items: center; }
.car-form-actions button { width: auto; margin: 0; }
.car-delete-btn {
  margin-left: auto !important; background: transparent; color: #b71c1c;
  border: 1px solid #b71c1c; font-size: 0.8rem; padding: 0.25rem 0.7rem;
}

/* Photo lightbox overlay (assets/js/lightbox.js) */
.lightbox {
  position: fixed; inset: 0; z-index: 100; display: flex;
  align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.88);
}
.lightbox img { max-width: 94vw; max-height: 92vh; width: auto; height: auto; box-shadow: 0 4px 30px rgba(0,0,0,0.6); }
.lightbox button {
  position: absolute; width: auto; margin: 0; padding: 0.1rem 0.8rem;
  background: rgba(255,255,255,0.12); border: 0; color: #fff; cursor: pointer;
  font-size: 2rem; line-height: 1.3; border-radius: 999px;
}
.lightbox .lb-close { top: 0.6rem; right: 0.8rem; }
.lightbox .lb-prev { left: 0.6rem; top: 50%; transform: translateY(-50%); }
.lightbox .lb-next { right: 0.6rem; top: 50%; transform: translateY(-50%); }
.lightbox .lb-count {
  position: absolute; bottom: 0.7rem; left: 50%; transform: translateX(-50%);
  color: #ccc; font-size: 0.85rem;
}

/* Change history on the household page */
.history-toggle { display: flex; align-items: center; gap: 0.5rem; margin: 1rem 0 0.4rem; }
.history-list { font-size: 0.85rem; padding-left: 1rem; }
.history-list > li { margin-bottom: 0.35rem; }
.history-list ul { margin: 0.1rem 0 0.2rem; padding-left: 1.2rem; }
.history-list code { font-size: 0.8rem; }

/* Contact name + login status + actions on the household page */
.contact-line { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.contact-line .fa-envelope { color: #d4a017; }
.contact-line .fa-user { color: #2c8a3e; }
.contact-line .fa-user-secret { color: #2563eb; }

/* Login-state glyphs in the admin list */
.login-glyphs { white-space: nowrap; }
.login-glyphs .fa-square-o { color: var(--pico-muted-color); }
.login-glyphs .fa-envelope { color: #d4a017; }
.login-glyphs .fa-user { color: #2c8a3e; }
.login-glyphs .fa-user-secret { color: #2563eb; }

.badge.ACTIVE { background: #2c8a3e; color: white; }
.badge.LIFE { background: #7c3aed; color: white; }
.badge.UNKNOWN { background: #c2410c; color: white; }
.badge.GRACE { background: #d4a017; color: white; }
.badge.EXPIRED { background: #888; color: white; }
.badge.DECEASED { background: #444; color: white; }
table { margin-bottom: 0.5rem; width: 100%; }
table th, table td { padding: 0.3rem 0.35rem; }
table.compact th, table.compact td { padding: 0.25rem 0.3rem; }
/* Round filled chevron SVGs (assets/img/chevron-*.svg); .open points down.
   Inverse-color variants load under a dark color scheme. */
.expando {
  background: transparent url('../img/chevron-right.svg') center / 100% 100% no-repeat;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  margin: 0;
  line-height: 1;
  width: 1.7rem;
  height: 1.7rem;
}
.expando.open { background-image: url('../img/chevron-down.svg'); }
@media (prefers-color-scheme: dark) {
  .expando { background-image: url('../img/chevron-right-dark.svg'); }
  .expando.open { background-image: url('../img/chevron-down-dark.svg'); }
}

/* Keep the search box reachable while scrolled into the list */
/* Search box + inline result count, sticky while scrolling the list */
.search-row {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--pico-background-color);
  padding-block: 0.25rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 3cm; /* generous breathing room between the field and the count */
}
.search-row form[role="search"] { flex: 1 1 auto; margin: 0; }
.search-row input[type="search"] { width: 100%; margin-bottom: 0; }
#result-count { white-space: nowrap; font-size: 0.85rem; }
/* Pico draws a :focus-within ring around the whole role=search form group —
   suppress it and ring the pill-shaped input itself instead. */
form[role="search"]:focus-within { outline: none !important; box-shadow: none !important; }
form[role="search"] input[type="search"]:focus {
  outline: none !important;
  box-shadow: 0 0 0 2px var(--pico-primary-focus, rgba(1, 114, 173, 0.35)) !important;
}

/* Tighten the gap between the menubar and the search box */
main.container { padding-top: 0.4rem; }

/* Horizontal-scroll wrapper for wide editors (cars table on phones) */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Flash messages: prominent, with long enrollment links wrapping */
article.flash {
  overflow-wrap: anywhere;
  background: #fff8e1;
  border-left: 4px solid #d4a017;
  color: #3d3320;
}
article.flash::before {
  font-family: FontAwesome;
  content: "\f05a";  /* fa-info-circle */
  color: #d4a017;
  margin-right: 0.45rem;
}
article.flash code { font-size: 0.8em; }
article.flash em.flash-note { font-size: 0.82em; color: #6b5c33; }
button.copy-btn {
  display: inline-block; width: auto; margin: 0 0 0 0.25rem;
  padding: 0.1rem 0.45rem; font-size: 0.8rem; border-radius: 4px;
  background: transparent; color: var(--pico-primary); border: 1px solid var(--pico-primary);
  cursor: pointer;
}
.edit-pencil {
  text-decoration: none;
  color: var(--pico-muted-color);
  margin-left: 0.3rem;
  font-size: 0.9rem;
}
.edit-pencil:hover { color: var(--pico-primary); }
tr.detail-row > td {
  background: var(--pico-card-background-color, #f8f8f8);
  padding: 0.5rem 0.75rem;
  border-top: 0;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.5rem 1rem;
  font-size: 0.85rem;
}
.detail-grid h6 { margin: 0 0 0.2rem; font-size: 0.72rem; text-transform: uppercase; color: var(--pico-muted-color); letter-spacing: 0.04em; }
/* Desktop: contacts take ~1/5 of the width (larger type), cars get the rest */
@media (min-width: 769px) {
  .detail-grid { grid-template-columns: minmax(13rem, 1fr) 4fr; }
  .detail-grid > div:first-child { font-size: 1.05rem; }
}

/* Desktop: menubar + search + table headings stay visible; results scroll
   under them. Offsets are measured by a tiny script in the layout. */
@media (min-width: 769px) {
  header.container { position: sticky; top: 0; z-index: 30; background: var(--pico-background-color); }
  .search-row { top: var(--hdr-h, 3.4rem); }
  #results table thead th {
    position: sticky; top: calc(var(--hdr-h, 3.4rem) + var(--search-h, 3.1rem));
    background: var(--pico-background-color); z-index: 5;
  }
}
.detail-grid p { margin: 0; line-height: 1.4; }
.detail-grid p + p { margin-top: 0.45rem; }

.addr-grid {
  display: grid;
  grid-template-columns: minmax(0, 15rem) 5rem 7rem;  /* City fills, State narrow, Zip ~5 digits + slack */
  gap: 0.4rem;
}



.row-flagged { background: var(--pico-mark-background-color); }
form.inline { display: inline; margin: 0; }
form.inline button { margin: 0; padding: 0.2rem 0.6rem; }
.photo-flag { color: var(--pico-muted-color); margin-right: 0.15rem; }
.make-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  margin: 0 0.2rem 0.25rem 0;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #1a1a1a;
  border: 1.5px solid rgba(0,0,0,0.25); /* border-color overridden per-make inline */
  box-shadow: 0 1px 2px rgba(0,0,0,0.18);
  line-height: 1.4;
}
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin: 0.3rem 0 0.5rem;
  font-size: 0.85rem;
}
.filter-bar .filter-label { color: var(--pico-muted-color); }
.filter-bar .pill {
  display: inline-block;
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--pico-muted-border-color, #d0d0d0);
  background: transparent;
  color: var(--pico-color);
  font-size: 0.78rem;
  text-decoration: none;
  cursor: pointer;
  line-height: 1.5;
}
.filter-bar .pill:hover { background: var(--pico-secondary-background); }
.filter-bar .pill.active {
  background: var(--pico-primary);
  color: var(--pico-primary-inverse);
  border-color: var(--pico-primary);
}
.filter-bar select {
  margin: 0;
  padding: 0.1rem 1.8rem 0.1rem 0.5rem;
  font-size: 0.78rem;
  width: auto;
  max-width: 14rem;
  min-height: unset;
  height: auto;
  display: inline-block;
  background-position: right 0.4rem center;
}
.filter-bar .clear-filters {
  margin-left: 0.4rem;
  font-size: 0.78rem;
  color: var(--pico-muted-color);
}
.make-badge.clickable { cursor: pointer; }
.make-badge.clickable:hover { filter: brightness(0.92); box-shadow: 0 0 0 1px rgba(0,0,0,0.2); }
.make-badge.active {
  box-shadow: 0 0 0 2px var(--pico-primary);
  font-weight: 600;
}
.edit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.edit-header h2 { margin: 0; }
.edit-actions, .edit-actions-bottom { display: flex; gap: 0.4rem; align-items: center; }
.edit-actions-bottom { margin-top: 0.6rem; }
/* Element prefixes give specificity >= Pico's `button[type=submit]` rule
   so this overrides Pico's default width: 100% on submit buttons. */
button.btn-narrow,
[type="submit"].btn-narrow,
[type="button"].btn-narrow,
a[role="button"].btn-narrow {
  width: auto;
  min-width: 8rem;
  padding: 0.3rem 1.2rem;
  margin: 0;
}
a[role="button"].btn-narrow { display: inline-block; }
legend {
  font-size: 1.05rem;
  font-weight: 600;
}
body > footer.container {
  border-top: 1px solid var(--pico-muted-border-color, #ddd);
  margin-top: 1rem;
  padding: 0.5rem 0.75rem;
  max-width: none;
  color: var(--pico-muted-color);
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Mobile-only "Show makes" toggle for the admin list (hidden on desktop) */
.makes-toggle { display: none; }

/* ---- Mobile (spec: usable on a phone-width viewport) ---- */
@media (max-width: 768px) {
  /* Column diet: keep Name, Status, Login, Location */
  .col-since, .col-renewed, .col-zip { display: none; }

  /* Bigger touch targets for the expando and edit pencil */
  .expando { font-size: 1rem; width: 2.2rem; height: 2.2rem; }
  td a[title="Edit"] { display: inline-block; padding: 0.4rem 0.3rem; }

  /* Topbar: drop the signed-in name, tighten gaps */
  .topbar { gap: 0.5rem; }
  .topbar nav ul { gap: 0.5rem; }
  .topbar nav li.muted { display: none; }

  table.compact th, table.compact td { padding: 0.3rem 0.35rem; }

  /* 3cm of desktop breathing room is a third of a phone screen */
  .search-row { gap: 0.75rem; }

  /* Member list becomes stacked cards: name, then location, then makes.
     No sideways scrolling, no hidden columns. Bigger type for readability. */
  table.member-list, table.member-list tbody { display: block; }
  table.member-list thead { display: none; }
  table.member-list { font-size: 1.05rem; }
  table.member-list tr {
    display: flex; flex-wrap: wrap; align-items: center;
    column-gap: 0.5rem; padding: 0.5rem 0.1rem;
    /* Separator above each household (not below) so an open expando's
       contact/cars aren't cut off from their household by a rule. */
    border-top: 1px solid var(--pico-muted-border-color);
    border-bottom: none;
  }
  table.member-list td { display: block; border: none; padding: 0.1rem 0; }
  /* Stripes paint per-cell boxes in the flex layout — the row border is enough */
  table.member-list tbody tr:nth-child(odd) td,
  table.member-list tbody td { background: transparent; }
  table.member-list td.col-since { display: none; }
  table.member-list td.col-expando { order: 0; }
  table.member-list td.col-name { order: 1; flex: 1 1 auto; font-size: 1.15rem; }
  table.member-list td.col-edit { order: 2; }
  table.member-list td.col-loc { order: 3; flex-basis: 100%; padding-left: 2.7rem; color: var(--pico-muted-color); }
  table.member-list td.col-makes { order: 4; flex-basis: 100%; padding-left: 2.7rem; }
  table.member-list .make-badge { font-size: 0.9rem; }
  table.member-list tr.detail-row { display: block; padding: 0; border-top: none; border-bottom: none; }
  table.member-list tr.detail-row td { display: block; width: 100%; padding-left: 2.7rem; font-size: 1rem; }

  /* Admin list: Makes hidden by default; the "Show makes" checkbox reveals it */
  .makes-toggle { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.8rem; margin: 0.2rem 0 0.4rem; }
  .makes-toggle input[type="checkbox"] { margin: 0; }
  table.admin-list .col-makes { display: none; }
  #results.show-makes table.admin-list .col-makes { display: table-cell; }

  /* Expando detail: one column — contact info first, then cars */
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .col-city { display: none; }
}

/* Fallback: whatever still overflows at phone width scrolls instead of clipping
   (admin table only — the member list wraps instead of scrolling) */
@media (max-width: 768px) {
  #results { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ---- Printable directory ---- */
.print-header { margin-bottom: 0.75rem; }
.print-directory { columns: 2; column-gap: 1.5rem; }
.print-entry {
  break-inside: avoid;
  margin-bottom: 0.55rem;
  font-size: 0.83rem;
  line-height: 1.35;
}
.print-entry h4 { margin: 0; font-size: 0.95rem; }
.print-entry .print-car { color: #333; }
@media (max-width: 600px) { .print-directory { columns: 1; } }

/* Paper margins: generous top/bottom, a bit of extra left/right. */
@page { margin: 0.75in 0.5in; }

@media print {
  body > header.container, body > footer.container, .no-print { display: none !important; }
  body { font-size: 11px; }
  /* column-fill: auto is load-bearing. Balanced columns (the default)
     compute their height against the whole document when fragmenting
     across pages, which collapses the printout to a single column. */
  .print-directory { columns: 2; column-fill: auto; }
  a { color: inherit; text-decoration: none; }
}
