/* ============================================================================
   Peak — component layer.

   Sits on top of Bootstrap 5.3. Bootstrap supplies reset, grid and utilities;
   this file supplies the look. All values come from tokens.css — if you are
   about to type a hex code or a pixel value here, add a token instead.

   Load order (see _Layout.cshtml):  bootstrap.min.css → tokens.css → site.css
   ========================================================================= */

/* ── Base ───────────────────────────────────────────────────────────────── */

html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface-sunken);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  /* Opt in to the fonts' proportional figures being overridden in tables. */
  font-variant-numeric: proportional-nums;
}

h1, h2, h3, h4, h5, h6 {
  line-height: var(--leading-tight);
  font-weight: var(--weight-semi);
  letter-spacing: -0.011em;
  text-wrap: balance;   /* avoids a single orphaned word on a heading's 2nd line */
  color: var(--ink);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4, h5 { font-size: var(--text-lg); }

p { text-wrap: pretty; }

a {
  color: var(--primary-text);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
  transition: color var(--duration-fast) var(--ease-out);
}
a:hover { color: color-mix(in oklab, var(--primary-text) 80%, var(--ink)); }

/* ── Focus ──────────────────────────────────────────────────────────────────
   One ring, everywhere, keyboard-only. Replaces the scaffold's white-then-blue
   double box-shadow, which broke against any non-white background.           */

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
:where(a, button, input, select, textarea, [tabindex]):focus:not(:focus-visible) {
  outline: none;
}

/* Bootstrap components carry their own focus shadow; retune rather than fight. */
.btn:focus-visible,
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  box-shadow: 0 0 0 0.2rem var(--focus-ring);
  border-color: var(--primary-500);
}

/* ── Skip link ──────────────────────────────────────────────────────────── */

.skip-link {
  position: absolute;
  left: var(--space-3);
  top: calc(var(--space-3) * -10);
  z-index: 200;
  padding: var(--space-2) var(--space-4);
  background: var(--primary-600);
  color: var(--ink-on-primary);
  border-radius: var(--radius-md);
  font-weight: var(--weight-medium);
  transition: top var(--duration-base) var(--ease-out);
}
.skip-link:focus {
  top: var(--space-3);
  color: var(--ink-on-primary);
}

/* ── App shell ───────────────────────────────────────────────────────────────
   Two columns: a fixed sidebar and a scrolling body. The sidebar is fixed to the
   viewport so it stays put while the main column scrolls; the body is offset by
   the sidebar width. Below the lg breakpoint the sidebar becomes an off-canvas
   drawer (see the media query at the end of this section).                     */

:root { --sidebar-width: 16rem; }

.app { min-height: 100dvh; }

.sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  z-index: 1040;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  overflow: hidden;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-4) var(--space-3);
}

.sidebar__nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--space-2) var(--space-3) var(--space-4);
  /* Fade the scroll edges so long nav lists don't hard-clip. */
  scrollbar-width: thin;
}

.sidebar__footer {
  flex-shrink: 0;
  padding: var(--space-3);
  border-block-start: 1px solid var(--border);
}

.sidebar__close {
  border: 0;
  background: transparent;
  color: var(--ink-subtle);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 var(--space-2);
}

.app__body {
  min-height: 100dvh;
  margin-inline-start: var(--sidebar-width);
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--header-height);
  padding-inline: var(--space-5);
  background: color-mix(in oklab, var(--surface) 85%, transparent);
  border-block-end: 1px solid var(--border);
  backdrop-filter: saturate(1.4) blur(10px);
}

.topbar__title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--weight-semi);
  letter-spacing: -0.01em;
}

.topbar__actions {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.topbar__menu {
  display: grid;
  place-items: center;
  inline-size: 2.25rem;
  block-size: 2.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.topbar__menu svg { inline-size: 1.15rem; block-size: 1.15rem; }

.app-main {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--content-max);
  padding: var(--space-6) var(--space-5) var(--space-7);
}

.app-footer {
  flex-shrink: 0;
  border-block-start: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-subtle);
  font-size: var(--text-sm);
  padding: var(--space-4) var(--space-5);
}

/* Backdrop shown behind the drawer on small screens. */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1030;
  background: color-mix(in oklab, var(--brand-ink) 55%, transparent);
  border: 0;
  padding: 0;
}
.sidebar-backdrop[hidden] { display: none; }

