/* Accident entry — isolated layout A (copied SAMPLE preview only; linked from revised/review.html only).
 * Every selector is scoped to .acc-entry (the Accident list/work page wrapper rendered by js/m/accident.js accPage).
 * Uses existing tokens only (tokens.css). Expanded task forms, other menus and common components are not restyled.
 * Width rules use a container query on .acc-entry so they follow the space actually left beside the global menu
 * (menu open or collapsed), not the window width. */
.acc-entry { container: acc-entry / inline-size; min-width: 0; position: relative; }
/* Scroll regions contain their absolutely positioned helpers (screen-reader text, popovers), so these never extend
 * the document and scrolling a task into view never moves the whole app frame. */
.acc-entry .ae-work, .acc-entry .acc-cards { position: relative; }
.acc-entry .ae-frame { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.acc-entry .ae-frame > .page-head { margin: 0; min-height: 36px; }

/* ---------- Low status row: Open / In process / Closed (moved out of the list) ---------- */
.acc-entry .ae-status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; min-width: 0; }
.acc-entry .ae-status .acc-views { display: grid; grid-template-columns: repeat(3, minmax(0, 188px)); gap: 6px; flex: 0 1 auto; min-width: 0; }
.acc-entry .ae-status .acc-view { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 14px 0 12px; border-radius: var(--r-panel); background: var(--surface); }
.acc-entry .ae-status .acc-view .av-top { font-size: 13px; gap: 6px; min-width: 0; }
.acc-entry .ae-status .acc-view .av-top .i { font-size: 15px; }
.acc-entry .ae-status .acc-view .av-n { margin-left: auto; font-size: 20px; line-height: 1; }
.acc-entry .ae-scope { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 12.5px; color: var(--text-2); min-width: 0; }
.acc-entry .ae-scope .i { color: var(--text-3); }

/* ---------- List: search on top, cards scroll on their own ---------- */
.acc-entry .acc-list-head { padding: 8px 10px; gap: 8px; grid-template-columns: minmax(0, 1fr); }
.acc-entry .acc-find .search { flex: 1 1 0; min-width: 0; }
.acc-entry .acc-find .search .input { width: 100%; min-width: 0; }
.acc-entry .acc-arch-entry { padding: 0; }
.acc-entry .acc-cards { gap: 8px; padding: 8px; }
.acc-entry .acc-card { gap: 6px; padding: 10px 12px 11px; }
.acc-entry .ac-top { gap: 4px 8px; }
.acc-entry .ac-ref { font-size: 15px; }
/* Risk grade at the right of the reference; a grade warning (short label, full reason on hover / card focus) wraps
 * below on the left instead of stretching the top line. */
.acc-entry .ac-risk { display: contents; }
.acc-entry .ac-top .risk-chip { margin: 0 0 0 auto; }
.acc-entry .ac-top .risk-warn-wrap.in-link { margin: 0; }
.acc-entry .ac-title { font-size: 13.5px; font-weight: 600; color: var(--text); line-height: 1.35; overflow-wrap: anywhere; }
/* Each related vehicle on its own line (truck · VIN), then driver and date — every vehicle stays visible. */
.acc-entry .ac-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-width: 0; }
.acc-entry .ac-meta .ac-unit { display: contents; }
.acc-entry .ac-meta .ac-veh, .acc-entry .ac-meta .ac-truck.none { flex: 0 0 100%; }
.acc-entry .ac-meta .ac-veh { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 2px 8px; min-width: 0; }
.acc-entry .ac-meta .ac-truck.none { flex-basis: auto; margin-right: 100%; }
.acc-entry .ac-meta .ac-drv { flex: 0 1 auto; min-width: 0; overflow-wrap: anywhere; }
.acc-entry .ac-meta .ac-date { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 0 auto; white-space: nowrap; }
.acc-entry .ac-meta .ac-date .i { font-size: 12px; }
.acc-entry .ac-prog { display: grid; gap: 6px; padding-top: 6px; border-top: 1px dashed var(--border); }
.acc-entry .ac-reason { gap: 6px; }

