/* ============================================================================
   CivicSync shared components
   Per DESIGN.md: "Citizen Flows" use a white top-bar + generous lg/xl
   spacing; "Authority Views" use a dark Civic-Blue sidebar + dense sm/md
   spacing. Buttons/cards/inputs follow the exact specs in DESIGN.md's
   "Components" section.
   ============================================================================ */

/* --- Citizen top navigation -------------------------------------------------- */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-height);
  display: flex;
  align-items: center;
  background: var(--color-surface-container-lowest);
  border-bottom: 1px solid var(--color-card-border);
  box-shadow: var(--shadow-sm);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  width: 100%;
  height: 100%;
  flex-wrap: nowrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-decoration: none;
  color: var(--color-on-surface);
}

.brand__mark {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}

.brand span {
  font-weight: 800;
  font-size: calc(19px * var(--a11y-font-scale));
  letter-spacing: -0.015em;
  color: var(--color-on-surface);
}

.site-nav-collapsible {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.site-nav a {
  text-decoration: none;
  font-size: var(--body-sm-size);
  font-weight: 500;
  color: var(--color-on-surface-variant);
  padding: var(--space-xs) 0;
  border-bottom: 2px solid transparent;
}

.site-nav a[aria-current='page'] {
  color: var(--color-on-surface);
  border-bottom-color: var(--color-action);
  font-weight: 600;
}

.site-nav a:hover {
  color: var(--color-on-surface);
}

.site-nav a.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* Authority Portal is a deliberate, distinct entry point -- filled
   institutional crimson (not another outlined/secondary button),
   communicating "restricted institutional access" without changing
   the actual authentication destination/logic. A thin gold accent
   underlines it -- gold stays a restrained accent line, never a fill. */
.site-header__authority-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  padding-top: 6px;
  padding-bottom: 6px;
  min-height: 36px;
  background: var(--color-authority-red);
  color: #ffffff;
  border: none;
  border-bottom: 2px solid var(--color-authority-gold);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.15);
}
.site-header__authority-btn:hover {
  background: var(--color-authority-red-hover);
}
.site-header__authority-btn:active {
  transform: translateY(1px);
}
.site-header__authority-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Hidden on desktop -- the full nav is always visible there, so there
   is nothing to toggle. */
.site-header__nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-default);
  color: var(--color-on-surface);
  font-size: calc(18px * var(--a11y-font-scale));
  line-height: 1;
  padding: 6px 10px;
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
}
.site-header__nav-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

@media (max-width: 860px) {
  .site-header {
    height: var(--header-height-mobile);
  }
  .site-header__nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Genuine overlay drawer (Milestone 25.9), not an inline push-down
     panel: fixed to the viewport, slides from the right, with its own
     backdrop. Closed by default; opened via .is-nav-open on
     .site-header__inner (JS in utils.js also locks body scroll and
     handles Escape/backdrop-click while open). */
  .site-nav-collapsible {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
    position: fixed;
    top: var(--header-height-mobile);
    right: 0;
    bottom: 0;
    width: min(320px, 85vw);
    padding: var(--space-lg);
    background: var(--color-surface-container-lowest);
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    transition: transform 0.2s ease;
    z-index: 60;
    overflow-y: auto;
  }
  .site-header__inner.is-nav-open .site-nav-collapsible {
    transform: translateX(0);
  }
  html[data-reduced-motion='true'] .site-nav-collapsible {
    transition: none;
  }

  .nav-backdrop {
    display: none;
    position: fixed;
    top: var(--header-height-mobile);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 55;
  }
  .site-header__inner.is-nav-open .nav-backdrop {
    display: block;
  }

  .site-nav {
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: var(--space-sm);
  }
  .site-nav a {
    padding: 8px 0;
    font-size: calc(15px * var(--a11y-font-scale));
    text-align: center;
  }
  .lang-dropdown {
    width: 100%;
  }
  .lang-dropdown__trigger {
    width: 100%;
    justify-content: space-between;
  }
  .lang-dropdown__menu {
    position: static;
    box-shadow: none;
    border: 1px solid var(--color-card-border);
    margin-top: var(--space-xs);
  }
  .site-header__authority-btn {
    width: 100%;
    text-align: center;
    justify-content: center;
  }
}

