/*
 * CommSuite shared stylesheet.
 * Applied across public (external) and authenticated (internal) pages so both
 * flows share a single, consistent look and feel.
 *
 * Design system: dark, high-contrast dispatch console. Full-bleed layout with
 * a persistent left sidebar for navigation (collapses to a top bar with a
 * slide-in drawer on phones), desaturated status colors, and a single accent
 * color reserved for primary actions.
 *
 * Contents
 *   1.  Design tokens
 *   2.  Base elements
 *   3.  App shell + sidebar navigation (includes its own breakpoints)
 *   4.  Page layout (full-bleed pages, page header, sub-navigation)
 *   5.  Cards, stats, detail lists
 *   6.  Badges
 *   7.  Alerts
 *   8.  Buttons + action rows
 *   9.  Forms
 *   10. Tables + pagination
 *   11. Layout patterns (compose, admin grid, reference grid)
 *   12. Landing page
 *   13. Incident history accordion
 *   14. Camera barcode scanner
 *   15. Shift Log / End of Tour
 *   16. Utilities
 *   17. Responsive overrides (everything except navigation)
 *	 18. Error Pages
 */


/* ====================================================================== *
 * 1. Design tokens
 * ====================================================================== */

:root {
  --color-bg: #12151a;
  --color-surface: #181c23;
  --color-surface-alt: #1f242c;
  --color-sidebar: #15181e;
  --color-border: #2a2f38;
  --color-text: #e4e7eb;
  --color-muted: #8b93a1;
  --color-heading: #f2f4f6;

  /* Single accent, used sparingly for primary actions/links only. */
  --color-accent: #3d8bd9;
  --color-accent-hover: #5a9de0;
  --color-accent-contrast: #0b1016;

  /* Desaturated status/priority colors (no bright SaaS gradient greens/reds). */
  --color-status-low: #5c6b73;
  --color-status-low-bg: #1d2429;
  --color-status-normal: #4c8a94;
  --color-status-normal-bg: #17262a;
  --color-status-high: #b08a52;
  --color-status-high-bg: #2a2318;
  --color-status-urgent: #a85c56;
  --color-status-urgent-bg: #2a1e1d;

  --color-error: #c07a76;
  --color-error-bg: #241819;
  --color-success: #7fa88a;
  --color-success-bg: #182420;

  --focus-ring: 0 0 0 3px rgba(61, 139, 217, 0.25);

  --radius: 4px;
  --sidebar-width: 220px;
  --topbar-height: 52px;
}


/* ====================================================================== *
 * 2. Base elements
 * ====================================================================== */

* {
  box-sizing: border-box;
}

html {
  background-color: var(--color-bg);
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100vh;
}

h1, h2, h3 {
  color: var(--color-heading);
  font-weight: 600;
}

a {
  color: var(--color-accent);
}


/* ====================================================================== *
 * 3. App shell + sidebar navigation
 *      > 1024px     full sidebar
 *      769-1024px   narrower sidebar, same groups
 *      <= 768px     top bar + slide-in drawer, same groups
 * ====================================================================== */

.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--color-sidebar);
  border-right: 1px solid var(--color-border);
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--color-border);
}

.sidebar .brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-heading);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.nav-toggle {
  display: none;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 0 12px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  padding-top: 14px;
}

.nav-group-label {
  padding: 0 20px 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-muted);
  opacity: 0.75;
}

.sidebar-nav a {
  display: block;
  color: var(--color-muted);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 8px 20px 8px 17px;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  color: var(--color-text);
  background: var(--color-surface-alt);
}

.sidebar-nav a.active {
  color: var(--color-heading);
  border-left-color: var(--color-accent);
  background: var(--color-surface-alt);
}

.sidebar-nav a:focus-visible,
.nav-toggle:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

.nav-footer {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
}

.sidebar-nav .nav-logout:hover {
  color: var(--color-error);
}

.nav-scrim {
  display: none;
}

.main-content {
  flex: 1 1 auto;
  min-width: 0;
  padding: 28px 32px 56px;
  width: 100%;
}

/* Tablet / small laptop: same layout, tighter. */
@media (min-width: 769px) and (max-width: 1024px) {
  :root {
    --sidebar-width: 188px;
  }

  .sidebar-top {
    padding: 16px 16px 12px;
  }

  .nav-group-label {
    padding: 0 16px 6px;
  }

  .sidebar-nav a {
    padding: 8px 16px 8px 13px;
    font-size: 0.86rem;
  }

  .main-content {
    padding: 24px 24px 48px;
  }
}

