:root {
  color-scheme: light;
  --bg: #eef1f3;
  --surface: #ffffff;
  --surface-soft: #f6f7f8;
  --surface-muted: #e8ecef;
  --border: #d4d9de;
  --border-strong: #b8c0c7;
  --text: #202428;
  --text-soft: #555d65;
  --text-muted: #727b84;
  --accent: #f2c94c;
  --accent-hover: #e6bb36;
  --accent-ink: #332a05;
  --focus: #2f6fc2;
  --danger: #a13a3a;
  --danger-soft: #f7e5e5;
  --success: #246a44;
  --success-soft: #e1f1e7;
  --warning: #805411;
  --warning-soft: #fff0cf;
  --info: #4f4385;
  --info-soft: #ebe7f7;
  --shadow: 0 18px 48px rgba(28, 35, 42, .16);
  --nav-width: 258px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171a1e;
  --surface: #20242a;
  --surface-soft: #262b31;
  --surface-muted: #30363d;
  --border: #3b424a;
  --border-strong: #555f69;
  --text: #f3f4f5;
  --text-soft: #c6cbd0;
  --text-muted: #929aa3;
  --accent: #e3bd42;
  --accent-hover: #f0c94b;
  --accent-ink: #282104;
  --focus: #79aef2;
  --danger: #f0a0a0;
  --danger-soft: #472c2f;
  --success: #8fd4ad;
  --success-soft: #253f33;
  --warning: #e8c078;
  --warning-soft: #483b24;
  --info: #c0b3ed;
  --info-soft: #39334d;
  --shadow: 0 18px 48px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; }
