/* Heritage Oaks Feedback — app.css
   Brand: teal #358873 / dark #256355
*/

:root {
  --teal: #358873;
  --teal-dark: #256355;
  --teal-soft: #e6f2ef;
  --teal-ink: #14413a;
  --text: #1f2a27;
  --muted: #6b7771;
  --border: #dbe3e0;
  --border-strong: #b9c5c0;
  --bg: #f6f9f8;
  --white: #ffffff;
  --danger: #b23b3b;
  --danger-soft: #fdecec;
  --ok: #2f8f6a;
  --shadow: 0 1px 3px rgba(20, 65, 58, 0.06), 0 2px 8px rgba(20, 65, 58, 0.04);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--teal-dark); }
a:hover { color: var(--teal); }
h1, h2, h3, h4 { color: var(--teal-ink); margin: 0.7em 0 0.4em; font-weight: 700; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: 0.95rem; }
code { background: #eef3f1; padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.88em; color: var(--teal-dark); }
.muted { color: var(--muted); }
.container { max-width: 1100px; margin: 0 auto; padding: 1.25rem; }

/* ----- Buttons ----- */
.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  border: 1px solid var(--border-strong);
  background: var(--white);
  color: var(--text);
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  line-height: 1.2;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { border-color: var(--teal); }
.btn--primary {
  background: var(--teal); color: var(--white); border-color: var(--teal);
}
.btn--primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); color: var(--white); }
.btn--ghost { background: transparent; border-color: var(--border); }
.btn--danger { color: var(--danger); border-color: var(--danger); background: var(--white); }
.btn--danger:hover { background: var(--danger); color: var(--white); }
.btn--block { display: block; width: 100%; text-align: center; }
.btn--lg { padding: 0.9rem 1.2rem; font-size: 1.05rem; }
.btn--tiny { padding: 0.2rem 0.55rem; font-size: 0.8rem; }
.btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ----- Alerts ----- */
.alert { padding: 0.7rem 1rem; border-radius: 6px; margin: 0 0 1rem; border: 1px solid transparent; }
.alert--success { background: var(--teal-soft); color: var(--teal-ink); border-color: #bcd8cf; }
.alert--error { background: var(--danger-soft); color: var(--danger); border-color: #f0c7c7; }

/* ----- Badges ----- */
.badge { display: inline-block; padding: 0.12rem 0.55rem; background: #e9eeec; color: var(--text); border-radius: 999px; font-size: 0.72rem; margin-left: 0.25rem; letter-spacing: 0.02em; }
.badge--ok { background: var(--teal-soft); color: var(--teal-dark); }
.badge--muted { background: #eee; color: var(--muted); }

/* ============================================================
   MEMBER-FACING FORM
   ============================================================ */
body.member, body.bare { background: var(--white); }

.member-header { text-align: center; padding: 1.25rem 1rem 0.5rem; }
.member-header .logo { max-width: 250px; width: 80%; height: auto; }
.member-main { max-width: 560px; margin: 0 auto; padding: 0.5rem 1.15rem 2rem; }
.member-footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 1.5rem 1rem 2rem; }

/* Form progress bar — thin teal stripe pinned at the top of the viewport
   that fills left-to-right as the member scrolls through the form. */
.form-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--border);
  z-index: 100;
}
.form-progress__bar {
  height: 100%;
  width: 0;
  background: var(--teal);
  transition: width 0.1s ease-out;
  border-radius: 0 2px 2px 0;
}

.form-title { text-align: center; margin-top: 0.3rem; }
.form-desc { text-align: center; color: var(--muted); margin-top: 0; }

.member-form fieldset {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem 1.2rem;
  margin: 0 0 1.1rem;
  background: var(--white);
}
.member-form legend {
  padding: 0 0.5rem;
  color: var(--teal-dark);
  font-weight: 600;
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field { display: block; margin: 0.85rem 0; }
.field > span {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--teal-ink);
  margin-bottom: 0.3rem;
}
.field input[type=text],
.field input[type=email],
.field input[type=password],
.field input[type=number],
.field input[type=date],
.field input[type=time],
.field select,
.field textarea,
.inline-form input[type=text],
.inline-form input[type=email],
.inline-form input[type=number],
.inline-form select {
  width: 100%;
  padding: 0.72rem 0.85rem;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-size: 1rem;
  background: var(--white);
  color: var(--text);
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
  border-color: var(--teal);
}
.field textarea { resize: vertical; min-height: 90px; }
.field abbr { color: var(--danger); text-decoration: none; }
.field .err { color: var(--danger); display: block; margin-top: 0.3rem; font-size: 0.85rem; }
.field-row { display: flex; gap: 0.8rem; }
.field-row .field { flex: 1; margin-top: 0.85rem; }
.option { display: block; padding: 0.45rem 0; font-size: 0.98rem; }
.option input { margin-right: 0.5rem; transform: translateY(1px); }

/* Number stepper — narrow number input flanked by +/- buttons */
.number-stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  overflow: hidden;
  background: var(--white);
  max-width: 190px;
}
.number-stepper input[type="number"] {
  width: 64px;
  text-align: center;
  border: none;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-radius: 0;
  padding: 0.7rem 0.3rem;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
  background: var(--white);
  color: var(--text);
}
/* Override the global .field input width: 100% rule */
.field .number-stepper input[type="number"] { width: 64px; }
.number-stepper input[type="number"]::-webkit-outer-spin-button,
.number-stepper input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.number-stepper input[type="number"]:focus {
  outline: none;
  background: var(--teal-soft);
}
.stepper-btn {
  width: 52px;
  min-height: 48px;
  border: none;
  background: var(--white);
  color: var(--teal-dark);
  font-size: 1.5rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  line-height: 1;
  padding: 0;
  font-family: inherit;
  touch-action: manipulation;
  transition: background 0.12s, color 0.12s;
  -webkit-tap-highlight-color: transparent; /* kill iOS gray tap tint */
}
/* Only apply hover styles on devices that actually support hover (mice).
   On touch devices :hover sticks after a tap and can bleed to sibling elements. */