/* --- Icons (Milestone 25.9) -------------------------------------------------- */

.icon {
  display: inline-block;
  flex-shrink: 0;
}
/* [hidden] and a class both setting `display` have equal specificity;
   without this, whichever is declared later in the stylesheet wins,
   which can silently defeat the native hidden attribute (this is
   exactly what caused the password eye/eye-off icons to render
   simultaneously). This guarantees hidden always actually hides,
   regardless of what other classes are present on the element. */
[hidden] {
  display: none !important;
}

/* --- Language dropdown (Milestone 25.9) --------------------------------------
   Replaces the old three-separate-buttons switcher. Reuses the exact
   same [data-language-option] elements/click-wiring from i18n.js --
   only the surrounding trigger/popover chrome is new. */
.lang-dropdown {
  position: relative;
}
.lang-dropdown__trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-default);
  padding: 7px 12px;
  min-height: 40px;
  font-size: var(--body-sm-size);
  font-weight: 600;
  color: var(--color-on-surface);
  cursor: pointer;
}
.lang-dropdown__trigger:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.lang-dropdown__trigger[aria-expanded='true'] .icon--chevron {
  transform: rotate(180deg);
}
.icon--chevron {
  transition: transform 0.15s ease;
}
html[data-reduced-motion='true'] .icon--chevron {
  transition: none;
}

.lang-dropdown__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--color-surface-container-lowest);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-sm);
  z-index: 70;
}
.lang-dropdown__heading {
  font-size: var(--label-md-size);
  font-weight: var(--label-md-weight);
  letter-spacing: var(--label-md-tracking);
  text-transform: uppercase;
  color: var(--color-on-surface-variant);
  padding: 4px var(--space-sm) 8px;
  margin: 0;
  border-bottom: 1px solid var(--color-card-header-border);
  margin-bottom: 4px;
}
.lang-dropdown__menu button[data-language-option] {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  background: transparent;
  border: none;
  border-radius: var(--radius-default);
  padding: 8px var(--space-sm);
  font-size: var(--body-sm-size);
  color: var(--color-on-surface);
  text-align: left;
  cursor: pointer;
  min-height: 40px;
}
.lang-dropdown__menu button[data-language-option]:hover {
  background: var(--color-surface-container-low);
}
.lang-dropdown__menu button[data-language-option]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.lang-dropdown__check {
  width: 14px;
  color: var(--color-action);
  opacity: 0;
}
.lang-dropdown__menu button[data-language-option].is-active .lang-dropdown__check {
  opacity: 1;
}
.lang-dropdown__menu button[data-language-option].is-active {
  font-weight: 600;
}

/* --- Theme toggle (Milestone 25.9/26.0) ---------------------------------------
   A proper animated sun/moon control: both icons occupy the same
   position (absolutely stacked) and crossfade with a subtle rotation
   as the theme changes, rather than an abrupt show/hide swap. */
.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-width: 44px;
  min-height: 44px;
  background: transparent;
  border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-default);
  color: var(--color-on-surface);
  cursor: pointer;
  overflow: hidden;
}
.theme-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.theme-toggle .icon--sun,
.theme-toggle .icon--moon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(0deg) scale(1);
  opacity: 1;
  transition: opacity 0.25s ease, transform 0.25s ease, color 0.25s ease;
}
.theme-toggle .icon--sun {
  color: #8a4d00;
}
.theme-toggle .icon--moon {
  color: #8fb2e8;
  opacity: 0;
  transform: translate(-50%, -50%) rotate(60deg) scale(0.5);
}
[data-theme='dark'] .theme-toggle .icon--sun {
  color: #f0b429;
}
.theme-toggle.is-dark .icon--sun {
  opacity: 0;
  transform: translate(-50%, -50%) rotate(-60deg) scale(0.5);
}
.theme-toggle.is-dark .icon--moon {
  opacity: 1;
  transform: translate(-50%, -50%) rotate(0deg) scale(1);
}
html[data-reduced-motion='true'] .theme-toggle .icon--sun,
html[data-reduced-motion='true'] .theme-toggle .icon--moon {
  transition: none;
}

