/* Shared finance presentation, 2026-10-17.
 * Loaded after the legacy theme and external workspace styles.
 * Screen overrides intentionally leave business visibility and print documents alone.
 */
@media screen {
  html body.ui-spacious {
    --ui-bg: #f5f7fa;
    --ui-panel: #fff;
    --ui-panel-soft: #f9fafc;
    --ui-text: #17263c;
    --ui-muted: #5d6c80;
    --ui-line: #dee5ee;
    --ui-brand: #245ce3;
    --ui-brand-strong: #194bd0;
    --ui-brand-soft: #edf3ff;
    --ui-success: #137d60;
    --ui-warning: #946010;
    --ui-danger: #aa3535;
    --ui-radius: 8px;
    --ui-shadow: none;
    --shadow: none;
    --sidebar-width: 224px;
    --bg: var(--ui-bg);
    --panel: var(--ui-panel);
    --surface: var(--ui-panel);
    --ink: var(--ui-text);
    --text: var(--ui-text);
    --muted: var(--ui-muted);
    --line: var(--ui-line);
    --border: var(--ui-line);
    --primary: var(--ui-brand);
    --brand: var(--ui-brand);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.6;
  }
  html[data-theme="dark"] body.ui-spacious {
    --ui-bg: #151a22;
    --ui-panel: #1d2530;
    --ui-panel-soft: #242e3a;
    --ui-text: #edf2f7;
    --ui-muted: #b6c2d1;
    --ui-line: #425066;
    --ui-brand: #9bbfff;
    --ui-brand-strong: #c2d7ff;
    --ui-brand-soft: #253b59;
    --ui-success: #8adab0;
    --ui-warning: #eac585;
    --ui-danger: #ffaaa3;
  }

  /* Keep the three company workspaces in the same fixed position. */
  html body.ui-spacious .company-workspaces a {
    min-height: 44px;
    padding: 10px 20px;
    border-radius: 7px;
    font-size: 15px;
    font-weight: 500;
  }
  html body.ui-spacious .company-workspaces a[aria-current="page"] {
    color: var(--ui-brand);
    background: var(--ui-brand-soft);
    border-color: transparent;
  }

  /* NSK has its own sidebar inside the frame; these rules apply to main and MY. */
  html:not([data-workspace="nsk"]) body.ui-spacious #appShell > .sidebar {
    width: 224px !important;
    padding: 30px 20px 20px !important;
    background: var(--ui-panel) !important;
    color: var(--ui-text) !important;
    border-right: 1px solid var(--ui-line) !important;
    box-shadow: none !important;
  }
  html:not([data-workspace="nsk"]) body.ui-spacious #appShell > .main {
    width: 100% !important;
    min-width: 0 !important;
    padding: 36px 40px 60px !important;
    background: var(--ui-bg) !important;
  }
  html body.ui-spacious #appShell .sidebar > .ui-nav-close { order: 0; }
  html body.ui-spacious #appShell .brand-block {
    order: 1;
    gap: 11px !important;
    margin: 0 0 26px !important;
    padding: 0 !important;
    border: 0 !important;
  }
  html body.ui-spacious #appShell .brand-mark {
    width: 37px !important;
    height: 40px !important;
    border-radius: 8px !important;
    font-size: 17px !important;
    font-weight: 700 !important;
    color: #fff !important;
    background: #245ce3 !important;
  }
  html body.ui-spacious #appShell .brand-title {
    color: var(--ui-text) !important;
    font-size: 18px !important;
    font-weight: 650 !important;
    letter-spacing: .5px !important;
  }
  html body.ui-spacious #appShell .brand-subtitle { font-size: 11px !important; }
  html body.ui-spacious #appShell .nav-list {
    order: 2;
    display: flex;
    flex-direction: column;
    align-content: start;
    flex: 1 1 auto;
    gap: 6px !important;
    margin: 0 !important;
    padding: 0 0 12px !important;
    scrollbar-color: #cbd5e1 transparent !important;
  }
  html body.ui-spacious #appShell .nav-list::-webkit-scrollbar-thumb { background: #cbd5e1 !important; }
  html body.ui-spacious #appShell .nav-section-label {
    flex: none;
    margin: 0 0 4px !important;
    padding: 0 12px 10px !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    color: var(--ui-muted) !important;
    letter-spacing: .5px !important;
  }
  html body.ui-spacious #appShell .nav-section-label::after { content: none !important; }
  html body.ui-spacious #appShell :is(.nav-link,.nav-group-toggle) {
    flex: none;
    gap: 11px !important;
    height: auto !important;
    min-height: 46px !important;
    padding: 12px 14px !important;
    border: 0 !important;
    border-radius: 7px !important;
    background: transparent !important;
    color: var(--ui-muted) !important;
    font-size: 15px !important;
    font-weight: 500 !important;
    line-height: 1.45 !important;
    box-shadow: none !important;
  }
  html body.ui-spacious #appShell :is(.nav-link,.nav-group-toggle):hover { background: var(--ui-panel-soft) !important; }
  html body.ui-spacious #appShell .nav-link:is(.active,[aria-current="page"]) {
    background: var(--ui-brand-soft) !important;
    color: var(--ui-brand) !important;
    font-weight: 600 !important;
  }
  html body.ui-spacious #appShell .finance-nav-icon {
    display: inline-block;
    width: 19px;
    height: 19px;
    flex: none;
    margin-right: 0;
    vertical-align: -4px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  html body.ui-spacious #appShell .nav-group-body {
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
  }
  html body.ui-spacious #appShell .sidebar-user-card {
    order: 3;
    flex: none;
    margin: 12px 8px 0 !important;
    padding: 17px 0 0 !important;
    border: 0 !important;
    border-top: 1px solid var(--ui-line) !important;
    border-radius: 0 !important;
    color: var(--ui-text) !important;
    background: transparent !important;
  }
  html body.ui-spacious #appShell .sidebar-user-card strong { color: var(--ui-text) !important; font-weight: 600 !important; }
  html body.ui-spacious #appShell .sidebar-footer {
    order: 4;
    flex: none;
    gap: 8px !important;
    margin: 0 !important;
    padding: 12px 8px 0 !important;
    color: var(--ui-muted) !important;
  }
  html body.ui-spacious #appShell .sidebar-footer summary {
    color: var(--ui-muted);
    font-size: 12px;
    cursor: pointer;
    padding: 6px 0;
  }
  html body.ui-spacious #appShell .sidebar-status-pill {
    padding: 6px 0 !important;
    color: var(--ui-muted) !important;
    font-size: 11px !important;
    overflow-wrap: anywhere;
  }
  html body.ui-spacious #appShell .sidebar-status-pill strong { font-weight: 400 !important; }
  html body.ui-spacious #appShell .finance-system-info { max-width: 100%; }

  /* Page hierarchy matches the NSK ledger without changing the main app routing. */
  html body.ui-spacious #appShell .main > .topbar {
    gap: 24px !important;
    padding: 0 !important;
    margin-bottom: 28px !important;
    border: 0 !important;
  }
  html body.ui-spacious #appShell .topbar h1 {
    font-size: 28px !important;
    font-weight: 600 !important;
    line-height: 1.35 !important;
    letter-spacing: -.5px !important;
    margin: 8px 0 9px !important;
  }
  html body.ui-spacious #appShell #viewSubtitle { font-size: 14px !important; line-height: 1.65 !important; }
  html body.ui-spacious #appShell .external-company-name {
    margin: 0 0 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--ui-line);
    color: var(--ui-text);
    font-size: 14px;
    font-weight: 500;
  }
  html body.ui-spacious #appShell .finance-workspace-context {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 24px;
    padding: 17px 20px;
    margin-bottom: 26px;
    border: 1px solid var(--ui-line);
    border-radius: 8px;
    background: var(--ui-panel);
    color: var(--ui-text);
  }
  html body.ui-spacious #appShell .finance-workspace-context > div { min-width: 0; }
  html body.ui-spacious #appShell .finance-workspace-context strong { display: block; font-size: 14px; font-weight: 500; }
  html body.ui-spacious #appShell :is(#financeWorkspaceBasis,.finance-unit) { color: var(--ui-muted); font-size: 12px; line-height: 1.65; }
  html body.ui-spacious #appShell .finance-unit { white-space: nowrap; }
  html body.ui-spacious #appShell .topbar-actions { max-width: 380px !important; }
  html body.ui-spacious #appShell :is(.view,.view > *, .form-grid > *, .grid-form > *, .kpi-grid > *, .report-charts > *) { min-width: 0; }
  html body.ui-spacious #appShell :is(.form-control,.form-select,.btn),
  html body.ui-spacious .modal:is(#vehicleModal,.modal) :is(.form-control,.form-select,.btn) {
    min-height: 44px !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    border-radius: 7px !important;
    box-shadow: none !important;
  }
  html body.ui-spacious #appShell .btn,
  html body.ui-spacious .modal:is(#vehicleModal,.modal) .btn { font-weight: 500 !important; padding: 10px 17px !important; }
  html body.ui-spacious #appShell :is(.btn-primary,.btn-dark),
  html body.ui-spacious .modal:is(#vehicleModal,.modal) :is(.btn-primary,.btn-dark) {
    background: #245ce3 !important;
    border-color: #245ce3 !important;
    color: #fff !important;
  }
  html body.ui-spacious #appShell :is(.btn-primary,.btn-dark):hover,
  html body.ui-spacious .modal:is(#vehicleModal,.modal) :is(.btn-primary,.btn-dark):hover { background: #194bd0 !important; border-color: #194bd0 !important; }
  html body.ui-spacious #appShell .btn-outline-primary,
  html body.ui-spacious .modal:is(#vehicleModal,.modal) .btn-outline-primary { color: var(--ui-brand) !important; background: var(--ui-panel) !important; border: 1px solid var(--ui-line) !important; }
  html body.ui-spacious #appShell .btn-outline-primary:hover,
  html body.ui-spacious .modal:is(#vehicleModal,.modal) .btn-outline-primary:hover { background: var(--ui-brand-soft) !important; border-color: var(--ui-brand) !important; }
  html body.ui-spacious #appShell :is(.form-panel,.monthly-profit-panel,.toolbar,.report-header) label,
  html body.ui-spacious .modal:is(#vehicleModal,.modal) label { font-size: 14px !important; font-weight: 500 !important; line-height: 1.6 !important; }
  html body.ui-spacious #appShell :is(.form-panel,.monthly-profit-panel,.chart-panel,.report-metric-panel,.kpi,.card,.panel,.intake-worklist,.tax-ledger-card,.bank-flow-layout,.voucher-rule-panel,.voucher-package-panel,.vat-return-sheet) {
    border-color: var(--ui-line) !important;
    border-radius: 9px !important;
    background: var(--ui-panel) !important;
    background-image: none !important;
    box-shadow: none !important;
  }
  html body.ui-spacious #appShell :is(.toolbar,.report-header) {
    padding: 0 !important;
    margin: 22px 0 !important;
    gap: 12px !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    align-items: end !important;
  }
  html body.ui-spacious #appShell :is(.section-head h2,.monthly-profit-panel h2,.intake-heading h2) { font-size: 18px !important; font-weight: 600 !important; }
  html body.ui-spacious #appShell :is(.kpi-grid,.dashboard-kpis,.monthly-profit-kpis,.tax-kpis,.tax-stats,.bank-center-kpis,.voucher-kpis,.financial-report-kpis) { gap: 18px !important; margin-bottom: 24px !important; }
  html body.ui-spacious #appShell .kpi strong { font-size: 28px !important; font-weight: 600 !important; font-variant-numeric: tabular-nums; }
  html body.ui-spacious #appShell :is(.external-close-loop-strip,.external-close-loop-copy,.external-close-loop-actions > *, .external-workflow,.external-workflow-step,.external-workflow-main,.invoice-workbench-flow article) {
    border-color: var(--ui-line) !important;
    border-radius: 7px !important;
    background: var(--ui-panel) !important;
    background-image: none !important;
    box-shadow: none !important;
    transform: none !important;
  }
  html body.ui-spacious #appShell :is(.external-close-loop-strip,.external-workflow) { padding: 18px !important; margin-bottom: 24px !important; }
  html body.ui-spacious #appShell .external-close-loop-copy { border: 0 !important; }
  html body.ui-spacious #appShell :is(.external-close-loop-copy,.external-close-loop-actions) strong { font-weight: 600 !important; }

  /* A ledger must scroll within its boundary; the entire page must not widen. */
  html body.ui-spacious #appShell :is(.table-wrap,.table-responsive,.table-scroll) {
    min-width: 0 !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overscroll-behavior-x: contain;
    border-color: var(--ui-line) !important;
    border-radius: 8px !important;
    background: var(--ui-panel) !important;
    box-shadow: none !important;
  }
  html body.ui-spacious #appShell .data-table { font-size: 14px; }
  html body.ui-spacious #appShell .data-table th {
    padding: 14px 18px !important;
    color: var(--ui-muted) !important;
    background: var(--ui-panel-soft) !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    line-height: 1.6 !important;
  }
  html body.ui-spacious #appShell .data-table td {
    padding: 18px !important;
    font-size: 14px !important;
    line-height: 1.65 !important;
    border-color: var(--ui-line) !important;
    box-shadow: none !important;
    background-image: none !important;
  }
  html body.ui-spacious #appShell .data-table :is(.num,.money-cell,.text-end,.text-right),
  html body.ui-spacious .modal:is(#vehicleModal,.modal) :is(.num,.money-cell,.text-end,.text-right) {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }
  html body.ui-spacious #appShell .data-table td.text-danger { color: var(--ui-danger) !important; }
  html body.ui-spacious #appShell .data-table td.text-success { color: var(--ui-success) !important; }
  html body.ui-spacious #appShell .table-pagination { padding: 17px 0 !important; }

  /* The file field and both frequent actions share a common control baseline. */
  html body.ui-spacious #appShell #invoiceImportForm {
    display: grid !important;
    grid-template-columns: minmax(220px,1fr) auto auto !important;
    gap: 12px !important;
    align-items: end !important;
    width: 100% !important;
  }
  html body.ui-spacious #appShell #invoiceImportForm > label {
    grid-column: 1 !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    align-self: end !important;
  }
  html body.ui-spacious #appShell #invoiceImportForm > label .form-control { width: 100% !important; min-width: 0 !important; height: 44px !important; margin: 7px 0 0 !important; padding: 7px 10px !important; }
  html body.ui-spacious #appShell #invoiceImportForm > .btn { width: auto !important; min-width: 0 !important; grid-column: auto !important; align-self: end !important; margin: 0 !important; white-space: nowrap !important; }
  html body.ui-spacious #appShell #invoiceImportForm > .muted-note { width: 100% !important; grid-column: 1 / -1 !important; margin: 0 !important; padding: 0 !important; text-align: left !important; background: transparent !important; }
  html body.ui-spacious #appShell #invoiceImportForm input::file-selector-button { height: 42px; margin: -7px 12px -7px -10px; padding: 9px 14px; color: var(--ui-text); background: var(--ui-panel-soft); border: 0; border-right: 1px solid var(--ui-line); }

  /* Match the legacy :not(#vehicleModal) specificity for all modal variants. */
  html body.ui-spacious .modal:is(#vehicleModal,.modal) .modal-content {
    border: 1px solid var(--ui-line) !important;
    border-radius: 10px !important;
    background: var(--ui-panel) !important;
    box-shadow: 0 12px 42px #17263c1a !important;
  }
  html body.ui-spacious .modal:is(#vehicleModal,.modal) :is(.modal-header,.modal-body,.modal-footer) {
    padding: 24px 28px !important;
    color: var(--ui-text) !important;
    background: var(--ui-panel) !important;
    border-color: var(--ui-line) !important;
  }
  html body.ui-spacious .modal:is(#vehicleModal,.modal) .modal-title { font-size: 20px !important; line-height: 1.45 !important; font-weight: 600 !important; }
  html body.ui-spacious .modal:is(#vehicleModal,.modal) .modal-footer { padding-block: 16px !important; }
  html body.ui-spacious .modal:is(#vehicleModal,.modal) .modal-header::after { content: none !important; }
}

@media screen and (min-width: 981px) {
  html:not([data-workspace="nsk"]) body.ui-spacious #appShell { grid-template-columns: 224px minmax(0,1fr) !important; }
  html[data-inline-workspaces="true"]:not([data-workspace="nsk"]) body.ui-spacious #appShell > .main { height: calc(100dvh - var(--workspace-bar-height,0px)) !important; }
  html:not([data-workspace="nsk"]) body.ui-spacious #mainContent > :not(.company-workspaces) { max-width: 1430px; margin-inline: auto; }
}
@media screen and (max-width: 1200px) {
  html:not([data-workspace="nsk"]) body.ui-spacious #appShell > .main { padding: 28px 24px 48px !important; }
  html body.ui-spacious #appShell .topbar-actions { max-width: none !important; }
}
@media screen and (max-width: 980px) {
  html:not([data-workspace="nsk"]) body.ui-spacious #appShell > .main { padding: 28px 24px 48px !important; }
  html:not([data-workspace="nsk"]) body.ui-spacious.ui-nav-open #appShell > .sidebar { width: min(300px,90vw) !important; height: calc(100dvh - var(--workspace-bar-height,0px)) !important; }
  html body.ui-spacious #appShell .main :is(.form-control,.form-select),
  html body.ui-spacious .modal:is(#vehicleModal,.modal) :is(.form-control,.form-select) { font-size: 16px !important; }
  html body.ui-spacious #appShell :is(.kpi-grid,.dashboard-kpis,.monthly-profit-kpis,.tax-kpis,.tax-stats,.bank-center-kpis,.voucher-kpis,.financial-report-kpis) { grid-template-columns: repeat(2,minmax(0,1fr)) !important; gap: 12px !important; }
  html body.ui-spacious #appShell #view-dashboard .kpi strong { font-size: 24px !important; }
  html body.ui-spacious #appShell .intake-heading { flex-wrap: wrap; align-items: flex-start; }
}
@media screen and (max-width: 600px) {
  html:not([data-workspace="nsk"]) body.ui-spacious #appShell > .main { padding: 24px 18px 40px !important; }
  html body.ui-spacious #appShell .topbar h1 { font-size: 25px !important; }
  html body.ui-spacious #appShell .company-workspaces a { padding: 10px 8px; font-size: 14px; }
  html body.ui-spacious #appShell .main :is(.form-panel,.monthly-profit-panel,.chart-panel,.intake-worklist) { padding: 20px 16px !important; }
  html body.ui-spacious #appShell #invoiceImportForm { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
  html body.ui-spacious #appShell #invoiceImportForm > label { grid-column: 1 / -1 !important; }
  html body.ui-spacious #appShell #invoiceImportForm > .btn { width: 100% !important; padding-inline: 8px !important; }
  html body.ui-spacious #appShell #invoiceImportForm > .muted-note { font-size: 12px !important; }
  html body.ui-spacious #appShell .data-table :is(th,td) { padding: 14px !important; }
  html body.ui-spacious .modal:is(#vehicleModal,.modal) :is(.modal-header,.modal-body,.modal-footer) { padding: 20px 18px !important; }
}

@media print {
  /* Never override the existing voucher/settlement print sheet visibility rules. */
  .company-workspaces { display: none !important; }
  .data-table :is(.num,.money-cell,.text-end,.text-right) { text-align: right; font-variant-numeric: tabular-nums; }
}
/* Shared accounting copy and secondary actions. */
@media screen {
  html:not([data-workspace="nsk"]) body.ui-spacious #appShell .main > .topbar {margin-inline:auto!important;width:100%;}
  html body.ui-spacious #appShell .finance-basis-note {padding:14px 18px;margin:0 0 24px;border-left:3px solid var(--ui-brand);background:var(--ui-panel-soft);font-size:13px;line-height:1.8;color:var(--ui-muted);}
  html body.ui-spacious .finance-more-actions {display:inline-block;vertical-align:middle;margin:4px 0;}
  html body.ui-spacious .finance-more-actions summary {padding:10px 12px;min-height:44px;cursor:pointer;font-size:13px;color:var(--ui-muted);}
  html body.ui-spacious .finance-more-actions[open] .btn {display:block;margin-top:8px;}
  .finance-report-basis {display:block;font-size:13px;color:var(--muted);margin-top:8px;}
}

/* Native company radios keep one clear accounting entity per vehicle. */
@media screen {
  html body.ui-spacious :is(#vehicleForm, #basicInfoForm) .vehicle-company-field {
    grid-column: 1 / -1;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
  }
  html body.ui-spacious :is(#vehicleForm, #basicInfoForm) .vehicle-company-field legend {
    float: none;
    width: auto;
    margin: 0 0 8px;
    padding: 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.6;
    color: var(--ui-text);
  }
  html body.ui-spacious :is(#vehicleForm, #basicInfoForm) .vehicle-company-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(360px, 100%);
    gap: 0;
  }
  html body.ui-spacious :is(#vehicleForm, #basicInfoForm) .vehicle-company-options label {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 44px;
    margin: 0 !important;
    padding: 9px 16px !important;
    border: 1px solid var(--ui-line);
    border-radius: 7px 0 0 7px;
    color: var(--ui-text);
    background: var(--ui-panel);
    font-size: 15px !important;
    font-weight: 500;
    cursor: pointer;
  }
  html body.ui-spacious :is(#vehicleForm, #basicInfoForm) .vehicle-company-options label + label {
    margin-left: -1px !important;
    border-radius: 0 7px 7px 0;
  }
  /* Legacy label:has(:required)::after also draws a star without the JS class. */
  html body.ui-spacious :is(#vehicleForm, #basicInfoForm) .vehicle-company-options label::after {
    content: none !important;
    display: none !important;
  }
  html body.ui-spacious :is(#vehicleForm, #basicInfoForm) .vehicle-company-options label:has(input:checked) {
    position: relative;
    border-color: var(--ui-brand);
    color: var(--ui-brand);
    background: var(--ui-brand-soft);
  }
  html body.ui-spacious :is(#vehicleForm, #basicInfoForm) .vehicle-company-options input[type="radio"] {
    appearance: auto;
    flex: 0 0 16px;
    width: 16px !important;
    height: 16px !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    accent-color: var(--ui-brand);
  }
  html body.ui-spacious :is(#vehicleForm, #basicInfoForm) .vehicle-company-options label:has(input:focus-visible) {
    z-index: 1;
    outline: 2px solid var(--ui-brand);
    outline-offset: 3px;
  }
  html body.ui-spacious :is(#vehicleForm, #basicInfoForm) .vehicle-company-options label:has(input:disabled) {
    opacity: .65;
    cursor: not-allowed;
  }
  html body.ui-spacious :is(#vehicleForm, #basicInfoForm) .vehicle-company-hint {
    margin: 8px 0 0;
    color: var(--ui-muted);
    font-size: 13px;
    line-height: 1.7;
  }
  html body.ui-spacious :is(#vehicleForm, #basicInfoForm) .vehicle-company-hint.is-unconfirmed {
    color: var(--ui-warning);
  }
  html body.ui-spacious :is(#vehicleForm, #basicInfoForm) .purchase-business-type-option {
    min-height: 44px;
    border: 1px solid var(--ui-line) !important;
    border-radius: 7px;
    background: var(--ui-panel) !important;
    color: var(--ui-text) !important;
    font-size: 14px;
    font-weight: 500;
    text-shadow: none !important;
    box-shadow: none !important;
  }
  html body.ui-spacious :is(#vehicleForm, #basicInfoForm) .purchase-business-type-option.is-selected {
    border-color: var(--ui-brand) !important;
    color: var(--ui-brand) !important;
    background: var(--ui-brand-soft) !important;
  }
  html body.ui-spacious :is(#vehicleForm, #basicInfoForm) .purchase-business-type-option:hover:not(:disabled) {
    border-color: var(--ui-brand) !important;
  }
  html body.ui-spacious :is(#vehicleForm, #basicInfoForm) .purchase-business-type-option:focus-visible {
    outline: 2px solid var(--ui-brand);
    outline-offset: 3px;
  }
  html body.ui-spacious :is(#vehicleForm, #basicInfoForm) .purchase-business-type-option:disabled {
    opacity: .55;
    cursor: not-allowed;
  }
  html body.ui-spacious :is(#vehicleForm, #basicInfoForm) .purchase-business-type-options[aria-invalid="true"] .purchase-business-type-option {
    border-color: var(--ui-danger) !important;
  }
  html body.ui-spacious #vehicleModal .vehicle-company-invoice-notice {
    margin: 0 0 20px;
    padding: 16px 18px;
    border-left: 3px solid var(--ui-brand);
    background: var(--ui-panel-soft);
  }
  html body.ui-spacious #vehicleModal .vehicle-company-invoice-notice p { margin: 0 0 12px; }
}

/* MY single-vehicle workflow: keep the frequent entries, collapse repeated explanation. */
html body.ui-spacious #appShell #externalCloseLoopStrip { display: block !important; padding: 12px !important; margin-bottom: 16px !important; }
html body.ui-spacious #appShell #externalCloseLoopStrip .external-close-loop-actions { width: 100%; }
html body.ui-spacious #appShell #view-tax > .vat-return-notice { margin-bottom: 18px; }
html body.ui-spacious #appShell #view-tax > .vat-return-notice details { margin: 8px 0; }
html body.ui-spacious #appShell #view-tax > .vat-return-notice summary { cursor: pointer; color: var(--ui-muted); }

@media screen {
  html body.ui-spacious #appShell #externalCloseLoopStrip .external-close-loop-actions { display: grid !important; grid-template-columns: repeat(5,minmax(0,1fr)) !important; gap: 8px !important; }
  html body.ui-spacious #appShell #externalCloseLoopStrip .external-close-loop-actions button { grid-template-columns: auto minmax(0,1fr) !important; align-content: center !important; align-items: center !important; min-height: 64px !important; gap: 5px 7px !important; padding: 10px 12px !important; }
  html body.ui-spacious #appShell #externalCloseLoopStrip .external-close-loop-actions small { grid-column: 1 / -1; font-weight: 400 !important; line-height: 1.4 !important; }
  html body.ui-spacious #appShell #externalCloseLoopStrip .external-close-loop-actions strong { font-size: 14px !important; }
  html body.ui-spacious #appShell #externalCloseLoopStrip .external-close-loop-actions button:focus-visible { outline: 2px solid var(--ui-brand); outline-offset: 2px; }
}
@media screen and (max-width: 700px) {
  html body.ui-spacious #appShell #externalCloseLoopStrip .external-close-loop-actions { grid-template-columns: repeat(3,minmax(0,1fr)) !important; }
  html body.ui-spacious #appShell #externalCloseLoopStrip .external-close-loop-actions button { min-height: 44px !important; padding: 8px !important; }
  html body.ui-spacious #appShell #externalCloseLoopStrip .external-close-loop-actions small { display: none; }
}
@media screen and (max-width: 420px) {
  html body.ui-spacious #appShell #externalCloseLoopStrip .external-close-loop-actions { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
}

/* Keep the optional third partner and its ratio on the same row. */
html body.ui-spacious :is(#vehicleForm, #basicInfoForm) .partner-third-start { grid-column: 1; }

/* Ownership is a ledger filter, separate from the legal-entity workspace switch. */
@media screen {
  html body.ui-spacious .ledger-company-filter {
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
    margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--ui-line);
  }
  html body.ui-spacious .ledger-company-label { color: var(--ui-muted); margin-right: 8px; }
  html body.ui-spacious .ledger-company-tab {
    min-height: 44px; padding: 8px 22px; border: 1px solid var(--ui-line);
    border-radius: 6px; background: var(--ui-panel); color: var(--ui-text); font: inherit;
  }
  html body.ui-spacious .ledger-company-tab:hover { background: var(--ui-panel-soft); }
  html body.ui-spacious .ledger-company-tab.active {
    background: var(--ui-brand-soft); color: var(--ui-brand-strong); border-color: var(--ui-brand); font-weight: 600;
  }
  html body.ui-spacious .ledger-company-tab:focus-visible { outline: 2px solid var(--ui-brand); outline-offset: 3px; }
  html body.ui-spacious .ledger-vehicle-model { display: flex; align-items: flex-start; flex-direction: column; gap: 5px; }
  html body.ui-spacious .ledger-company-badge {
    display: inline-block; white-space: nowrap; font-size: 12px; line-height: 1.5;
    padding: 1px 7px; border: 1px solid var(--ui-line); border-radius: 4px;
    color: var(--ui-muted); background: var(--ui-panel-soft);
  }
  html body.ui-spacious .ledger-company-badge.company-nsk { color: var(--ui-brand-strong); background: var(--ui-brand-soft); }
  html body.ui-spacious .ledger-company-badge.company-unknown { color: var(--ui-warning); }
}

/* Vehicle ledger: use the available workspace, without hiding financial columns. */
@media screen {
  html body.ui-spacious #mainContent > #view-inventory {
    width: 100%; max-width: none !important;
  }
  html body.ui-spacious #appShell > .main:has(#view-inventory.active) {
    padding-inline: 16px !important;
  }
  html body.ui-spacious #view-inventory .inventory-table-wrap {
    width: 100%; min-width: 0; overflow-x: auto !important;
  }
  html body.ui-spacious #view-inventory .inventory-table {
    table-layout: fixed !important; width: 100% !important; min-width: 1240px !important;
  }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td) {
    width: auto !important; min-width: 0 !important; max-width: none !important;
    padding: 14px 6px !important; white-space: nowrap !important;
    overflow: visible !important; text-overflow: clip !important;
  }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):nth-child(1) { width: 52px !important; }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):nth-child(2) { width: 96px !important; white-space: normal !important; }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):nth-child(3) { width: 68px !important; white-space: normal !important; }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):nth-child(4) { width: 64px !important; }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):nth-child(5) { width: 52px !important; }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):nth-child(6) { white-space: normal !important; overflow-wrap: anywhere; }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):nth-child(7) { width: 148px !important; letter-spacing: 0 !important; font-size: 13px !important; }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):is(:nth-child(8),:nth-child(11)) { width: 92px !important; }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):is(:nth-child(9),:nth-child(12)) { width: 60px !important; white-space: normal !important; overflow-wrap: anywhere; }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):is(:nth-child(10),:nth-child(13),:nth-child(14)) {
    width: 110px !important; font-family: inherit !important; font-style: normal !important; text-align: right !important; font-variant-numeric: tabular-nums;
  }
  html body.ui-spacious #view-inventory .inventory-table :is(.next-step,.badge-soft,.inventory-days,.business-cell) {
    min-width: 0 !important; max-width: 100% !important; white-space: normal !important;
    padding-inline: 4px !important; overflow: visible !important; text-overflow: clip !important;
    overflow-wrap: anywhere;
  }
  html body.ui-spacious #view-inventory .inventory-table th { white-space: nowrap !important; }
  html body.ui-spacious #view-inventory .inventory-table .business-cell { white-space: nowrap !important; padding-inline: 0 !important; }
  html body.ui-spacious #view-inventory .inventory-table .next-step { border-radius: 4px !important; line-height: 1.5 !important; }
  html body.ui-spacious #view-inventory .inventory-table .btn {
    min-width: 0 !important; width: 40px; padding-inline: 4px !important;
  }
  html body.ui-spacious #view-inventory .ledger-vehicle-model { min-width: 0; max-width: none !important; }
}

