/* ============================================================================
   eFeasibility - design system
   Palette matches Feasibility_Configurator/styles.css exactly (bg/surface/
   surface-2/border/text/text-muted/accent/accent-hover/danger/danger-bg/ok/
   shadow/radius), so the two tools in this project look like one product.
   That stylesheet has no separate "warning" tone - it colors "required"
   badges with its danger color, so this does the same (--color-warning is
   an alias of --color-error) rather than inventing an amber not present in
   the source palette. Sidebar chrome doesn't exist in the source (a
   tab-based single page tool, no side nav). In light mode the sidebar is
   a light panel (same neutral family as the page, separated by a hairline
   border, not a solid dark block - a dark sidebar on a light page read as
   heavy/generic chrome rather than "light, clinical, non-heavy"). Dark
   mode keeps a dark sidebar, consistent with the rest of that theme. Light
   theme is the default; dark theme is applied via
   html[data-theme="dark"] (toggled + persisted to a cookie by
   theme-toggle.js, read back server-side in the layouts so there is no
   flash of the wrong theme on load) - deliberately NOT tied to
   prefers-color-scheme, so an OS dark-mode user still lands on light by
   default until they opt in.
   ============================================================================ */

:root {
  --color-bg: #f4f6f8;
  --color-surface: #ffffff;
  --color-surface-alt: #eef1f6;
  --color-border: #d7dee6;
  --color-text: #2c3e50;
  --color-text-muted: #6c7a89;
  --color-primary: #0072b2;
  --color-primary-hover: #3a5f6f;
  --color-primary-contrast: #ffffff;
  --color-accent: #0072b2;
  --color-success: #3d9970;
  --color-success-bg: rgba(61, 153, 112, 0.12);
  --color-warning: #c0392b;
  --color-warning-bg: #fdecea;
  --color-error: #c0392b;
  --color-error-bg: #fdecea;

  --sidebar-bg: #eef1f6;
  --sidebar-active-tint: rgba(0, 114, 178, 0.09);
  --sidebar-hover: rgba(44, 62, 80, 0.05);
  --sidebar-text: #6c7a89;
  --sidebar-text-strong: #2c3e50;
  --sidebar-active-bg: #0072b2;
  --sidebar-border: #d7dee6;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.06), 0 1px 8px rgba(0, 0, 0, 0.04);

  --radius-sm: 6px;
  --radius-md: 6px;
  --radius-lg: 10px;

  color-scheme: light;
}

html[data-theme="dark"] {
  --color-bg: #121212;
  --color-surface: #121212;
  --color-surface-alt: #323232;
  --color-border: #b0c4ce;
  --color-text: #eceff1;
  --color-text-muted: #b0c4ce;
  --color-primary: #5b8aa0;
  --color-primary-hover: #abdaf0;
  --color-primary-contrast: #ffffff;
  --color-accent: #5b8aa0;
  --color-success: #3d9970;
  --color-success-bg: rgba(61, 153, 112, 0.15);
  --color-warning: #c0392b;
  --color-warning-bg: #3a1f1f;
  --color-error: #c0392b;
  --color-error-bg: #3a1f1f;

  --sidebar-bg: #0a0a0a;
  --sidebar-active-tint: rgba(91, 138, 160, 0.18);
  --sidebar-hover: rgba(255, 255, 255, 0.05);
  --sidebar-text: #b0c4ce;
  --sidebar-text-strong: #eceff1;
  --sidebar-active-bg: #5b8aa0;
  --sidebar-border: rgba(255, 255, 255, 0.06);

  --shadow-sm: 0 1px 3px rgba(255, 255, 255, 0.08);
  --shadow-md: 0 1px 3px rgba(255, 255, 255, 0.08), 0 4px 6px rgba(255, 255, 255, 0.12);

  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  background: var(--color-bg);
  color: var(--color-text);
  transition: background-color 0.15s ease, color 0.15s ease;
}

h1, h2, h3, h4 {
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--color-text);
}

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

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

/* --- Theme toggle button ---------------------------------------------- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  margin: 0;
  border-radius: 999px;
  border: 1px solid var(--sidebar-border);
  background: transparent;
  color: var(--sidebar-text);
  cursor: pointer;
}
.theme-toggle:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-strong);
  opacity: 1;
}
.theme-toggle-icon {
  width: 15px;
  height: 15px;
}
html[data-theme="dark"] .theme-toggle-icon-sun {
  display: none;
}
html[data-theme="light"] .theme-toggle-icon-moon,
:root:not([data-theme]) .theme-toggle-icon-moon {
  display: none;
}

/* Standalone toggle for pages with no sidebar (login, snapshot interstitial) */
.theme-toggle-standalone {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  border-color: var(--color-border);
  color: var(--color-text-muted);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}
