/* API compatibility layer for the protected original K-RAVE presentation shell. */
.hidden { display: none !important; }

#page-content {
  display: grid;
  gap: 16px;
  padding-bottom: 30px;
}

.original-boot-card {
  justify-items: center;
  color: var(--gold);
  font-size: 24px;
  letter-spacing: 0;
}

.loader {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(215, 181, 109, .25);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: krave-spin .8s linear infinite;
}

@keyframes krave-spin { to { transform: rotate(360deg); } }

.original-nav-close {
  display: none;
  margin: 0 14px 10px;
}

.original-refresh {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  min-width: 42px;
  padding: 0 11px;
  white-space: nowrap;
  flex: 0 0 auto;
}
.original-user-button { gap: 8px; }
.original-user-button #user-initials {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(215, 181, 109, .35);
  border-radius: 50%;
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
}

.original-user-menu {
  position: absolute;
  z-index: 90;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  min-width: 190px;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.top-actions { position: relative; }

.view-as,
.legacy-banner,
.global-notice,
.notice {
  padding: 11px 13px;
  border: 1px solid rgba(120, 168, 255, .28);
  border-radius: var(--radius);
  background: rgba(16, 81, 155, .13);
  color: var(--text);
}

.view-as,
.legacy-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.legacy-banner > div { display: grid; gap: 3px; }
.legacy-banner span { color: var(--muted); font-size: 12px; }
.notice.danger,
.global-notice.danger { border-color: rgba(240, 107, 107, .45); background: rgba(240, 107, 107, .11); }
.notice.success,
.global-notice.success { border-color: rgba(86, 211, 131, .4); background: rgba(86, 211, 131, .1); }

.panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(20, 28, 37, .94), rgba(10, 15, 21, .96));
  box-shadow: 0 12px 34px rgba(0, 0, 0, .2);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 15px; }
.panel-body { padding: 14px; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.metric {
  display: grid;
  gap: 7px;
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(14, 20, 27, .92);
}
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { color: var(--text); font-size: 24px; }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, .8fr); gap: 14px; }

.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
}
.quick-action {
  display: grid;
  gap: 6px;
  min-height: 92px;
  padding: 15px;
  text-align: left;
  border-color: rgba(215, 181, 109, .32) !important;
  background: rgba(215, 181, 109, .07) !important;
}
.quick-action strong { color: var(--gold); font-size: 15px; }
.quick-action span { color: var(--muted); font-size: 12px; }

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.filters label { min-width: 160px; }

#page-content button:not(.bottom-nav-item),
#modal button,
.original-user-menu button {
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--text);
}
#page-content button:hover,
#modal button:hover { border-color: rgba(215, 181, 109, .5); }
#page-content button.primary,
#modal button.primary { border-color: var(--brand); background: var(--brand); color: #fff; }
#page-content button.danger,
#modal button.danger { border-color: rgba(240, 107, 107, .55); color: #ffb4b4; }
#page-content button:disabled,
#modal button:disabled { cursor: not-allowed; opacity: .45; }