@media (hover: hover) {
  .stepper-btn:hover:not(:disabled) { background: var(--teal-soft); }
}
.stepper-btn:active:not(:disabled) { background: var(--teal); color: var(--white); }
.stepper-btn:disabled {
  color: #c3cbc7;
  cursor: not-allowed;
  background: #fafbfb;
}

/* Star rating — reverse flex trick for "all previous stars light up" on hover */
.rating-input {
  display: inline-flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  gap: 0.1rem;
  margin-top: 0.15rem;
}
.rating-input input { position: absolute; left: -9999px; }
.rating-input label {
  font-size: 2.2rem;
  color: #d5d8d6;
  cursor: pointer;
  padding: 0 0.1rem;
  line-height: 1;
  transition: color 0.12s;
  user-select: none;
}
.rating-input input:checked ~ label,
.rating-input label:hover,
.rating-input label:hover ~ label { color: var(--teal); }
.rating-input input:focus-visible + label { outline: 2px solid var(--teal); border-radius: 4px; }

.privacy-notice {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 1rem;
  text-align: center;
  padding: 0 0.5rem;
}

.thanks { max-width: 480px; margin: 3rem auto 1.5rem; text-align: center; padding: 0 1.2rem; }
.thanks h1 { color: var(--teal); }
.thanks-more {
  max-width: 560px;
  margin: 0.5rem auto 2rem;
  padding: 0 1.15rem;
}
.thanks-more h2 {
  text-align: center;
  margin-top: 1rem;
}
.thanks-more .muted {
  text-align: center;
  margin-bottom: 1rem;
}

/* ============================================================
   ADMIN
   ============================================================ */
body.admin { background: var(--bg); }

.admin-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1.2rem;
  background: var(--white);
  border-bottom: 3px solid var(--teal);
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}
.admin-header__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}
.admin-header__brand:hover .admin-title { color: var(--teal); }
.logo--sm { max-height: 42px; height: auto; }
.admin-title { font-weight: 700; color: var(--teal-dark); font-size: 1.05rem; }

.admin-nav { display: flex; gap: 1rem; margin-left: auto; flex-wrap: wrap; }
.admin-nav a {
  color: var(--text);
  text-decoration: none;
  padding: 0.4rem 0.2rem;
  border-bottom: 2px solid transparent;
  font-size: 0.95rem;
}
.admin-nav a:hover { border-color: var(--teal); color: var(--teal-dark); }
.admin-nav a.is-active { border-color: var(--teal); color: var(--teal-dark); font-weight: 600; }
.nav-more.is-active > summary { border-color: var(--teal); color: var(--teal-dark); font-weight: 600; }
.nav-more__panel a.is-active { background: var(--teal-soft); color: var(--teal-dark); font-weight: 600; }

.logout-form { display: flex; align-items: center; gap: 0.6rem; margin: 0; }
.admin-user { font-size: 0.85rem; color: var(--muted); }
.admin-user em { font-style: normal; color: var(--teal-dark); }

.admin-main { padding: 1.25rem; max-width: 1200px; margin: 0 auto; }