.theme-toggle-standalone:hover {
  color: var(--color-text);
}

.error-page {
  max-width: 480px;
  margin: 4rem auto;
  padding: 2rem;
  text-align: center;
}
.error-page h1 {
  margin-top: 0;
}

/* Phase 0 scaffold status page */
main.scaffold-status {
  max-width: 640px;
  margin: 4rem auto;
  padding: 2rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
main.scaffold-status ul {
  padding-left: 1.2rem;
  line-height: 1.8;
}

/* --- Login + Study Snapshot interstitial (no sidebar) ------------------ */
main.login-page,
main.snapshot-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.75rem;
  padding: 2rem;
}

.brand-lockup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.brand-logo {
  display: block;
  height: 34px;
  width: auto;
  filter:hue-rotate(120deg)
}
.brand-logo-lg {
  height: 52px;
}
.brand-lockup-sub {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.login-card,
.snapshot-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-md);
}

.snapshot-card {
  max-width: 640px;
}

.login-card h1,
.snapshot-card h1 {
  margin-top: 0;
  font-size: 1.4rem;
}

.login-subtitle {
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.92rem;
}

.login-cross-link {
  margin: 1.2rem 0 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-card label,
.snapshot-card label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.login-card input[type="password"],
.login-card input[type="text"] {
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 1rem;
  letter-spacing: 0.04em;
}
.login-card input:focus,
.snapshot-card input:focus,
.question-input input:focus,
.question-input textarea:focus,
.contact-field input:focus,
.contact-field select:focus,
.contact-field textarea:focus,
.admin-form input:focus,
.admin-form select:focus,
.admin-form textarea:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.consent-label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-weight: 400 !important;
  font-size: 0.85rem !important;
  color: var(--color-text-muted);
}

button {
  background: var(--color-primary);
  color: var(--color-primary-contrast);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: background-color 0.15s ease;
}
button:hover {
  background: var(--color-primary-hover);
}
.link-button:hover {
  background: initial;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.88rem;
}
.alert-error {
  background: var(--color-error-bg);
  color: var(--color-error);
  border: 1px solid var(--color-error);
}
.alert-success {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid var(--color-success);
}

.protocol-summary {
  margin: 1rem 0 1.5rem;
  line-height: 1.6;
}

/* --- App shell (sidebar + content) -------------------------------------- */
body.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 264px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-right: 1px solid var(--sidebar-border);
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  padding: 1.4rem 1.5rem;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-brand .brand-logo {
  height: 30px;
}
.sidebar-brand-subtitle {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sidebar-text);
  opacity: 0.75;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0;
  flex: 1;
  overflow-y: auto;
}

.nav-link {
  color: var(--sidebar-text);
  text-decoration: none;
  padding: 0.65rem 1.5rem;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
}
.nav-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-strong);
}
.nav-link.active {
  background: var(--sidebar-active-tint);
  border-left-color: var(--sidebar-active-bg);
  color: var(--sidebar-text-strong);
  font-weight: 600;
}
.nav-section-label {
  padding: 0.9rem 1.5rem 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sidebar-text);
  opacity: 0.6;
}
/* Theme row + Logout are grouped together and pinned to the bottom of the
   sidebar, in that order - the toggle sits directly above Logout. */
.sidebar-bottom {
  margin-top: auto;
  border-top: 1px solid var(--sidebar-border);
  padding-top: 0.5rem;
}

.sidebar-theme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 1.5rem;
}
.sidebar-footer-label {
  font-size: 0.78rem;
  color: var(--sidebar-text);
  opacity: 0.8;
}

.app-content {
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 980px;
}

/* --- Dashboard ----------------------------------------------------------- */
.dashboard-instructions {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-primary);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  margin: 1rem 0;
  font-size: 0.92rem;
  color: var(--color-text);
}
.dashboard-instructions p:first-child {
  margin-top: 0;
}
.dashboard-instructions p:last-child {
  margin-bottom: 0;
}

.stats-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin: 1.5rem 0;
}
@media (max-width: 800px) {
  .stats-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 1.25rem;
  border-radius: var(--radius-md);
}
.stat-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
}
.stat-value.stat-warning {
  color: var(--color-warning);
}
.stat-sub {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.3rem;
}