/* The authority sidebar is always a dark surface (its own --color-primary
   background, independent of the page's light/dark theme), so its
   theme-toggle needs light-on-dark colors always -- matching the
   existing convention for other sidebar text (e.g. .authority-nav a). */
.theme-toggle--sidebar {
  width: auto;
  height: auto;
  min-height: 40px;
  padding: 8px 12px;
  padding-left: 34px;
  gap: var(--space-sm);
  border-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
  font-size: var(--body-sm-size);
  font-weight: 600;
  justify-content: flex-start;
}
/* The sidebar button has a text label beside the icon, so its icons
   anchor to a fixed left-edge slot instead of centering within the
   whole (wider) button as the header's icon-only square variant does. */
.theme-toggle--sidebar .icon--sun,
.theme-toggle--sidebar .icon--moon {
  left: 12px;
  transform: translateY(-50%) rotate(0deg) scale(1);
}
.theme-toggle--sidebar .icon--moon {
  transform: translateY(-50%) rotate(60deg) scale(0.5);
}
.theme-toggle--sidebar.is-dark .icon--sun {
  transform: translateY(-50%) rotate(-60deg) scale(0.5);
}
.theme-toggle--sidebar.is-dark .icon--moon {
  transform: translateY(-50%) rotate(0deg) scale(1);
}

.site-footer {
  border-top: 1px solid var(--color-card-border);
  padding-top: var(--space-xl);
  margin-top: var(--space-xl);
  background: var(--color-surface-container-lowest, #ffffff);
}

.site-footer__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 240px));
  justify-content: center;
  gap: var(--space-xl) calc(var(--space-xl) * 1.5);
  padding-bottom: var(--space-lg);
}

.site-footer__brand,
.site-footer__col {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.site-footer__brand .brand {
  justify-content: center;
  margin-bottom: var(--space-sm);
}

.site-footer__tagline {
  font-size: var(--body-sm-size);
  color: var(--color-on-surface-variant);
  max-width: 28em;
  margin: 0;
}

.site-footer__col {
  gap: var(--space-sm);
}

.site-footer__col-heading {
  font-size: var(--label-md-size);
  font-weight: var(--label-md-weight);
  letter-spacing: var(--label-md-tracking);
  text-transform: uppercase;
  color: var(--color-on-surface-variant);
  margin: 0 0 4px;
}

.site-footer__col a {
  color: var(--color-on-surface);
  text-decoration: none;
  font-size: var(--body-sm-size);
}
.site-footer__col a:hover {
  color: var(--color-action);
  text-decoration: underline;
}

.site-footer__bottom {
  border-top: 1px solid var(--color-card-border);
  padding: var(--space-md) 0;
  font-size: var(--body-sm-size);
  color: var(--color-on-surface-variant);
  text-align: center;
}

@media (max-width: 700px) {
  .site-footer__grid {
    grid-template-columns: 1fr;
    justify-content: stretch;
    justify-items: center;
    gap: var(--space-lg);
  }
}

/* --- Buttons ----------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-size: var(--body-sm-size);
  font-weight: 600;
  padding: var(--space-sm) var(--space-md);
  min-height: 44px;
  border-radius: var(--radius-default);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  text-decoration: none;
  line-height: 1;
}

/* Consistent, visible keyboard focus for buttons and citizen nav links
   (Milestone 25.1) -- previously relied on the browser's inconsistent
   default outline. :focus-visible so this only appears for keyboard
   navigation, never on a mouse click, preserving the existing feel for
   mouse/touch use. Uses --focus-ring (Action Blue) -- no new color. */
.btn:focus-visible,
.site-nav a:focus-visible,
.brand:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.btn-primary {
  background: var(--color-btn-primary-bg);
  color: var(--color-btn-primary-text);
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(0.92);
}

.btn-secondary {
  background: transparent;
  border-color: var(--color-outline-variant);
  color: var(--color-on-surface);
}
.btn-secondary:hover:not(:disabled) {
  border-color: var(--color-outline);
  background: var(--color-surface-container-low);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-block {
  width: 100%;
}

/* --- Cards --------------------------------------------------------------- */

.card {
  background: var(--color-surface-container-lowest);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card__header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-card-header-border);
}

.card__body {
  padding: var(--space-lg);
}

/* --- Form fields ----------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

/* Milestone 25.8: a subtle divider between consecutive top-level form
   sections (describe the issue / location) inside the report form, so
   the two are visually grouped as distinct steps rather than one
   continuous block. Scoped to #report-form so it never affects the
   compact location-adjust sub-fields or any other form on the site. */
#report-form > .field + .field {
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-card-border);
}