/* Phones (all sizes): top bar with a drawer. */
@media (max-width: 768px) {
  .app-shell {
    flex-direction: column;
    min-height: auto;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    flex: none;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    padding-top: env(safe-area-inset-top, 0px);
  }

  .sidebar-top {
    height: var(--topbar-height);
    padding: 0 6px 0 16px;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    border-bottom: none;
  }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    color: var(--color-text);
  }

  .nav-toggle:hover {
    background: var(--color-surface-alt);
  }

  /* Three-bar icon that turns into an X when open. */
  .nav-toggle-bars,
  .nav-toggle-bars::before,
  .nav-toggle-bars::after {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    transition: transform 0.2s ease, background 0.2s ease;
  }

  .nav-toggle-bars {
    position: relative;
  }

  .nav-toggle-bars::before,
  .nav-toggle-bars::after {
    content: "";
    position: absolute;
    left: 0;
  }

  .nav-toggle-bars::before {
    top: -6px;
  }

  .nav-toggle-bars::after {
    top: 6px;
  }

  .nav-toggle[aria-expanded="true"] .nav-toggle-bars {
    background: transparent;
  }

  .nav-toggle[aria-expanded="true"] .nav-toggle-bars::before {
    transform: translateY(6px) rotate(45deg);
  }

  .nav-toggle[aria-expanded="true"] .nav-toggle-bars::after {
    transform: translateY(-6px) rotate(-45deg);
  }

  /* Drawer sits below the top bar so the close button stays reachable. */
  .sidebar-nav {
    position: fixed;
    top: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
    bottom: 0;
    left: 0;
    z-index: 40;
    width: min(300px, 86vw);
    background: var(--color-sidebar);
    border-right: 1px solid var(--color-border);
    padding: 4px 0 calc(12px + env(safe-area-inset-bottom, 0px));
    padding-left: env(safe-area-inset-left, 0px);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
  }

  body.nav-open .sidebar-nav {
    transform: none;
    visibility: visible;
    transition: transform 0.2s ease;
  }

  .nav-scrim {
    display: block;
    position: fixed;
    top: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  body.nav-open .nav-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  body.nav-open {
    overflow: hidden;
  }

  /* 44px touch targets. */
  .sidebar-nav a {
    padding: 11px 20px 11px 17px;
    font-size: 0.95rem;
  }

  .main-content {
    padding: 20px 16px calc(32px + env(safe-area-inset-bottom, 0px));
  }
}

/* Very narrow phones (SE, older Androids). */
@media (max-width: 360px) {
  .main-content {
    padding-left: 12px;
    padding-right: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar-nav,
  .nav-scrim,
  .nav-toggle-bars,
  .nav-toggle-bars::before,
  .nav-toggle-bars::after {
    transition: none !important;
  }
}


/* ====================================================================== *
 * 4. Page layout
 * ====================================================================== */

/* Simple full-bleed page (login, public forms) without a sidebar. */
.page {
  width: 100%;
  margin: 0;
  padding: 24px 32px 48px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}

.page-header .brand {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-heading);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.page-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header nav a {
  margin: 0;
  color: var(--color-muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.page-header nav a:hover {
  color: var(--color-accent);
}

.page-subtitle {
  color: var(--color-muted);
  font-size: 0.9rem;
  margin: -8px 0 20px;
}

.back-link {
  display: inline-block;
  margin-bottom: 14px;
  font-size: 0.85rem;
  color: var(--color-muted);
  text-decoration: none;
}

.back-link:hover {
  color: var(--color-accent);
}

/* Secondary (section-level) tab bar under the page header, e.g. Radio Inventory. */
.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--color-border);
}

.subnav a {
  color: var(--color-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.subnav a:hover {
  color: var(--color-text);
  background: var(--color-surface-alt);
}

.subnav a.active {
  color: var(--color-heading);
  border-bottom-color: var(--color-accent);
}


/* ====================================================================== *
 * 5. Cards, stats, detail lists
 * ====================================================================== */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

/* Compact stat row (page-level summary counts above the fold). */
.stat-grid-compact {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 20px;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.stat-card.is-alert {
  border-color: var(--color-status-high);
  background: var(--color-status-high-bg);
}

.stat-value {
  display: block;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--color-heading);
  font-variant-numeric: tabular-nums;
}

.stat-card.is-alert .stat-value {
  color: var(--color-status-high);
}

.stat-label {
  display: block;
  font-size: 0.78rem;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 4px;
}

.empty-state {
  color: var(--color-muted);
  font-size: 0.88rem;
  padding: 12px 0 4px;
}

/* Detail view: key/value info list. */
.info-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 20px;
  margin: 0;
}

.info-list dt {
  color: var(--color-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 2px;
}

.info-list dd {
  margin: 0;
  color: var(--color-text);
}


/* ====================================================================== *
 * 6. Badges
 *    All variants reuse the status palette so meaning reads consistently.
 * ====================================================================== */

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--color-status-urgent-bg);
  color: var(--color-status-urgent);
  margin-left: 8px;
}

/* Low / neutral */
.badge-low,
.badge-public,
.badge-access-viewer {
  background: var(--color-status-low-bg);
  color: var(--color-status-low);
}

/* Normal / informational */
.badge-normal,
.badge-internal,
.badge-dispatch-initial {
  background: var(--color-status-normal-bg);
  color: var(--color-status-normal);
}

/* High / attention */
.badge-high,
.badge-dispatch-update,
.badge-access-editor {
  background: var(--color-status-high-bg);
  color: var(--color-status-high);
}

/* Urgent / privileged */
.badge-urgent,
.badge-access-admin {
  background: var(--color-status-urgent-bg);
  color: var(--color-status-urgent);
}

/* Success / complete */
.badge-success,
.badge-dispatch-complete {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.badge-login {
  background: var(--color-surface-alt);
  color: var(--color-muted);
  font-size: 0.62rem;
  padding: 2px 8px;
  margin-left: 0;
}


/* ====================================================================== *
 * 7. Alerts
 * ====================================================================== */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.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);
}