/* ── Brand mark ─────────────────────────────────────────────────────────── */

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--ink);
  text-decoration: none;
}

/* Peak's real logo. Intrinsic size is 132x177 (portrait), which sits naturally
   at the head of a vertical sidebar. width/height on the <img> reserve the box
   so the sidebar doesn't reflow when the image loads. */
.brand__logo {
  height: 3.25rem;
  width: auto;
  display: block;
}

/* ── Sidebar nav ────────────────────────────────────────────────────────── */

.nav-group { margin-bottom: var(--space-4); }
.nav-group:last-child { margin-bottom: 0; }

.nav-group__label {
  margin: 0 0 var(--space-1);
  padding-inline: var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-subtle);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--ink-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out),
              background-color var(--duration-fast) var(--ease-out);
}
.nav-item:hover {
  color: var(--ink);
  background: var(--surface-sunken);
}
.nav-item svg {
  inline-size: 1.15rem;
  block-size: 1.15rem;
  flex-shrink: 0;
  color: var(--ink-subtle);
  transition: color var(--duration-fast) var(--ease-out);
}
.nav-item:hover svg { color: var(--ink-muted); }

.nav-item[aria-current="page"] {
  color: var(--primary-text);
  background: var(--primary-50);
  font-weight: var(--weight-semi);
}
.nav-item[aria-current="page"] svg { color: var(--primary-text); }

/* ── User card (sidebar footer) ─────────────────────────────────────────── */

.usercard {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.usercard__link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1 1 auto;
  min-width: 0;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  color: var(--ink);
  text-decoration: none;
}
.usercard__link:hover { background: var(--surface-sunken); color: var(--ink); }

.usercard__avatar {
  display: grid;
  place-items: center;
  inline-size: 2rem;
  block-size: 2rem;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: linear-gradient(140deg, var(--primary-500), var(--primary-700));
  color: var(--ink-on-primary);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}
.usercard__name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.usercard__signout {
  display: grid;
  place-items: center;
  inline-size: 2rem;
  block-size: 2rem;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink-subtle);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out),
              background-color var(--duration-fast) var(--ease-out);
}
.usercard__signout:hover { color: var(--status-danger); background: var(--surface-sunken); }
.usercard__signout svg { inline-size: 1.05rem; block-size: 1.05rem; }

/* ── Off-canvas behaviour below lg ──────────────────────────────────────── */

@media (max-width: 991.98px) {
  .app__body { margin-inline-start: 0; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--duration-base) var(--ease-out);
    box-shadow: var(--shadow-lg);
  }
  .app.sidebar-open .sidebar { transform: translateX(0); }
}

@media (min-width: 992px) {
  /* The drawer controls are only for the mobile layout. */
  .topbar__menu, .sidebar__close, .sidebar-backdrop { display: none !important; }
}

/* ── Theme toggle ───────────────────────────────────────────────────────── */

.theme-toggle {
  display: grid;
  place-items: center;
  inline-size: 2.25rem;
  block-size: 2.25rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink-muted);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}
.theme-toggle:hover {
  background: var(--surface-sunken);
  color: var(--ink);
}
.theme-toggle svg { inline-size: 1.05rem; block-size: 1.05rem; }

/* Show sun in dark mode, moon in light. Avoids a JS round-trip on toggle. */
.theme-toggle .icon-sun  { display: none; }
[data-bs-theme="dark"] .theme-toggle .icon-sun  { display: block; }
[data-bs-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ── Cards ──────────────────────────────────────────────────────────────── */

.card {
  --bs-card-bg: var(--surface);
  --bs-card-border-color: var(--border);
  --bs-card-border-radius: var(--radius-lg);
  --bs-card-inner-border-radius: calc(var(--radius-lg) - 1px);
  --bs-card-cap-bg: var(--surface);
  box-shadow: var(--shadow-sm);
}

/* An interactive card — the dashboard tiles. :has() lets the whole card react
   to focus landing on the link inside it, with no wrapper element or JS. */
.card--action {
  container-type: inline-size;
  transition: transform var(--duration-base) var(--ease-out),
              box-shadow var(--duration-base) var(--ease-out),
              border-color var(--duration-base) var(--ease-out);
}
.card--action:hover,
.card--action:has(a:focus-visible) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-200);
}