.progress-toggle {
  margin: 1rem 0;
}
.progress-toggle a {
  font-size: 0.88rem;
  text-decoration: none;
  border: 1px solid var(--color-border);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
}
.progress-toggle a:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.empty-state {
  color: var(--color-text-muted);
  font-style: italic;
}

.category-progress-row {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.3rem;
  margin-bottom: 0.9rem;
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: center;
}
.category-name a {
  font-weight: 600;
  text-decoration: none;
  color: var(--color-text);
}
.category-name a:hover {
  color: var(--color-primary);
}
.category-required-status {
  font-size: 0.8rem;
  margin-top: 0.3rem;
}
.text-warning {
  color: var(--color-warning);
}
.text-ok {
  color: var(--color-success);
}
.missing-required-details {
  margin-top: 0.4rem;
  font-size: 0.8rem;
}
.missing-required-details summary {
  cursor: pointer;
  color: var(--color-text-muted);
}
.missing-required-details ul {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
  color: var(--color-text-muted);
}

.ask-question-details {
  margin-top: 0.4rem;
  font-size: 0.8rem;
}
.ask-question-details summary {
  cursor: pointer;
  color: var(--color-primary);
}
.ask-question-details textarea {
  display: block;
  width: 100%;
  max-width: 480px;
  margin: 0.5rem 0;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: 0.85rem;
  resize: vertical;
}
.category-progress-bar-wrap {
  min-width: 220px;
}
.category-progress-pct {
  font-size: 0.85rem;
  text-align: right;
  margin-bottom: 0.35rem;
}
.progress-bar-track {
  width: 100%;
  background: var(--color-surface-alt);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  transition: width 0.3s ease;
}

.placeholder-page {
  color: var(--color-text-muted);
}

/* --- Questionnaire --------------------------------------------------------- */
.category-status-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}
.last-saved-hint {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.required-info {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  margin-bottom: 1rem;
}

.required-star {
  color: var(--color-warning);
  font-weight: 600;
  margin-left: 0.2rem;
}

.question-row {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  padding: 0.6rem 0;
}

/* Border lives on the row itself (not a separate <hr> sibling) so it
   disappears along with the row when a conditional question is hidden
   (display:none) - a standalone separator element has no visibility of its
   own and would otherwise pile up wherever several hidden questions sit in
   a row, leaving a stack of bare lines with nothing shown between them. */
.question-row + .question-row {
  border-top: 1px solid var(--color-border);
}

.question-row-label .question-text {
  font-weight: 700;
}

.question-text {
  flex: 3;
}

.help-tooltip {
  position: relative;
  display: inline-flex;
  vertical-align: middle;
  margin-left: 0.35rem;
  color: var(--color-text-muted);
  cursor: help;
}
.help-tooltip-icon {
  width: 15px;
  height: 15px;
}
.help-tooltip-bubble {
  display: none;
  position: absolute;
  z-index: 5;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 260px;
  padding: 0.5rem 0.7rem;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.4;
  white-space: normal;
}
.help-tooltip:hover .help-tooltip-bubble,
.help-tooltip:focus .help-tooltip-bubble,
.help-tooltip:focus-visible .help-tooltip-bubble {
  display: block;
}

.question-input {
  flex: 2;
  display: flex;
  align-items: center;
}

.question-input input[type="text"],
.question-input input[type="number"],
.question-input input[type="date"],
.question-input textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.95rem;
  font-family: inherit;
}

.radio-inline,
.checkbox-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}
.radio-inline label,
.checkbox-inline label {
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.attachment-input {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.attachment-current {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.attachment-size,
.attachment-hint {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}
.attachment-remove {
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
}

.questionnaire-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.btn-reset {
  color: var(--color-warning);
  text-decoration: none;
  font-size: 0.9rem;
}

.readonly-badge {
  color: var(--color-text-muted);
}

/* --- Site Contact Details --------------------------------------------------- */
.group-select-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

#group-select {
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.95rem;
  margin-bottom: 1rem;
  min-width: 260px;
}

.contact-layout {
  display: grid;
  grid-template-columns: 5fr 3fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 900px) {
  .contact-layout {
    grid-template-columns: 1fr;
  }
}

.contact-section {
  background: var(--color-surface-alt);
  border-left: 3px solid var(--color-primary);
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
}
.contact-section h4 {
  margin-top: 0;
  color: var(--color-primary);
}
.contact-section h4 i {
  margin-right: 0.4rem;
}

.contact-field {
  margin-bottom: 0.8rem;
}
.contact-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  color: var(--color-text-muted);
}
.contact-field input,
.contact-field select,
.contact-field textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.9rem;
  font-family: inherit;
}
.contact-field textarea {
  min-height: 70px;
}