/* ====================================================================== *
 * 8. Buttons + action rows
 * ====================================================================== */

button,
input[type="submit"] {
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 9px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

button:hover,
input[type="submit"]:hover {
  background: var(--color-accent-hover);
}

button:disabled,
input[type="submit"]:disabled {
  background: var(--color-surface-alt);
  color: var(--color-muted);
  cursor: not-allowed;
}

/* Secondary / non-primary actions should not use the accent color. */
.btn-secondary {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-border);
}

.link-button {
  background: none;
  border: none;
  color: var(--color-accent);
  cursor: pointer;
  padding: 0;
  margin-top: 6px;
}

.actions-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* Inline row-action forms (e.g. per-row update/remove in a cart table). */
.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}


/* ====================================================================== *
 * 9. Forms
 * ====================================================================== */

/* --- Base fields ------------------------------------------------------ */

form {
  margin-bottom: 16px;
}

.form-row {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 480px;
}

.form-row label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--color-text);
}

.form-row .hint {
  font-size: 0.8rem;
  color: var(--color-muted);
  font-weight: normal;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="file"],
select,
textarea {
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  background: var(--color-surface-alt);
  color: var(--color-text);
  width: 100%;
  max-width: 480px;
}

input::placeholder,
textarea::placeholder {
  color: var(--color-muted);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: var(--focus-ring);
}

.qty-input {
  width: 70px;
  max-width: 70px;
}

.req-mark {
  color: var(--color-status-urgent);
}

.hint-block {
  color: var(--color-muted);
  font-size: 0.85rem;
  font-style: italic;
  margin: -6px 0 16px;
}

.form-actions {
  margin-top: 8px;
}

.disclaimer-block {
  margin-top: 20px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--color-surface-alt);
  color: var(--color-muted);
  font-size: 0.88rem;
  border: 1px dashed var(--color-border);
}

/* --- Filter bar (inline row of short fields) ------------------------- */

.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: flex-end;
  padding-bottom: 10px;
}

.filter-form .form-row {
  margin-bottom: 0;
  max-width: 220px;
}

.filter-form label.checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

/* --- Multi-section forms (ticket submission, time sheets) ------------ */

.form-section {
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--color-border);
}

.form-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.form-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
  margin: 0 0 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 20px;
  max-width: none;
}

.form-grid .form-row {
  max-width: none;
}

.ticket-form-card {
  max-width: 760px;
}

.timesheet-form-card {
  max-width: 860px;
}

.overtime-allocation-toggle {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

.overtime-toggle-options {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.overtime-toggle-options label {
  position: relative;
  flex: 1;
  cursor: pointer;
}

.overtime-toggle-options input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.overtime-toggle-options span {
  display: block;
  padding: 12px 8px;
  text-align: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface-alt);
}

.overtime-toggle-options input:checked + span {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  border-color: var(--color-accent);
}

.overtime-toggle-options input:focus-visible + span {
  box-shadow: var(--focus-ring);
}

.run-card-form-card {
  max-width: 1120px;
}

/* Wider ticket forms: 3-4 fields per row when wide, 1 when narrow. */
.ticket-form-card .form-grid,
.ticket-form-wide .form-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.ticket-form-card #description,
.ticket-form-wide #description {
  min-height: 140px;
}

