/* WorkshopERP 2.2.6: unified, readable responsive theme.
   Loaded after the original and footer legacy styles. Screen only: no change to invoices/receipts/print templates.
   Original brand gradients, financial calculations and workflow logic are preserved. */
@media screen {
  :root {
    --aw-ui-gutter:clamp(12px,1.55vw,24px);
    --aw-field-padding:10px 12px;
    --aw-ui-line-height:1.5;
  }
  html { min-width:320px; }
  html,body { max-width:100%; }
  body { line-height:var(--aw-ui-line-height); }
  #app-shell,.app-shell,.main,.page { min-width:0; }
  .main { overflow:clip; }
  .page { width:100%; max-width:1780px; margin-inline:auto; padding:12px var(--aw-ui-gutter) 24px; }
  .page :is(.panel,.form-grid,.settings-shell,.settings-content,.table-wrap,.page-hero,.showroom-transaction-form),
  .page :is(.autoerp-dashboard,.autoerp-dashboard-top,.autoerp-dashboard-grid,.autoerp-kpis,.autoerp-secondary-grid,.showroom-mini-grid,.vb-dashboard-grid,.vb-kpi-grid,.vb-quick-grid) { min-width:0; max-width:100%; }
  .page :is(.panel-head,.page-hero,.top-search,.settings-tab,.record-detail-row,.showroom-mini-list>a) > * { min-width:0; }
  .page :is(h1,h2,h3,h4,p,small,strong,b,em,label) { overflow-wrap:break-word; }
  .panel { border-radius:12px; }
  .panel-head { height:auto!important; min-height:52px; padding:12px 16px; gap:12px; flex-wrap:wrap; align-items:center; }
  .panel-head :is(h2,h3) { line-height:1.35; }
  .panel-head p { font-size:max(11px,calc(11px * var(--aw-font-scale,1)))!important; line-height:1.45; }
  .page-hero { min-height:76px; padding:14px 16px; gap:12px; flex-wrap:wrap; }
  .page-hero :is(h1,h2,p) { margin-block:4px; }
  .page-hero .hero-actions,.panel-head .actions { display:flex; flex-wrap:wrap; align-items:center; gap:8px; max-width:100%; }
  .page :is(label,.field-label) { line-height:1.4; }
  .page :is(input:not([type=checkbox]):not([type=radio]):not([type=range]),select,textarea),
  .settings-shell :is(input:not([type=checkbox]):not([type=radio]):not([type=range]),select,textarea) {
    box-sizing:border-box; min-width:0; max-width:100%; min-height:38px; padding:var(--aw-field-padding); line-height:1.45;
    font-size:max(12px,calc(12px * var(--aw-font-scale,1)))!important;
  }
  .page textarea,.settings-shell textarea { min-height:82px; height:auto; }
  .page :is(.aw-select,.aw-select-trigger,.aw-select-popover) { min-width:0; max-width:100%; }
  .page .aw-select-trigger { min-height:39px; padding:9px 12px; white-space:normal; line-height:1.35; }
  .page .aw-select-option { line-height:1.5; white-space:normal; padding:9px 12px; }
  .page :is(.btn,a.btn,button.btn) { min-height:35px; height:auto!important; padding:8px 12px; line-height:1.35; white-space:normal; text-align:center; }
  .page .btn.sm { min-height:32px; padding:7px 10px; }
  .page :is(.form-grid,.form-grid-compact,.showroom-form-grid,.gp2-form-grid) > * { min-width:0; }
  .page :is(.form-grid,.form-grid-compact,.showroom-form-grid,.gp2-form-grid) { gap:12px; }
  .table-wrap,.dashboard-table-wrap,.showroom-list-panel .table-wrap,.record-list .table-wrap,
  .crm-table-panel .table-wrap,.accessory-stock-list .table-wrap,.accessory-transaction-list .table-wrap {
    min-width:0; max-width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; overscroll-behavior-inline:contain;
  }
  .page :is(th,td) { padding:10px 12px!important; line-height:1.45; vertical-align:middle; }
  .page thead th { letter-spacing:.02em; }
  .page td :is(a,b,small,span) { line-height:1.4; }
  .page :is(.dashboard-compact-table,.aw-testdrive-dashboard-widget table) { min-width:700px; }
  .page .dashboard-compact-table { table-layout:auto; }
  .page .dashboard-compact-table :is(th,td) { padding:9px 12px!important; }
  .page .dashboard-compact-table td small { overflow:visible; text-overflow:clip; white-space:normal; font-size:11px; }
  .page td .status { display:inline-flex; max-width:100%; white-space:normal; }
  .side-nav .nav-text { overflow-wrap:anywhere; }
  .sidebar-premium .nav-link { min-height:42px; height:auto!important; padding-block:7px!important; }
  .sidebar-premium .nav-text { white-space:normal; text-overflow:clip; line-height:1.4; overflow:visible; }
  .sidebar-premium .nav-group-toggle { height:auto!important; min-height:35px; line-height:1.4; }
  .sidebar-premium .brand-copy { min-width:0; }
  .sidebar-premium .brand-copy :is(b,small) { overflow-wrap:anywhere; white-space:normal; }
  .app-shell.sidebar-collapsed .sidebar-premium .nav-link { min-height:40px; height:42px!important; padding:0!important; }
  .topbar { min-height:56px; height:auto!important; padding:8px var(--aw-ui-gutter); gap:10px; flex-wrap:wrap; }
  .topbar .top-search { flex:1 1 200px; min-width:130px; }
  .topbar .top-actions { flex:0 0 auto; max-width:100%; }
  .topbar .user-menu { min-width:0; }
  .vb-top-menu { top:0; min-width:0; max-width:100%; }
  .vb-top-links { min-width:0; overflow-x:auto; overscroll-behavior-x:contain; scrollbar-width:thin; }
  .aw-top-division-switch { flex:0 0 auto; }

  /* Two and only two dashboard tabs, sized for readable labels. */
  .business-dashboard-tabs.autoerp-business-tabs.aw-business-switcher {
    width:100%; max-width:650px; display:grid; grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:8px; padding:7px; margin:10px 0 16px; border-radius:13px;
  }
  .business-dashboard-tabs.autoerp-business-tabs.aw-business-switcher :is(a,.aw-disabled-dashboard-option) {
    display:flex; align-items:center; justify-content:flex-start; gap:11px; min-height:62px; min-width:0; padding:11px 15px!important;
    border-radius:10px; line-height:1.4; text-align:left;
  }
  .business-dashboard-tabs.autoerp-business-tabs.aw-business-switcher :is(a,.aw-disabled-dashboard-option) > span { flex:0 0 34px; width:34px; height:34px; display:grid; place-items:center; }
  .business-dashboard-tabs.autoerp-business-tabs.aw-business-switcher :is(a,.aw-disabled-dashboard-option) b {
    display:block; font-size:max(13px,calc(13px * var(--aw-font-scale,1)))!important; line-height:1.3; white-space:normal;
  }
  .business-dashboard-tabs.autoerp-business-tabs.aw-business-switcher :is(a,.aw-disabled-dashboard-option) small {
    display:block!important; font-size:max(11px,calc(11px * var(--aw-font-scale,1)))!important; white-space:normal;
  }

  /* Remove fixed heights and overflow clipping from both dashboards. */
  .autoerp-dashboard { display:grid; gap:16px; min-width:0; }
  .autoerp-dashboard-top { display:grid; grid-template-columns:minmax(0,1fr) minmax(220px,260px); gap:14px; }
  .autoerp-welcome-hero { height:auto!important; min-height:144px; padding:22px 24px; }
  .autoerp-welcome-hero .welcome-copy { z-index:1; min-width:0; }
  .autoerp-welcome-hero h1 { font-size:clamp(20px,2vw,28px)!important; line-height:1.18; white-space:normal; }
  .autoerp-welcome-hero p { font-size:clamp(12px,1vw,14px); line-height:1.5; }
  .autoerp-welcome-hero em { display:block; line-height:1.4; }
  .autoerp-date-card { height:auto!important; min-height:144px; padding:18px; background:var(--panel); border-color:var(--line); }
  .autoerp-date-card :is(small,span) { font-size:12px; line-height:1.35; }
  .autoerp-date-card>b { font-size:17px; line-height:1.3; overflow-wrap:anywhere; }
  .autoerp-date-card>div { grid-template-columns:10px minmax(0,1fr); gap:8px; align-items:start; }
  .autoerp-date-card>div small { grid-column:2; }
  .autoerp-kpis,.autoerp-kpis.aw-combined-kpis { display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr))!important; gap:12px; }
  .autoerp-kpis article { display:flex; align-items:center; gap:12px; height:auto!important; min-height:110px; padding:16px; overflow:visible; }
  .autoerp-kpis article>span { flex:0 0 44px; }
  .autoerp-kpis article>div { min-width:0; flex:1; }
  .autoerp-kpis article :is(small,b,em) { display:block; white-space:normal; overflow-wrap:anywhere; line-height:1.3; }
  .autoerp-kpis article small { font-size:12px!important; }
  .autoerp-kpis article b { font-size:clamp(18px,1.7vw,26px)!important; margin:6px 0; }
  .autoerp-kpis article em { font-size:11px!important; }
  .autoerp-dashboard-grid { display:grid; grid-template-columns:minmax(0,1.22fr) minmax(0,1fr) minmax(0,1.05fr); gap:14px; align-items:stretch; }
  .autoerp-dashboard-card { height:auto!important; min-height:286px; overflow:visible!important; margin:0!important; }
  .autoerp-dashboard-card .panel-head { height:auto!important; min-height:54px; padding:12px 16px; }
  .autoerp-dashboard-card .panel-head h2 { font-size:14px!important; }
  .autoerp-revenue-chart { height:196px; min-height:190px; padding:16px 14px 6px; }
  .autoerp-revenue-chart .revenue-axis { font-size:11px; }
  .autoerp-revenue-chart small { font-size:10px; }
  .autoerp-donut-layout { display:grid; grid-template-columns:135px minmax(0,1fr); height:auto; min-height:198px; gap:12px; padding:16px; align-items:center; overflow:visible; }
  .autoerp-donut { max-width:100%; }
  .autoerp-donut:before { background:var(--panel); }
  .autoerp-status-legend { gap:10px; min-width:0; }
  .autoerp-status-legend span { grid-template-columns:10px minmax(0,1fr) auto; gap:7px; }
  .autoerp-status-legend b,.autoerp-status-legend em { font-size:11px; line-height:1.35; }
  .autoerp-status-legend em { color:var(--muted); white-space:normal; text-align:right; }
  .appointment-list { height:auto; max-height:290px; overflow-y:auto; padding:10px 14px 14px; }
  .appointment-list>div:not(.empty-mini) { height:auto; min-height:46px; padding-block:8px; gap:8px; grid-template-columns:80px 110px minmax(140px,1fr) auto; }
  .appointment-list>div :is(b,strong,span) { white-space:normal; overflow-wrap:anywhere; line-height:1.35; }
  .autoerp-quick-actions { min-width:0; }
  .autoerp-action-row { display:grid; grid-template-columns:repeat(auto-fit,minmax(165px,1fr)); gap:10px; padding:12px 14px 16px; }
  .autoerp-action-row a { height:auto!important; min-height:56px; padding:10px 12px; justify-content:flex-start; text-align:left; gap:10px; }
  .autoerp-action-row a b { min-width:0; font-size:12px!important; line-height:1.35; white-space:normal; overflow-wrap:anywhere; }
  .autoerp-secondary-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; align-items:stretch; }
  .autoerp-secondary-grid .span-2 { grid-column:1/-1; }
  .autoerp-mini-dashboard-card { overflow:visible; min-width:0; }
  .autoerp-mini-dashboard-card :is(.dashboard-queue-list,.showroom-mini-list,.dashboard-performance) { min-width:0; }
  .autoerp-list-kpis { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:10px; }
  .autoerp-list-kpis article { min-height:78px; height:auto; }
  .showroom-mini-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(270px,1fr)); gap:14px; }
  .showroom-mini-list>a { min-height:56px; padding:10px 4px; }
  .showroom-mini-list :is(b,small,strong,em) { white-space:normal; overflow-wrap:anywhere; line-height:1.35; }
  .showroom-ops-summary { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .vb-hero { min-height:0; padding:20px 22px; gap:16px; flex-wrap:wrap; }
  .vb-hero-copy,.vb-hero-actions { min-width:0; }
  .vb-kpi-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); gap:12px; }
  .vb-kpi { min-width:0; min-height:113px; height:auto; padding:15px; }
  .vb-kpi>div { min-width:0; }
  .vb-kpi :is(small,strong,p) { white-space:normal; overflow-wrap:anywhere; }
  .vb-dashboard-grid { display:grid; grid-template-columns:minmax(0,1.6fr) minmax(270px,1fr); gap:14px; }
  .vb-quick-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(185px,1fr)); gap:10px; padding:12px 14px 16px; }
  .vb-quick-grid a { min-width:0; height:auto; min-height:78px; padding:12px; }
  .vb-quick-grid a :is(b,small) { white-space:normal; overflow-wrap:anywhere; }
  .aw-testdrive-widget-summary { gap:10px; margin:0 14px 16px; }
  .aw-testdrive-widget-summary a { padding:16px; }
  .aw-testdrive-dashboard-widget .panel-head { gap:12px; }
  .aw-drive-filter-bar a { line-height:1.45; white-space:normal; }
  .settings-shell { min-width:0; gap:14px; }
  .settings-content,.settings-side { min-width:0; }
  .settings-tab { min-height:53px; height:auto; padding:10px; }
  .settings-tab :is(b,small) { white-space:normal; overflow:visible; }
  .quick-launcher-panel { max-width:min(680px,calc(100vw - 28px)); }
  .quick-launcher-links a :is(b,small) { white-space:normal; overflow:visible; }
}