/* ----- Dashboard cards ----- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1rem 0 1.8rem;
}
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
  text-align: center;
}
.card-label { font-size: 0.82rem; color: var(--muted); display: block; text-transform: uppercase; letter-spacing: 0.04em; }
.card-val { font-size: 1.75rem; color: var(--teal-dark); font-weight: 700; display: block; margin-top: 0.3rem; }
.card-val small { font-size: 0.95rem; color: var(--muted); font-weight: 500; }
.card-trend { font-size: 0.78rem; color: var(--muted); margin-top: 0.3rem; }
.trend { font-weight: 600; display: inline-block; margin-right: 0.2rem; }
.trend--up { color: #2f8f6a; }
.trend--down { color: var(--danger); }
.trend--flat { color: var(--muted); }

/* Needs attention callout */
.attention-card {
  background: #fff8ec;
  border: 1px solid #f1d08a;
  border-left: 4px solid #d4a017;
  border-radius: 6px;
  padding: 0.8rem 1.1rem;
  margin: 0 0 1rem;
  font-size: 0.92rem;
  color: #5a4a00;
}

/* Onboarding checklist */
.onboarding-card {
  margin: 0 0 1.2rem;
  padding: 1.2rem 1.4rem;
}
.onboarding-card h2 { margin: 0 0 0.3rem; font-size: 1.1rem; color: var(--teal-dark); text-transform: none; letter-spacing: 0; }
.onboarding-checklist {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}
.onboarding-checklist li {
  padding: 0.4rem 0;
  font-size: 0.95rem;
}
.onboarding-checklist li.is-done { color: var(--muted); }
.onboarding-checklist a { color: var(--teal-dark); }

/* Heatmap (day-of-week × meal period) */
.heatmap-table {
  border-collapse: separate;
  border-spacing: 3px;
  width: auto;
  margin: 0.5rem auto;
}
.heatmap-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 0.3rem 0.6rem;
  text-align: center;
  background: transparent;
}
.heatmap-day {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-align: right;
  padding-right: 0.5rem;
}
.heatmap-cell {
  width: 52px;
  height: 36px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--white);
  border-radius: 4px;
  vertical-align: middle;
}
.heatmap-cell:empty { background: #f0f3f2 !important; }

/* Session timeout warning bar */
.session-warning {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff8ec;
  border-top: 2px solid #d4a017;
  padding: 0.7rem 1.2rem;
  text-align: center;
  font-size: 0.92rem;
  color: #5a4a00;
  z-index: 200;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
}
.session-warning .btn { margin-left: 0.8rem; }

/* Table tent template picker */
.tent-section { margin-bottom: 1.2rem; }
.tent-section h2 { margin: 0 0 0.3rem; font-size: 1.05rem; color: var(--teal-dark); text-transform: none; letter-spacing: 0; }
.tent-themes {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-top: 0.7rem;
}
.tent-theme-card {
  display: flex;
  flex-direction: column;
  width: 180px;
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 0.1s, box-shadow 0.1s;
}
.tent-theme-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(20, 65, 58, 0.15);
}
.tent-theme-card__swatch {
  padding: 0.7rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
}
.tent-theme-card__body {
  padding: 0.7rem 0.8rem;
  font-size: 0.85rem;
  text-align: center;
}
.tent-theme-card__icon {
  display: block;
  font-size: 1.2rem;
  margin-bottom: 0.2rem;
}

/* ----- Data tables ----- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
/* When an inline-rename popover is actually open inside the table, let
   it escape the rounded-corner clipping mask. Rounded corners stay
   clipped in the normal (non-interactive) state. */