/* Fixed model width; dates, amounts and next steps share surplus space. */
@media screen {
  html body.ui-spacious #view-inventory .inventory-table { min-width: 1340px !important; }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):nth-child(1) { width: 52px !important; }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):nth-child(2) { width: auto !important; }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):nth-child(3) { width: 68px !important; }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):nth-child(4) { width: 68px !important; }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):nth-child(5) { width: 48px !important; }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):nth-child(6) { width: 200px !important; }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):nth-child(7) { width: calc(18ch + 16px) !important; }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):nth-child(8) { width: auto !important; }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):nth-child(9) { width: 60px !important; }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):nth-child(10) { width: auto !important; }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):nth-child(11) { width: auto !important; }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):nth-child(12) { width: 60px !important; }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):nth-child(13) { width: auto !important; }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):nth-child(14) { width: auto !important; }
  html body.ui-spacious #view-inventory .inventory-table :is(th,td):nth-child(7) { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important; font-size: 13px !important; }
}

/* Ledger compact v3: one-line models and a shared filter/table alignment. */
@media screen {
  html body.ui-spacious #mainContent:has(#view-inventory.active) > :is(.topbar,#financeWorkspaceContext) {
    width: 100% !important; max-width: none !important; margin-inline: 0 !important;
  }
  html body.ui-spacious #mainContent:has(#view-inventory.active) > .topbar { margin-block: 12px 16px !important; }
  html body.ui-spacious #appShell #mainContent #view-inventory { gap: 10px !important; }
  html body.ui-spacious #appShell #mainContent #view-inventory > :is(.ledger-company-filter,.ledger-summary,.ledger-performance,.inventory-owner-summary,.toolbar,.ledger-filter-summary,.ui-secondary-tools) {
    width: 100% !important; max-width: none !important; margin: 0 !important; box-sizing: border-box;
  }
  html body.ui-spacious #appShell #mainContent #view-inventory .ledger-company-filter { padding-bottom: 8px !important; }
  html body.ui-spacious #appShell #mainContent #view-inventory :is(.ledger-company-tab,.summary-chip) { min-height: 36px !important; padding: 6px 12px !important; }
  html body.ui-spacious #appShell #mainContent #view-inventory .ledger-performance { flex-wrap: wrap !important; gap: 8px !important; }
  html body.ui-spacious #appShell #mainContent #view-inventory .ledger-performance-title { padding: 4px 0 !important; gap: 8px !important; background: transparent !important; box-shadow: none !important; }
  html body.ui-spacious #appShell #mainContent #view-inventory .inventory-owner-summary { padding: 10px 12px !important; gap: 8px !important; }
  html body.ui-spacious #appShell #mainContent #view-inventory :is(.inventory-owner-summary-main,.inventory-owner-summary-grid article) { padding: 0 6px !important; gap: 3px !important; }
  html body.ui-spacious #appShell #mainContent #view-inventory .inventory-owner-summary strong { font-size: 14px !important; line-height: 1.5 !important; }
  html body.ui-spacious #appShell #mainContent #view-inventory .ledger-performance-title :is(.form-control,.form-select,.btn) { min-height: 36px !important; height: 36px !important; padding-block: 6px !important; }
  html body.ui-spacious #appShell #mainContent #view-inventory .ledger-filter-summary { padding: 6px 10px !important; min-height: 0 !important; gap: 6px !important; }
  html body.ui-spacious #appShell #mainContent #view-inventory .ledger-filter-summary-chips { gap: 4px !important; }
  html body.ui-spacious #appShell #mainContent #view-inventory .ledger-filter-summary-chips span { padding-inline: 6px !important; }
  html body.ui-spacious #appShell #mainContent #view-inventory .ui-secondary-tools > summary { min-height: 32px !important; padding: 5px 0 !important; }
  html body.ui-spacious #appShell #mainContent #view-inventory .ledger-sortbar { padding: 8px 0 !important; }
  html body.ui-spacious #appShell #mainContent #view-inventory .inventory-table td { padding-block: 10px !important; }
  html body.ui-spacious #appShell #mainContent #view-inventory .inventory-table td:nth-child(6) { white-space: nowrap !important; overflow-wrap: normal !important; }
  html body.ui-spacious #appShell #mainContent #view-inventory .ledger-vehicle-model {
    display: flex !important; flex-direction: row !important; align-items: center !important; gap: 5px !important;
    width: 100%; min-width: 0; white-space: nowrap !important;
  }
  html body.ui-spacious #appShell #mainContent #view-inventory .ledger-company-badge { flex: 0 0 auto; padding-inline: 4px !important; }
  html body.ui-spacious #appShell #mainContent #view-inventory .ledger-model-text {
    flex: 1 1 0; min-width: 0; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap !important;
  }
}
@media screen and (max-width: 980px) {
  html body.ui-spacious #appShell #mainContent #view-inventory :is(.toolbar,.ledger-performance-title) :is(.form-control,.form-select,.btn),
  html body.ui-spacious #appShell #mainContent #view-inventory :is(.ledger-company-tab,.summary-chip) { min-height: 44px !important; height: auto !important; }
}