.field label {
  font-size: var(--label-md-size);
  font-weight: var(--label-md-weight);
  letter-spacing: var(--label-md-tracking);
  text-transform: uppercase;
  color: var(--color-on-surface-variant);
}

textarea,
input[type='text'],
input[type='password'],
input[type='email'],
input[type='number'] {
  border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-default);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--body-md-size);
  font-family: inherit;
  color: var(--color-on-surface);
  background: var(--color-surface-container-lowest);
  resize: vertical;
}

.field textarea {
  min-height: 140px;
}

/* Password visibility toggle (Milestone 26.0): sits inside the input's
   own box so the field's overall footprint is unchanged; the input
   gets right padding to clear the button. */
.password-field {
  position: relative;
}
.password-field input[type='password'],
.password-field input[type='text'] {
  padding-right: 44px;
  width: 100%;
  box-sizing: border-box;
}
.password-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  background: transparent;
  border: none;
  border-radius: var(--radius-default);
  color: var(--color-on-surface-variant);
  cursor: pointer;
}
.password-toggle:hover {
  color: var(--color-on-surface);
}
.password-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

textarea:focus,
input[type='text']:focus,
input[type='password']:focus,
input[type='email']:focus,
input[type='number']:focus {
  outline: none;
  border: 2px solid var(--color-action);
  padding: calc(var(--space-sm) - 1px) calc(var(--space-md) - 1px);
}

.field-hint {
  font-size: var(--body-sm-size);
  color: var(--color-on-surface-variant);
}

.field-error {
  font-size: var(--body-sm-size);
  color: var(--color-error);
  display: none;
}

.field.has-error textarea,
.field.has-error input[type='text'],
.field.has-error input[type='password'] {
  border-color: var(--color-error);
}

.field.has-error .field-error {
  display: block;
}

/* --- Status chips ------------------------------------------------------------ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px var(--space-sm);
  border-radius: var(--radius-full);
  font-size: calc(12px * var(--a11y-font-scale));
  font-weight: 600;
  white-space: nowrap;
}

.chip-neutral {
  background: var(--color-surface-container);
  color: var(--color-on-surface-variant);
}
.chip-progress {
  background: #dbe9ff;
  color: #16407a;
}
.chip-success {
  background: var(--color-success-container);
  color: var(--color-success);
}
.chip-warning {
  background: var(--color-warning-container);
  color: var(--color-warning);
}
.chip-error {
  background: var(--color-error-container);
  color: var(--color-on-error-container);
}
.chip-severity-low { background: var(--color-success-container); color: var(--color-success); }
.chip-severity-medium { background: var(--color-warning-container); color: var(--color-warning); }
.chip-severity-high { background: #ffe3d6; color: #9a3b00; }
.chip-severity-critical { background: var(--color-error-container); color: var(--color-on-error-container); }
.chip-severity-unknown { background: var(--color-surface-container); color: var(--color-on-surface-variant); }

/* --- Alert / inline notice banners ------------------------------------------- */