.data-table:has(details.inline-rename[open]) { overflow: visible; }
.data-table th, .data-table td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
  vertical-align: middle;
}
.data-table th {
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
/* Sortable column headers on the Responses page */
.data-table th.sortable { padding: 0; }
.data-table th.sortable > a {
  display: block;
  padding: 0.65rem 0.85rem;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.data-table th.sortable > a:hover { background: #dbeae4; }
.data-table th.sortable.is-active > a { color: var(--teal-dark); background: #cfe3db; }
.sort-arrow { font-weight: 700; margin-left: 0.2rem; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fafcfb; }
.data-table a { color: var(--teal-dark); }

/* Table scroll wrapper — prevents wide tables from breaking the layout on mobile */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 0 0.5rem; }

/* Star rating display color (teal, not default black) */
.stars { color: var(--teal); }
/* row-actions stays a real table cell. The inner __wrap div is the flex
   container — never set display:flex on a <td> directly because it removes
   the cell from the table layout and rows render inconsistently. */
.data-table td.row-actions {
  white-space: nowrap;
  vertical-align: middle;
  text-align: right;
}
.row-actions__wrap {
  display: flex;
  gap: 0.4rem;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
}
.row-actions__wrap > * { flex-shrink: 0; margin: 0; }
.row-actions .btn { padding: 0.35rem 0.7rem; font-size: 0.85rem; }

/* ----- Inline forms / cards ----- */
.inline-form {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 0.6rem 0 1rem;
}
.inline-form input[type=text] { flex: 1; min-width: 180px; }
.inline { display: inline-block; margin: 0; }
.card-form {
  background: var(--white);
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

/* ----- Login ----- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; background: var(--bg); }
.login-card {
  max-width: 400px;
  width: 100%;
  padding: 2rem 1.8rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.login-card h1 { text-align: center; margin-top: 0.5rem; }
.login-logo { text-align: center; margin-bottom: 0.5rem; }
.login-logo img { max-width: 220px; width: 80%; height: auto; }
.login-form .btn { margin-top: 0.8rem; }

/* ----- Forms builder ----- */
.form-meta {
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
  align-items: center;
  padding: 0.7rem 1rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 0.6rem 0 1.2rem;
}
.form-meta strong { color: var(--muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; margin-right: 0.3rem; }

.question-list { list-style: none; padding: 0; margin: 0; }
.question-row {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  margin: 0.55rem 0;
  box-shadow: var(--shadow);
}
.question-row.retired { opacity: 0.65; }
.question-row summary { cursor: pointer; list-style: none; outline: none; }
.question-row summary::-webkit-details-marker { display: none; }
.question-row summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.5rem;
  color: var(--teal);
  transition: transform 0.15s;
}
.question-row details[open] summary::before { transform: rotate(90deg); }

.builder-add, .builder-edit {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.8rem;
  padding: 0.95rem 1rem;
  margin: 0.8rem 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f9fbfa;
  align-items: end;
}
.builder-add .field, .builder-edit .field { margin: 0; }
.builder-add button, .builder-edit button { grid-column: 1 / -1; justify-self: start; }
@media (max-width: 720px) {
  .builder-add, .builder-edit { grid-template-columns: 1fr; }
}
.checkbox-field { display: flex; align-items: center; gap: 0.45rem; font-size: 0.92rem; }

.option-list { list-style: none; padding: 0; margin: 0.5rem 0; }
.option-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.2rem;
  border-bottom: 1px dashed var(--border);
}
.option-list li:last-child { border-bottom: 0; }

/* ----- Response detail ----- */
.meta { display: grid; grid-template-columns: 160px 1fr; gap: 0.4rem 1rem; background: var(--white); padding: 1rem 1.2rem; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.meta dt { font-weight: 600; color: var(--muted); text-transform: uppercase; font-size: 0.78rem; letter-spacing: 0.04em; padding-top: 0.15rem; }
.meta dd { margin: 0; }
.answers { background: var(--white); padding: 1rem 1.2rem; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.answers dt { font-weight: 600; margin-top: 0.9rem; color: var(--teal-dark); }
.answers dt:first-child { margin-top: 0; }
.answers dd { margin-left: 0; margin-bottom: 0.2rem; }
.delete-form { margin-top: 1.5rem; }

/* ----- Lookups ----- */
.lookup-list { display: flex; flex-direction: column; gap: 0.5rem; }
.lookup-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}
.lookup-row .lookup-edit { margin: 0; flex: 1; min-width: 280px; }

/* ----- Mobile polish ----- */
@media (max-width: 640px) {
  .admin-nav { gap: 0.7rem; font-size: 0.88rem; }
  .admin-header { gap: 0.6rem; padding: 0.7rem 0.9rem; }
  .logout-form { margin-left: auto; }
  .admin-user { display: none; }
  .meta { grid-template-columns: 1fr; gap: 0.15rem 0; }
  .meta dt { padding-top: 0.6rem; }
  .data-table { font-size: 0.86rem; }
  .data-table th, .data-table td { padding: 0.55rem 0.6rem; }
}

/* ============================================================
   PHASE 2 — Filters, charts, bulk, flagging, pagination
   ============================================================ */

/* ----- Filter form (legacy + shared bits) ----- */
.filter-form { margin: 0 0 1.2rem; }
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.7rem 0.9rem;
}
.filter-grid .field { margin: 0; }
.filter-grid .field > span {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}
.filter-grid .field input,
.filter-grid .field select {
  padding: 0.55rem 0.65rem;
  font-size: 0.92rem;
}
.filter-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-top: 0.9rem;
  flex-wrap: wrap;
}

/* ----- New filter bar (presets + chips + collapsible advanced) ----- */
.filter-bar { margin: 0 0 1rem; }
.filter-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.filter-preset {
  display: inline-block;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--white);
  color: var(--text);
  font-size: 0.9rem;
  text-decoration: none;
  line-height: 1.2;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.filter-preset:hover { border-color: var(--teal); color: var(--teal-dark); }
.filter-preset.is-active {
  background: var(--teal);
  border-color: var(--teal);
  color: var(--white);
}
.filter-preset.is-active:hover { background: var(--teal-dark); border-color: var(--teal-dark); color: var(--white); }
.filter-preset__sep {
  display: inline-block;
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 0.3rem;
}

/* "More filters" disclosure — popover that floats over content */
.filter-more {
  position: relative;
  display: inline-block;
  margin-left: auto;
}
.filter-more > summary {
  list-style: none;
  cursor: pointer;
  display: inline-block;
}
.filter-more > summary::-webkit-details-marker { display: none; }
.filter-more__panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 30;
  width: min(680px, calc(100vw - 2rem));
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(20, 65, 58, 0.15);
  padding: 1rem 1.1rem;
}

/* Active filter chips */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.6rem;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  background: var(--teal-soft);
  color: var(--teal-dark);
  border: 1px solid #bcd8cf;
  border-radius: 999px;
  font-size: 0.82rem;
  text-decoration: none;
  line-height: 1.2;
  transition: background 0.12s;
}
.filter-chip:hover { background: #d5e8e1; color: var(--teal-dark); }
.filter-chip__x {
  font-size: 1rem;
  color: var(--teal-dark);
  line-height: 1;
  margin-left: 0.1rem;
}
.filter-chip__clear {
  font-size: 0.82rem;
  color: var(--muted);
  text-decoration: underline;
  margin-left: 0.3rem;
}
.filter-chip__clear:hover { color: var(--danger); }

/* Page header (title + right-aligned action like Download CSV) */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}
.page-header h1 { margin: 0; }