/* ---------- Selected accident header: identity · related vehicles · risk · progress ---------- */
.acc-entry .ae-head { position: static; gap: 8px; padding: 10px 14px 10px; }
/* Line 1: reference + accident state | record actions. Line 2 (full width): accident title + reference note. */
.acc-entry .ae-h1 { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 14px; min-width: 0; }
.acc-entry .ae-h1 .aw-ref { display: contents; }
.acc-entry .ae-h1 .aw-kick { display: none; } /* the page title already says Accidents */
.acc-entry .ae-h1 .aw-ref h2 { grid-column: 1; grid-row: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 22px; min-width: 0; }
.acc-entry .ae-h1 .ae-sub { grid-column: 1 / -1; grid-row: 2; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; min-width: 0; }
.acc-entry .ae-h1 .aw-title { font-size: 14.5px; font-weight: 600; color: var(--text-2); line-height: 1.35; overflow-wrap: anywhere; }
.acc-entry .ae-h1 .aw-int { margin: 0; font-size: 11.5px; color: var(--text-3); }
.acc-entry .ae-h1 .aw-state .badge { font-size: 12.5px; }
.acc-entry .ae-acts { grid-column: 2; grid-row: 1; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px; }
.acc-entry .ae-h1 .acc-back { grid-column: 1 / -1; grid-row: 1; justify-self: start; }
.acc-entry .ae-h2 { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding-top: 8px; border-top: 1px solid var(--border); min-width: 0; }
.acc-entry .ae-veh { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.acc-entry .ae-h2 .aw-l2 { gap: 4px 16px; }
.acc-entry .ae-head .aw-risk { gap: 6px 10px; }
.acc-entry .ae-head .aw-prog { grid-template-columns: minmax(120px, 200px) minmax(0, 1fr) auto; gap: 6px 14px; padding-top: 8px; }
.acc-entry .ae-head .acc-strip.lg .sg { height: 8px; }
.acc-entry .ae-head .aw-counts { gap: 2px 14px; }
.acc-entry .ae-head .aw-counts b { font-size: 16px; }

/* ---------- Collapsed nine task rows: line 1 number · task · required · state · arrow; line 2 summary ---------- */
.acc-entry .acc-tasks { gap: 6px; }
.acc-entry .acc-task { scroll-margin-top: 8px; }
.acc-entry .acc-task-btn {
  grid-template-columns: 30px minmax(0, 1fr) 100px minmax(100px, 150px) 16px;
  grid-template-areas: "n t c st chev" "n s s s chev";
  gap: 3px 12px; padding: 9px 12px; align-items: center;
}
.acc-entry .acc-task-btn > .at-n { grid-area: n; align-self: center; }
.acc-entry .acc-task-btn > .at-t { grid-area: t; }
.acc-entry .acc-task-btn > .at-s { grid-area: s; }
.acc-entry .acc-task-btn > .at-c { grid-area: c; justify-content: flex-end; }
.acc-entry .acc-task-btn > .at-st { grid-area: st; }
.acc-entry .acc-task-btn > .at-chev { grid-area: chev; align-self: center; }
.acc-entry .at-t { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
.acc-entry .at-t b { font-size: 14px; line-height: 1.3; }
.acc-entry .at-s { font-size: 12.5px; font-weight: 400; line-height: 1.4; color: var(--text-2); overflow-wrap: break-word; }
.acc-entry .at-s:empty { display: none; }

/* ---------- Wide work space: bounded list beside a flexible work area ---------- */
@container acc-entry (min-width: 860px) {
  .acc-entry .acc-split { grid-template-columns: clamp(280px, 30cqi, 344px) minmax(0, 1fr); gap: 14px; }
  .acc-entry .acc-split.has-sel .acc-list { display: flex; }
  .acc-entry .acc-split.has-sel .acc-back, .acc-entry .acc-split .acc-back { display: none; }
  .acc-entry .acc-list { position: sticky; top: 0; max-height: calc(100vh - var(--header-h) - var(--tabs-h) - 28px); overflow: hidden; }
  .acc-entry .acc-cards { overflow-y: auto; }
  .acc-entry .ae-work { min-width: 0; }
  /* Enough height: the page fits the window; the list and the work area each scroll on their own. */
  @media (min-height: 560px) {
    .acc-entry .ae-frame { height: calc(100vh - var(--header-h) - var(--tabs-h) - 48px); min-height: 0; }
    /* A “Back to …” return link above the page (opened from another record) takes about one row. */
    .return-bar + .acc-entry .ae-frame { height: calc(100vh - var(--header-h) - var(--tabs-h) - 48px - 66px); }
    .acc-entry .acc-split { flex: 1 1 auto; min-height: 0; grid-template-rows: minmax(0, 1fr); align-items: stretch; }
    .acc-entry .acc-list { position: static; max-height: none; min-height: 0; }
    .acc-entry .ae-work { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 0 2px 12px 0; }
  }
  /* Tall windows keep the accident identity in view while working in a task. */
  @media (min-height: 860px) {
    .acc-entry .ae-head { position: sticky; top: 0; z-index: 3; }
    .acc-entry .acc-task { scroll-margin-top: 210px; }
  }
}

/* ---------- Narrow work space: one column — list, or the selected accident with “All accidents” ---------- */
@container acc-entry (max-width: 859px) {
  .acc-entry .acc-split { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .acc-entry .acc-list { position: static; max-height: none; overflow: visible; }
  .acc-entry .acc-cards { overflow: visible; }
  .acc-entry .acc-split.has-sel .acc-list { display: none; }
  .acc-entry .acc-split.has-sel .acc-back { display: inline-flex; }
  .acc-entry .acc-split:not(.has-sel) .ae-work { display: none; }
  .acc-entry .ae-status .acc-views { grid-template-columns: repeat(3, minmax(0, 1fr)); flex: 1 1 100%; }
  /* “All accidents” first, then the identity lines. */
  .acc-entry .acc-split.has-sel .ae-h1 .aw-ref h2, .acc-entry .acc-split.has-sel .ae-acts { grid-row: 2; }
  .acc-entry .acc-split.has-sel .ae-h1 .ae-sub { grid-row: 3; }
}
@container acc-entry (max-width: 559px) {
  .acc-entry .acc-task-btn {
    grid-template-columns: 30px auto minmax(0, 1fr) 16px;
    grid-template-areas: "n t t chev" ". s s ." ". c st .";
    gap: 4px 10px; padding: 10px;
  }
  .acc-entry .acc-task-btn > .at-c { justify-content: flex-start; }
  .acc-entry .ae-h1 .aw-ref h2 { font-size: 20px; grid-column: 1 / -1; }
  .acc-entry .acc-split.has-sel .ae-acts { grid-column: 1 / -1; grid-row: 4; justify-content: flex-start; padding-top: 4px; }
  .acc-entry .ae-head .aw-prog { grid-template-columns: minmax(0, 1fr); }
  .acc-entry .ae-head .aw-reasons { justify-content: flex-start; }
  .acc-entry .ae-status .acc-view { padding: 0 10px; gap: 6px; }
}
/* ---------- F2 · phone navigation: a visible, usable collapse control while the drawer is open ----------
 * Scoped to the app frame of a page that contains the Accident entry (.acc-entry). The off-canvas drawer (≤760px)
 * covers the header's own toggle; here that SAME toggle (data-act="toggle-sidebar", aria-label “Collapse navigation”)
 * is shown just right of the open drawer and above it, so pointer and keyboard (Tab · Enter / Space) both reach it.
 * Outside click and Escape keep closing the drawer. Other screens and the shared shell are unchanged. */
@media (max-width: 760px) {
  .app.is-mobile-open:has(.acc-entry) .topbar [data-act="toggle-sidebar"] {
    position: fixed; z-index: 61; top: calc(var(--header-h) + var(--tabs-h) + 8px); left: calc(var(--sidebar-w) + 8px);
    width: auto; height: 34px; display: inline-flex; align-items: center; gap: 6px; padding: 0 12px 0 10px;
    border: 1px solid var(--border-strong); border-radius: var(--r-control); background: var(--surface);
    color: var(--text); font-size: var(--fs-sm); font-weight: 600; box-shadow: var(--shadow-pop);
  }
  .app.is-mobile-open:has(.acc-entry) .topbar [data-act="toggle-sidebar"] .i { display: none; }
  .app.is-mobile-open:has(.acc-entry) .topbar [data-act="toggle-sidebar"]::before { content: "×"; font-size: 20px; line-height: 1; font-weight: 500; }
  .app.is-mobile-open:has(.acc-entry) .topbar [data-act="toggle-sidebar"]::after { content: "Collapse"; }
  .app.is-mobile-open:has(.acc-entry) .topbar [data-act="toggle-sidebar"]:hover { background: var(--surface-sunken); }
  .app.is-mobile-open:has(.acc-entry) .topbar [data-act="toggle-sidebar"]:focus-visible { box-shadow: var(--focus-ring), var(--shadow-pop); }
}
@container acc-entry (max-width: 420px) {
  .acc-entry .ae-status .acc-view .av-top .i { display: none; }
  .acc-entry .ae-status .acc-view .av-top { font-size: 12.5px; }
  .acc-entry .ae-status .acc-view .av-n { font-size: 18px; }
}

/* Keep the next accident task touchable while the mobile confirmation is visible. */
@media (max-width: 559px) {
  body:has(.acc-entry) .toast-region .toast { pointer-events: none; }
  body:has(.acc-entry) .toast-region .toast :is(button, a[href]) { pointer-events: auto; }
}

/* Keep the enhanced file input inside the accident completion drawer. */
#ca-ev.file-native,
#claim-filing-document.file-native,
#claim-correct-file.file-native { max-inline-size: 1px; }