/* Category select doesn't need to be full width. */
.ticket-form-card #categorySelect,
.ticket-form-card .select-wrap:has(#categorySelect),
.ticket-form-wide #categorySelect,
.ticket-form-wide .select-wrap:has(#categorySelect) {
  max-width: 480px;
}

.ticket-fields {
  opacity: 0;
  transition: opacity 0.15s ease;
}

.ticket-fields.is-visible {
  opacity: 1;
}

/* --- Custom select chevron ------------------------------------------- */

.select-wrap {
  position: relative;
  max-width: 480px;
}

.select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  max-width: none;
}

.select-wrap select.input-invalid {
  border-color: var(--color-error);
}

.select-wrap::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--color-muted);
  border-bottom: 2px solid var(--color-muted);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}

.select-wrap-search {
  display: flex;
  flex-direction: column;
}

.select-wrap-search .select-search {
  margin: 0;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.select-wrap-search select {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.select-wrap.select-wrap-search::after {
  top: auto;
  bottom: 16px;
  transform: rotate(45deg);
}

/* --- Searchable combo (dispatcher picker, etc.) ----------------------- */

.combo {
  position: relative;
}

.combo .select-search {
  width: 100%;
  max-width: none;
}

.combo-list {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 50;
  margin: 2px 0 0;
  padding: 4px 0;
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
  background: var(--color-surface-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

.combo-list[hidden] {
  display: none;
}

.combo-list li {
  padding: 7px 10px;
  cursor: pointer;
  font-size: 0.85rem;
}

.combo-list li.is-active,
.combo-list li:hover {
  background: var(--color-surface);
  color: var(--color-heading);
}

.combo-list li.is-selected {
  font-weight: 600;
  border-left: 2px solid var(--color-accent);
}

.combo-list li.combo-empty {
  color: var(--color-muted);
  cursor: default;
}

/* --- Attachments: drag-and-drop zone + file list ---------------------- */

.dropzone {
  max-width: 480px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface-alt);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  color: var(--color-muted);
}

.dropzone:hover,
.dropzone:focus {
  border-color: var(--color-accent);
  outline: none;
}

.dropzone.is-dragging {
  border-color: var(--color-accent);
  background: var(--color-surface);
  color: var(--color-text);
}

.dropzone-icon {
  font-size: 1.3rem;
  color: var(--color-accent);
  margin-bottom: 6px;
}

.dropzone-text {
  font-size: 0.85rem;
}

.dropzone-text strong {
  color: var(--color-text);
}

.file-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.file-list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface-alt);
  font-size: 0.82rem;
}

.file-list-name {
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-list-size {
  color: var(--color-muted);
  flex: 0 0 auto;
}

/* --- Repeating rows (radio system assignments, time sheet entries) ---- */

.repeat-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.system-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 10px;
  align-items: center;
}

.system-row input {
  max-width: none;
}

.repeatable-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 14px 0 10px;
}

.repeatable-entry-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.repeatable-entry {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--color-surface-alt);
}

.lookup-button-row {
  justify-content: flex-end;
}

.lookup-summary {
  margin-top: 10px;
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface-alt);
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.response-matrix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.response-matrix-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--color-surface-alt);
}

.response-matrix-card h4 {
  margin: 0 0 14px;
}

/* --- Recipient group checklist: scannable, scrollable multi-select ---- */

.group-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 8px;
  background: var(--color-surface-alt);
}

.group-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
}

.group-option:hover {
  background: var(--color-surface);
}

.group-option input[type="checkbox"] {
  width: auto;
  margin: 3px 0 0;
}

.group-option-meta {
  display: block;
  color: var(--color-muted);
  font-size: 0.78rem;
  margin-top: 2px;
}


/* ====================================================================== *
 * 10. Tables + pagination
 *     Data-dense tables on desktop/tablet; stacked cards on phones (see 17).
 * ====================================================================== */

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  font-size: 0.85rem;
}

table th,
table td {
  border-bottom: 1px solid var(--color-border);
  padding: 7px 10px;
  text-align: left;
  white-space: nowrap;
}