/* Full DARK scheme across navigation, dashboards, cards, dropdowns, lists, forms,
   dialogs, settings, feature requests, branch branding and login. */
@media screen {
  html[data-theme="dark"] { color-scheme:dark; background:#0b1422; }
  html[data-theme="dark"] body {
    --bg:#0b1422; --panel:#182537; --panel2:#202f44; --text:#ebf2fc;
    --muted:#afc1d7; --line:#344760; --soft-blue:#203d5d; --aw-card:#182537;
    --aw-shadow:0 5px 20px rgba(0,0,0,.23); --shadow:0 6px 22px rgba(0,0,0,.25);
    --aw-ui-border:#344760; --aw-ui-subtle:#202f44;
    background:#0b1422!important; color:var(--text);
  }
  html[data-theme="dark"] :is(.main,.page,.app-footer) { background:var(--bg); color:var(--text); }
  html[data-theme="dark"] :is(.topbar,.vb-top-menu,.sidebar.sidebar-premium) {
    background:#142235; border-color:var(--line); color:var(--text);
  }
  html[data-theme="dark"] .sidebar.sidebar-premium { box-shadow:3px 0 18px rgba(0,0,0,.16); }
  html[data-theme="dark"] .sidebar :is(.brand-copy b,.nav-group-toggle,.nav-text,.mini-user b,.sidebar-status-card b) { color:#e8f2ff; }
  html[data-theme="dark"] .sidebar :is(.brand-copy small,.mini-user small,.sidebar-section-label) { color:#aebed4; }
  html[data-theme="dark"] .sidebar :is(.nav-link:hover,.sidebar-quick a:hover) { background:#273950; }
  html[data-theme="dark"] .sidebar :is(.sidebar-quick a,.sidebar-status-card,.sidebar-collapse-btn,.nav-icon,.sidebar-section-label .nav-collapse-all) {
    background:#21334a; color:#dae8f9; border-color:var(--line);
  }
  html[data-theme="dark"] .sidebar .nav-link.active { background:linear-gradient(90deg,#194978,#21364d); color:#fff; }
  html[data-theme="dark"] .sidebar .nav-link.active .nav-icon { background:#1569c6; color:#fff; }
  html[data-theme="dark"] .sidebar :is(.nav-group-toggle:hover,.nav-collapse-all:hover) { background:#283a51; }
  html[data-theme="dark"] :is(.top-search,.branch-context-switch,.top-workspace-menu,.aw-top-division-switch,.vb-header-mega) { background:#202f44; border-color:var(--line); color:var(--text); }
  html[data-theme="dark"] .aw-top-division-switch a:not(.active) { color:#c6d7e9; }
  html[data-theme="dark"] .top-search :is(input,kbd),
  html[data-theme="dark"] .topbar :is(.user-menu b,.user-menu small,.workspace-copy b,.workspace-copy small) { color:var(--text); }
  html[data-theme="dark"] :is(.panel,.data-panel,.settings-side,.settings-content,.settings-panel,.autoerp-date-card,
    .autoerp-list-kpis article,.showroom-mini-card,.showroom-ops-summary>div,.vb-kpi,.vb-chart-panel,
    .autoerp-dashboard-card,.autoerp-mini-dashboard-card,.record-summary-strip article,
    .charge-live-summary>span,.charge-override form,.report-summary-strip article,.permission-category,
    .permission-category-head,.permission-module,.gatepass-choice,.crm-kpis article,.crm-pipeline div,
    .fr-timeline article,.td-event,.aw-testdrive-widget-summary a,.settings-recovery-card,.settings-help,
    .job-customer-hint,.job-type-active,.autoerp-bottom-actions,.quick-launcher-panel,
    .dashboard-quick-launch,.dash-quick-btn,.public-feedback-card) {
    background:var(--panel); color:var(--text); border-color:var(--line);
  }
  html[data-theme="dark"] :is(.panel-head,.settings-side-head,.settings-tab-list,.settings-section,
    .crm-subnav,.toolbar.autoerp-filterbar,.autoerp-filterbar,.job-create-tabs,
    .record-list>.table-wrap,.vb-quick-panel,.quick-launcher-search,.quick-launcher-head,
    .quick-launcher-links a,.aw-drive-settings-reminder) {
    background:var(--panel); border-color:var(--line); color:var(--text);
  }
  html[data-theme="dark"] :is(.settings-tab:hover,.settings-tab.active,.quick-launcher-links a:hover,
    .crm-subnav a:hover,.showroom-mini-list>a:hover,.vb-pipeline-list>a:hover,
    .table-wrap tbody tr:hover td,.side-nav .nav-link:hover) { background:#243b55; color:var(--text); }
  html[data-theme="dark"] :is(.settings-tab.active,.settings-tab.active b) { color:#edf6ff; }
  html[data-theme="dark"] :is(.panel-head h2,.panel h2,.page-hero h2,.autoerp-date-card b,
    .dashboard-performance b,.showroom-mini-list b,.showroom-mini-list strong,
    .vb-kpi strong,.vb-quick-grid b,.aw-testdrive-widget-summary b,
    .settings-section h2,.settings-tab b,.record-detail-value) { color:var(--text); }
  html[data-theme="dark"] :is(.panel p,.panel-head p,.muted,.help-text,.hint,.sub,.showroom-mini-list small,
    .showroom-ops-summary span,.autoerp-date-card>small,.autoerp-date-card>span,
    .fr-timeline small,.td-event small,.aw-drive-settings-reminder p,.settings-tab small,
    .vb-pipeline-list small,.vb-quick-grid small,.quick-launcher-links small) { color:var(--muted); }
  html[data-theme="dark"] :is(.table-wrap,table,thead,tbody,tfoot,th,td,.record-list,.record-detail-row) {
    background:transparent; border-color:var(--line); color:var(--text);
  }
  html[data-theme="dark"] :is(th,thead th,.table-wrap thead th) { background:var(--panel2); color:#c1d2e6; }
  html[data-theme="dark"] tbody :is(tr:nth-child(even) td,tr.low td) { background:#1b2b3e; }
  html[data-theme="dark"] tbody tr:hover td { background:#263b53!important; }
  html[data-theme="dark"] :is(input:not([type=checkbox]):not([type=radio]),select,textarea,
    .aw-select-trigger,.aw-select-popover,.aw-select-search,.aw-select-search input,
    .command-search,.command-dialog,.print-format-dialog,.quick-launcher-search input,
    .auth-input-wrap,.branch-context-switch select) {
    background:var(--panel2); color:var(--text); border-color:var(--line);
  }
  html[data-theme="dark"] :is(input,select,textarea)::placeholder { color:#a2b3c9; opacity:1; }
  html[data-theme="dark"] :is(.aw-select-option,.aw-select-value,.aw-select-caret,.aw-select-popover) { color:var(--text); }
  html[data-theme="dark"] :is(.aw-select-option:hover,.aw-select-option.selected) { background:#254c73; color:#e7f3ff; }
  html[data-theme="dark"] :is(.btn:not(.primary):not(.whatsapp-support),a.btn:not(.primary),button.btn:not(.primary),
    .icon-btn,.icon-action,.quick-create-btn,.settings-section-badge,.currency-current-chip) {
    background:#253a52; color:#e8f3ff; border-color:#415977;
  }
  html[data-theme="dark"] :is(.btn.primary,.auth-submit,.autoerp-kpis article,.autoerp-action-row a,
    .business-dashboard-tabs.autoerp-business-tabs a.active) { color:#fff; }
  html[data-theme="dark"] :is(.aw-drive-filter-bar a,.aw-business-switcher>.aw-disabled-dashboard-option,
    .aw-workspace-branch-note,.aw-drive-workflow-hint,.branch-brand-preview,
    .settings-section-badge,.currency-current-chip,.td-event) { background:#203349; border-color:#3b5872; color:#d8e8fa; }
  html[data-theme="dark"] .aw-drive-filter-bar a.active { background:#0e6fcb; color:#fff; }
  html[data-theme="dark"] .business-dashboard-tabs.autoerp-business-tabs.aw-business-switcher {
    background:#152438; border-color:#344760;
  }
  html[data-theme="dark"] .business-dashboard-tabs.autoerp-business-tabs.aw-business-switcher a:not(.active) {
    background:#23364e; color:#e7f2fd; border-color:#344760;
  }
  html[data-theme="dark"] .business-dashboard-tabs.autoerp-business-tabs.aw-business-switcher a:not(.active) b { color:#edf5ff; }
  html[data-theme="dark"] .business-dashboard-tabs.autoerp-business-tabs.aw-business-switcher a:not(.active)>span {
    background:#304b69; color:#8cc6ff;
  }
  html[data-theme="dark"] :is(.business-dashboard-tabs a.active b,.business-dashboard-tabs a.active small,
    .autoerp-action-row a b,.autoerp-kpis article b,.autoerp-kpis article small,.autoerp-kpis article em) { color:#fff; }
  html[data-theme="dark"] .autoerp-welcome-hero { color:#fff; }
  html[data-theme="dark"] .autoerp-donut:before { background:var(--panel); }
  html[data-theme="dark"] .autoerp-status-legend em { color:#b4c7dd; }
  html[data-theme="dark"] .showroom-ops-summary>div { background:#23364e; }
  html[data-theme="dark"] .showroom-mini-list>a { border-color:var(--line); }
  html[data-theme="dark"] :is(.showroom-mini-list .mini-vehicle-icon,.settings-tab>span:first-child,
    .quick-launcher-links a>span,.settings-recovery-card>span) { background:#304a66; color:#b5d8ff; }
  html[data-theme="dark"] .record-detail-row:nth-child(odd) { background:#1d2d41; }
  html[data-theme="dark"] :is(.alert.success,.status.status-confirmed) { background:#133e34; color:#81e4c5; border-color:#286d57; }
  html[data-theme="dark"] .alert.error { background:#4a2733; color:#ffb9c7; border-color:#844354; }
  html[data-theme="dark"] :is(.command-grid a,.print-format-option) { background:var(--panel2); color:var(--text); border-color:var(--line); }
  html[data-theme="dark"] .command-grid a small { color:var(--muted); }
  html[data-theme="dark"] :is(.command-dialog,.print-format-dialog,.quick-launcher-panel) { box-shadow:0 16px 50px rgba(0,0,0,.44); }
  html[data-theme="dark"] :is(.app-footer,.settings-help,.fr-timeline article,.test-drive-actions) { border-color:var(--line); }
  html[data-theme="dark"] .login-card-modern { background:var(--panel); color:var(--text); }
  /* Public login receives the same theme. Do not change the brand's dark illustration. */
  html[data-theme="dark"] body.showroom-login { background:#0b1422; color:#eaf2ff; }
  html[data-theme="dark"] .showroom-auth { background:linear-gradient(145deg,#101b2a,#152338); }
  html[data-theme="dark"] .auth-card-v2 { background:#1a293e; border-color:#354b66; color:#edf4ff; box-shadow:0 24px 50px rgba(0,0,0,.28); }
  html[data-theme="dark"] .auth-card-v2 :is(h2,.auth-field,.auth-meta b,.auth-help strong,.auth-mini-brand b) { color:#e8f3ff; }
  html[data-theme="dark"] .auth-card-v2 :is(p,.auth-meta,.auth-help) { color:#adc1da; }
  html[data-theme="dark"] .auth-input-wrap { background:#223750; border-color:#38536f; }
  html[data-theme="dark"] .auth-input-wrap:focus-within { background:#29415d; border-color:#73aeff; }
  html[data-theme="dark"] .auth-input-wrap input { color:#eff6ff; }
  html[data-theme="dark"] .auth-meta { border-color:#3a4c61; }
  html[data-theme="dark"] .auth-mini-brand small,.showroom-auth .auth-help { color:#b3c5d8; }
}

/* Responsive grid breakpoints must beat the original 5-column fixed form rules. */
@media screen and (max-width:1370px) {
  .autoerp-dashboard-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .autoerp-dashboard-grid>.appointment-card { grid-column:1/-1; }
  .vb-kpi-grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .page :is(.showroom-transaction-form,.showroom-form>.panel:first-of-type) .form-grid { grid-template-columns:repeat(3,minmax(0,1fr))!important; }
}
@media screen and (max-width:1050px) {
  .autoerp-dashboard-top,.autoerp-dashboard-grid,.vb-dashboard-grid { grid-template-columns:1fr; }
  .autoerp-dashboard-grid>.appointment-card { grid-column:auto; }
  .autoerp-kpis,.autoerp-kpis.aw-combined-kpis { grid-template-columns:repeat(3,minmax(0,1fr))!important; }
  .autoerp-secondary-grid { grid-template-columns:1fr; }
  .autoerp-secondary-grid .span-2 { grid-column:auto; }
  .vb-kpi-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .autoerp-date-card { min-height:0; }
  .page :is(.showroom-transaction-form,.showroom-form>.panel:first-of-type) .form-grid { grid-template-columns:repeat(2,minmax(0,1fr))!important; }
  .page .settings-jobtype-layout { grid-template-columns:1fr; }
}
@media screen and (max-width:840px) {
  .page { padding:12px 14px 20px!important; }
  .main { width:100%!important; max-width:100%!important; margin-left:0!important; }
  .topbar { gap:8px; padding:10px 14px; }
  .topbar .top-search { order:3; flex:1 1 100%; }
  .topbar .top-actions { order:2; margin-left:auto; }
  .topbar .mobile-menu { order:1; }
  .topbar .aw-top-division-switch { order:4; width:100%; }
  .vb-top-menu { top:0; flex-wrap:wrap; padding:8px 12px; }
  .vb-top-links { order:3; flex-basis:100%; }
  .business-dashboard-tabs.autoerp-business-tabs.aw-business-switcher { max-width:100%; }
  .autoerp-welcome-hero .welcome-art { opacity:.33; }
  .quick-launcher-panel { max-width:calc(100vw - 16px); }
}
@media screen and (max-width:650px) {
  .page { padding:10px 12px 22px!important; }
  .panel-head { padding:12px; }
  .page-hero { padding:12px; }
  .autoerp-kpis,.autoerp-kpis.aw-combined-kpis { grid-template-columns:repeat(2,minmax(0,1fr))!important; }
  .autoerp-kpis article { min-height:103px; padding:12px; gap:8px; }
  .autoerp-kpis article>span { flex:0 0 32px; }
  .autoerp-kpis article b { font-size:17px!important; }
  .autoerp-kpis article small { font-size:11px!important; }
  .autoerp-kpis article em { font-size:10px!important; }
  .autoerp-dashboard-top,.autoerp-dashboard-grid,.showroom-mini-grid { grid-template-columns:1fr; }
  .autoerp-welcome-hero { min-height:134px; padding:16px; }
  .autoerp-welcome-hero h1 { font-size:21px!important; }
  .autoerp-date-card { padding:14px; }
  .autoerp-donut-layout { grid-template-columns:130px minmax(0,1fr); padding:12px; gap:8px; }
  .appointment-list>div:not(.empty-mini) { grid-template-columns:1fr 1fr; }
  .appointment-list>div :is(span,.status) { grid-column:1/-1; }
  .autoerp-action-row { grid-template-columns:repeat(2,minmax(0,1fr)); padding:10px 12px 14px; }
  .vb-kpi-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .vb-kpi { padding:12px; }
  .vb-quick-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .aw-testdrive-widget-summary { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .page :is(.form-grid,.form-grid-compact,.gp2-form-grid,.showroom-form-grid),
  .page :is(.showroom-transaction-form,.showroom-form>.panel:first-of-type) .form-grid {
    grid-template-columns:1fr!important;
  }
  .page :is(.form-grid,.form-grid-compact,.gp2-form-grid,.showroom-form-grid) :is(.span-2,.span-3,.span-4) { grid-column:auto!important; }
  .page .settings-form-grid { grid-template-columns:1fr!important; }
  .quick-launcher-links { grid-template-columns:1fr; }
  .business-dashboard-tabs.autoerp-business-tabs.aw-business-switcher :is(a,.aw-disabled-dashboard-option) {
    padding:10px!important; gap:7px; min-height:61px; flex-direction:row; text-align:left;
  }
  .business-dashboard-tabs.autoerp-business-tabs.aw-business-switcher :is(a,.aw-disabled-dashboard-option) > span { flex-basis:25px; width:25px; height:25px; }
  .business-dashboard-tabs.autoerp-business-tabs.aw-business-switcher :is(a,.aw-disabled-dashboard-option) b { font-size:12px!important; }
  .business-dashboard-tabs.autoerp-business-tabs.aw-business-switcher :is(a,.aw-disabled-dashboard-option) small { font-size:10px!important; }
  .showroom-auth { padding:14px; }
  .auth-card-v2 { padding:22px; }
}
@media screen and (max-width:390px) {
  .autoerp-kpis,.autoerp-kpis.aw-combined-kpis { grid-template-columns:1fr!important; }
  .autoerp-donut-layout { grid-template-columns:1fr; justify-items:center; }
  .autoerp-status-legend { width:100%; }
  .vb-kpi-grid,.vb-quick-grid,.autoerp-action-row { grid-template-columns:1fr; }
  .business-dashboard-tabs.autoerp-business-tabs.aw-business-switcher { gap:4px; padding:5px; }
  .business-dashboard-tabs.autoerp-business-tabs.aw-business-switcher :is(a,.aw-disabled-dashboard-option) { padding:8px!important; }
  .business-dashboard-tabs.autoerp-business-tabs.aw-business-switcher :is(a,.aw-disabled-dashboard-option) small { display:none!important; }
  .auth-card-v2 .welcome { flex-wrap:wrap; }
}
@media screen and (prefers-reduced-motion:reduce) {
  .autoerp-dashboard *,.business-dashboard-tabs a { animation:none!important; transition:none!important; }
}

@media screen {
 .auth-theme-btn {align-self:flex-start; flex:0 0 auto; min-height:32px; padding:7px 10px; margin-left:auto; border:1px solid #d8e5f1; background:#edf5ff; color:#285078; border-radius:9px; font-size:12px; font-weight:750; cursor:pointer; white-space:nowrap;}
 html[data-theme="dark"] .auth-theme-btn {background:#283e56; color:#e7f4ff; border-color:#52708b;}
}

/* Legacy v2.2.x selectors carry !important light colors; dark tokens must win those too. */
@media screen {
 html[data-theme="dark"] :is(.panel,.panel-head,.topbar,.vb-top-menu,.sidebar.sidebar-premium,
   .toolbar.autoerp-filterbar,.autoerp-filterbar,.autoerp-bottom-actions,.business-dashboard-tabs.autoerp-business-tabs,
   .business-dashboard-tabs.autoerp-business-tabs a:not(.active),.sidebar-status-card,.sidebar-quick a,
   .branch-context-switch,.top-search,.detail-v2-field-grid>div,.record-list.data-panel,
   .settings-content,.showroom-mini-card,.aw-testdrive-dashboard-widget,.quick-launcher-panel) {
   background:var(--panel)!important; border-color:var(--line)!important; color:var(--text);
 }
 html[data-theme="dark"] :is(.topbar,.sidebar.sidebar-premium,.vb-top-menu) { background:#142235!important; }
 html[data-theme="dark"] :is(.panel,.panel-head,.sidebar-status-card,.sidebar-quick a,.toolbar.autoerp-filterbar,
   .autoerp-filterbar,.business-dashboard-tabs.autoerp-business-tabs,.detail-v2-field-grid>div) { border-color:var(--line)!important; }
 html[data-theme="dark"] :is(th,thead th,.table-wrap thead th,.record-list.data-panel thead th,
   .record-list.data-panel th:last-child) { background:var(--panel2)!important; color:#c1d2e6!important; }
 html[data-theme="dark"] :is(input:not([type=checkbox]):not([type=radio]),select,textarea,.aw-select-trigger,.aw-select-popover) {
   background:var(--panel2)!important; color:var(--text)!important; border-color:var(--line)!important;
 }
 html[data-theme="dark"] :is(.top-search,.branch-context-switch) { background:var(--panel2)!important; }
 html[data-theme="dark"] :is(a.btn:not(.primary):not(.whatsapp),button.btn:not(.primary):not(.whatsapp),
   .btn:not(.primary):not(.whatsapp),.icon-action,.btn.ghost,.icon-btn) {
   background:#253a52!important; color:#edf5ff!important; border-color:#425b78!important;
 }
 html[data-theme="dark"] :is(.btn.danger,.btn.danger-soft) { color:#ffc5cd!important; background:#422536!important; border-color:#854455!important; }
 html[data-theme="dark"] :is(.quick-create-btn,.business-dashboard-tabs.autoerp-business-tabs a.active) { background:linear-gradient(135deg,#137de9,#236dd6)!important; color:#fff!important; }
 html[data-theme="dark"] .business-dashboard-tabs.autoerp-business-tabs.aw-business-switcher a:not(.active) {
   background:#25374e!important; color:#e6f1ff!important; border-color:#3c5169!important;
 }
 html[data-theme="dark"] :is(.sidebar .nav-group-toggle:hover,.sidebar .nav-link:hover) { background:#283a51!important; color:#f3f8ff!important; }
 html[data-theme="dark"] .sidebar .nav-link.active { background:linear-gradient(90deg,#15579e,#1d4780)!important; color:#fff!important; }
 html[data-theme="dark"] .sidebar .nav-text { color:inherit!important; }
 html[data-theme="dark"] .sidebar .nav-icon { background:#2b4059!important; color:#bed8f4!important; }
 html[data-theme="dark"] .sidebar .nav-link.active .nav-icon { background:#1169cc!important; color:#fff!important; }
 html[data-theme="dark"] .panel :is(.panel-head,.panel-head h2) { color:var(--text); }
 html[data-theme="dark"] .settings-tab.active { background:#264262!important; color:#fff!important; }
 html[data-theme="dark"] .settings-tab.active :is(b,small) { color:#f3f8ff!important; }
}

@media screen {
  .autoerp-kpis,.autoerp-kpis.aw-combined-kpis { grid-template-columns:repeat(3,minmax(0,1fr))!important; }
  .autoerp-date-card>div { display:flex!important; flex-wrap:wrap; align-items:center; justify-content:flex-start; gap:7px; }
  .autoerp-date-card>div small { margin-left:0; }
  .appointment-list>div:not(.empty-mini) { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); align-items:start; gap:7px 12px; padding:12px 4px; }
  .appointment-list>div:not(.empty-mini)>span { grid-column:1/-1; }
  .appointment-list>div:not(.empty-mini)>.status { grid-column:1/-1; width:max-content; max-width:100%; }
  .sidebar .nav-text { font-size:max(12px,calc(12px * var(--aw-font-scale,1)))!important; }
  .sidebar .brand-copy { line-height:1.4; }
  html[data-theme="dark"] .sidebar .brand-copy :is(b,small),
  html[data-theme="dark"] .sidebar .mini-user :is(b,small),
  html[data-theme="dark"] .sidebar .sidebar-status-card :is(b,small),
  html[data-theme="dark"] .sidebar .sidebar-quick :is(a,b),
  html[data-theme="dark"] .sidebar .sidebar-section-label,
  html[data-theme="dark"] .sidebar .nav-group-toggle,
  html[data-theme="dark"] .sidebar .nav-link:not(.active) .nav-text { color:#d7e7f7!important; }
  html[data-theme="dark"] .business-dashboard-tabs.autoerp-business-tabs.aw-business-switcher a:not(.active) :is(b,small) { color:#e6f2fe!important; }
}
@media screen and (min-width:1800px) {
 .autoerp-kpis,.autoerp-kpis.aw-combined-kpis { grid-template-columns:repeat(6,minmax(0,1fr))!important; }
}
@media screen and (max-width:650px) and (min-width:391px) {
 .autoerp-kpis,.autoerp-kpis.aw-combined-kpis { grid-template-columns:repeat(2,minmax(0,1fr))!important; }
}
@media screen and (max-width:390px) {
 .autoerp-kpis,.autoerp-kpis.aw-combined-kpis { grid-template-columns:1fr!important; }
}

@media screen {
  .page :is(th,td), .page :is(label,.field-label), .page .panel :is(p,.hint,.help-text),
  .page :is(.showroom-mini-list small,.autoerp-status-legend b,.autoerp-status-legend em),
  .page :is(.autoerp-date-card small,.settings-tab small),
  .page :is(.revenue-axis span,.chart-legend,.appointment-list span) {
    font-size:max(12px,calc(12px * var(--aw-font-scale,1)))!important;
    line-height:1.45;
  }
  .page .eyebrow { font-size:max(11px,calc(11px * var(--aw-font-scale,1)))!important; }
  .page :is(.autoerp-dashboard-card,.autoerp-mini-dashboard-card) .panel-head h2 { font-size:max(14px,calc(14px * var(--aw-font-scale,1)))!important; }
  html[data-theme="dark"] .page .status { background:#2d405b; color:#d8e9fc; border-color:#405a75; }
  html[data-theme="dark"] .page :is(.status.status-confirmed,.status.status-completed,.status.status-closed) { background:#164b3b; color:#a2f5d9; }
  html[data-theme="dark"] .page :is(.status.status-pending,.status.status-warning) { background:#4a3922; color:#ffd39a; }
  html[data-theme="dark"] .page :is(.status.status-cancelled,.status.status-rejected,.status.status-danger) { background:#532938; color:#ffc3d0; }
}