.notice {
  border-radius: var(--radius-default);
  padding: var(--space-md);
  font-size: var(--body-sm-size);
  border: 1px solid transparent;
  display: flex;
  gap: var(--space-sm);
  align-items: flex-start;
}
.notice[hidden] {
  display: none;
}
.notice-error {
  background: var(--color-error-container);
  color: var(--color-on-error-container);
  border-color: #f3b8b3;
}
.notice-info {
  background: var(--color-surface-container-low);
  color: var(--color-on-surface);
  border-color: var(--color-outline-variant);
}

/* --- Spinner ----------------------------------------------------------------- */

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.spinner-dark {
  border: 2px solid var(--color-outline-variant);
  border-top-color: var(--color-action);
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --- Timeline (public tracking) ---------------------------------------------- */

.timeline {
  position: relative;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline__item {
  position: relative;
  padding-left: 36px;
  padding-bottom: var(--space-lg);
}

.timeline__item:last-child {
  padding-bottom: 0;
}

.timeline__item::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px var(--color-primary);
}

.timeline__item::after {
  content: '';
  position: absolute;
  left: 13px;
  top: 18px;
  bottom: -8px;
  width: 2px;
  background: var(--color-outline-variant);
}

.timeline__item:last-child::after {
  display: none;
}

.timeline__item--current::before {
  background: var(--color-action);
  box-shadow: 0 0 0 1px var(--color-action), 0 0 0 4px var(--color-secondary-container);
}

/* Milestone 25.4: past/completed steps recede slightly so the current
   status (already visually distinguished above by a larger, ringed
   dot) is unambiguously the focal point of the timeline. */
.timeline__item:not(.timeline__item--current) .timeline__status {
  color: var(--color-on-surface-variant);
  font-weight: 500;
}

.timeline__status {
  font-weight: 600;
  font-size: var(--body-md-size);
  margin-bottom: 2px;
}

.timeline__timestamp {
  font-size: var(--body-sm-size);
  color: var(--color-on-surface-variant);
  margin-bottom: 4px;
}

.timeline__reason {
  font-size: var(--body-sm-size);
  color: var(--color-on-surface-variant);
}

/* --- Authority shell (placeholder, Milestone 11 foundation) ------------------ */

.authority-shell {
  display: flex;
  min-height: 100vh;
}

.authority-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--color-primary);
  color: var(--color-inverse-on-surface);
  padding: var(--space-lg) var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.authority-sidebar__top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.authority-sidebar__collapsible {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  flex: 1;
  min-height: 0;
}

/* Hidden on desktop -- the sidebar is always fully expanded there, so
   there is nothing to toggle. */
.mobile-nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-default);
  color: #ffffff;
  font-size: calc(18px * var(--a11y-font-scale));
  line-height: 1;
  padding: 6px 10px;
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
}

.mobile-nav-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.authority-sidebar .brand {
  color: #ffffff;
}
.authority-sidebar .brand span {
  color: #ffffff;
}

.authority-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.authority-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-sm);
  border-radius: var(--radius-default);
  color: #aab4c8;
  text-decoration: none;
  font-size: var(--body-sm-size);
}

.authority-nav a.active {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-weight: 600;
}

