/*
 * Final responsive geometry layer.
 * Keeps authenticated pages inside the viewport and switches tablets to the drawer shell.
 */
.app-shell:not(.public-shell)
  :where(
    .page-content,
    .dashboard-header,
    .dashboard-metric-grid,
    .dashboard-list-grid,
    .dashboard-main-grid,
    .deadline-list,
    .metric-card,
    .table-panel,
    .table-scroll
  ) {
  min-width: 0;
  max-width: 100%;
}

.app-shell:not(.public-shell)
  :where(.page-intro, .metric-card span, .deadline-list strong, .deadline-list small) {
  overflow-wrap: anywhere;
  word-break: normal;
}

@media (max-width: 1180px) {
  .app-shell:not(.public-shell) {
    grid-template-areas:
      "header"
      "main";
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--shell-header-height) minmax(0, 1fr);
  }

  .app-shell:not(.public-shell) > .app-sidebar {
    position: fixed;
    top: var(--shell-header-height);
    right: auto;
    bottom: 0;
    left: 0;
    width: min(19rem, calc(100vw - 2rem));
    max-width: 100%;
    height: auto;
    padding: 1rem 0.875rem;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-104%);
    transition:
      transform var(--transition-fast),
      visibility 0s linear 140ms;
    z-index: 40;
  }

  .app-shell:not(.public-shell) > .app-sidebar.is-open {
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
    transition-delay: 0s;
  }

  .app-shell:not(.public-shell) > .drawer-scrim {
    position: fixed;
    top: var(--shell-header-height);
    right: 0;
    bottom: 0;
    left: 0;
    display: block;
    visibility: hidden;
    border: 0;
    opacity: 0;
    pointer-events: none;
    touch-action: none;
    background: rgba(0, 32, 66, 0.5);
    transition:
      opacity var(--transition-fast),
      visibility 0s linear 140ms;
    z-index: 35;
  }

  .app-shell:not(.public-shell) > .drawer-scrim.is-open {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transition-delay: 0s;
  }

  .app-shell:not(.public-shell) .app-topbar {
    padding: 0 1rem;
  }

  .app-shell:not(.public-shell) .drawer-toggle {
    display: inline-grid;
    min-width: 2.5rem;
    min-height: 2.5rem;
    border-color: var(--line, #d1d1d1);
    color: var(--primary, #002855);
    background: var(--surface, #ffffff);
  }

  .app-shell:not(.public-shell) .topbar-brand {
    display: inline-flex;
    flex: 0 1 auto;
    max-width: 13rem;
    color: var(--primary, #002855);
  }

  .app-shell:not(.public-shell) .topbar-brand-icon {
    width: 1.75rem;
    height: 1.75rem;
  }

  .app-shell:not(.public-shell) .user-chip,
  .app-shell:not(.public-shell) .side-brand {
    display: none;
  }

  .app-shell:not(.public-shell) .main-nav {
    padding-top: 0;
  }

  .app-shell:not(.public-shell) .page-content {
    width: auto;
    margin-right: 1.25rem;
    margin-left: 1.25rem;
    padding: 1.5rem 0 2.5rem;
  }

  .dashboard-main-grid,
  .analytics-main-grid,
  .report-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .dashboard-side,
  .analytics-side,
  .report-side {
    position: static;
  }
}

@media (max-width: 760px) {
  .table-scroll .damage-table.mobile-priority-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
  }

  .mobile-priority-table colgroup,
  .mobile-priority-table > thead > tr > th,
  .mobile-priority-table > tbody > tr > td {
    display: none;
  }

  .mobile-priority-table
    > thead
    > tr
    > :is(.mobile-primary, .mobile-context, .mobile-status, .mobile-actions),
  .mobile-priority-table
    > tbody
    > tr
    > :is(.mobile-primary, .mobile-context, .mobile-status, .mobile-actions),
  .mobile-priority-table > tbody > tr > td[colspan] {
    display: table-cell;
    min-width: 0;
    padding: 0.75rem 0.45rem;
    overflow-wrap: anywhere;
  }

  .mobile-priority-table .mobile-primary {
    width: 38%;
  }

  .mobile-priority-table .mobile-context,
  .mobile-priority-table .mobile-status {
    width: 27%;
  }

  .mobile-priority-table .mobile-actions {
    width: 35%;
    min-width: 0;
  }

  .mobile-priority-table .mobile-status .status-badge {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .mobile-priority-table
    .mobile-actions
    :is(.inline-link, .link-button, .primary-button, .secondary-button, select) {
    display: flex;
    align-items: center;
    width: fit-content;
    max-width: 100%;
    min-width: 0;
    min-height: 2.75rem;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    margin: 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .mobile-priority-table
    .mobile-actions
    :is(.inline-link, .link-button, .primary-button, .secondary-button, select)
    + :is(.inline-link, .link-button, .primary-button, .secondary-button, select) {
    margin-top: 0.375rem;
    margin-left: 0;
  }

  .driver-vehicle-detail .table-scroll,
  .driver-vehicle-detail-page .table-scroll {
    overflow-x: auto;
  }

  .driver-vehicle-detail .damage-table,
  .driver-vehicle-detail-page .damage-table {
    min-width: 0;
  }

  .app-shell:not(.public-shell) .app-topbar {
    gap: 0.5rem;
    padding: 0 0.75rem;
  }

  .app-shell:not(.public-shell) .topbar-brand {
    max-width: 10.5rem;
  }

  .app-shell:not(.public-shell) .topbar-action {
    min-width: 0;
    padding: 0.375rem 0.625rem;
    font-size: 0.78rem;
    white-space: nowrap;
  }

  .app-shell:not(.public-shell) .page-content {
    margin-right: 0.875rem;
    margin-left: 0.875rem;
    padding-top: 1rem;
  }

  .dashboard-header {
    align-items: stretch;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.25rem;
  }

  .dashboard-header .header-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 0.625rem;
  }

  .dashboard-header .header-actions > * {
    width: 100%;
    min-width: 0;
  }

  .dashboard-metric-grid,
  .dashboard-list-grid,
  .deadline-columns {
    grid-template-columns: minmax(0, 1fr);
  }

  .dashboard-metric-grid {
    gap: var(--space-3, 24px);
    margin-bottom: var(--space-4, 32px);
  }

  .dashboard-metric-grid .metric-card {
    width: 100%;
    min-height: 96px;
    padding: 0.8rem 0.9rem;
  }

  .dashboard-metric-grid .metric-card strong {
    margin: 0.55rem 0 0;
    font-size: 2rem;
  }

  .deadline-list {
    padding: 0.95rem;
  }

  .deadline-list li {
    align-items: stretch;
    flex-direction: column;
    gap: 0.5rem;
  }

  .deadline-list time {
    white-space: normal;
  }
}

@media (max-width: 520px) {
  .app-shell:not(.public-shell) .app-topbar {
    gap: 0.375rem;
    padding: 0 0.5rem;
  }

  .app-shell:not(.public-shell) .drawer-toggle {
    min-width: 2.25rem;
    min-height: 2.25rem;
  }

  .app-shell:not(.public-shell) .topbar-brand-name,
  .app-shell:not(.public-shell) .topbar-password-action {
    display: none;
  }

  .app-shell:not(.public-shell) .topbar-brand-icon {
    width: 1.5rem;
    height: 1.5rem;
  }

  .app-shell:not(.public-shell) .page-content {
    margin-right: 0.625rem;
    margin-left: 0.625rem;
    padding-bottom: 2rem;
  }

  .dashboard-header .header-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .dashboard-header h1 {
    font-size: 1.65rem;
  }

  .dashboard-header .page-intro {
    font-size: 0.9rem;
  }
}

@media (max-width: 380px) {
  .app-shell:not(.public-shell) .page-content {
    margin-right: 0.5rem;
    margin-left: 0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-shell:not(.public-shell) > .app-sidebar,
  .app-shell:not(.public-shell) > .drawer-scrim {
    transition: none;
  }
}