table th {
  background: var(--color-surface-alt);
  color: var(--color-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
}

table tbody tr:hover {
  background: var(--color-surface-alt);
}

/* Tabular figures for numeric columns (ticket #s, timestamps) so they align. */
.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

tr.sla-breached,
tr.sla-breached:hover {
  background-color: var(--color-status-urgent-bg);
}

.pagination {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.pagination a {
  color: var(--color-accent);
  text-decoration: none;
}

.pagination .disabled {
  color: var(--color-muted);
  pointer-events: none;
  opacity: 0.5;
}

.pagination-wrap {
  justify-content: space-between;
}


/* ====================================================================== *
 * 11. Layout patterns
 * ====================================================================== */

/* Compose: primary form + sticky context panel (open incidents, recipient
 * preview) so an operator isn't scrolling away from what they're sending. */
.compose-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
  margin-bottom: 20px;
}

.sidebar-panel {
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Admin setup: short related forms side by side instead of stacked. */
.admin-forms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.admin-forms-grid .card {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
}

.admin-forms-grid form {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.admin-forms-grid .form-row {
  max-width: none;
  margin-bottom: 0;
}

.admin-forms-grid button {
  align-self: flex-start;
  margin-top: auto;
}

/* Reference data (Groups / Contacts): side by side on wide screens. */
.reference-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
  align-items: start;
}

.reference-grid .card {
  margin-bottom: 0;
}


/* ====================================================================== *
 * 12. Landing page: hero intro + grouped action cards
 * ====================================================================== */

.hero {
  padding: 12px 0 32px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 28px;
}

.hero-eyebrow {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-accent);
  margin-bottom: 10px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: 2rem;
}

.hero-subtitle {
  color: var(--color-muted);
  font-size: 0.95rem;
  margin: 0;
  max-width: 520px;
}

.action-section {
  margin-bottom: 28px;
}

.action-section:last-child {
  margin-bottom: 0;
}

.section-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
  margin: 0 0 12px;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.action-card {
  position: relative;
  display: block;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px 20px 20px;
  text-decoration: none;
  color: var(--color-text);
  transition: border-color 0.12s ease, background 0.12s ease;
}

.action-card:hover {
  border-color: var(--color-accent);
  background: var(--color-surface-alt);
}

.action-card-title {
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--color-heading);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.action-card-desc {
  color: var(--color-muted);
  font-size: 0.85rem;
  margin: 0;
  padding-right: 24px;
}

.action-card-arrow {
  position: absolute;
  right: 18px;
  top: 18px;
  color: var(--color-muted);
  font-size: 1rem;
}

.action-card:hover .action-card-arrow {
  color: var(--color-accent);
}

.action-card-login {
  border-style: dashed;
}


/* ====================================================================== *
 * 13. Incident history accordion
 *     One line per entry until opened; native <details>, no JS. Also used
 *     by Recent Shift Logs (section 15).
 * ====================================================================== */

.incident-entry {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  background: var(--color-surface);
}

.incident-entry:last-child {
  margin-bottom: 0;
}

.incident-entry[open] {
  border-color: var(--color-accent);
}

.incident-entry summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.incident-entry summary::-webkit-details-marker {
  display: none;
}

.incident-entry summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--color-muted);
  border-bottom: 2px solid var(--color-muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  flex: 0 0 auto;
  margin-left: 8px;
}

.incident-entry[open] summary::after {
  transform: rotate(-135deg);
}

.incident-summary-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.incident-summary-title {
  font-weight: 600;
  color: var(--color-heading);
}

.incident-summary-meta {
  font-size: 0.82rem;
  color: var(--color-muted);
}

.incident-summary-stats {
  display: flex;
  gap: 18px;
  font-size: 0.82rem;
  color: var(--color-muted);
  white-space: nowrap;
}