body { margin: 0; overflow: hidden; background: var(--bg); color: var(--text); font-size: 13px; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, select { cursor: pointer; }
button:disabled, select:disabled { cursor: default; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.icon { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { width: 100%; height: 100vh; display: grid; grid-template-columns: var(--nav-width) minmax(0, 1fr); overflow: hidden; }
.side-nav { position: relative; z-index: 20; width: var(--nav-width); min-height: 0; display: flex; flex-direction: column; overflow: visible; border-right: 1px solid var(--border); background: var(--surface-soft); }
.brand { min-height: 64px; padding: 8px 8px 8px 18px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); background: var(--surface); }
.brand-logo { width: min(196px, 100%); height: 46px; object-fit: contain; object-position: left center; filter: brightness(0) saturate(100%) invert(81%) sepia(66%) saturate(575%) hue-rotate(351deg) brightness(98%) contrast(93%); }
.nav-reveal img { width: 142px; height: 36px; object-fit: contain; object-position: left center; filter: brightness(0) saturate(100%) invert(81%) sepia(66%) saturate(575%) hue-rotate(351deg) brightness(98%) contrast(93%); }
.brand-arrow { width: 36px; height: 36px; margin-left: auto; display: grid; flex: 0 0 auto; place-items: center; border: 0; background: transparent; color: var(--text-muted); }
.brand-arrow:hover { background: var(--surface-soft); color: var(--text); }
.brand-arrow .icon, .nav-arrow .icon { width: 16px; height: 16px; }
.global-search-wrap { position: relative; margin: 12px 10px 8px; }
.global-search { min-height: 40px; padding: 0 9px; display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 7px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text-soft); }
.global-search:focus-within { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.global-search input { width: 100%; min-height: 36px; padding: 0; border: 0; outline: 0; background: transparent; }
.function-results { position: absolute; z-index: 80; top: calc(100% + 4px); right: 0; left: 0; max-height: min(440px, 62vh); overflow: auto; border: 1px solid var(--border-strong); border-radius: 4px; background: var(--surface); box-shadow: var(--shadow); }
.function-result { width: 100%; min-height: 45px; padding: 7px 10px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; border: 0; border-bottom: 1px solid var(--border); background: transparent; text-align: left; }
.function-result:last-child { border-bottom: 0; }
.function-result:hover:not(:disabled) { background: var(--surface-soft); }
.function-result:disabled { opacity: .55; }
.function-result b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.function-result span { color: var(--text-muted); font-size: 11px; }
.function-empty { padding: 18px 10px; color: var(--text-muted); text-align: center; }
kbd { padding: 3px 5px; border: 1px solid var(--border); border-radius: 3px; background: var(--surface-muted); color: var(--text-muted); font-size: 10px; }
.nav-label { padding: 10px 15px 6px; color: var(--text-muted); font-size: 11px; font-weight: 700; }
.module-list { flex: 1; padding: 0 8px 16px; overflow: auto; }
.module { margin-bottom: 3px; }
.module-link { width: 100%; min-height: 40px; padding: 8px 9px; display: grid; grid-template-columns: 22px minmax(0, 1fr) 18px; align-items: center; gap: 9px; border: 0; border-radius: 4px; background: transparent; color: var(--text-soft); text-align: left; }
.module-link:hover:not(:disabled) { background: var(--surface-muted); color: var(--text); }
.module.active > .module-link, .module.open > .module-link { color: var(--text); box-shadow: inset 2px 0 var(--accent-hover); font-weight: 700; }
.module:not(.available) > .module-link { color: var(--text-muted); }
.module-link.unavailable { grid-template-columns: 22px 1fr; opacity: .58; }
.module-chevron { display: grid; }
.module-chevron .icon { width: 15px; height: 15px; }
.module.open .module-chevron { transform: rotate(-90deg); }
.module-flyout { position: absolute; z-index: 70; top: 112px; left: calc(100% - 5px); width: 270px; max-height: min(560px, calc(100vh - 130px)); overflow: auto; border: 1px solid var(--border-strong); border-radius: 4px; background: var(--surface); box-shadow: var(--shadow); }
.module-flyout header { position: sticky; top: 0; z-index: 1; min-height: 44px; padding: 0 8px 0 12px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); background: var(--surface); }
.module-flyout header button { width: 34px; height: 34px; display: grid; place-items: center; border: 0; background: transparent; color: var(--text-muted); }
.module-flyout header .icon { width: 14px; height: 14px; }
.module-flyout > div { padding: 5px 0; display: grid; }
.module-flyout > div > button { min-height: 37px; padding: 7px 12px 7px 14px; border: 0; border-left: 2px solid transparent; background: transparent; color: var(--text-soft); text-align: left; }
.module-flyout > div > button:hover:not(:disabled) { background: var(--surface-soft); color: var(--text); }
.module-flyout > div > button:disabled { color: var(--text-muted); opacity: .58; }
.module-flyout > div > button.active { border-left-color: var(--accent-hover); color: var(--text); font-weight: 700; }
.side-footer { padding: 8px 10px 10px; display: grid; gap: 7px; border-top: 1px solid var(--border); background: var(--surface); }
.theme-switch { min-height: 39px; padding: 0 8px; display: flex; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--text-soft); }
.theme-switch:hover { border-color: var(--border); background: var(--surface-soft); }
.theme-switch [data-theme-icon] { display: grid; }
.user { min-height: 42px; padding: 4px 7px; display: flex; align-items: center; gap: 9px; }
.user i, .avatar { width: 30px; height: 30px; display: inline-grid; place-items: center; border-radius: 50%; background: var(--surface-muted); color: var(--text-soft); font-size: 11px; font-style: normal; font-weight: 800; }
.user span, .user b, .user small { display: block; }
.user b { font-size: 12px; }
.user small { margin-top: 2px; color: var(--text-muted); font-size: 11px; }

