/* Staff-facing workspace. Print documents retain their independent paper styles. */
@media screen {
  :root { --canvas: #f5f5f6; --line: #dedfe2; --radius: 10px; }
  .skip-link { position: absolute; top: -70px; left: 18px; padding: 12px 18px; color: #000; background: #fff; z-index: 100; }
  .skip-link:focus { top: 12px; }
  .app-header { min-height: 76px; padding: 14px 32px; }
  .brand-logo { width: 158px; }
  .brand-lockup { gap: 22px; }
  .brand-divider { height: 25px; background: #4a4a4a; }
  .product-name { font-size: .875rem; letter-spacing: .1em; }
  .header-actions { gap: 25px; }
  .studio-nav { display: inline-flex; align-items: center; gap: 8px; border: 0; padding: 8px 0; background: transparent; color: #aaa; text-decoration: none; font-size: .875rem; }
  .studio-nav.active { color: #fff; border-bottom: 1px solid #fff; }
  .studio-nav:hover { color: #fff; }
  .nav-count { display: inline-grid; place-items: center; min-width: 21px; height: 21px; padding: 0 5px; background: #303030; border-radius: 4px; font-size: .75rem; color: #eee; }
  .app-header .icon-button { width: 36px; height: 36px; border: 0; }
  .mode-ribbon { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 7px 32px; background: #f1eee7; border-bottom: 1px solid #e1ddd3; color: #61563f; font-size: .8125rem; }
  .mode-ribbon strong { margin-right: 9px; font-weight: 600; }
  .mode-ribbon button { border: 0; padding: 2px 0; background: transparent; color: #4b4130; font-size: .8125rem; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
  .document-bar { display: flex; align-items: center; gap: 16px; max-width: 1680px; margin: 0 auto; padding: 22px 32px 0; }
  .document-picker { display: flex; align-items: center; gap: 14px; min-width: 0; }
  .document-picker > span { flex-shrink: 0; color: #74787f; font-size: .8125rem; }
  .document-picker select { min-width: 0; width: min(390px, 32vw); border: 0; border-bottom: 1px solid #bfc2c7; background: transparent; padding: 8px 20px 8px 0; font-size: .875rem; color: #34383d; border-radius: 0; }
  .draft-count { font-size: .75rem; color: #858a91; white-space: nowrap; }
  .document-utilities { display: flex; align-items: center; gap: 10px; margin-left: auto; }
  .document-utilities > button { min-height: 36px; padding: 7px 12px; font-size: .8125rem; }
  .document-menu { position: relative; }
  .document-menu summary { display: grid; place-items: center; list-style: none; width: 38px; height: 36px; cursor: pointer; border: 1px solid #d0d3d8; border-radius: 6px; font-size: .75rem; letter-spacing: 2px; }
  .document-menu summary::-webkit-details-marker { display: none; }
  .document-menu[open] > div { position: absolute; right: 0; top: 43px; display: grid; padding: 5px; min-width: 180px; background: #fff; border: 1px solid #d4d6db; border-radius: 8px; box-shadow: 0 10px 25px #00000012; z-index: 25; }
  .document-menu button { border: 0; background: #fff; text-align: left; padding: 10px; color: #34383d; font-size: .875rem; }
  .document-menu button:hover { background: #f1f2f3; }
  .document-menu #deleteDraftButton { color: #93443a; }
  .document-heading { max-width: 1680px; margin: 0 auto; padding: 24px 32px 18px; display: flex; align-items: center; justify-content: space-between; gap: 22px; position: sticky; top: 0; z-index: 8; background: #f5f5f6f5; backdrop-filter: blur(12px); }
  .title-line { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
  .title-line h1 { text-transform: none; font-size: clamp(1.7rem, 2.4vw, 2.1rem); letter-spacing: -.035em; font-weight: 500; }
  .document-stage { display: inline-block; padding: 3px 9px; background: #e8e9eb; color: #5b6067; border: 1px solid #d8dbe0; border-radius: 4px; font-size: .75rem; white-space: nowrap; }
  .document-stage[data-state="ready"] { color: #235c46; background: #eaf2ed; border-color: #cbded2; }
  .document-stage[data-state="attention"] { color: #964838; background: #fff0eb; border-color: #efd5cc; }
  .workspace-context { margin: 6px 0 0; color: #70767e; font-size: .875rem; overflow-wrap: anywhere; }
  .command-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; flex-shrink: 0; }
  .primary-button, .secondary-button { border-radius: 7px; letter-spacing: 0; min-height: 42px; font-size: .875rem; font-weight: 500; padding: 10px 14px; box-shadow: none; }
  .primary-button { background: #111; }
  .primary-button:hover { background: #323232; }
  .secondary-button { border-color: #cfd2d7; background: #fff; }
  .workflow-band { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 35px; max-width: 1680px; margin: 0 auto; padding: 0 32px 22px; }
  .workflow-track { display: flex; flex-wrap: wrap; gap: 18px 36px; padding: 0; margin: 0; list-style: none; }
  .workflow-track li { display: flex; align-items: center; gap: 9px; color: #555d67; font-size: .875rem; }
  .workflow-marker { display: grid; place-items: center; flex: 0 0 27px; width: 27px; height: 27px; border: 1px solid #cdd1d7; border-radius: 50%; background: #fff; color: #6d7580; font-size: .75rem; }
  .workflow-description { min-width: 0; }
  .workflow-description strong { display: block; color: #303740; font-weight: 500; }
  .workflow-track small { display: block; color: #606975; font-size: .8125rem; }
  .workflow-track .complete .workflow-marker { background: #e9efeb; border-color: #c8d4cd; color: #35604a; }
  .workflow-scenario { font-size: .75rem; color: #876434; }
  .workflow-scenario:empty { display: none; }
  .workspace { width: calc(100% - 64px); max-width: 1616px; grid-template-columns: minmax(0, 1fr); gap: 26px; align-items: start; }
  .preview-window-button { display: inline-flex; align-items: center; gap: 10px; }
  .preview-window-button > span { font-size: 1.125rem; line-height: 1; }
  .editor-panel { padding: 0; }
  .editor-topline { min-height: 55px; margin: 0; padding: 10px 18px; gap: 15px; background: #fff; border: 1px solid #d8dce1; border-bottom: 0; border-radius: 10px 10px 0 0; }
  .editor-caption { font-size: .75rem; color: #858b93; }
  .document-switcher { border: 0; background: #f0f1f3; padding: 3px; border-radius: 6px; }
  .switch-button { min-height: 33px; padding: 6px 14px; border-radius: 4px; font-size: .875rem; font-weight: 500; }
  .switch-button.active { background: #fff; color: #111; box-shadow: 0 1px 4px #00000017; }
  #documentForm { border-radius: 0 0 10px 10px; box-shadow: none; }
  .form-section { padding: 20px; }
  .section-heading { margin-bottom: 16px; gap: 10px; align-items: center; }
  .section-heading h2 { font-size: 1rem; font-weight: 500; letter-spacing: 0; }
  .section-heading p { margin-top: 3px; color: #80868f; font-size: .8125rem; }
  .step-number { width: 25px; height: 25px; font-size: .75rem; border: 0; border-radius: 0; color: #9da3ad; background: transparent; }
  .heading-with-step { align-items: center; gap: 10px; }
  .field-grid { gap: 15px 16px; }
  .field { font-size: .875rem; font-weight: 500; gap: 6px; color: #4d555f; }
  .field input, .field select, .field textarea { min-height: 43px; padding: 9px 11px; border-radius: 5px; border-color: #d4d8de; background: #fff; font-size: 1rem; }
  .field textarea { line-height: 1.35; }
  .field input[readonly] { background: #f5f6f7; }
  .catalog-badge { margin-top: 3px; color: #828994; font-size: .75rem; }
  .line-section { padding: 18px 16px; }
  .line-heading { margin-left: 4px; margin-right: 4px; }
  .line-heading .secondary-button { min-height: 34px; padding: 6px 10px; font-size: .8125rem; }
  .line-table { display: table; table-layout: fixed; border-collapse: collapse; }
  .line-table thead { display: table-header-group; position: static; width: auto; height: auto; margin: 0; clip: auto; overflow: visible; }
  .line-table thead th { font-size: .875rem; padding: 9px 4px; text-align: left; font-weight: 600; color: #3c4653; background: #f1f3f5; border-bottom: 1px solid #cbd0d7; overflow-wrap: anywhere; }
  .line-table th:nth-child(1) { width: 26%; }
  .line-table th:nth-child(2) { width: 31%; }
  .line-table th:nth-child(3) { width: 8%; }
  .line-table th:nth-child(4) { width: 11%; }
  .line-table th:nth-child(5) { width: 8%; }
  .line-table th:nth-child(6) { width: 12%; }
  .line-table th:nth-child(7) { width: 4%; }
  .line-table tbody { display: table-row-group; }
  .line-table tr { display: table-row; border: 0; border-bottom: 1px solid #e1e3e6; }
  .line-table td { display: table-cell; padding: 11px 4px; vertical-align: top; }
  .line-table td[data-label]::before { display: none; }
  .line-table .cell-input { font-size: .875rem; min-height: 39px; border-radius: 4px; border: 1px solid #daddE2; padding: 8px 6px; background: #ffffffb8; }
  .line-table select.cell-input { padding-right: 13px; }
  .line-table textarea { min-height: 62px; }
  .line-table .item-action { padding-top: 12px !important; }
  .line-table .amount-cell { font-size: .875rem; font-weight: 500; line-height: 39px; white-space: nowrap; }
  .tax-check { width: 16px; height: 16px; margin-top: 12px; }
  .tax-option { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 6px; cursor: pointer; color: #46515f; font-size: .875rem; }
  .tax-option .tax-check { margin: 0; }
  .remove-line { width: 24px; height: 36px; }
  .editor-totals { display: grid; grid-template-columns: 1fr 1fr 1.15fr; gap: 22px; padding: 18px 20px; border-bottom: 1px solid #e1e3e6; }
  .editor-totals > div { display: grid; gap: 5px; }
  .editor-totals span { font-size: .8125rem; color: #767f8b; }
  .editor-totals small { font-size: .75rem; color: #9399a1; }
  .editor-totals strong { font-size: 1.125rem; font-weight: 500; font-variant-numeric: tabular-nums; }
  .editor-totals .editor-grand { border-left: 1px solid #dadde2; padding-left: 22px; }
  .editor-grand strong { font-size: 1.375rem; line-height: 1.2; }
  .form-actions { padding: 11px 20px; border-radius: 0 0 10px 10px; background: #fafafa; }
  .save-state { font-size: .75rem; color: #7c838e; }
  .delivery-panel { padding: 20px; margin-top: 16px; }
  .delivery-panel h2 { font-size: 1rem; font-weight: 500; }
  .delivery-panel > p { font-size: .875rem; margin-top: 7px; }
  .delivery-lock { font-size: .75rem; border: 0; border-radius: 4px; background: #f1f2f4; color: #657080; }
  .delivery-checks { margin-top: 10px; }
  .delivery-checks li { padding: 9px 0; font-size: .875rem; }
  .delivery-panel .delivery-connection-note { margin-top: 12px; color: #87909a; font-size: .75rem; }
  .recovery-actions { margin-top: 0; }
  .recovery-actions:has(button:not([hidden])) { margin-top: 14px; }
  .test-records { margin-top: 14px; }
  .test-records summary { font-size: .875rem; font-weight: 500; }
  .test-records summary span { float: right; }
  .activity-list time { font-size: .75rem; }
  .preview-panel { padding: 20px; border: 1px solid #dadde1; border-radius: 10px; background: #e9eaec; position: sticky; top: 114px; max-height: calc(100dvh - 134px); overflow: auto; scrollbar-width: thin; }
  .preview-toolbar { margin-bottom: 17px; min-height: 34px; }
  .preview-toolbar .eyebrow { color: #838a95; font-size: .75rem; letter-spacing: .09em; margin-bottom: 3px; }
  .preview-toolbar h2 { font-size: .9375rem; font-weight: 500; }
  .preview-expand { display: flex; align-items: center; gap: 9px; font-size: .8125rem; border: 0; padding: 6px 0; color: #5d6773; background: transparent; }
  .preview-expand span { font-size: 1.125rem; }
  .paper-scroll { padding-bottom: 14px; }
  .paper-preview { --paper-pad: 28px; box-shadow: 0 5px 14px #0000000c; }
  .preview-footnote { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 7px; font-size: .75rem; color: #7a828e; margin: 0 0 14px; }
  .preview-footnote strong { font-weight: 500; }
  .output-rules { margin: 16px 0 0; padding: 12px 0 0; border: 0; border-top: 1px solid #d1d4d9; background: transparent; }
  .output-rules summary { cursor: pointer; color: #69727e; font-size: .8125rem; }
  .output-rules p { font-size: .75rem; color: #7c8590; margin: 12px 0 8px; }
  .rule-chip { color: #767f8a; background: #f5f5f6; font-size: .75rem; }
  .workspace-footer { max-width: 1680px; margin: 0 auto; padding: 22px 32px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px 20px; color: #8c929b; font-size: .75rem; }
  .workspace-footer > span { letter-spacing: .055em; }
  .workspace-footer .storage-status { margin: 0; border: 0; padding: 0; }
  .settings-intro, .settings-section p { color: #777f8a; font-size: .875rem; }
  .settings-section { margin-top: 25px; padding-top: 22px; border-top: 1px solid #e1e3e6; }
  .settings-section h3 { font-size: .9375rem; font-weight: 500; margin-bottom: 6px; }
  .settings-section p { margin-bottom: 13px; }
  .reset-section { display: flex; align-items: center; gap: 25px; justify-content: space-between; }
  .reset-section button { flex-shrink: 0; }
  .reset-section p { margin: 0; }
  .outbox-library { width: min(860px, calc(100vw - 32px)); }
  .outbox-intro { padding: 17px 24px; font-size: .875rem; color: #777f8a; }
  #outboxList { padding-bottom: 16px; }
  .email-verification { font-size: .875rem; border-left-width: 2px; }
  .email-party { font-size: .9375rem; }
  .email-help { font-size: .8125rem; }
  .message-body { font-size: 1rem; }
}
@media screen and (max-width: 1240px) {
  .preview-panel { position: static; max-height: none; }
  .paper-preview { min-height: 890px; --paper-pad: 42px; }
  .preview-footnote { font-size: .8125rem; }
  .editor-caption { display: block; }
  .document-heading { align-items: flex-start; }
  .command-actions { max-width: 45%; }
}
@media screen and (max-width: 700px) {
  .app-header { padding: 13px 16px; min-height: 65px; gap: 14px; }
  .brand-logo { width: 119px; }
  .brand-lockup { gap: 10px; }
  .brand-divider, .product-name, .studio-nav.active { display: none; }
  .header-actions { gap: 14px; }
  .studio-nav { font-size: .875rem; }
  .mode-ribbon { padding: 8px 16px; font-size: .75rem; align-items: flex-start; gap: 14px; }
  .mode-ribbon strong { display: block; }
  .mode-ribbon button { padding-top: 1px; font-size: .75rem; }
  .document-bar { padding: 16px 16px 0; flex-wrap: wrap; gap: 12px; }
  .document-picker { flex: 1 1 calc(100% - 75px); flex-direction: column; align-items: stretch; gap: 0; }
  .document-picker > span { font-size: .75rem; }
  .document-picker select { width: 100%; font-size: .875rem; }
  .document-utilities { width: 100%; justify-content: flex-end; }
  .document-heading { padding: 18px 16px 14px; position: static; flex-direction: column; gap: 16px; }
  .command-actions { max-width: none; width: 100%; justify-content: flex-start; }
  .command-actions .primary-button { margin-left: auto; }
  .command-actions button { font-size: .8125rem; padding: 9px 10px; }
  .workflow-band { padding: 0 16px 18px; }
  .workflow-track { display: grid; width: 100%; grid-template-columns: 1fr 1fr; gap: 13px; }
  .workflow-track li { font-size: .875rem; }
  .workspace { width: calc(100% - 28px); gap: 20px; }
  .editor-topline { flex-direction: row; align-items: center; padding: 10px; }
  .document-switcher { width: auto; }
  .switch-button { padding: 6px 11px; }
  .editor-caption { display: none; }
  .form-section { padding: 18px 14px; }
  .section-heading { gap: 7px; }
  .field-grid { gap: 14px; }
  .line-table { display: block; }
  .line-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  .line-table tbody { display: grid; gap: 12px; }
  .line-table tr { display: grid; padding: 13px; border: 1px solid #dde0e4; border-radius: 6px; grid-template-columns: minmax(54px,.8fr) minmax(65px,1fr) 30px minmax(62px,1fr) 24px; gap: 10px 8px; }
  .line-table td { display: block; padding: 0; }
  .line-table td[data-label]::before { display: block; font-size: .8125rem; margin-bottom: 5px; }
  .line-table .item-action { padding-top: 21px !important; }
  .line-table .cell-input { font-size: 1rem; }
  .tax-option { padding-top: 0; }
  .tax-option > span { display: none; }
  .line-table .amount-cell { font-size: .9375rem; line-height: 39px; }
  .editor-totals { gap: 12px; padding: 16px; }
  .editor-totals .editor-grand { padding-left: 12px; }
  .editor-totals strong { font-size: 1rem; }
  .editor-grand strong { font-size: 1.25rem; }
  .editor-totals span { font-size: .8125rem; }
  .editor-totals small { display: block; }
  .delivery-panel { padding: 18px 16px; }
  .preview-panel { padding: 14px; }
  .paper-preview { --paper-pad: 26px; min-height: 740px; }
  .workspace-footer { padding: 20px 16px; }
  .reset-section { flex-direction: column; align-items: flex-start; gap: 12px; }
  .test-records summary span { float: none; display: inline; margin-left: 10px; }
}
@media screen and (max-width: 380px) {
  .command-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .command-actions .primary-button { grid-column: 1 / -1; margin: 0; }
  .line-table tr { grid-template-columns: repeat(3,minmax(0,1fr)) 24px; }
  .line-table .item-service { grid-column: 1 / 4; }
  .line-table .item-action { grid-column: 4; }
  .line-table .amount-cell { grid-column: 1 / -1; }
}

@media screen {
  .new-document-dialog { width: min(700px, calc(100vw - 32px)); }
  .new-document-intro { margin-bottom: 20px; color: #65707c; font-size: 1rem; }
  .new-document-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .document-choice { display: grid; align-content: start; gap: 12px; text-align: left; padding: 22px; border: 1px solid #cfd4dc; border-radius: 8px; background: #fff; color: #15191e; }
  .document-choice:hover { border-color: #111; background: #f5f6f7; }
  .document-choice .choice-type { color: #838c97; font-size: .75rem; letter-spacing: .08em; }
  .document-choice strong { font-size: 1.125rem; font-weight: 500; }
  .document-choice > span:last-child { color: #65707c; font-size: .875rem; }
  .new-document-error { color: #a1392a; font-size: .875rem; margin: 16px 0; }
  .new-document-error:empty { margin: 18px 0; }
}
@media screen and (max-width: 540px) { .new-document-choices { grid-template-columns: 1fr; } }