.incident-summary-stats strong {
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.incident-entry-body {
  padding: 4px 18px 18px;
  border-top: 1px solid var(--color-border);
}

.incident-groups {
  padding: 14px 0 4px;
  color: var(--color-muted);
  font-size: 0.85rem;
}


/* ====================================================================== *
 * 14. Camera barcode scanner
 * ====================================================================== */

.camera-scanner {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.camera-scanner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.camera-scanner__frame {
  position: relative;
  width: 100%;
  max-width: 480px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}

.camera-scanner__preview {
  display: block;
  width: 100%;
  background: #000;
  min-height: 240px;
  object-fit: cover;
}

.camera-scanner__focus-box {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(76%, 320px);
  max-width: calc(100% - 24px);
  aspect-ratio: 2.9 / 1;
  transform: translate(-50%, -50%);
  border: 3px solid rgba(242, 244, 246, 0.95);
  border-radius: 12px;
  box-shadow:
    0 0 0 999px rgba(11, 16, 22, 0.4),
    0 0 0 1px rgba(61, 139, 217, 0.75) inset,
    0 0 24px rgba(61, 139, 217, 0.25);
  pointer-events: none;
}

@supports not (aspect-ratio: 1 / 1) {
  .camera-scanner__focus-box {
    height: calc(min(76%, 320px) * 0.3448275862);
  }
}

.camera-scan-debug {
  max-width: 480px;
  padding: 12px 16px;
  border: 1px dashed var(--color-status-high);
  border-radius: var(--radius);
  background: var(--color-status-high-bg);
  color: var(--color-text);
  font-size: 0.88rem;
}

.camera-scan-debug strong {
  display: block;
  margin-bottom: 8px;
  color: var(--color-status-high);
}

.camera-scan-debug__list {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 12px;
}

.camera-scan-debug__list dt {
  color: var(--color-muted);
  font-weight: 600;
}

.camera-scan-debug__list dd {
  margin: 0;
  word-break: break-word;
}


/* ====================================================================== *
 * 15. Shift Log / End of Tour
 * ====================================================================== */

.shiftlog-header {
  display: block;
}

.shiftlog-header h1 {
  margin: 0 0 4px;
}

.shiftlog-header p {
  margin: 0;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.shiftlog-form {
  margin-bottom: 0;
}

.shiftlog-draft-dialog,
.inventory-dialog {
  width: min(440px, calc(100% - 32px));
  padding: 24px;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.inventory-dialog {
  color-scheme: dark;
  width: min(1100px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  overscroll-behavior: contain;
}

.inventory-dialog .card {
  margin-bottom: 0;
  padding: 0;
  border: 0;
}

.inventory-dialog .form-actions {
  position: sticky;
  bottom: -24px;
  padding: 16px 0;
  background: var(--color-surface);
}

.dialog-cancel {
  display: inline-block;
  padding: 9px 18px;
  border-radius: var(--radius);
  text-decoration: none;
}

.shiftlog-draft-dialog::backdrop,
.inventory-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.shiftlog-draft-dialog h2,
.inventory-dialog h2,
.inventory-dialog h3 {
  margin-top: 0;
}

.shiftlog-draft-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* Let fields fill their grid cells instead of the global 480px cap. */
.shiftlog-form .form-row {
  max-width: none;
  margin-bottom: 0;
}

.shiftlog-form input[type="text"],
.shiftlog-form input[type="date"],
.shiftlog-form select,
.shiftlog-form textarea,
.shiftlog-form .select-wrap {
  max-width: none;
}

.shiftlog-section .form-section-title {
  margin-bottom: 14px;
}

.shiftlog-section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}

.shiftlog-section-head .form-section-title {
  margin: 0;
}

.shiftlog-count {
  font-size: 0.8rem;
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
}

/* Shift details: date / shift / supervisor on one row. */
.shiftlog-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px 20px;
}

/* Console seating: compact card per console. */
.console-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
}

.console-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-border);
  border-radius: var(--radius);
}

.console-card.is-staffed {
  border-left-color: var(--color-accent);
}

.console-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.console-card-head .select-wrap {
  flex: 1;
  min-width: 0;
}

.console-num {
  flex: 0 0 2.6em;
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
}

.console-card.is-staffed .console-num {
  color: var(--color-heading);
}

.console-card select,
.console-card input[type="text"] {
  padding: 6px 8px;
  font-size: 0.85rem;
  background: var(--color-surface);
}

.console-card .select-wrap select {
  padding-right: 30px;
}

/* Narrative: major events + shift notes side by side. */
.shiftlog-narrative {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 20px;
}

.shiftlog-narrative textarea {
  min-height: 140px;
}

.shiftlog-training {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.shiftlog-training textarea,
.shiftlog-new-issues textarea {
  min-height: 72px;
}

.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  align-self: flex-start;
}

.check-inline input {
  width: auto;
  margin: 0;
  accent-color: var(--color-accent);
}

/* Open issue turnover. */
.issue-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.issue-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 16px;
  padding: 12px 14px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-status-high);
  border-radius: var(--radius);
}

.issue-card.is-closing {
  border-left-color: var(--color-success);
}

.issue-desc {
  font-weight: 600;
  color: var(--color-heading);
}

.issue-meta {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: 2px;
}

.issue-actions {
  display: flex;
  gap: 6px;
  align-items: flex-start;
}

.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.toggle-pill input {
  width: auto;
  margin: 0;
  accent-color: var(--color-accent);
}

.toggle-pill:has(input:checked) {
  color: var(--color-heading);
  border-color: var(--color-accent);
}

.toggle-pill-close input {
  accent-color: var(--color-success);
}

.toggle-pill-close:has(input:checked) {
  color: var(--color-success);
  border-color: var(--color-success);
}

.toggle-pill:has(input:focus-visible) {
  box-shadow: var(--focus-ring);
}

.issue-fields {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px 12px;
}

.issue-fields input[type="text"],
.issue-fields textarea {
  padding: 6px 8px;
  font-size: 0.85rem;
  background: var(--color-surface);
}