/* Recent responses heading + View all link */
.recent-header {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  margin: 1.2rem 0 0.4rem;
}
.recent-header h2 { margin: 0; font-size: 0.95rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.recent-viewall {
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
}
.recent-viewall:hover { color: var(--teal-dark); text-decoration: underline; }

/* Breakdown section with a View all link (e.g. Top servers) */
.breakdown__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
  margin: 0.4rem 0 0.5rem;
}
.breakdown__head h2 { margin: 0; font-size: 0.95rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* Inline rename popover (server-names page, response detail server field) */
.inline-rename {
  position: relative;
  display: inline-block;
}
.inline-rename > summary {
  list-style: none;
  cursor: pointer;
  display: inline-block;
}
.inline-rename > summary::-webkit-details-marker { display: none; }
.inline-rename__form {
  position: absolute;
  top: calc(100% + 0.3rem);
  right: 0;
  z-index: 40;
  width: 280px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(20, 65, 58, 0.15);
  padding: 0.9rem 1rem;
  margin: 0;
  /* The parent td.row-actions sets white-space:nowrap so its buttons
     don't wrap. That inherits into the popover and prevents long label
     text from wrapping. Reset it here. */
  white-space: normal;
}
.inline-rename__form .field { margin: 0 0 0.5rem; }
.inline-rename__form .field > span {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: normal;
}
.inline-rename__actions { display: flex; gap: 0.5rem; justify-content: flex-end; }

/* Response detail: server name with inline edit popover */
.meta .server-name-display { margin-right: 0.5rem; }

/* ============================================================
   Print / PDF-style response view (standalone bare layout)
   ============================================================ */
body.print {
  background: var(--white);
  color: var(--text);
}
.print-sheet {
  max-width: 740px;
  margin: 2rem auto;
  padding: 2rem 2.4rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.print-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 3px solid var(--teal);
  padding-bottom: 1rem;
  margin-bottom: 1.2rem;
}
.print-logo { max-width: 110px; height: auto; }
.print-header__title { text-align: right; }
.print-club { color: var(--teal-dark); font-weight: 700; font-size: 1rem; }
.print-subtitle { color: var(--muted); font-size: 0.85rem; }
.print-h1 { font-size: 1.5rem; color: var(--teal-ink); margin: 0 0 0.6rem; }
.print-h2 { font-size: 1.05rem; color: var(--teal-dark); margin: 1.5rem 0 0.4rem; border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }

.print-meta {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 0.35rem 1rem;
  margin: 0.5rem 0 0.8rem;
}
.print-meta dt {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: 0.15rem;
}
.print-meta dd { margin: 0; }

.print-rating {
  background: var(--teal-soft);
  border-left: 4px solid var(--teal);
  padding: 0.9rem 1.2rem;
  margin: 1rem 0;
  border-radius: 0 6px 6px 0;
}
.print-rating__label {
  color: var(--teal-dark);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.print-rating__stars {
  color: var(--teal);
  font-size: 1.7rem;
  letter-spacing: 0.15rem;
}
.print-rating__value {
  color: var(--teal-dark);
  font-size: 1.4rem;
  font-weight: 700;
}

.print-cat {
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 1.2rem 0 0.3rem;
}
.print-answers dt {
  font-weight: 600;
  color: var(--teal-dark);
  margin-top: 0.7rem;
  font-size: 0.95rem;
}
.print-answers dd { margin: 0.1rem 0 0; }

.print-actions {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
}

/* Print-only footer (hidden on screen, shown on paper) */
.print-only-footer {
  display: none;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border);
}

/* Actual print output — hide non-essentials, strip paper chrome */
@media print {
  body.print { background: white; }
  .print-sheet {
    max-width: none;
    margin: 0;
    padding: 0;
    border: none;
    box-shadow: none;
  }
  .no-print { display: none !important; }
  .print-only-footer { display: block !important; }
}

/* Clickable breakdown rows on the dashboard */
.data-table--clickable tbody tr[data-href]:hover {
  background: var(--teal-soft);
  cursor: pointer;
}
/* first-child bold for clickable rows is now handled by
   .breakdown .data-table td:first-child above */

/* Top servers in-place expand: hide rows 11+ by default, show when toggled */
.breakdown--servers .server-extra { display: none; }
.breakdown--servers.is-expanded .server-extra { display: table-row; }

/* The expand/collapse button uses the existing .recent-viewall text style
   but needs a button reset since it's a <button>, not a link */
button.recent-viewall {
  background: transparent;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}
button.recent-viewall:hover { color: var(--teal-dark); text-decoration: underline; }

@media (max-width: 720px) {
  .filter-more { margin-left: 0; width: 100%; }
  .filter-presets { gap: 0.35rem; }
  .filter-preset { padding: 0.4rem 0.7rem; font-size: 0.85rem; }
}

/* ----- Charts ----- */
.chart-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  margin: 1.2rem 0 1.4rem;
}
@media (max-width: 900px) {
  .chart-grid { grid-template-columns: 1fr; }
}
.chart-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem 1.2rem;
  box-shadow: var(--shadow);
}
.chart-box h2 { margin-top: 0; text-align: center; font-size: 0.95rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.chart-box canvas { width: 100% !important; height: 240px !important; }

/* ----- Breakdown tables grid ----- */
.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  margin: 1rem 0 1.5rem;
}
.breakdown h2 { margin-top: 0.4rem; font-size: 0.95rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.breakdown .data-table { font-size: 0.88rem; }
/* Center-align the numeric columns (Responses + Avg) in breakdown tables
   so they look uniform across all three sections */
.breakdown .data-table th:nth-child(2),
.breakdown .data-table td:nth-child(2),
.breakdown .data-table th:nth-child(3),
.breakdown .data-table td:nth-child(3) { text-align: center; }
/* First column (venue/meal/server name) gets a bit of weight */
.breakdown .data-table td:first-child { font-weight: 600; color: var(--teal-dark); }

/* ----- Responses list extras ----- */
.result-summary { margin: 0.5rem 0 0.9rem; }
.row-flagged { background: #fff8ec !important; }
.row-flagged:hover { background: #fff3df !important; }
.bulk-bar {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  margin-top: 0.8rem;
  padding: 0.6rem 0.8rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* ----- Pagination ----- */
.pager {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  justify-content: center;
  margin: 1.2rem 0 0.5rem;
}
.btn--disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* ----- Flag badge + flag form ----- */
.badge--flag {
  background: #fff1d6;
  color: #8a5a00;
  border: 1px solid #f1d08a;
}
.flag-form { margin-top: 0.5rem; }
.flag-toggle { font-weight: 600; color: var(--teal-dark); margin-bottom: 0.6rem; }
.delete-form { margin-top: 1.5rem; }

/* Checkbox column keeps a reasonable size */
.data-table th:first-child,
.data-table td:first-child { width: 34px; text-align: center; }

/* ============================================================
   PHASE 3 — Conditional logic, drag-to-reorder, QR code
   ============================================================ */

/* Drag handle on builder question rows */
.question-row__head {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}
.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  min-height: 28px;
  color: var(--muted);
  cursor: grab;
  font-size: 1.1rem;
  user-select: none;
  padding-top: 0.15rem;
  flex-shrink: 0;
}
.drag-handle:hover { color: var(--teal); }
.drag-handle:active { cursor: grabbing; }
.question-row__body { flex: 1; min-width: 0; }
.question-row--ghost { opacity: 0.4; background: var(--teal-soft) !important; }

/* Conditional logic section inside builder */
.badge--logic { background: #e8ecff; color: #3a4691; border: 1px solid #c3cbf0; }
.small { font-size: 0.85rem; }

.logic-list {
  list-style: none;
  padding: 0;
  margin: 0.4rem 0 0.6rem;
}
.logic-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.7rem;
  background: #f4f7fb;
  border: 1px solid #dde4ee;
  border-radius: 6px;
  margin: 0.3rem 0;
  font-size: 0.9rem;
}
.logic-list li em { color: var(--muted); font-style: normal; padding: 0 0.25rem; }
.logic-list li code { background: #fff; border: 1px solid #dde4ee; }

.logic-add {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 0.6rem;
  padding: 0.8rem;
  border: 1px dashed var(--border-strong);
  border-radius: 7px;
  background: #fcfcfc;
  margin: 0.4rem 0 0.8rem;
  align-items: end;
}
.logic-add .field { margin: 0; }
.logic-add button { align-self: end; }
@media (max-width: 760px) {
  .logic-add { grid-template-columns: 1fr; }
}

.retire-form { margin-top: 0.6rem; }

/* Member form: hidden-by-conditional questions */
.member-form .field.question.is-hidden {
  display: none !important;
}

/* Form picker (when a parent form has linked sub-forms) */
.form-picker {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin: 1.25rem 0 0.5rem;
}
.picker-card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1.1rem 1.2rem;
  background: var(--white);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  min-height: 72px;
  transition: border-color 0.12s, transform 0.08s, box-shadow 0.12s;
}
.picker-card:hover {
  border-color: var(--teal);
  color: var(--text);
}
.picker-card:active {
  transform: scale(0.99);
}
.picker-card__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.picker-card__name {
  font-weight: 700;
  color: var(--teal-ink);
  font-size: 1.08rem;
}
.picker-card__desc {
  color: var(--muted);
  font-size: 0.88rem;
}
.picker-card__arrow {
  color: var(--teal);
  font-size: 1.5rem;
  font-weight: 600;
  flex-shrink: 0;
}

/* Admin forms index: child-row visual indent */
.forms-row--child td:first-child {
  padding-left: 2.2rem;
  position: relative;
}
.forms-row__indent {
  position: absolute;
  left: 0.8rem;
  color: var(--muted);
  font-size: 1.1rem;
}
.forms-row--child { background: #fafcfb; }
.forms-row--child strong { font-weight: 600; }
.forms-row--child td small.muted { display: block; font-size: 0.78rem; margin-top: 0.1rem; }

/* QR code page */
.qr-wrap { padding: 1.4rem 1.4rem 1.2rem; }
.qr-meta {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem 2rem;
  margin-bottom: 1.2rem;
}
.qr-meta strong {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}
.qr-url {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.qr-url code {
  background: #eef3f1;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  font-size: 0.92rem;
  word-break: break-all;
}
.qr-canvas-wrap {
  display: flex;
  justify-content: center;
  padding: 1.2rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 0.5rem 0 1rem;
}
.qr-canvas-wrap canvas {
  max-width: 100%;
  height: auto;
  width: 320px;
}
.qr-actions {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ============================================================
   PHASE 4 — Nav dropdown, users, notifications, audit, settings
   ============================================================ */

/* Info alert (neutral blue) */
.alert--info {
  background: #eff5fb;
  color: #245b8f;
  border-color: #c9dcef;
}

/* Mobile nav toggle — hidden on desktop */
.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--teal-dark);
  font-size: 1.2rem;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  margin-left: auto;
}

/* "Setup" dropdown inside the nav */
.nav-more {
  position: relative;
  display: inline-block;
}
.nav-more > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.4rem 0.2rem;
  color: var(--text);
  user-select: none;
  border-bottom: 2px solid transparent;
}
.nav-more > summary::-webkit-details-marker { display: none; }
.nav-more > summary:hover { color: var(--teal-dark); border-color: var(--teal); }
.nav-more[open] > summary { color: var(--teal-dark); }
.nav-more__panel {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 200px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(20, 65, 58, 0.12);
  padding: 0.4rem 0;
  z-index: 20;
}
.nav-more__panel a {
  display: block;
  padding: 0.55rem 1rem;
  text-decoration: none;
  color: var(--text);
  font-size: 0.93rem;
}
.nav-more__panel a:hover { background: var(--teal-soft); color: var(--teal-dark); }

/* Hover styling for the Setup dropdown — the actual open/close is
   handled by JS (mouseenter/mouseleave) because <details> content
   visibility can't be reliably overridden with CSS alone. */
@media (hover: hover) {
  .nav-more:hover > summary { border-color: var(--teal); color: var(--teal-dark); }
}
.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 0.3rem 0;
}

/* Archived users collapsible section on /admin/users */
.archive-section {
  margin: 2rem 0 1rem;
  border-top: 1px dashed var(--border-strong);
  padding-top: 1rem;
}
.archive-section > summary {
  cursor: pointer;
  list-style: none;
  display: inline-block;
}
.archive-section > summary::-webkit-details-marker { display: none; }
.archive-section > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.5rem;
  color: var(--muted);
  transition: transform 0.15s;
}
.archive-section[open] > summary::before { transform: rotate(90deg); }
.archive-section__title {
  display: inline-block;
  margin: 0;
  color: var(--muted);
  font-size: 1.1rem;
}
.archive-section[open] .archive-section__title { color: var(--teal-dark); }
.archive-section .data-table { opacity: 0.85; }

/* Users index — card-based layout instead of a table */
.user-card-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.user-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.user-card__summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.85rem 1rem;
  flex-wrap: wrap;
}
.user-card__summary::-webkit-details-marker { display: none; }
.user-card__summary::before {
  content: "▸";
  color: var(--teal);
  transition: transform 0.15s;
  display: inline-block;
  flex-shrink: 0;
}
.user-card[open] > .user-card__summary::before { transform: rotate(90deg); }
.user-card[open] > .user-card__summary { border-bottom: 1px solid var(--border); background: #fafcfb; }
.user-card__info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.user-card__name { font-size: 1rem; color: var(--teal-ink); }
.user-card__meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.88rem;
}
.user-card__body {
  padding: 1rem;
}
.user-card__edit {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.7rem;
  padding: 0.5rem 0 0.8rem;
  align-items: end;
}
.user-card__edit .field { margin: 0; }
.user-card__edit button { grid-column: 1 / -1; justify-self: start; }
.user-card__edit p { grid-column: 1 / -1; }
@media (max-width: 720px) {
  .user-card__edit { grid-template-columns: 1fr; }
  .user-card__meta { font-size: 0.82rem; }
}