.authority-nav a[aria-disabled='true'] {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.authority-nav a:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.authority-main {
  flex: 1;
  min-width: 0;
  padding: var(--space-lg);
  background: var(--color-background);
}

@media (max-width: 768px) {
  .authority-shell {
    flex-direction: column;
  }
  .authority-sidebar {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    gap: 0;
  }
  .mobile-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  /* Collapsed by default on mobile -- a citizen/authority visiting on a
     phone sees a slim brand+menu-button bar, then the actual page
     content immediately below it, NOT the full desktop sidebar stacked
     on top (Milestone 25.3). The nav/jurisdiction/logout panel becomes
     an expandable drawer instead. */
  .authority-sidebar__collapsible {
    display: none;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
  }
  .authority-sidebar.is-nav-open .authority-sidebar__collapsible {
    display: flex;
  }
  .authority-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

/* --- KPI cards (authority placeholder) ---------------------------------------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-md);
}

.kpi-card {
  background: var(--color-surface-container-lowest);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
}

/* Headline KPI strip (the top-of-dashboard summary row) reads as the
   primary entry point into the page -- stronger elevation plus a
   restrained accent top-border in the existing Action Blue, so it's
   visually distinct from secondary/nested metric grids elsewhere on
   the same page without introducing a new color. */
.kpi-grid--headline .kpi-card {
  box-shadow: var(--shadow-md);
  border-top: 3px solid var(--color-action);
}

.kpi-card__label {
  font-size: var(--label-md-size);
  font-weight: var(--label-md-weight);
  letter-spacing: var(--label-md-tracking);
  text-transform: uppercase;
  color: var(--color-on-surface-variant);
  margin-bottom: var(--space-sm);
}

.kpi-card__value {
  font-size: calc(32px * var(--a11y-font-scale));
  font-weight: 700;
  color: var(--color-on-surface);
}

/* --- Floating accessibility widget (Milestone 25.9) --------------------------
   Bottom-left, persistent, 44px minimum touch target. Respects safe-area
   insets for notched/gesture-bar devices. */
.a11y-widget {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 80;
}

@media (max-width: 480px) {
  /* Milestone 25.9 (revised): JS in utils.js continuously checks
     whether either widget's actual on-screen position would overlap a
     real control/label/link anywhere on the page, for the citizen's
     current scroll position -- not just at page load. A widget that
     would collide gets .is-collision-hidden and is faded out and made
     non-interactive until it's clear again. This is a general,
     content-independent fix rather than page-specific spacing tuned to
     dodge one particular layout. */
  .a11y-widget.is-collision-hidden,
  .contact-widget.is-collision-hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
  }
  html[data-reduced-motion='true'] .a11y-widget.is-collision-hidden,
  html[data-reduced-motion='true'] .contact-widget.is-collision-hidden {
    transition: none;
  }
}
.a11y-widget__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--color-action);
  color: #ffffff;
  border: none;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
}
.a11y-widget__toggle:focus-visible {
  outline: none;
  box-shadow: var(--shadow-lg), var(--focus-ring);
}
.a11y-widget__panel {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  width: 260px;
  background: var(--color-surface-container-lowest);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-md);
}
.a11y-widget__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  font-size: var(--body-sm-size);
}
.a11y-widget__row + .a11y-widget__row {
  border-top: 1px solid var(--color-card-header-border);
}
.a11y-widget__stepper {
  display: flex;
  gap: 4px;
}
.a11y-widget__stepper button {
  min-width: 40px;
  min-height: 36px;
  border: 1px solid var(--color-outline-variant);
  background: transparent;
  color: var(--color-on-surface);
  border-radius: var(--radius-default);
  font-size: calc(12px * var(--a11y-font-scale));
  font-weight: 600;
  cursor: pointer;
}
.a11y-widget__stepper button:focus-visible,
.a11y-widget__row input[type='checkbox']:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.a11y-widget__row input[type='checkbox'] {
  width: 20px;
  height: 20px;
  accent-color: var(--color-action);
}

/* --- Floating contact widget (Milestone 25.9) --------------------------------
   Bottom-right, a real mailto link (not a fake live-chat system). */
.contact-widget {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 80;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: #ffffff;
  box-shadow: var(--shadow-lg);
  text-decoration: none;
}
.contact-widget:focus-visible {
  outline: none;
  box-shadow: var(--shadow-lg), var(--focus-ring);
}

/* On narrow phones, keep the floating widgets from ever overlapping the
   citizen's primary form controls by giving the page a bit of bottom
   breathing room. */
@media (max-width: 480px) {
  .a11y-widget__panel {
    width: min(260px, 78vw);
  }
  .a11y-widget__toggle,
  .contact-widget {
    width: 44px;
    height: 44px;
  }
}