.issue-fields textarea {
  min-height: 60px;
}

/* Submit bar stays in view while the form is on screen. */
.shiftlog-submit-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0 0 20px;
  padding: 12px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 -6px 16px rgba(0, 0, 0, 0.35);
}

.shiftlog-submit-bar span {
  color: var(--color-muted);
  font-size: 0.82rem;
}

/* Recent logs (extends the section 13 accordion; must come after it). */
.shiftlog-entry-shift {
  color: var(--color-muted);
  font-weight: 500;
}

.shiftlog-entry-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 24px;
  padding-top: 14px;
}

.shiftlog-entry-block h4 {
  margin: 0 0 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-muted);
}

.shiftlog-entry-block p {
  margin: 0;
  font-size: 0.88rem;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.shiftlog-entry-wide {
  grid-column: 1 / -1;
}


/* ====================================================================== *
 * 16. Utilities
 * ====================================================================== */

.is-hidden {
  display: none !important;
}


/* ====================================================================== *
 * 17. Responsive overrides (navigation breakpoints live in section 3)
 * ====================================================================== */

@media (max-width: 900px) {
  .compose-layout {
    grid-template-columns: 1fr;
  }

  .sidebar-panel {
    position: static;
  }
}

@media (max-width: 768px) {
  /* Page layout */
  .page {
    padding: 16px 16px 32px;
  }

  .page-header {
    align-items: flex-start;
    gap: 12px;
  }

  .page-header nav {
    width: 100%;
  }

  /* Forms */
  .system-row {
    grid-template-columns: 1fr;
  }

  /* Tables become stacked cards (label on the left, value on the right). */
  table thead {
    display: none;
  }

  table,
  table tbody,
  table tr,
  table td {
    display: block;
    width: 100%;
  }

  table tbody tr {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    padding: 6px 0;
    background: var(--color-surface);
  }

  table td {
    white-space: normal;
    border-bottom: none;
    padding: 6px 12px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    text-align: right;
  }

  table td::before {
    content: attr(data-label);
    color: var(--color-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    text-align: left;
  }

  table td:empty::before {
    content: none;
  }

  /* Shift log */
  .shiftlog-narrative,
  .shiftlog-entry-body {
    grid-template-columns: 1fr;
  }

  .issue-card {
    grid-template-columns: 1fr;
  }

  .shiftlog-submit-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .shiftlog-submit-bar button {
    width: 100%;
  }
}

@media (max-width: 640px) {
  /* Sub-navigation scrolls sideways instead of wrapping. */
  .subnav {
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .subnav a {
    white-space: nowrap;
  }

  /* Landing page */
  .action-grid {
    grid-template-columns: 1fr;
  }

  .action-card {
    padding: 16px;
  }

  .action-card-desc {
    padding-right: 0;
  }

  .action-card-arrow {
    position: static;
    display: inline-flex;
    margin-top: 12px;
  }

  /* Forms */
  .form-grid,
  .group-checklist {
    grid-template-columns: 1fr;
  }

  .timesheet-form-card .lookup-summary {
    flex-direction: column;
    gap: 6px;
  }

  .timesheet-form-card .repeatable-section-header {
    flex-direction: column;
    align-items: stretch;
  }

  .timesheet-form-card .lookup-button-row,
  .timesheet-form-card .form-actions {
    align-items: stretch;
  }

  .timesheet-form-card .lookup-button-row button,
  .timesheet-form-card .repeatable-section-header .btn-secondary,
  .timesheet-form-card .form-actions button {
    width: 100%;
  }

  .actions-row > * {
    width: 100%;
  }

  /* Incident accordion */
  .incident-summary-stats {
    gap: 12px;
  }
}

@media (max-width: 480px) {
  .hero h1 {
    font-size: 1.6rem;
  }
}

/* Phones: 16px form text stops iOS/iPadOS Safari from zooming on focus. */
@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="tel"],
  input[type="number"],
  input[type="search"],
  input[type="date"],
  input[type="time"],
  input[type="datetime-local"],
  select,
  textarea {
    font-size: 16px;
    max-width: 100%;
  }
}

/* Touch devices (tablets at dispatch positions, phones): larger tap targets. */
@media (pointer: coarse) {
  button,
  input[type="submit"],
  .btn,
  .btn-secondary,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="tel"],
  input[type="number"],
  input[type="search"],
  input[type="date"],
  input[type="time"],
  input[type="datetime-local"],
  select {
    min-height: 44px;
  }

  input[type="checkbox"],
  input[type="radio"] {
    width: 20px;
    height: 20px;
  }

  .sidebar-nav a,
  .subnav a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

/* ====================================================================== *
 * 18. Error Pages )
 * ====================================================================== */
 
 
.error-page {
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: calc(24px + env(safe-area-inset-top, 0px));
}
 
.error-panel {
  width: 100%;
  max-width: 560px;
  margin: 8vh auto 0;
  padding-left: 20px;
  border-left: 3px solid var(--color-status-high);
}
 
.error-panel.is-forbidden {
  border-left-color: var(--color-status-urgent);
}
 
.error-code {
  margin: 0 0 10px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-status-high);
  font-variant-numeric: tabular-nums;
}
 