.map-sidebar {
  position: sticky;
  top: 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
}
.map-sidebar h4 {
  margin-top: 0;
}
.map-hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}
#contact-map {
  height: 480px;
  border-radius: var(--radius-sm);
}
#viewer-map {
  height: 560px;
  border-radius: var(--radius-sm);
}

.map-status-box {
  background: var(--color-surface);
  color: var(--color-text);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  box-shadow: var(--shadow-sm);
}
.map-status-ok {
  color: var(--color-success);
}
.map-status-warn {
  color: var(--color-error);
}
.map-status-loading {
  color: var(--color-text-muted);
}

/* --- Admin panel ------------------------------------------------------------- */
.admin-page h1, .admin-dashboard h1 {
  margin-top: 0;
}

.hint {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 2rem;
  font-size: 0.9rem;
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--color-border);
}
.admin-table th {
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.admin-table-actions {
  display: flex;
  gap: 0.8rem;
  align-items: center;
}
.inline-form {
  display: inline;
}
.link-button {
  background: none;
  border: none;
  color: var(--color-primary);
  padding: 0;
  margin: 0;
  font-size: inherit;
  font-weight: 400;
  cursor: pointer;
  text-decoration: underline;
}
.row-highlight {
  background: var(--color-warning-bg);
}
.pin-reveal {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.1rem;
  letter-spacing: 2px;
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  max-width: 520px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.3rem;
}
.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
}
.admin-form label:has(input[type="checkbox"]) {
  flex-direction: row;
  align-items: center;
}
.admin-form-inline {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  max-width: none;
  gap: 0.9rem 1.2rem;
}
.admin-form-inline label {
  max-width: 220px;
}
.bulk-actions-bar {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  font-size: 0.88rem;
}
.pagination-status {
  color: var(--color-text-muted);
}
.admin-form input[type="text"],
.admin-form input[type="number"],
.admin-form input[type="email"],
.admin-form input[type="file"],
.admin-form select,
.admin-form textarea {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 400;
}

.import-forms {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}
.admin-form-box .export-btn {
  display: inline-block;
  margin-top: 0.9rem;
}
@media (max-width: 800px) {
  .import-forms {
    grid-template-columns: 1fr;
  }
}
.admin-form-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.3rem;
}
.admin-form-box form {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-top: 0.8rem;
}

/* --- Results Viewer (/view) --------------------------------------------- */
.viewer-page h1 {
  margin-top: 0;
}
.viewer-page-hint {
  color: var(--color-text-muted);
  font-size: 0.88rem;
  margin-top: -0.5rem;
}

.funnel-widget {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin: 1rem 0 1.5rem;
}
.funnel-chart-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem;
}
.funnel-chart-box h4 {
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}
/* Chart.js with responsive:true manages the <canvas>'s own size via a
   ResizeObserver on its parent - giving the canvas itself a fixed CSS
   height (especially !important) fights that and typically collapses the
   chart to blank/zero-size. The fixed height belongs on this wrapper
   instead; Chart.js sizes the canvas to fill it. */
.chart-container {
  position: relative;
  height: 200px;
}
@media (max-width: 700px) {
  .funnel-widget {
    grid-template-columns: 1fr;
  }
}
.question-detail-charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  max-width: 900px;
  margin-bottom: 1.2rem;
}
@media (max-width: 700px) {
  .question-detail-charts {
    grid-template-columns: 1fr;
  }
}
.question-detail-link {
  font-size: 0.75rem;
  font-weight: 400;
  white-space: nowrap;
}

.export-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1rem 0 1.5rem;
}
.export-btn {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  background: var(--color-primary);
  color: var(--color-primary-contrast);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  transition: background-color 0.15s ease;
}
.export-btn:hover {
  background: var(--color-primary-hover);
}
.export-btn-secondary {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-border);
}
.export-btn-secondary:hover {
  background: var(--color-surface-alt);
  color: var(--color-primary);
}

