/* Shared mobile conventions: small toolbars, explicit labels, and records with
 * their identity first. Opt-in tables retain all fields in their details. */
.mobile-record-toggle, .mobile-table-sort { display: none; }
.mobile-disclosure { display: contents; }
.mobile-disclosure > summary { display: none; }
.driver-status-meta { color: var(--theme-muted, #b5c2d4); font-size: 12px; line-height: 1.5; }
#expense-modal .expense-modal-card { background: var(--theme-surface, #0f172a); }
#expense-modal .expense-modal-body { background: var(--theme-surface, #0f172a); }
#expense-modal label { color: var(--theme-text, #e2e8f0); }
.pe-table .pe-description { max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.pe-payment { display: flex; align-items: center; gap: 5px; color: var(--theme-text, #e2e8f0); font-size: 13px; text-transform: capitalize; }
.pe-payment i { font-size: 12px; }

@media screen and (max-width: 768px) {
  .mobile-bottom-tab-bar .bottom-tab { font-size: 12px; letter-spacing: 0; }
  .mobile-bottom-tab-bar .bottom-tab span { white-space: normal; overflow-wrap: anywhere; line-height: 1.2; }
  :is(.main-content, .pe-page) { --mobile-border: var(--theme-border, rgba(148,163,184,.3)); --mobile-muted: var(--theme-muted, #b5c2d4); }
  .main-content :is(input, select, textarea) { min-width: 0; max-width: 100%; box-sizing: border-box; }
  .main-content :is(input[type=date], input[type=month], input[type=datetime-local]) { min-width: 0; min-height: 40px; font-size: 16px; padding: 7px 9px; }
  .main-content :is(h1, h2, h3, p, label) { overflow-wrap: anywhere; }
  .main-content :is(h1) { line-height: 1.25; }
  .main-content :is(.fm-wrap, .mt-wrap, .dash-wrap, .tach-wrap, .sc-workspace, .pricing, .dm-workspace) { min-width: 0; }
  .main-content :is(.fm-top, .mt-top, .sc-heading, .pricing-heading, .tach-top, .dm-heading) { gap: 10px; margin-bottom: 12px; }
  .main-content :is(.fm-top, .mt-top, .sc-heading, .pricing-heading, .tach-top, .dm-heading) h1 { font-size: 22px; margin: 0; }
  .main-content :is(.fm-search, .prof-search, #cm-search, #dm-search, #sc-search) { font-size: 16px; }
  .main-content :is(.fm-form-group, .mt-form-group) label { font-size: 13px; letter-spacing: 0; text-transform: none; }

  .mobile-disclosure { display: block; margin: 8px 0 12px; border: 1px solid var(--mobile-border); border-radius: 8px; }
  .mobile-disclosure > summary { display: list-item; padding: 11px 12px; cursor: pointer; font-size: 14px; font-weight: 650; color: var(--theme-text, #e2e8f0); }
  .mobile-disclosure[open] > summary { border-bottom: 1px solid var(--mobile-border); }
  .mobile-disclosure > [data-mobile-disclosure] { margin: 0; padding: 12px; }
  .mobile-table-sort { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin: 8px 0; font-size: 13px; }
  .mobile-table-sort select { width: auto; max-width: 70%; min-height: 40px; padding: 6px; font-size: 16px; color: var(--theme-text, #e2e8f0); background: var(--theme-surface, #1e293b); border: 1px solid var(--mobile-border); border-radius: 6px; }

  /* Deliberate opt-in, never apply card layouts to calendars or editor tables. */
  :is(.main-content, .pe-page) table[data-mobile-columns] { display: block; min-width: 0 !important; width: 100%; border-collapse: collapse; }
  table[data-mobile-columns] > thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table[data-mobile-columns] > tbody { display: block; width: 100%; }
  :is(.main-content, .pe-page) table[data-mobile-columns] .mobile-record { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px 12px; padding: 11px 12px; border: 0; border-bottom: 1px solid var(--mobile-border); border-radius: 0; background: var(--theme-surface, #18283e); }
  :is(.main-content, .pe-page) table[data-mobile-columns] .mobile-record > td { display: none !important; min-width: 0; width: auto; max-width: none; border: 0 !important; padding: 0 !important; font-size: 14px !important; line-height: 1.4; white-space: normal !important; overflow: visible !important; overflow-wrap: anywhere; text-align: left !important; color: var(--theme-text, #e2e8f0); }
  :is(.main-content, .pe-page) table[data-mobile-columns] .mobile-record > .mobile-record-title { display: block !important; grid-column: 1 / -1; order: -2; padding-right: 72px !important; font-size: 16px !important; font-weight: 650; }
  :is(.main-content, .pe-page) table[data-mobile-columns] .mobile-record > .mobile-record-preview { display: block !important; order: -1; }
  :is(.main-content, .pe-page) table[data-mobile-columns] .mobile-record-expanded > td { display: block !important; padding-top: 5px !important; }
  :is(.main-content, .pe-page) table[data-mobile-columns] .mobile-record > td:not(.mobile-record-title)::before { content: attr(data-mobile-label); display: block; font-size: 12px; font-weight: 500; color: var(--mobile-muted); margin-bottom: 2px; }
  .mobile-record-toggle { display: inline-flex; align-items: center; justify-content: center; position: absolute; right: 7px; top: 5px; min-width: 65px; min-height: 44px; padding: 7px; color: var(--theme-text, #e2e8f0); border: 0; border-radius: 6px; background: transparent; font-size: 13px; font-weight: 600; cursor: pointer; }
  .mobile-record-toggle:focus-visible { outline: 2px solid var(--theme-accent, #c9a961); outline-offset: -2px; }
  :is(.main-content, .pe-page) table[data-mobile-columns] .mobile-record > .fm-actions { grid-column: 1 / -1; }
  :is(.main-content, .pe-page) table[data-mobile-columns] .mobile-record .fm-act-btn { display: inline-flex; width: 44px; height: 44px; margin-right: 5px; }
  :is(.main-content, .pe-page) table[data-mobile-columns] .cell-vehicle-unit { min-width: 0; gap: 8px; }
  :is(.main-content, .pe-page) table[data-mobile-columns] .cell-vehicle-image { width: 38px; height: 38px; flex: 0 0 38px; }
  :is(.main-content, .pe-page) table[data-mobile-columns] .cell-vehicle-sub { max-width: none; white-space: normal; font-size: 13px; }
  .main-content :is(.fm-table-wrap, .mt-table-wrap, .sc-table-wrap, .pricing-table-wrap) { margin-left: 0; margin-right: 0; width: 100%; }

  /* Fleet, clients, maintenance and team summaries stay above their records. */
  .main-content :is(.fm-kpi-grid, .fm-kpi-grid.fm-kpi-2col, .mt-kpi-grid, .tach-kpi-grid, .sc-summary, .kpi-strip) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 10px 0 14px; }
  .main-content :is(.fm-kpi, .mt-kpi, .tach-kpi, .kpi-card, .sc-summary > div) { padding: 9px 10px; min-width: 0; min-height: 0; gap: 8px; }
  .main-content :is(.fm-kpi-label, .mt-kpi-label, .tach-kpi-lbl, .kpi-lbl, .sc-summary > div > span) { font-size: 12px; line-height: 1.3; letter-spacing: 0; text-transform: none; }
  .main-content :is(.fm-kpi-val, .mt-kpi-val, .tach-kpi-val, .kpi-val, .sc-summary strong) { font-size: 20px; line-height: 1.2; }
  .main-content :is(.fm-kpi-icon, .mt-kpi-icon, .tach-kpi-icon, .kpi-ico) { display: none; }
  .main-content :is(.fm-panel-header, .mt-panel-header) { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 0; }
  .main-content :is(.fm-add-btn, .mt-add-btn) { width: auto; padding: 8px 12px; }
  .main-content :is(.fm-tab, .mt-tab, .mt-sub-tab, .sc-tabs button) { font-size: 13px; text-transform: none; letter-spacing: 0; min-height: 44px; }
  .main-content .fm-tab-bar { margin-bottom: 6px; }
  .main-content :is(.sc-workspace, .dm-workspace) { padding: 12px; }
  .sc-summary small { display: none; }
  .sc-toolbar { gap: 8px; }
  .sc-toolbar label { font-size: 13px; }
  .sc-toolbar .sc-button { width: auto; margin-left: auto; }
  .sc-heading .sc-muted { display: none; }
  .dm-heading p { display: none; }
  .dm-tools { gap: 8px; }
  .dm-card-header h2, .dm-person h2 { white-space: normal; }

  /* Financial pages: the reporting period is secondary to the actual records. */
  :is(.theme-management-expenses, .theme-page-profitability) .main-content > .container { max-width: 100%; padding: 12px; }
  :is(.theme-management-expenses, .theme-page-profitability) .main-content h1 { font-size: 22px; }
  :is(.theme-management-expenses, .theme-page-profitability) .main-content h2 { font-size: 19px; }
  :is(.theme-management-expenses, .theme-page-profitability) .main-content .glass-panel.p-6 { padding: 12px; }
  :is(.theme-management-expenses, .theme-page-profitability) .main-content .text-4xl { font-size: 26px; }
  :is(.theme-management-expenses, .theme-page-profitability) .main-content :is(.mb-12, .mb-8) { margin-bottom: 18px; }
  :is(.theme-management-expenses, .theme-page-profitability) .main-content .gap-6 { gap: 12px; }
  .theme-management-expenses #pdf-dropzone { width: 100%; padding: 10px; display: flex; align-items: center; gap: 8px; text-align: left; }
  .theme-management-expenses #pdf-dropzone i { font-size: 20px; margin: 0; }
  .theme-management-expenses #pdf-dropzone p { font-size: 13px; margin: 0; }
  .theme-management-expenses #category-filters { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .theme-management-expenses #category-filters button { flex-shrink: 0; min-height: 40px; }
  .prof-filter-bar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .prof-filter-bar > * { min-width: 0; }
  .prof-filter-bar input[type=date] { width: 100%; }

  /* Operational screens retain visible identity and labelled dates. */
  .dispatch-toolbar { gap: 8px; padding: 10px; }
  .dispatch-toolbar-left { flex-direction: row; flex-wrap: wrap; justify-content: space-between; width: 100%; gap: 8px; }
  .dispatch-title { font-size: 20px; margin: 0; }
  .dispatch-date-wrap { width: auto; flex: 0 1 155px; }
  .dispatch-date-input { width: 100%; min-width: 0; }
  .dispatch-toolbar-right { gap: 6px; flex-wrap: wrap; }
  .dispatch-stat-badge { font-size: 12px; padding: 5px 8px; }
  .tach-controls { gap: 8px; padding: 10px; }
  .tach-date-input { width: auto; flex: 1; }
  .tach-label { font-size: 13px; }
  .tach-top h1 { font-size: 21px; }
  .tach-legend { flex-wrap: wrap; gap: 8px 12px; }
  .vacation-toolbar { gap: 8px; padding: 10px; }
  .vacation-toolbar label { min-width: 0; font-size: 13px; }
  .vacation-toolbar input[name=year] { width: 86px; }
  .vacation-heading h1 { font-size: 22px; }
  .pricing-heading h1 { font-size: 22px; }
  .pricing-panel { padding: 12px; }
  .pricing-fields { gap: 8px; }
  .pricing label { font-size: 13px; }
  .pricing-map-panel #prices-map { height: 260px; min-height: 0; }
  .email-assistant-container { padding: 12px; }

  /* Maps, charts, logs and technical grids scroll within their own region. */
  [data-mobile-scroll] { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
  [data-mobile-scroll]:focus-visible { outline: 2px solid var(--theme-accent, #c9a961); }
}
@media print {
  .mobile-record-toggle, .mobile-table-sort { display: none !important; }
}

.mobile-field-label { display: none; }
@media screen and (max-width: 768px) {
  .mobile-field-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
  .mobile-disclosure summary small { display: block; margin-top: 3px; font-size: 12px; font-weight: 400; color: var(--mobile-muted); }
  :is(.main-content, .pe-page) table[data-mobile-columns] .cell-driver { font-size: 14px; }
  :is(.main-content, .pe-page) table[data-mobile-columns] .mobile-record > td { box-shadow: none !important; }
  :is(.main-content, .pe-page) table[data-mobile-columns] .mobile-record > td:only-of-type { grid-column: 1 / -1; }
  .main-content .fm-wrap { padding: 8px; }
  .main-content .fm-table-wrap { margin-top: 6px; }
  .main-content .fm-kpi-grid { margin-bottom: 8px; }
  .main-content .email-assistant-page { padding: 14px; }
  .email-assistant-hero { gap: 10px; margin-bottom: 14px; }
  .email-assistant-hero h1 { font-size: 23px; }
  .email-assistant-hero p:not(.email-assistant-eyebrow) { font-size: 14px; margin-top: 6px; }
  .email-assistant-brand { display: none; }
  .email-assistant-card { padding: 14px; }
  .email-assistant-card-heading h2 { font-size: 18px; }
  .email-assistant-extension-state { padding: 10px; margin-bottom: 12px; }
  .email-period-controls { gap: 8px; }
  .email-custom-period:not([hidden]) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .email-period-field { min-width: 0; }
  .email-period-field input { width: 100%; }
  .theme-page-home .sidebar-card-header { font-size: 13px !important; }
  .theme-page-home .map-header h3 { font-size: 14px !important; }
  .theme-page-home .quick-action { font-size: 13px !important; min-height: 44px; }
  .theme-page-home .stat-label { font-size: 12px !important; letter-spacing: 0; }
  .theme-page-home .activity-text { font-size: 14px; }
  .theme-page-home .city-home-meta { font-size: 13px; }
  .theme-page-home .activity-time { font-size: 12px; }
  .cam-wrap { padding: 10px; }
  .cam-top h1 { font-size: 22px; }
  .cam-kpi-inline { flex-wrap: wrap; gap: 6px; }
  .cam-kpi-pill { padding: 6px 9px; font-size: 13px; }
  .cam-card-header { padding: 10px; }
  .cam-card-title { font-size: 15px; }
  .cam-layout, .cam-grid { gap: 12px; }
  .page-wrap { margin: 12px auto; gap: 12px; }
  .page-wrap .card { padding: 16px; text-align: left; }
  .page-wrap .card h2 { font-size: 20px; }
  .page-wrap .card :is(.muted, .file-note) { font-size: 14px; }
  .theme-page-client_map_editor .cme-sidebar-header { padding: 12px; }
  .theme-page-client_map_editor .cme-sidebar-header h2 { font-size: 20px; }
  .theme-page-client_map_editor :is(.cme-tab, .cme-entity-tab) { min-height: 42px; font-size: 13px; }
  .theme-page-client_map_editor .cme-search input { font-size: 16px; }
  .theme-page-clients_map .content-area > h1 { font-size: 22px; margin-bottom: 6px; }
  .theme-page-clients_map .content-area > p { font-size: 14px; margin-bottom: 10px; }
  .theme-page-statistics .main-content .container { max-width: 100% !important; padding: 10px; margin-top: 8px; }
  .theme-page-statistics h1 { font-size: 22px; }
  .theme-page-statistics h2 { font-size: 18px; margin-top: 18px; }
  .theme-page-statistics :is(#company-select, #month-select, #month-a-select, #month-b-select) { width: 100%; min-height: 44px; font-size: 16px; }
  .theme-page-statistics .table-wrapper { overflow-x: auto; }
  .theme-page-statistics .table-wrapper table { min-width: 580px; }
  .theme-page-statistics .table-wrapper th:first-child, .theme-page-statistics .table-wrapper td:first-child { position: sticky; left: 0; min-width: 130px; max-width: 180px; white-space: normal; background: var(--theme-surface, #18283e); }
  .driver-welcome { padding: 12px; gap: 8px; }
  .driver-welcome-text h2 { font-size: 21px; }
  .driver-welcome-time { font-size: 22px; }
  .driver-welcome-date { font-size: 13px; }
  .driver-day-plan { padding: 12px; }
  .driver-plan-client { font-size: 16px; white-space: normal; }
  .driver-plan-meta { font-size: 13px; }
  .driver-entries-search input { font-size: 16px; }
  .driver-panel-header h3 { font-size: 17px; }
  .pe-wrap { padding: 12px; }
  .pe-table-header { padding: 12px; gap: 8px; }
  .pe-category-pills { flex-wrap: nowrap; overflow-x: auto; }
  .pe-pill { flex-shrink: 0; min-height: 40px; }
  .theme-admin-workspace .container { width: 100%; box-sizing: border-box; padding: 10px; }
  .theme-admin-workspace :is(.table-responsive, .model-list) { max-width: 100%; overflow-x: auto; }
  .theme-admin-workspace .model-list { display: block; }
  .theme-admin-workspace :is(input:not([type=checkbox]):not([type=radio]), select, textarea) { min-width: 0; max-width: 100%; font-size: 16px; }
  .theme-admin-workspace .nav-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
  .theme-admin-workspace .nav-tabs > li { float: none; }
  .theme-page-database .pin-card { padding: 20px; width: min(100%, 340px); box-sizing: border-box; }
}

.sc-filter-fields { display: contents; }
@media screen and (max-width: 768px) {
  .main-content .mobile-summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px !important; margin-bottom: 12px !important; }
  .main-content .mobile-summary-grid > .glass-panel { min-height: 0; padding: 10px !important; text-align: left; }
  .main-content .mobile-summary-grid .w-12 { display: none; }
  .main-content .mobile-summary-grid .text-4xl { font-size: 22px !important; margin: 4px 0; }
  .main-content .mobile-summary-grid p.text-xs { font-size: 12px !important; letter-spacing: 0 !important; text-transform: none; }
  .main-content .mobile-summary-grid .justify-between { display: block; }
  .main-content .mobile-expense-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px !important; width: 100%; }
  .mobile-expense-actions > .relative { grid-column: 1 / -1; }
  .main-content .mobile-expense-actions #pdf-dropzone { grid-column: 1 / -1; padding: 8px 10px !important; }
  .main-content .mobile-expense-actions :is(#export-btn, #add-expense-btn) { width: 100% !important; padding: 8px !important; }
  .sc-toolbar > .mobile-disclosure { flex-basis: 100%; order: 3; width: 100%; margin: 0; }
  .sc-toolbar > .sc-search { flex: 1 1 180px; }
  .sc-toolbar > .sc-button { align-self: end; }
  .sc-filter-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .sc-filter-fields label { min-width: 0; }
  .sc-table .mobile-record-title strong { font-size: 16px; }
  .sc-table .mobile-record-title small { font-size: 13px; font-weight: 400; }
}

.dm-card-disclosure { display: contents; }
.dm-card-disclosure > summary { display: none; }
@media screen and (max-width: 768px) {
  .main-content .mobile-summary-grid .mt-3 { display: flex; margin-top: 4px !important; padding: 0 !important; border: 0; background: transparent !important; box-shadow: none; font-size: 12px !important; letter-spacing: 0 !important; }
  .main-content .dispatch-toolbar-left { display: grid; grid-template-columns: minmax(0, 1fr) 132px; gap: 6px; }
  .main-content .dispatch-title { font-size: 18px; }
  .main-content .dispatch-date-wrap { width: 132px; max-width: 132px; padding: 0; border: 0; }
  .main-content .dispatch-date-wrap > i { display: none; }
  .main-content .dispatch-date-input { font-size: 14px !important; padding: 6px !important; min-height: 40px; }
  .dispatch-stat-badge { min-width: 0; display: flex; flex-wrap: wrap; justify-content: center; text-align: center; gap: 3px; }
  .dispatch-stat-badge i { display: none; }
  .dispatch-stat-badge strong { flex-basis: 100%; }
  .dm-main #dm-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .dm-main .dm-driver-card { height: auto; min-height: 0; }
  .dm-card-disclosure { display: block; }
  .dm-card-disclosure > summary { display: list-item; padding: 10px 12px; font-size: 13px; color: var(--dm-text); cursor: pointer; }
  .dm-card-disclosure > summary span { display: block; padding-top: 3px; color: var(--dm-muted); font-size: 12px; }
  .dm-main .dm-card-history-bottom { display: none; }
  .dm-main .dm-person strong { font-size: 16px; white-space: normal; }
  .dm-main .dm-person small { font-size: 13px; white-space: normal; }
  .dm-main .dm-card-panel { height: auto; min-height: 0; padding: 12px; }
  .dm-main .dm-card-metrics { gap: 10px; }
  .dm-main .dm-card-metrics span:not(.dm-skeleton) { font-size: 12px; }
  .dm-main .dm-card-metrics strong { font-size: 15px; }
  .dm-main .dm-card-tabs button { min-height: 40px; font-size: 13px; }
  .dm-main .dm-card-actions .dm-button { min-height: 40px; font-size: 13px; }
  .dm-main .dm-card-note { font-size: 13px; }
  .dm-main .dm-stat-top span { font-size: 12px; }
  .main-content .h-kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
  .main-content .h-kpi { min-height: 0; padding: 10px; }
  .main-content .h-kpi-label { font-size: 12px; letter-spacing: 0; }
  .main-content :is(.h-lbl, .h-val, .h-jetson-metric-detail) { font-size: 13px; white-space: normal; }
}
@media screen and (max-width: 768px) {
  .theme-page-dashboard .gasoleo-block { display: none; }
  .theme-page-dashboard .calc-card { padding: 10px; }
  .theme-page-dashboard .calc-card > .sec-title { display: none; }
  .theme-page-dashboard .calc-card > .mobile-disclosure { margin: 0; }
  :is(.theme-page-profitability, .theme-management-expenses) .glass-panel > .border-b { padding: 10px !important; gap: 8px; background: var(--theme-header, #203149) !important; }
  :is(.theme-page-profitability, .theme-management-expenses) .glass-panel > .border-b h3 { font-size: 16px !important; }
}
@media screen and (max-width: 768px) {
  .driver-day-plan-head { flex-wrap: wrap; padding: 10px; gap: 10px; }
  .driver-day-plan-title { flex: 1 1 160px; min-width: 0; }
  .driver-day-plan-title h3 { font-size: 17px; }
  .driver-day-plan-title p { font-size: 13px; }
  .driver-plan-nav { flex: 1 1 100%; justify-content: space-between; }
  .driver-week-overview { gap: 8px; flex-wrap: wrap; padding: 10px; }
  .driver-week-label { font-size: 13px; }
  .main-content .tach-controls { display: grid; grid-template-columns: 42px minmax(0, 1fr); align-items: center; padding: 10px; }
  .tach-controls .tach-label { margin: 0; font-size: 13px; text-transform: none; letter-spacing: 0; }
  .tach-controls .tach-date-input { width: 100%; font-size: 14px; }
  .tach-controls .tach-sep { display: none; }
  .tach-controls .tach-view-btns { min-width: 0; flex-wrap: nowrap; }
  .tach-controls .tach-view-btn { font-size: 13px; padding: 6px; }
  .tach-controls .tach-action-row { grid-column: 1 / -1; }
}
@media screen and (max-width: 768px) {
  .main-content :is(.fm-kpi-label, .mt-kpi-label, .fm-panel-count, .mt-panel-count, .tach-kpi-lbl) { color: var(--theme-muted, #b5c2d4); }
}

@media screen and (max-width: 768px) {
  :is(.main-content, .pe-page) .mobile-record > td button:not(.mobile-record-toggle) { min-width: 44px; min-height: 44px; }
}

/* Forms and overlays use the space left by browser chrome and the keyboard. */
@media screen and (max-width: 768px), screen and (max-width: 1024px) and (max-height: 500px) {
  html { scroll-padding-top: 60px; scroll-padding-bottom: 90px; }
  :is(.fm-overlay, .mt-overlay, .popup-dd-overlay, .dispatch-manual-task-overlay, .swal2-container) {
    box-sizing: border-box;
    top: var(--mobile-viewport-top, 0px) !important;
    bottom: auto !important;
    height: var(--mobile-viewport-height, 100dvh) !important;
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }
  :is(.fm-overlay, .mt-overlay) { align-items: center !important; z-index: 20000; }
  .swal2-container { z-index: 30000 !important; overflow-y: auto; }
  :is(.fm-modal:not(.fm-modal-sm), .mt-modal) {
    box-sizing: border-box; display: flex; flex-direction: column;
    width: 100%; max-width: 560px;
    max-height: calc(var(--mobile-viewport-height, 100dvh) - 24px - env(safe-area-inset-bottom));
    overflow: hidden; border-radius: 14px;
  }
  :is(.fm-modal-head, .mt-modal-head) { flex-shrink: 0; padding: 10px 12px; gap: 10px; }
  :is(.fm-modal-head, .mt-modal-head) h3 { font-size: 17px; line-height: 1.35; }
  :is(.fm-modal-body, .mt-modal-body) { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px; scroll-padding: 12px; }
  :is(.fm-modal-foot, .mt-modal-foot) { flex-shrink: 0; flex-direction: row; gap: 8px; padding: 10px 12px; }
  :is(.fm-modal-foot, .mt-modal-foot) > button { flex: 1; width: auto !important; min-height: 44px; margin: 0; }
  :is(.fm-modal-x, .mt-modal-x, .popup-dd-close, .sc-close, #dm-close, #close-modal-x, #closeModal) { min-width: 44px; min-height: 44px; flex-shrink: 0; }
  :is(.fm-form-group, .mt-form-group) { min-width: 0; margin-bottom: 12px; }
  :is(.fm-form-group, .mt-form-group) label { font-size: 13px !important; text-transform: none; letter-spacing: 0; line-height: 1.4; }
  :is(.fm-modal, .mt-modal, .sc-dialog, .dm-dialog, .pricing-dialog, .pe-modal-content, .swal2-popup, .dispatch-manual-task-dialog, .vacation-dialog) :is(input:not([type=checkbox]):not([type=radio]):not([type=hidden]), select, textarea) {
    box-sizing: border-box; min-width: 0; max-width: 100%; font-size: 16px !important; min-height: 44px;
  }
  :is(.fm-modal, .mt-modal, .sc-dialog, .dm-dialog, .pricing-dialog, .pe-modal-content) :is(input, select, textarea):focus { scroll-margin-block: 16px; }
  :is(.sc-dialog, .dm-dialog, .pricing-dialog, .vacation-dialog, .extension-install-dialog, .pe-modal-content, .swal2-popup) {
    box-sizing: border-box;
    max-width: calc(100vw - 16px) !important;
    max-height: calc(var(--mobile-viewport-height, 100dvh) - 24px - env(safe-area-inset-bottom)) !important;
    overflow-y: auto; overscroll-behavior: contain;
  }
  .popup-dd-panel { max-height: calc(var(--mobile-viewport-height, 100dvh) - 24px); border-radius: 12px; }
  .popup-dd-header { flex-shrink: 0; padding: 8px 12px; }
  .popup-dd-title { overflow-wrap: anywhere; }
  .popup-dd-search-wrap { flex-shrink: 0; }
  .popup-dd-list { min-height: 0; overscroll-behavior: contain; }
  .swal2-title { font-size: 20px !important; padding: 16px 16px 0; }
  .swal2-html-container { margin: 12px 16px !important; font-size: 15px !important; overflow-wrap: anywhere; }
  .swal2-actions { gap: 8px; margin: 10px 12px 14px; }
  .swal2-actions button { min-height: 44px; margin: 0 !important; }
  #expense-modal { z-index: 20000; }
  #expense-modal .expense-modal-viewport { top: var(--mobile-viewport-top, 0px); height: var(--mobile-viewport-height, 100dvh); bottom: auto; }
  #expense-modal .expense-modal-centre { box-sizing: border-box; min-height: 100%; padding: 8px; }
  #expense-modal .expense-modal-card { display: flex; flex-direction: column; width: 100%; max-width: 520px; max-height: calc(var(--mobile-viewport-height, 100dvh) - 16px); }
  #expense-modal .expense-modal-heading { flex-shrink: 0; padding: 10px 12px; }
  #expense-modal #modal-title { flex: 1; min-width: 0; font-size: 18px; }
  #expense-modal #close-modal-x { width: 44px !important; }
  #expense-modal .expense-modal-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px; }
  #expense-modal .expense-modal-actions { display: flex; flex-shrink: 0; gap: 8px; padding: 10px 12px; }
  #expense-modal .expense-modal-actions button { flex: 1; width: auto !important; margin: 0; min-height: 44px; }
  #expense-modal :is(input,select,textarea) { min-width: 0; max-width: 100%; font-size: 16px !important; }
  #expense-modal label { font-size: 13px !important; text-transform: none; letter-spacing: 0; }
  body:has(.fm-overlay.open, .mt-overlay.open, .popup-dd-visible, #expense-modal:not(.hidden)) { overflow: hidden; }
  body:has(.fm-overlay.open, .mt-overlay.open, .popup-dd-visible, #expense-modal:not(.hidden), dialog[open], .swal2-container) #ai-chat-bubble { visibility: hidden; pointer-events: none; }
  html[data-mobile-keyboard] :is(.mobile-bottom-tab-bar, .fixed-header, #ai-chat-bubble) { visibility: hidden; pointer-events: none; }
  html[data-mobile-keyboard] #ai-chat-panel { top: var(--mobile-viewport-top, 0px); bottom: auto !important; max-height: calc(var(--mobile-viewport-height, 100dvh) - 8px) !important; }
}
@media screen and (max-width: 768px) {
  .vertical-navbar { height: 100dvh !important; max-width: calc(100vw - 48px); }
  .vertical-navbar .nav-link { min-height: 44px; }
  .main-content { padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)) !important; }
  .main-content > .content-area { min-width: 0; }
  :is(.sc-dialog, .pricing-dialog, .pe-modal-content) { padding: 14px; }
  .pe-page { padding: 12px; }
  .pe-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .pe-month-nav { grid-column: 1 / -1; justify-content: space-between; }
  .pe-actions { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .pe-controls .pe-btn { min-height: 44px; width: 100%; justify-content: center; }
  .pe-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .pe-stat { min-width: 0; flex-direction: column; align-items: flex-start; gap: 6px; }
  .pe-stat-icon { display: none; }
  .pe-stat-content { width: 100%; }
  .pe-stat-lbl { font-size: 12px; letter-spacing: 0; text-transform: none; }
  .pe-charts-grid { grid-template-columns: minmax(0, 1fr); }
  .pe-chart-box { min-width: 0; }
  .pe-chart-box canvas { max-width: 100%; }
  .pe-page .pe-table { min-width: 0; }
  .pe-page :is(.pe-stat-label, .pe-stat-sub, .pe-table-footer) { font-size: 12px; }
  .pe-page .pe-table-search input { min-height: 44px; font-size: 16px; }
  .pe-page .pe-modal-footer { flex-direction: row; }
  .vacation-main .vacation-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .vacation-main .vacation-toolbar label { min-width: 0; font-size: 13px; }
  .vacation-main .vacation-toolbar label:has(select) { grid-column: 1 / -1; order: 2; font-size: 13px; }
  .vacation-main .vacation-toolbar select { flex: 1; width: 100%; max-width: none; min-width: 0; }
  .vacation-main .vacation-toolbar :is(input, select, button) { min-height: 44px; font-size: 16px; }
  .vacation-main .vacation-toolbar h2 { grid-column: 1 / -1; }
  .vacation-main .vacation-toolbar .vacation-summary { grid-column: 1 / -1; order: 3; max-width: none; }
  .vacation-details-dialog { box-sizing: border-box; max-width: calc(100vw - 24px); max-height: calc(var(--mobile-viewport-height, 100dvh) - 24px); overflow-y: auto; }
}
@media screen and (max-width: 1024px) and (max-height: 500px) {
  .fixed-header { height: 36px !important; }
  .fixed-header .header-logo img { width: 26px !important; height: 26px !important; }
  .top-right-welcome-bar { display: none !important; }
  .main-content { margin-top: 44px !important; }
}

/* Transport and tachograph pages share the same comfortable phone canvas. */
.vd-mobile-heading, .vd-mobile-search { display: none; }
@media (max-width: 768px) {
  body.operations-mobile-page { background: #0f1929 !important; }
  html[data-theme="light"] body.operations-mobile-page { background: #f5f6f8 !important; }
  body.operations-mobile-page::before, body.operations-mobile-page::after { display: none !important; }
  body.operations-mobile-page:is(.view-data-page, .tachograph-page) .main-content {
    box-sizing: border-box; width: 100% !important; max-width: 100% !important;
    margin: 58px 0 0 !important; padding: 22px 18px 100px !important;
    border: 0 !important; border-radius: 0 !important; background: transparent !important;
    box-shadow: none !important; backdrop-filter: none !important;
  }
  html body.operations-mobile-page .main-content .content-area {
    min-width: 0; padding: 0 !important; border: 0 !important; border-radius: 0 !important;
    background: transparent !important; box-shadow: none !important;
  }
  body.operations-mobile-page .content-area::before, body.operations-mobile-page .content-area::after { display: none !important; }
  .vd-mobile-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
  .vd-mobile-heading p { margin: 0 0 6px; color: var(--vd-text-secondary); font-size: 11px; font-weight: 650; letter-spacing: .14em; text-transform: uppercase; }
  .vd-mobile-heading h1 { margin: 0; font-size: 28px; line-height: 1.2; font-weight: 700; color: var(--vd-text-primary); }
  .vd-mobile-search { display: block; margin-bottom: 12px; }
  .vd-mobile-search .vd-filter-lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .vd-mobile-search #filter-container { width: 100%; min-height: 48px; padding: 12px 14px; font: inherit; font-size: 16px; background: var(--theme-input, #172437); border: 1px solid var(--vd-border); border-radius: 12px; color: var(--vd-text-primary); }
  .vd-mobile-search #filter-container::placeholder { color: var(--vd-text-secondary); opacity: 1; }
  body.view-data-page .vd-filter-system { padding: 0; border: 0; background: transparent !important; box-shadow: none; margin-bottom: 16px; }
  body.view-data-page .vd-filter-title { font-size: 14px; gap: 9px; padding: 0 4px; }
  body.view-data-page .vd-filter-actions { gap: 8px; }
  body.view-data-page :is(#generate-report, #export-button) { background: transparent !important; border: 1px solid var(--vd-border) !important; border-radius: 10px !important; color: var(--vd-text-primary) !important; box-shadow: none !important; }
  body.view-data-page .vd-filter-grid { gap: 14px 12px; padding-top: 12px; }
  body.view-data-page .vd-filter-lbl { font-size: 13px; line-height: 1.4; text-transform: none; letter-spacing: 0; }
  body.view-data-page .vd-filter-item:last-child { grid-column: 1 / -1; }
  body.view-data-page .vd-mobile-search .vd-filter-item { width: 100%; }
  body.view-data-page .popup-dd-trigger { font-size: 16px; }
  body.view-data-page #vd-data-status { font-size: 13px; line-height: 1.5; margin: 0 0 12px; }
  body.view-data-page .vd-table-card { border-radius: 14px; background: var(--theme-surface, #172437); }
  body.view-data-page .view-data-table tbody tr {
    grid-template-columns: minmax(0, 1fr) 88px 44px;
    grid-template-areas: "container price price" "client client client" "date vehicle actions";
    column-gap: 8px; row-gap: 8px; padding: 16px 14px 8px;
    background: transparent !important; border-bottom: 1px solid var(--vd-border-subtle);
    box-shadow: none !important;
  }
  body.view-data-page .view-data-table tbody tr:last-child { border-bottom: 0; }
  body.view-data-page .view-data-table tbody tr.has-guide { box-shadow: none !important; }
  body.view-data-page .view-data-table tbody td { font-size: 14px !important; line-height: 1.5 !important; }
  body.view-data-page .view-data-table tbody :is(.vd-cell-client, .vd-cell-container) { white-space: normal !important; overflow-wrap: anywhere; overflow: visible; }
  body.view-data-page .view-data-table tbody .vd-cell-container { font-size: 16px !important; letter-spacing: 0; }
  body.view-data-page .view-data-table tbody .vd-cell-price { font-size: 16px !important; font-variant-numeric: tabular-nums; }
  body.view-data-page .view-data-table tbody :is(.vd-cell-date, .vd-cell-vehicle) { font-size: 13px !important; align-self: center; }
  body.view-data-page .vd-details-button { width: 44px; min-width: 44px; min-height: 44px; border-radius: 8px; }
  body.view-data-page .vd-details-button:focus-visible { outline: 2px solid var(--vd-gold); outline-offset: -2px; }
  body.view-data-page #pagination-container:empty { display: none; }
  .swal2-popup.vd-service-modal {
    display: flex !important; flex-direction: column; overflow: hidden; padding: 0 !important;
    background: var(--theme-surface, #172437); color: var(--theme-text, #e2e8f0); border-radius: 16px;
  }
  .vd-service-modal .swal2-html-container { padding: 0 !important; min-height: 0; overflow-y: auto; overscroll-behavior: contain; color: inherit; }
  .vd-service-modal .swal2-actions { flex-shrink: 0; width: auto; align-self: stretch; border-top: 1px solid var(--theme-border, #334155); padding-top: 12px; }
  .vd-service-modal .swal2-confirm { width: 100%; background: #c9a961 !important; color: #15243a !important; border-radius: 10px; }
  .vd-service-modal .swal2-title { flex-shrink: 0; color: inherit; font-size: 22px; padding: 20px 20px 0; }
  .vd-service-modal .vd-service-details { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .vd-service-modal .vd-service-details > div { padding-bottom: 12px; border-bottom: 1px solid var(--theme-border, #334155); }
  .vd-service-modal .vd-service-details dt { font-size: 13px; opacity: 1; color: var(--theme-muted, #aab8cd); }
  .vd-service-modal .vd-service-details dd { font-size: 16px; }
}
@media (max-width: 360px) {
  body.operations-mobile-page:is(.view-data-page, .tachograph-page) .main-content { padding-left: 14px !important; padding-right: 14px !important; }
  body.view-data-page .view-data-table tbody tr { grid-template-columns: minmax(0, 1fr) 78px 44px; column-gap: 6px; padding-left: 12px; padding-right: 12px; }
  body.view-data-page .view-data-table tbody .vd-cell-price { font-size: 14px !important; }
}

/* A calm card surface separates records without decorative table borders. */
@media (max-width: 768px) {
  body.view-data-page .vd-table-card { background: transparent !important; }
  body.view-data-page .view-data-table tbody { display: grid; gap: 12px; }
  body.view-data-page .view-data-table tbody tr,
  body.view-data-page .view-data-table tbody tr.has-guide,
  body.view-data-page .view-data-table tbody tr:last-child {
    padding: 16px 16px 10px; border: 1px solid rgba(148, 163, 184, .17) !important;
    border-radius: 16px; background: linear-gradient(120deg, #19283c, #162235) !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .08) !important;
  }
  html[data-theme="light"] body.view-data-page .view-data-table tbody tr {
    background: #fff !important; border-color: #dce3ec !important; box-shadow: 0 3px 12px rgba(32, 49, 73, .04) !important;
  }
  body.view-data-page .view-data-table tbody .vd-cell-price { color: var(--theme-accent, #e2c787); }
  body.view-data-page .view-data-table tbody .vd-cell-client { color: var(--theme-muted, #b5c2d4); }
  body.view-data-page .view-data-table tbody .vd-cell-vehicle { padding: 4px 6px !important; background: rgba(148, 163, 184, .08); border-radius: 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
  body.view-data-page .vd-details-button { border: 1px solid var(--vd-border-subtle); border-radius: 50%; background: rgba(148, 163, 184, .04); color: var(--vd-text-primary); }
  body.view-data-page .view-data-table tbody tr.missing-article { border-left: 3px solid #c9a961 !important; }
  body.view-data-page .vd-mobile-heading { margin-bottom: 20px; }
  body.operations-mobile-page .mobile-chat-dock #ai-chat-bubble { background: transparent !important; border: 1px solid rgba(148,163,184,.25) !important; box-shadow: none !important; color: var(--theme-muted, #b5c2d4) !important; }
}
@media (max-width: 768px) {
  html[data-theme="light"] body.view-data-page.operations-mobile-page .view-data-table tbody tr:nth-child(n) {
    background: #fff !important; border: 1px solid #dce3ec !important;
  }
  html[data-theme="light"] body.view-data-page.operations-mobile-page .view-data-table tbody td {
    background: transparent !important; border: 0 !important;
  }
  html[data-theme="light"] body.view-data-page.operations-mobile-page .view-data-table tbody .vd-cell-vehicle {
    background: #f1f4f8 !important;
  }
}

/* Dense phone browsing: one search/filter row and three-line service records. */
@media (max-width: 768px) {
  body.view-data-page.operations-mobile-page .main-content { padding-top: 10px !important; }
  body.view-data-page .vd-mobile-heading { margin-bottom: 10px; min-height: 44px; }
  .vd-mobile-heading p { display: none; }
  .vd-mobile-heading h1 { font-size: 24px; }
  .vd-mobile-search { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
  body.view-data-page .vd-mobile-search .vd-filter-item { flex: 1; width: auto; min-width: 0; }
  .vd-mobile-search #filter-container { height: 44px; min-height: 44px; padding: 8px 12px; border-radius: 10px; }
  .vd-mobile-search .vd-filter-title { flex: 0 0 44px; min-width: 44px; min-height: 44px; justify-content: center; border: 1px solid var(--vd-border); border-radius: 10px; gap: 2px; }
  .vd-mobile-search .vd-filter-title > [data-i18n], .vd-mobile-search .vd-filter-chevron { display: none; }
  body.view-data-page .vd-filter-toolbar { display: none; }
  body.view-data-page .vd-filter-system { margin: 0; }
  body.view-data-page #vd-filter-panel { margin-bottom: 12px; }
  body.view-data-page #vd-filter-panel .vd-filter-actions { padding-top: 8px; justify-content: flex-end; }
  body.view-data-page #vd-data-status { margin-bottom: 8px; font-size: 12px; }
  body.view-data-page .view-data-table tbody { gap: 6px; }
  body.view-data-page .view-data-table tbody tr,
  body.view-data-page .view-data-table tbody tr.has-guide,
  body.view-data-page .view-data-table tbody tr:last-child {
    grid-template-columns: minmax(0, 1fr) 76px 44px;
    grid-template-areas: "container price actions" "client client actions" "date vehicle actions";
    padding: 10px 10px 10px 12px; row-gap: 3px; column-gap: 6px; border-radius: 12px;
  }
  body.view-data-page .view-data-table tbody :is(.vd-cell-container, .vd-cell-price) { font-size: 14px !important; line-height: 20px !important; }
  body.view-data-page .view-data-table tbody .vd-cell-client { font-size: 13px !important; line-height: 18px !important; }
  body.view-data-page .view-data-table tbody :is(.vd-cell-date, .vd-cell-vehicle) { font-size: 12px !important; line-height: 18px !important; }
  body.view-data-page .view-data-table tbody .vd-cell-vehicle { padding: 0 !important; background: transparent !important; }
  html[data-theme="light"] body.view-data-page.operations-mobile-page .view-data-table tbody .vd-cell-vehicle { background: transparent !important; }
  body.view-data-page .vd-cell-actions { align-self: center; }
}
@media (max-width: 768px) {
  body.view-data-page .view-data-table tbody tr,
  body.view-data-page .view-data-table tbody tr.has-guide,
  body.view-data-page .view-data-table tbody tr:last-child {
    grid-template-areas: "container price driver" "client client actions" "date vehicle actions";
  }
  body.view-data-page .view-data-table tbody .vd-cell-driver { display: flex; grid-area: driver; align-items: center; justify-content: center; overflow: visible; }
  body.view-data-page .vd-cell-driver .driver-badge { width: 26px; height: 24px; border-radius: 7px; font-size: 10px; }
}