.main-area { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.mobile-bar { display: none; }
.workspace-tabs { min-height: 42px; padding: 6px 8px 0; display: flex; align-items: end; gap: 3px; overflow-x: auto; overflow-y: hidden; border-bottom: 1px solid var(--border-strong); background: var(--surface-muted); scrollbar-width: thin; }
.workspace-tab { height: 36px; min-width: 0; display: flex; align-items: stretch; border: 1px solid var(--border); border-bottom: 0; border-radius: 5px 5px 0 0; background: var(--surface-soft); color: var(--text-soft); }
.workspace-tab.active { background: var(--surface); color: var(--text); box-shadow: inset 0 3px var(--accent); }
.workspace-tab > button:first-child { min-width: 0; padding: 0 7px 0 11px; display: flex; align-items: center; gap: 7px; border: 0; background: transparent; }
.workspace-tab > button:first-child span { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab-close { width: 34px; display: grid; place-items: center; border: 0; background: transparent; color: var(--text-muted); }
.tab-close:hover { color: var(--text); }
.tab-close .icon { width: 14px; height: 14px; }
.dirty { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); }
.new-tab, .mobile-tabs-menu { width: 36px; height: 36px; display: grid; flex: 0 0 auto; place-items: center; border: 0; background: transparent; color: var(--text-soft); }
.new-tab:hover { background: var(--surface-soft); }
.mobile-tabs-menu { display: none; }
.workspace { min-height: 0; flex: 1; overflow: auto; background: var(--bg); }

.page { min-height: 100%; display: flex; flex-direction: column; }
.page-header { min-height: 78px; padding: 15px 20px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--border); background: var(--surface); }
.page-header h1 { margin: 0; font-size: 21px; line-height: 1.2; letter-spacing: -.015em; }
.page-header p { margin: 5px 0 0; color: var(--text-muted); font-size: 12px; }
.page-actions { display: flex; align-items: center; gap: 7px; }
.button { min-height: 38px; padding: 7px 12px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--border-strong); border-radius: 4px; background: var(--surface); color: var(--text); font-weight: 700; }
.button:hover:not(:disabled) { background: var(--surface-soft); }
.button.primary { border-color: var(--accent-hover); background: var(--accent); color: var(--accent-ink); }
.button.primary:hover:not(:disabled) { background: var(--accent-hover); }
.button:disabled { opacity: .45; }
.button .icon { width: 17px; height: 17px; }