/* Stretch the primary link to cover the card, so the whole tile is clickable
   while the accessible name stays on the real anchor. */
.card--action .stretched-link::after { border-radius: var(--radius-lg); }

/* The title anchor carries the card's accessible name, but it should read as a
   heading, not as a link. */
.card--action .card-title a,
.card--action .card-title a:hover {
  color: var(--ink);
}

.card__icon {
  display: grid;
  place-items: center;
  inline-size: 2.5rem;
  block-size: 2.5rem;
  margin-bottom: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--primary-50);
  color: var(--primary-text);
}
.card__icon svg { inline-size: 1.25rem; block-size: 1.25rem; }

/* ── Hero ───────────────────────────────────────────────────────────────── */

.hero {
  padding: var(--space-8) 0 var(--space-6);
  max-width: 42rem;
}

.hero__logo {
  height: 5rem;
  width: auto;
  display: block;
  margin-bottom: var(--space-4);
}

.hero__eyebrow {
  margin: 0 0 var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary-text);
}

.hero__title {
  margin: 0;
  font-size: var(--text-3xl);
  letter-spacing: -0.025em;
}

.hero__lead {
  margin: var(--space-4) 0 0;
  font-size: var(--text-lg);
  color: var(--ink-muted);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

/* ── Buttons ────────────────────────────────────────────────────────────────
   Bootstrap's .btn-* hardcode their own --bs-btn-* values rather than reading
   --bs-primary, so each variant is rebound to our tokens explicitly.         */

.btn {
  --bs-btn-font-weight: var(--weight-medium);
  --bs-btn-border-radius: var(--radius-md);
  transition: transform var(--duration-fast) var(--ease-out),
              background-color var(--duration-fast) var(--ease-out);
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  --bs-btn-bg: var(--primary-600);
  --bs-btn-border-color: var(--primary-600);
  --bs-btn-color: var(--ink-on-primary);
  --bs-btn-hover-bg: var(--primary-700);
  --bs-btn-hover-border-color: var(--primary-700);
  --bs-btn-hover-color: var(--ink-on-primary);
  --bs-btn-active-bg: var(--primary-800);
  --bs-btn-active-border-color: var(--primary-800);
  --bs-btn-disabled-bg: var(--primary-200);
  --bs-btn-disabled-border-color: var(--primary-200);
}

.btn-secondary {
  --bs-btn-bg: var(--surface);
  --bs-btn-border-color: var(--border-strong);
  --bs-btn-color: var(--ink);
  --bs-btn-hover-bg: var(--surface-sunken);
  --bs-btn-hover-border-color: var(--border-strong);
  --bs-btn-hover-color: var(--ink);
  --bs-btn-active-bg: var(--surface-sunken);
}

.btn-outline-secondary {
  --bs-btn-color: var(--ink-muted);
  --bs-btn-border-color: var(--border-strong);
  --bs-btn-hover-bg: var(--surface-sunken);
  --bs-btn-hover-border-color: var(--border-strong);
  --bs-btn-hover-color: var(--ink);
}

.btn-outline-danger {
  --bs-btn-color: var(--status-danger);
  --bs-btn-border-color: color-mix(in oklab, var(--status-danger) 40%, transparent);
  --bs-btn-hover-bg: var(--status-danger);
  --bs-btn-hover-border-color: var(--status-danger);
  --bs-btn-hover-color: #fff;
}

/* ── Tables ─────────────────────────────────────────────────────────────────
   Tabular figures make columns of numbers line up on the decimal point.      */

.table {
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--border);
  --bs-table-color: var(--ink);
  --bs-table-striped-bg: var(--surface-sunken);
  --bs-table-striped-color: var(--ink);
  --bs-table-hover-bg: var(--primary-50);
  margin-bottom: 0;
}