.table-filter-input {
  display: block;
  width: 100%;
  max-width: 320px;
  margin-bottom: 0.8rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.88rem;
}
.note-preview {
  color: var(--color-text-muted);
  font-style: italic;
}
.compare-subset-box {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1.2rem;
  margin-bottom: 1.2rem;
}
.compare-subset-box summary {
  cursor: pointer;
  font-weight: 600;
}
.compare-subset-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.2rem;
  margin: 0.8rem 0;
}
.compare-subset-checkboxes label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.88rem;
  font-weight: normal;
}
.compare-subset-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.reviewer-note-box {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem;
  margin-bottom: 1.5rem;
}
.reviewer-note-box h4 {
  margin: 0 0 0.2rem;
}
.reviewer-note-textarea {
  display: block;
  width: 100%;
  max-width: 640px;
  margin: 0.6rem 0;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  resize: vertical;
}
table[data-filterable] thead th[data-sort-key] {
  cursor: pointer;
  user-select: none;
}
table[data-filterable] thead th[data-sort-key]:hover {
  color: var(--color-primary);
}
table[data-filterable] thead th[data-sort-key][data-sort-dir]::after {
  content: attr(data-sort-dir);
  margin-left: 0.3em;
  font-size: 0.7em;
}
table[data-filterable] thead th[data-sort-key][data-sort-dir="asc"]::after {
  content: "▲";
}
table[data-filterable] thead th[data-sort-key][data-sort-dir="desc"]::after {
  content: "▼";
}

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.status-badge-complete {
  background: var(--color-success-bg);
  color: var(--color-success);
}
.status-badge-in_progress {
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
}
.status-badge-never_logged_in {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.status-badge-undecided {
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
}
.status-badge-selected {
  background: var(--color-success-bg);
  color: var(--color-success);
}
.status-badge-rejected {
  background: var(--color-error-bg);
  color: var(--color-error);
}
.status-badge-reserve {
  background: rgba(0, 114, 178, 0.12);
  color: var(--color-primary);
}
.status-badge-on_hold {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.status-badge-not_started {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}
.status-badge-active {
  background: var(--color-success-bg);
  color: var(--color-success);
}
.status-badge-inactive {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}
.status-badge-deleted {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.report-header {
  margin-bottom: 1.2rem;
}
.report-header h1 {
  margin-bottom: 0.2rem;
}
.report-meta {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}
.report-section {
  margin-bottom: 1.8rem;
}
.report-section h2 {
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.report-table td, .report-table th {
  text-align: left;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}
.report-table th {
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.report-table-question {
  color: var(--color-text-muted);
  width: 55%;
}
.report-table-answer {
  font-weight: 500;
}
.report-table-label td {
  font-weight: 700;
  color: var(--color-primary);
  border-bottom: none;
  padding-top: 1rem;
}
.report-table-striped tbody tr:nth-child(even) {
  background: var(--color-surface-alt);
}

.matrix-scroll {
  overflow-x: auto;
  margin-bottom: 1rem;
}
.matrix-table {
  min-width: 100%;
}
.matrix-table th, .matrix-table td {
  white-space: normal;
  overflow-wrap: break-word;
  max-width: 260px;
}
/* Higher specificity than ".matrix-table th, .matrix-table td" above is
   required here, or the wider min/max-width loses the cascade regardless of
   source order - a plain ".matrix-wrap-col" alone has the same specificity
   as ".matrix-table td" and would lose ties going the wrong way. Used for
   the frozen question/site label column, which tends to run longer than a
   typical answer and so gets a bit more room. */
.matrix-table .matrix-wrap-col {
  min-width: 220px;
  max-width: 320px;
}
.matrix-question-col {
  position: sticky;
  left: 0;
  background: var(--color-surface);
}

/* --- Printable reports (/view/*​/print) ---------------------------------- */
.print-toolbar {
  padding: 1rem;
  text-align: right;
}
.print-report {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem 2rem;
  background: var(--color-bg);
  color: var(--color-text);
}
@media print {
  .no-print {
    display: none !important;
  }
  .print-report {
    max-width: none;
    padding: 0;
  }
  .report-section {
    page-break-inside: avoid;
  }
}

/* Marketing homepage (myaddress.com/) */
.marketing-header {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}
.marketing-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.marketing-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-text);
  text-decoration: none;
}
.marketing-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}
.marketing-hero {
  text-align: center;
  max-width: 760px;
  margin: 0 auto 3rem;
}
.marketing-hero h1 {
  font-size: 2.1rem;
  margin-bottom: 0.8rem;
}
.marketing-hero-sub {
  color: var(--color-text-muted);
  font-size: 1.05rem;
}
.marketing-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.2rem;
  margin-bottom: 3.5rem;
}
.marketing-feature {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.2rem 1.4rem;
}
.marketing-feature h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
}
.marketing-feature p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.92rem;
}
.marketing-forms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}
.marketing-form-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}
.marketing-form-card h2 {
  margin-top: 0;
}
.marketing-footer {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding: 1.5rem;
}