.filter-bar, .report-toolbar { min-height: 66px; padding: 10px 14px; display: flex; align-items: end; gap: 8px; border-bottom: 1px solid var(--border); background: var(--surface-soft); }
.filter-bar label:not(.search-field) { min-width: 165px; display: grid; gap: 5px; color: var(--text-muted); font-size: 11px; }
input, select, textarea { border: 1px solid var(--border-strong); border-radius: 4px; background: var(--surface); color: var(--text); }
input, select { min-height: 38px; padding: 0 10px; }
textarea { min-height: 110px; padding: 10px; resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
.search-field { min-width: 260px; min-height: 38px; padding: 0 10px; display: flex; flex: 1; align-items: center; gap: 7px; border: 1px solid var(--border-strong); border-radius: 4px; background: var(--surface); }
.search-field:focus-within { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.search-field input { width: 100%; min-height: 36px; padding: 0; border: 0; outline: 0; background: transparent; }
.segmented { padding: 3px; display: flex; align-items: center; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); }
.segmented button { min-height: 30px; padding: 5px 9px; border: 0; border-radius: 3px; background: transparent; color: var(--text-muted); }
.segmented button.active { background: var(--surface-muted); color: var(--text); font-weight: 700; }

.table-frame { min-width: 0; overflow: auto; background: var(--surface); }
.data-table { width: 100%; min-width: 900px; border-collapse: collapse; table-layout: auto; }
.data-table th { position: sticky; top: 0; z-index: 1; padding: 10px; border-bottom: 1px solid var(--border-strong); background: var(--surface-muted); color: var(--text-soft); font-size: 11px; font-weight: 700; text-align: left; white-space: nowrap; }
.data-table td { padding: 10px; border-bottom: 1px solid var(--border); color: var(--text-soft); vertical-align: middle; white-space: nowrap; }
.table-frame.compact .data-table td { padding-top: 7px; padding-bottom: 7px; }
.data-table tbody tr:hover td { background: var(--surface-soft); }
.data-table .check { width: 42px; text-align: center; }
.data-table .number { text-align: right; }
.document-link { padding: 2px 0; border: 0; background: transparent; color: var(--focus); font-weight: 750; text-align: left; }
.document-link:hover { text-decoration: underline; }
.status { max-width: 220px; min-height: 23px; padding: 4px 7px; display: inline-flex; align-items: center; border-radius: 3px; background: var(--surface-muted); color: var(--text-soft); font-size: 10px; font-weight: 750; line-height: 1.2; }
.status.success { background: var(--success-soft); color: var(--success); }
.status.warning { background: var(--warning-soft); color: var(--warning); }
.status.danger { background: var(--danger-soft); color: var(--danger); }
.status.info { background: var(--info-soft); color: var(--info); }
.data-table .avatar { width: 28px; height: 28px; }
.mobile-order-list { display: none; }
.table-footer { min-height: 50px; padding: 8px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--border); background: var(--surface); color: var(--text-muted); }
.table-footer nav { display: flex; gap: 4px; }
.table-footer button { min-height: 34px; padding: 5px 9px; border: 1px solid var(--border); border-radius: 3px; background: var(--surface); }
.table-footer button.active { border-color: var(--accent-hover); background: var(--accent); color: var(--accent-ink); }
.empty-state { min-height: 280px; display: grid; place-content: center; gap: 7px; color: var(--text-muted); text-align: center; }
.empty-state b { color: var(--text); font-size: 15px; }

.mobile-back { display: none; }
.document-status-row { min-height: 48px; padding: 8px 20px; display: flex; align-items: center; gap: 7px; border-bottom: 1px solid var(--border); background: var(--surface-soft); }
.document-status-row .status { margin-right: auto; }
.document-status-row button, .inline-actions button { min-height: 34px; padding: 5px 9px; border: 1px solid var(--border); border-radius: 3px; background: var(--surface); }
.document-status-row button:hover, .inline-actions button:hover { border-color: var(--border-strong); }
.section-tabs { min-height: 43px; padding: 0 20px; display: flex; align-items: end; gap: 15px; border-bottom: 1px solid var(--border); background: var(--surface); }
.section-tabs button { min-height: 42px; padding: 8px 2px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--text-muted); text-transform: none; }
.section-tabs button.active { border-bottom-color: var(--accent-hover); color: var(--text); font-weight: 700; }
.document-body { padding: 16px 20px 28px; }
.document-grid { width: 100%; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr); gap: 14px; }
.content-panel { border: 1px solid var(--border); background: var(--surface); }
.positions-panel, .document-body > .content-panel { width: 100%; }
.panel-heading { min-height: 58px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); }
.panel-heading > div:last-child { display: flex; gap: 7px; }
.panel-heading h2 { margin: 0; font-size: 15px; }
.panel-heading p { margin: 4px 0 0; color: var(--text-muted); font-size: 11px; }
.detail-grid { margin: 0; padding: 15px; display: grid; grid-template-columns: repeat(2, minmax(150px, 1fr)); gap: 18px 20px; }
.detail-grid div { min-width: 0; }
.detail-grid dt { margin-bottom: 5px; color: var(--text-muted); font-size: 11px; }
.detail-grid dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.field { display: grid; gap: 6px; color: var(--text-muted); font-size: 11px; }
.content-panel > .field { padding: 15px; }
.inline-actions { padding: 10px 14px; display: flex; gap: 7px; border-top: 1px solid var(--border); background: var(--surface-soft); }
.positions-table { min-width: 780px; }
.related-documents { padding: 12px; display: grid; grid-template-columns: repeat(2, minmax(230px, 1fr)); gap: 8px; }
.related-documents button { min-height: 64px; padding: 10px; display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); text-align: left; }
.related-documents button:hover { background: var(--surface-soft); }
.related-documents i { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 3px; background: var(--surface-muted); color: var(--text-soft); font-size: 10px; font-style: normal; font-weight: 800; }
.related-documents span, .related-documents b, .related-documents small { display: block; }
.related-documents small { margin-top: 3px; color: var(--text-muted); }
.related-documents em { color: var(--text-muted); font-style: normal; }
.timeline { margin: 0; padding: 10px 18px 18px 42px; }
.timeline li { padding: 10px 0 10px 4px; }
.timeline b, .timeline span { display: block; }
.timeline span { margin-top: 4px; color: var(--text-muted); font-size: 11px; }