.table > thead th {
  background: var(--surface-sunken);
  color: var(--ink-subtle);
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

/* Any table inside a card scrolls on its own rather than forcing the page to
   scroll sideways on a phone. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Badges ─────────────────────────────────────────────────────────────── */

.badge {
  font-weight: var(--weight-medium);
  font-size: var(--text-xs);
  letter-spacing: 0.01em;
  padding: 0.35em 0.65em;
  border-radius: var(--radius-full);
}

/* Status badges, driven by a data attribute rather than concatenated classes.
   See _StatusBadge.cshtml. */
.status {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.3em 0.7em;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1.4;
  white-space: nowrap;
  background: color-mix(in oklab, var(--_status, var(--ink-subtle)) 14%, transparent);
  color: color-mix(in oklab, var(--_status, var(--ink-subtle)) 80%, var(--ink));
  border: 1px solid color-mix(in oklab, var(--_status, var(--ink-subtle)) 30%, transparent);
}
.status::before {
  content: "";
  inline-size: 0.45em;
  block-size: 0.45em;
  border-radius: var(--radius-full);
  background: var(--_status, var(--ink-subtle));
}
.status[data-status="approved"]  { --_status: var(--status-success); }
.status[data-status="pending"]   { --_status: var(--status-warning); }
.status[data-status="rejected"]  { --_status: var(--status-danger); }
.status[data-status="submitted"] { --_status: var(--status-info); }
.status[data-status="queried"]   { --_status: var(--brand-accent); }

/* ── Alerts ─────────────────────────────────────────────────────────────── */

.alert {
  --bs-alert-border-radius: var(--radius-md);
  border-width: 1px;
  border-left-width: 3px;
}
.alert-success { --bs-alert-color: var(--status-success); --bs-alert-bg: color-mix(in oklab, var(--status-success) 8%, var(--surface)); --bs-alert-border-color: color-mix(in oklab, var(--status-success) 30%, transparent); }
.alert-danger  { --bs-alert-color: var(--status-danger);  --bs-alert-bg: color-mix(in oklab, var(--status-danger)  8%, var(--surface)); --bs-alert-border-color: color-mix(in oklab, var(--status-danger)  30%, transparent); }
.alert-warning { --bs-alert-color: var(--status-warning); --bs-alert-bg: color-mix(in oklab, var(--status-warning) 8%, var(--surface)); --bs-alert-border-color: color-mix(in oklab, var(--status-warning) 30%, transparent); }
.alert-info    { --bs-alert-color: var(--status-info);    --bs-alert-bg: color-mix(in oklab, var(--status-info)    8%, var(--surface)); --bs-alert-border-color: color-mix(in oklab, var(--status-info)    30%, transparent); }

/* ── Forms ──────────────────────────────────────────────────────────────── */

.form-control, .form-select {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--ink);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}
.form-control::placeholder { color: var(--ink-subtle); }

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink-muted);
  margin-bottom: var(--space-1);
}

.text-danger.field-validation-error,
.validation-summary-errors {
  color: var(--status-danger);
  font-size: var(--text-sm);
}

/* ── Page header ────────────────────────────────────────────────────────── */

.page-header {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}
.page-header__title { margin: 0; }
.page-header__lead {
  margin: var(--space-1) 0 0;
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

/* ── Content layout helpers ─────────────────────────────────────────────────
   Conventions used across the reskinned views:
   - the page <h1> lives in the topbar, so views never render their own;
   - .page-header carries page-level actions and an optional one-line lead;
   - .form-narrow constrains a single-column form to a readable measure;
   - .form-card is the standard card wrapper for a form.                        */

.content-lead {
  margin: 0 0 var(--space-5);
  color: var(--ink-muted);
  font-size: var(--text-sm);
  max-width: 60ch;
}

.form-narrow { max-width: 40rem; }
.form-card .card-body { padding: var(--space-5); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}
.toolbar--end { justify-content: flex-end; }
.toolbar--between { justify-content: space-between; }

/* Section heading inside a page (below the topbar h1). */
.section-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semi);
  margin: 0 0 var(--space-3);
}

/* Key/value display for detail and summary pages. Renders as aligned rows that
   collapse to stacked pairs on narrow screens. Use with a <dl>. */