/* Compact work queues: empty results stay quiet; actionable details expand. */
@media screen {
  html body.ui-spacious #appShell .intake-overview { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
  html body.ui-spacious #appShell .main .intake-worklist { padding:10px 12px !important; margin:0 !important; min-width:0; }
  html body.ui-spacious #appShell .intake-heading { margin:0; align-items:center; gap:8px; flex-wrap:nowrap; }
  html body.ui-spacious #appShell .intake-heading > div { display:flex; align-items:baseline; flex-wrap:wrap; gap:4px 10px; min-width:0; }
  html body.ui-spacious #appShell .intake-heading h2 { font-size:15px !important; margin:0; white-space:nowrap; }
  html body.ui-spacious #appShell .intake-heading strong { font-size:13px; font-weight:500; }
  html body.ui-spacious #appShell .intake-heading .btn { flex:none; min-height:36px; padding:6px 10px; }
  html body.ui-spacious #appShell .intake-details > summary { cursor:pointer; font-size:12px; color:var(--ui-muted,#64748b); padding:6px 0 0; }
  html body.ui-spacious #appShell .intake-details[open] > summary { margin-bottom:8px; }
  html body.ui-spacious #appShell .intake-worklist p, html body.ui-spacious #appShell #intakeSyncStatus { font-size:13px; margin:8px 0; }
  html body.ui-spacious #appShell .intake-overview:has(.intake-details[open]) { grid-template-columns:1fr; }
}
@media screen and (max-width:980px) {
  html body.ui-spacious #appShell .intake-overview { grid-template-columns:1fr; }
  html body.ui-spacious #appShell .intake-heading .btn { min-height:44px; }
}