.error-panel.is-forbidden .error-code {
  color: var(--color-status-urgent);
}
 
.error-panel h1 {
  margin: 0 0 10px;
  font-size: 1.6rem;
  line-height: 1.25;
}
 
.error-panel p {
  margin: 0 0 16px;
  color: var(--color-muted);
  max-width: 60ch;
}
 
.error-path {
  display: block;
  margin: 0 0 16px;
  padding: 8px 10px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}
 
.error-panel .error-note {
  font-size: 0.85rem;
}
 
.error-note strong {
  color: var(--color-text);
}
 
.error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}
 
@media (max-width: 640px) {
  .error-panel {
    margin-top: 4vh;
    padding-left: 14px;
  }
 
  .error-panel h1 {
    font-size: 1.35rem;
  }
 
  .error-actions > * {
    width: 100%;
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 9px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
 
.btn:hover {
  background: var(--color-accent-hover);
}
 
.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* --- Custom surveys --------------------------------------------------- */

.survey-builder {
  max-width: 1000px;
}

.survey-builder .form-row,
.survey-response-form .form-row,
.survey-builder input[type="text"],
.survey-builder input[type="datetime-local"],
.survey-builder select,
.survey-builder textarea,
.survey-response-form input,
.survey-response-form select,
.survey-response-form textarea {
  max-width: none;
}

.survey-builder .form-grid {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
}

.survey-builder .survey-section-editor .form-grid {
  grid-template-columns: minmax(0, 1fr);
}

.survey-section-editor {
  border-left: 4px solid var(--color-accent);
}

.survey-question {
  min-width: 0;
}

.survey-question .repeatable-section-header {
  margin-top: 0;
  flex-wrap: wrap;
  gap: 12px;
}

.survey-question-number {
  color: var(--color-accent);
}

.survey-question .actions-row button {
  padding: 6px 12px;
  width: auto;
}

.survey-add-actions {
  margin-top: 20px;
}

.survey-add-actions .hint-block {
  margin: 0;
}

.survey-page {
  max-width: 900px;
}

.survey-page h2,
.survey-section-heading h3,
.survey-section-summary strong {
  overflow-wrap: anywhere;
}

.survey-form-card {
  max-width: none;
}

.survey-description {
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.survey-section-heading {
  padding: 20px;
  border-left: 4px solid var(--color-accent);
  border-radius: var(--radius);
  background: var(--color-surface-alt);
  margin: 12px 0 24px;
}

.survey-section-heading h3 {
  margin: 0;
}

.survey-section-heading p {
  margin: 8px 0 0;
  color: var(--color-muted);
}

.survey-section-summary {
  background: var(--color-surface-alt);
}

.survey-section-summary p {
  margin: 6px 0 0;
}

.survey-answer {
  padding-bottom: 24px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--color-border);
  min-width: 0;
}

.survey-answer > label,
.survey-answer-label {
  font-weight: 600;
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.survey-help {
  color: var(--color-muted);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.survey-answer .choice-list {
  gap: 8px;
}

.survey-answer .choice-list label {
  padding: 10px 12px;
  min-height: 44px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow-wrap: anywhere;
}

.survey-answer .choice-list label:focus-within {
  box-shadow: var(--focus-ring);
}

.survey-answer .choice-list input {
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .survey-builder .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .survey-section-heading {
    padding: 16px;
  }

  .survey-add-actions button,
  .survey-response-form .form-actions button {
    width: 100%;
  }
}

.survey-link-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  max-width: none;
}

.survey-link-row input {
  flex: 1 1 320px;
  max-width: 640px;
  font-family: monospace;
}

.choice-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.choice-list label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  cursor: pointer;
}

.choice-list input {
  width: auto;
  margin: 0;
}

.field-error {
  color: var(--color-status-urgent);
  font-size: 0.85rem;
  font-weight: 600;
}

.form-row.has-error input,
.form-row.has-error textarea,
.form-row.has-error select {
  border-color: var(--color-status-urgent);
}