.detail-grid {
  display: grid;
  grid-template-columns: minmax(8rem, 14rem) 1fr;
  gap: var(--space-2) var(--space-4);
  margin: 0;
}
.detail-grid dt {
  color: var(--ink-subtle);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.detail-grid dd {
  margin: 0;
  color: var(--ink);
}
@media (max-width: 40rem) {
  .detail-grid { grid-template-columns: 1fr; gap: var(--space-1); }
  .detail-grid dd { margin-bottom: var(--space-3); }
}

/* Vertical settings sub-nav (Identity account Manage section). */
.settings-nav .nav-link {
  color: var(--ink-muted);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.settings-nav .nav-link:hover { background: var(--surface-sunken); color: var(--ink); }
.settings-nav .nav-link.active {
  background: var(--primary-50);
  color: var(--primary-text);
  font-weight: var(--weight-semi);
}

/* ── Dashboard grid ─────────────────────────────────────────────────────────
   auto-fit + minmax gives a responsive grid with no breakpoints and no
   col-md-* classes to keep in sync.                                          */

.tile-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(min(17rem, 100%), 1fr));
}

/* ── Empty state ────────────────────────────────────────────────────────── */

.empty-state {
  display: grid;
  place-items: center;
  gap: var(--space-2);
  padding: var(--space-7) var(--space-4);
  text-align: center;
  color: var(--ink-subtle);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

/* ── Pagination ─────────────────────────────────────────────────────────── */

.pagination {
  --bs-pagination-color: var(--ink-muted);
  --bs-pagination-bg: var(--surface);
  --bs-pagination-border-color: var(--border);
  --bs-pagination-hover-bg: var(--surface-sunken);
  --bs-pagination-hover-color: var(--ink);
  --bs-pagination-active-bg: var(--primary-600);
  --bs-pagination-active-border-color: var(--primary-600);
  --bs-pagination-border-radius: var(--radius-md);
  /* Wrap rather than overflow if a page ever renders many links. The partial
     already windows the range, so this is just a safety net. */
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-2);
}

/* ── Table search box ───────────────────────────────────────────────────── */

.table-search {
  position: relative;
  width: min(22rem, 100%);
}
.table-search__icon {
  position: absolute;
  inset-block: 0;
  inset-inline-start: var(--space-3);
  display: grid;
  place-items: center;
  color: var(--ink-subtle);
  pointer-events: none;
}
.table-search__icon svg { inline-size: 1rem; block-size: 1rem; }
.table-search .form-control {
  /* Leave room for the leading icon. */
  padding-inline-start: calc(var(--space-3) * 2 + 1rem);
}

/* ── Width utilities ────────────────────────────────────────────────────────
   These replace inline style="width:..." / style="max-width:..." attributes.
   A strict Content-Security-Policy blocks inline style attributes (style-src-attr
   falls back to style-src, and we do not allow 'unsafe-inline'), so sizing that
   used to live in markup lives here instead. Bootstrap ships no equivalents. */

.field-w-sm { max-width: 150px; }
.field-w-md { max-width: 200px; }
.field-w-lg { max-width: 250px; }

.col-w-sm { width: 110px; }
.col-w-md { width: 130px; }
.col-w-lg { width: 160px; }

/* ── View transitions ───────────────────────────────────────────────────────
   Cross-document transitions on same-origin MVC navigations. Browsers without
   support simply navigate normally.                                          */

@view-transition { navigation: auto; }

::view-transition-old(root) { animation: fade-out var(--duration-base) var(--ease-out) both; }
::view-transition-new(root) { animation: fade-in  var(--duration-base) var(--ease-out) both; }

@keyframes fade-out { to   { opacity: 0; } }
@keyframes fade-in  { from { opacity: 0; } }

/* ── Reduced motion ─────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  @view-transition { navigation: none; }
  .card--action:hover { transform: none; }
}

/* ── Print ──────────────────────────────────────────────────────────────── */

@media print {
  .sidebar, .topbar, .app-footer, .btn, .pagination { display: none !important; }
  .app__body { margin-inline-start: 0; }
  .app-main { max-width: none; padding: 0; }
  .card { box-shadow: none; border: 1px solid #999; }
}

/*--------- Add for autocomplete on lookups ----------------*/
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    max-height: 220px;
    overflow-y: auto;
    display: none;
    box-shadow: var(--shadow-md);
}

    .autocomplete-dropdown.show {
        display: block;
    }

.autocomplete-item {
    padding: var(--space-2) var(--space-3);
    cursor: pointer;
    color: var(--ink);
    font-size: var(--text-sm);
}

    .autocomplete-item:hover,
    .autocomplete-item.active {
        background: var(--surface-sunken);
    }