.document-form { width: auto; margin: 16px 20px 28px; display: grid; gap: 14px; }
.form-grid { padding: 15px; display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 14px; }
.position-editor { overflow: auto; }
.position-editor-head, .position-editor-row { min-width: 720px; padding: 8px 12px; display: grid; grid-template-columns: 170px minmax(240px, 1fr) 80px 130px; gap: 8px; }
.position-editor-head { border-bottom: 1px solid var(--border); background: var(--surface-muted); color: var(--text-soft); font-size: 11px; font-weight: 700; }
.position-editor-row input { width: 100%; }

.report-toolbar { align-items: center; }
.report-toolbar .search-field { max-width: 440px; margin-left: auto; }

.nav-scrim, .nav-reveal { display: none; }
.toast { position: fixed; z-index: 250; right: 18px; bottom: 18px; max-width: 380px; padding: 11px 14px; border: 1px solid var(--border-strong); border-radius: 5px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .16s ease, transform .16s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (min-width: 821px) {
  .app-shell { transition: grid-template-columns .16s ease; }
  .app-shell.nav-collapsed { grid-template-columns: 0 minmax(0, 1fr); }
  .app-shell.nav-collapsed .side-nav { transform: translateX(-100%); }
  .app-shell.nav-collapsed .nav-reveal { position: fixed; z-index: 60; top: 0; left: 0; width: var(--nav-width); height: 42px; padding: 2px 8px 2px 18px; display: flex; align-items: center; gap: 8px; border: 0; border-right: 1px solid var(--border-strong); border-bottom: 1px solid var(--border-strong); background: var(--surface-muted); }
  .app-shell.nav-collapsed .nav-reveal:hover { background: var(--surface-soft); }
  .app-shell.nav-collapsed .nav-arrow { margin-left: auto; display: grid; place-items: center; color: var(--text-muted); transform: rotate(180deg); }
  .app-shell.nav-collapsed .workspace-tabs { padding-left: calc(var(--nav-width) + 8px); }
}

@media (max-width: 1100px) {
  .app-shell { --nav-width: 224px; grid-template-columns: var(--nav-width) minmax(0, 1fr); }
  .brand { padding-left: 14px; }
  .form-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
  .document-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  body { overflow: hidden; }
  .app-shell { height: 100dvh; display: block; }
  .side-nav { position: fixed; z-index: 120; inset: 0 auto 0 0; width: min(86vw, 330px); transform: translateX(-102%); transition: transform .18s ease; box-shadow: var(--shadow); }
  .app-shell.nav-open .side-nav { transform: translateX(0); }
  .nav-scrim { position: fixed; z-index: 110; inset: 0; width: 100%; border: 0; background: rgba(10, 14, 18, .42); }
  .app-shell.nav-open .nav-scrim { display: block; }
  .module-flyout { top: 112px !important; right: 10px; left: 10px; width: auto; max-height: calc(100dvh - 132px); }
  .main-area { height: 100dvh; }
  .mobile-bar { min-height: 52px; padding: 0 8px; display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; border-bottom: 1px solid var(--border); background: var(--surface); }
  .mobile-bar b { text-align: center; }
  .mobile-bar button { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: transparent; }
  .workspace-tabs { min-height: 44px; padding: 5px 5px 0; }
  .workspace-tab { height: 39px; }
  .workspace-tab > button:first-child { min-height: 39px; }
  .tab-close, .new-tab { width: 40px; height: 39px; }
  .workspace { overflow: auto; }
  .page-header { min-height: 72px; padding: 12px; align-items: flex-start; }
  .page-header h1 { font-size: 18px; }
  .page-header p { font-size: 11px; }
  .page-actions { flex-wrap: wrap; justify-content: flex-end; }
  .button { min-height: 44px; }
  .button.secondary { padding-left: 10px; padding-right: 10px; }
  .filter-bar { padding: 9px; display: grid; grid-template-columns: 1fr 1fr; }
  .filter-bar .search-field { min-width: 0; grid-column: 1 / -1; }
  .filter-bar label:not(.search-field) { min-width: 0; }
  input, select { min-height: 44px; }
  .orders-page .table-frame { display: none; }
  .mobile-order-list { padding: 8px; display: grid; gap: 7px; background: var(--bg); }
  .order-card { min-height: 108px; padding: 12px; display: grid; gap: 8px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); text-align: left; }
  .order-card:active { background: var(--surface-soft); }
  .order-card-head, .order-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .order-card-head > b { color: var(--focus); }
  .order-card-head .status { max-width: 53%; font-size: 10px; text-align: right; }
  .order-card-customer { color: var(--text); font-weight: 700; }
  .order-card-meta { color: var(--text-muted); font-size: 11px; }
  .order-card-meta strong { color: var(--text); font-size: 12px; }
  .table-footer { min-height: 54px; padding: 8px 10px; }
  .table-footer nav button { min-height: 40px; }
  .mobile-back { min-height: 44px; padding: 0 12px; display: flex; align-items: center; gap: 7px; border: 0; border-bottom: 1px solid var(--border); background: var(--surface-soft); color: var(--text-soft); }
  .document-page .page-header { min-height: auto; display: grid; }
  .document-page .page-actions { justify-content: flex-start; }
  .document-status-row { min-height: 50px; padding: 7px 10px; overflow-x: auto; }
  .document-status-row .status { min-width: max-content; }
  .document-status-row button, .inline-actions button { min-height: 40px; min-width: max-content; }
  .section-tabs { min-height: 46px; padding: 0 10px; gap: 16px; overflow-x: auto; }
  .section-tabs button { min-height: 45px; min-width: max-content; }
  .document-body { padding: 10px; }
  .detail-grid { grid-template-columns: 1fr 1fr; gap: 14px 10px; }
  .panel-heading { align-items: flex-start; }
  .panel-heading > div:last-child { flex-wrap: wrap; justify-content: flex-end; }
  .related-documents { grid-template-columns: 1fr; }
  .related-documents button { min-height: 70px; }
  .inline-actions { overflow-x: auto; }
  .document-form { width: auto; margin: 10px 10px 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .report-toolbar { padding: 9px; display: grid; grid-template-columns: 1fr; }
  .report-toolbar .search-field { width: 100%; max-width: none; margin-left: 0; }
  .report-page .table-frame { overflow: auto; }
  .report-page .data-table { min-width: 760px; }
  .toast { right: 10px; bottom: 10px; left: 10px; max-width: none; }
}

@media (max-width: 520px) {
  .page-header { display: grid; }
  .page-actions { justify-content: flex-start; }
  .page-actions .button { flex: 1 1 auto; }
  .filter-bar { grid-template-columns: 1fr; }
  .filter-bar .search-field { grid-column: 1; }
  .detail-grid { grid-template-columns: 1fr; }
  .document-status-row { align-items: stretch; }
  .workspace-tab > button:first-child span { max-width: 128px; }
}