.table-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.cell-main { display: block; color: var(--text); font-weight: 650; }
.cell-sub { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.empty { padding: 24px; color: var(--muted); text-align: center; }
.pagination { display: flex; justify-content: space-between; gap: 12px; padding: 11px 14px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }

.badge.archived,
.badge.disabled,
.badge.revoked { color: var(--muted); border-color: var(--line); }
.badge.active,
.badge.approved,
.badge.generated,
.badge.green { color: var(--green); border-color: rgba(86, 211, 131, .35); }
.badge.cancelled,
.badge.blocked,
.badge.expired,
.badge.locked { color: #ffb4b4; border-color: rgba(240, 107, 107, .42); }

.original-subnav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0 2px;
}
.original-subnav button { white-space: nowrap; }
.original-subnav button.active { border-color: rgba(215, 181, 109, .52) !important; color: var(--gold) !important; background: rgba(215, 181, 109, .09) !important; }

.original-api-modal { width: min(720px, calc(100vw - 28px)); max-height: min(88vh, 850px); overflow: auto; }
.modal-body { padding: 14px 0; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full,
.form-grid .form-section { grid-column: 1 / -1; }
.form-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.form-grid input,
.form-grid select,
.form-grid textarea { width: 100%; }
.form-grid textarea { min-height: 88px; resize: vertical; }
.form-section h3 { margin: 8px 0 0; color: var(--gold); font-size: 13px; }
.field-error { min-height: 14px; color: #ff9c9c; font-size: 11px; }
.checkbox { display: flex !important; grid-column: 1 / -1; align-items: center; gap: 8px !important; }
.checkbox input { width: auto; }
.details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0; background: var(--line); }
.details > div { min-width: 0; padding: 10px 12px; background: var(--panel); }
.details dt { color: var(--muted); font-size: 11px; }
.details dd { margin: 4px 0 0; overflow-wrap: anywhere; }

/* Phase 9L.3A (5A): section labels on the Sale/Transfer Review step. Matches
   the existing .form-section h3 treatment so Review reads like the rest of the
   panel rather than introducing a new heading style. */
.review-heading { margin: 14px 0 6px; color: var(--gold); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
.review-heading:first-of-type { margin-top: 8px; }

@media (max-width: 900px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .original-nav-close { display: block; }
}

@media (max-width: 620px) {
  .metric-grid,
  .form-grid,
  .details { grid-template-columns: 1fr; }
  .metric { min-height: 78px; }
  .metric strong { font-size: 21px; }
  .toolbar,
  .filters { align-items: stretch; flex-direction: column; }
  .filters label { min-width: 0; }
  .view-as,
  .legacy-banner { align-items: stretch; flex-direction: column; }
  .original-user-button #user-label { display: none; }
}

/* ===== Phase 9L.4A: Global Mobile Shell, Touch Targets & Toast Clearance ===== */
.header-menu-toggle {
  min-height: 42px;
  min-width: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.mobile-menu {
  min-height: 42px;
  min-width: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.original-nav-close {
  min-height: 42px;
  min-width: 42px;
}
.modal-close {
  min-height: 42px;
  min-width: 42px;
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
}
.mobile-more-close {
  min-height: 42px;
  min-width: 42px;
}
.header-menu-items .btn {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}
.header-menu-items .lang-toggle .btn {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card .lang-toggle .btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 1050px) {
  .header-menu-items .btn {
    width: 100%;
  }
  .top-actions {
    display: flex !important;
    flex-direction: row;
    flex-wrap: nowrap;
    width: auto;
    gap: 8px;
    position: relative;
    align-items: center;
    flex: 0 0 auto;
  }
}

@media (min-width: 1051px) and (max-width: 1280px) {
  .header-menu-items .btn {
    width: 100%;
  }
  .top-actions {
    display: flex !important;
    flex-direction: row;
    flex-wrap: nowrap;
    width: auto;
    gap: 8px;
    position: relative;
    align-items: center;
    flex: 0 0 auto;
  }
}

@media (max-width: 640px) {
  .original-refresh .refresh-label {
    display: none;
  }
  .original-refresh {
    min-width: 42px !important;
    width: 42px;
    padding-inline: 0 !important;
    font-size: 17px;
  }
  .toast-host {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    z-index: 95;
  }
}

/* ===================== Phase 9L.4CD: cockpit + dense-data polish ===================== */
.dashboard-cockpit {
  display: grid;
  gap: 14px;
  min-width: 0;
}
.dashboard-cockpit > * { min-width: 0; margin: 0; }
.dashboard-ops-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(215, 181, 109, .42);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  background: rgba(215, 181, 109, .07);
}
.dashboard-ops-summary > div { display: grid; gap: 3px; min-width: 0; }
.dashboard-ops-summary span { color: var(--muted); font-size: 12px; font-weight: 750; }
.dashboard-ops-summary strong { color: var(--text); font-size: 20px; line-height: 1.2; overflow-wrap: anywhere; }
.dashboard-actions { display: grid; gap: 8px; }
.dashboard-actions header h2 { margin: 0; font-size: 15px; }
.dashboard-recent .panel-head button { min-height: 36px; }
.dash-recent-list { display: grid; }
.dash-recent-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft, rgba(255,255,255,.07));
}
.dash-recent-row:last-child { border-bottom: 0; }
.dash-recent-row > span { display: grid; gap: 2px; min-width: 0; }
.dash-recent-row > span:last-child { text-align: right; }
.dash-recent-row strong { overflow-wrap: anywhere; }
.dash-recent-row small { color: var(--muted); overflow-wrap: anywhere; }

/* Setup/unknown states are not success states. Healthy remains the only green state. */
.dashboard-attention.state-setup_required .attention-clear,
.dashboard-attention.state-no_operational_data .attention-clear { color: var(--orange); }
.dashboard-attention.state-unknown .attention-clear { color: var(--muted); }
.dashboard-attention.state-attention_required .attention-clear { color: var(--text); }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 12px 14px;
  border-top: 1px solid var(--line-soft, rgba(255,255,255,.07));
}
.pagination-summary { color: var(--muted); font-size: 12px; font-weight: 700; }
.pagination-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.pagination .page-button {
  min-width: 38px;
  min-height: 38px;
  padding: 7px 10px;
  white-space: nowrap;
}
.pagination .page-button.active {
  color: #071019;
  border-color: var(--gold);
  background: var(--gold);
  font-weight: 850;
}
.pagination-ellipsis { min-width: 18px; text-align: center; color: var(--muted); }

/* Long valid operational values wrap inside their own cells rather than widening the page. */
.table-wrap td,
.table-wrap .cell-main,
.table-wrap .cell-sub,
.location-pro-meta,
.panel-head span { overflow-wrap: anywhere; word-break: normal; }

.production-measure { white-space: nowrap; overflow-wrap: normal; }

/* Closed mobile navigation cannot intercept input while its transform completes. */
@media (max-width: 1050px) {
  .sidebar { pointer-events: none; }
  .sidebar.open { pointer-events: auto; }
  .sidebar-backdrop.hidden { pointer-events: none !important; }
}

/* Keep the compact utility-menu header through the former 1281px wrap point. */
@media (min-width: 1051px) and (max-width: 1360px) {
  .topbar { min-height: 80px; }
  .top-actions { max-width: none; }
}

@media (max-width: 640px) {
  .pagination { align-items: stretch; padding: 10px; }
  .pagination-summary { width: 100%; }
  .pagination-controls {
    display: grid;
    grid-template-columns: repeat(5, minmax(38px, auto));
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }
  #page-content .pagination .page-button { min-height: 44px; }
  .dashboard-ops-summary { align-items: stretch; flex-direction: column; }
  .dashboard-ops-summary button { min-height: 44px; }
  .dash-recent-row { gap: 10px; }
}

@media (max-width: 430px) {
  .topbar h2 {
    white-space: normal !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    font-size: 17px;
  }
  .report-action-card,
  .report-overview-card { padding: 11px; }
}

/* Phase 9L.5: operator hierarchy and bounded canonical-identity pickers. */
.nav-group { display: grid; gap: 3px; margin: 0 0 10px; }
.nav-group-label,
.mobile-more-group-label {
  padding: 8px 10px 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}
.mobile-more-group + .mobile-more-group { margin-top: 8px; }
@media (min-width: 1361px) and (max-width: 1600px) {
  .topbar { align-items: center; flex-wrap: nowrap; gap: 16px; }
  .topbar > div:first-child { min-width: 0; }
  .topbar h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .top-actions { position: relative; display: flex !important; flex: 0 0 auto; flex-wrap: nowrap; gap: 8px; }
  .header-menu-toggle { display: inline-flex !important; min-width: 44px; padding-inline: 11px; font-size: 18px; line-height: 1; }
  .top-actions .header-menu-items {
    position: absolute;
    z-index: 60;
    top: calc(100% + 8px);
    right: 0;
    display: none;
    width: min(240px, 80vw);
    padding: 10px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: 0 18px 44px rgba(0, 0, 0, .55);
  }
  .top-actions.header-menu-open .header-menu-items { display: flex; }
  .top-actions .header-menu-items .btn { width: 100%; justify-content: center; }
}
.hybrid-picker { position: relative; display: grid; gap: 4px; min-width: 0; }
.hybrid-picker-control { position: relative; min-width: 0; }
.hybrid-picker-control input[type="search"] { width: 100%; min-height: 42px; padding-right: 40px; }
.hybrid-picker-clear {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 34px;
  min-width: 34px !important;
  min-height: 34px !important;
  padding: 0 !important;
}
.hybrid-picker-list {
  position: absolute;
  z-index: 120;
  top: calc(100% - 1px);
  left: 0;
  right: 0;
  max-height: min(300px, 45vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.hybrid-picker-option {
  display: block;
  width: 100%;
  min-height: 42px !important;
  text-align: left;
  overflow-wrap: anywhere;
}
.hybrid-picker-option.active,
.hybrid-picker-option.selected { border-color: rgba(215, 181, 109, .62) !important; background: rgba(215, 181, 109, .1) !important; }
.hybrid-picker-empty { padding: 12px; color: var(--muted); text-align: center; }
.hybrid-picker-status { min-height: 14px; color: var(--muted); font-size: 11px; }
.quick-directory-links,
.filter-feedback,
.company-hub-actions,
.success-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}
.quick-directory-links > div:first-child,
.success-summary { display: grid; gap: 4px; }
.quick-directory-links span,
.filter-feedback span,
.success-summary p { margin: 0; color: var(--muted); font-size: 12px; }
.company-hub-actions { align-items: flex-start; flex-direction: column; margin: 12px 0; }
.company-create-actions { align-items: center; }

@media (max-width: 700px) {
  .quick-directory-links,
  .filter-feedback { align-items: stretch; flex-direction: column; }
  .company-create-actions { width: 100%; }
  .company-create-actions button { flex: 1 1 auto; }
  .hybrid-picker-list { max-height: min(260px, 40vh); }
}
/* ===================== END Phase 9L.4CD ===================== */

/* ===================== Phase 9L.4B: Mobile Operational Layouts ===================== */

/* 1. Bottom Navigation Clearance on Small Screens */
@media (max-width: 640px) {
  #page-content {
    padding-bottom: calc(84px + env(safe-area-inset-bottom)) !important;
  }
}

/* 2. Delivery Note Location Model & Fields */
.dn-delivery-location-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  grid-column: 1 / -1;
  margin-top: 4px;
}
.dn-delivery-location-field select {
  width: 100%;
  min-height: 42px;
  box-sizing: border-box;
}
.dn-delivery-location-field .field-hint {
  font-size: 11.5px;
  color: var(--muted, #94a3b8);
  margin-top: 2px;
  line-height: 1.4;
}

/* 3. Touch Targets & Ergonomics for Operational Controls (>= 42px) */
.stock-view-tab {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.stock-filter-pill {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.stock-control-action {
  min-height: 44px;
}
.activity-accordion-summary {
  min-height: 48px;
}
.history-text-action {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
}
.composer-remove {
  min-width: 42px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.wizard-btn,
.wizard-tab,
.wizard-option {
  min-height: 42px;
}
.top-actions .top-quick {
  min-height: 42px !important;
}
.header-menu-toggle {
  min-width: 42px;
  width: 42px !important;
  min-height: 42px !important;
}
.header-menu-items .btn {
  min-width: 42px;
  min-height: 42px;
}

/* 4. Audit Density & Horizontal Scroll Preservation for Raw/Audit Ledgers */
.advanced-ledger-shell .table-wrap,
.table-scrollable,
.table-wrap.table-scrollable,
.stock-ledger-table-wrap {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

@media screen and (max-width: 700px) {
  .advanced-ledger-shell .table-wrap,
  .table-scrollable,
  .table-wrap.table-scrollable,
  .stock-ledger-table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    display: block !important;
    border: 1px solid var(--line, rgba(255, 255, 255, 0.08)) !important;
    border-radius: var(--radius-sm, 6px);
    background: var(--surface, rgba(255, 255, 255, 0.02)) !important;
  }

  .advanced-ledger-shell .table-wrap table,
  .table-scrollable table,
  .table-wrap.table-scrollable table,
  .stock-ledger-table-wrap table {
    display: table !important;
    min-width: 640px !important;
    width: 100% !important;
    border-collapse: collapse !important;
    border-spacing: 0 !important;
  }

  .advanced-ledger-shell .table-wrap thead,
  .table-scrollable thead,
  .table-wrap.table-scrollable thead,
  .stock-ledger-table-wrap thead {
    display: table-header-group !important;
    position: static !important;
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
  }

  .advanced-ledger-shell .table-wrap tbody,
  .table-scrollable tbody,
  .table-wrap.table-scrollable tbody,
  .stock-ledger-table-wrap tbody {
    display: table-row-group !important;
  }

  .advanced-ledger-shell .table-wrap tr,
  .table-scrollable tr,
  .table-wrap.table-scrollable tr,
  .stock-ledger-table-wrap tr {
    display: table-row !important;
    border: none !important;
    border-bottom: 1px solid var(--line-soft, rgba(255, 255, 255, 0.06)) !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
  }

  .advanced-ledger-shell .table-wrap th,
  .advanced-ledger-shell .table-wrap td,
  .table-scrollable th,
  .table-scrollable td,
  .table-wrap.table-scrollable th,
  .table-wrap.table-scrollable td,
  .stock-ledger-table-wrap th,
  .stock-ledger-table-wrap td {
    display: table-cell !important;
    padding: 8px 10px !important;
    text-align: left !important;
    border-bottom: 1px solid var(--line-soft, rgba(255, 255, 255, 0.06)) !important;
    white-space: nowrap !important;
    grid-template-columns: none !important;
    gap: 0 !important;
  }

  .advanced-ledger-shell .table-wrap td::before,
  .table-scrollable td::before,
  .table-wrap.table-scrollable td::before,
  .stock-ledger-table-wrap td::before {
    display: none !important;
    content: none !important;
  }
}

/* 5. IBC Fleet Neutral Presentation (No unapproved traffic lights) */
.ibc-progress {
  width: 100%;
  height: 8px;
  background: var(--surface-2, rgba(255, 255, 255, 0.08));
  border-radius: 4px;
  overflow: hidden;
  margin: 6px 0 8px;
}
.ibc-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #d6b66d, #f59e0b);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.ibc-liquid {
  width: 100%;
  background: linear-gradient(180deg, rgba(214, 182, 109, 0.85), rgba(180, 145, 65, 0.95));
  border-top: 1px solid rgba(255, 255, 255, 0.3);
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  transition: height 0.3s ease;
}

/* 6. Filter and Toolbar Ergonomics on Mobile */
.stock-history-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
}
.stock-history-page > * { min-width: 0; max-width: 100%; }
.stock-history-page > .history-chip-row { grid-area: auto; }
.stock-history-page > .advanced-ledger-shell,
.stock-history-page .advanced-ledger-body,
.stock-history-page #ledger-body {
  min-width: 0;
  max-width: 100%;
  width: 100%;
}
@media (max-width: 700px) {
  .stock-history-page .activity-accordion-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }
  .stock-history-page .activity-accordion-main {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    min-width: 0;
  }
  .stock-history-page .activity-accordion-headline,
  .stock-history-page .activity-accordion-date {
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .stock-history-page .activity-accordion-figures { grid-column: 1; grid-row: 3; }
  .stock-history-page .activity-accordion-chevron { grid-column: 2; grid-row: 1; }
  #page-content .composer-flow button,
  #page-content .wizard-flow button,
  #modal-footer button {
    min-height: 42px;
    min-width: 42px;
  }
}
@media (max-width: 640px) {
  .history-chip-row {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }
  .history-summary-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
  }
  .stock-action-bar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
}