/* Audit log details popover */
.audit-details summary {
  cursor: pointer;
  color: var(--teal-dark);
  font-size: 0.85rem;
}
.audit-details pre {
  background: #f6f9f8;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.5rem 0.7rem;
  font-size: 0.78rem;
  max-width: 420px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Code block (settings) */
.code-block {
  background: #14413a;
  color: #eaf5f1;
  padding: 0.8rem 1rem;
  border-radius: 6px;
  font-family: ui-monospace, "Cascadia Mono", "Menlo", "Consolas", monospace;
  font-size: 0.85rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ============================================================
   Mobile polish pass
   ============================================================ */
@media (max-width: 860px) {
  .admin-header { position: relative; }
  .nav-toggle { display: inline-block; }
  .admin-nav {
    display: none;
    width: 100%;
    order: 10;
    flex-direction: column;
    gap: 0;
    margin: 0.6rem 0 0;
    padding: 0.5rem 0;
    border-top: 1px solid var(--border);
  }
  .admin-nav.is-open { display: flex; }
  .admin-nav > a {
    padding: 0.65rem 0.4rem;
    border-bottom: 1px solid var(--border);
  }
  .admin-nav > a:last-child { border-bottom: none; }
  .nav-more {
    display: block;
    width: 100%;
  }
  .nav-more > summary {
    display: block;
    padding: 0.65rem 0.4rem;
    border-bottom: 1px solid var(--border);
  }
  .nav-more__panel {
    position: static;
    box-shadow: none;
    border: none;
    padding: 0 0 0 1rem;
    min-width: 0;
  }
  .logout-form {
    width: 100%;
    order: 11;
    justify-content: flex-end;
    padding: 0.5rem 0 0.2rem;
    border-top: 1px solid var(--border);
  }
  .admin-user { display: inline; }

  .filter-grid { grid-template-columns: 1fr 1fr; }
  .card-grid { grid-template-columns: 1fr 1fr; }
  .chart-box canvas { height: 200px !important; }
}

@media (max-width: 640px) {
  /* Hide lower-priority columns on narrow screens */
  .data-table .col-hide-sm { display: none; }
}

@media (max-width: 520px) {
  .filter-grid { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  .form-meta { gap: 0.7rem; }
  .form-meta > span, .form-meta > a, .form-meta > form { width: 100%; }
  .btn { padding: 0.6rem 1rem; }
  .btn--lg { padding: 0.85rem 1rem; }
  /* Slightly bigger touch targets on member form */
  .member-form .field input,
  .member-form .field select,
  .member-form .field textarea { padding: 0.85rem 0.9rem; }
  .rating-input label { font-size: 2.4rem; padding: 0 0.2rem; }
}
