/* Shared Operate polish. Module layouts, density preferences and business states
   remain in their original stylesheets; lazy CRM/Finance/Reports stay lazy. */
:root {
  --field-line: #d8e0ea;
  --focus-line: #7599ed;
  --focus-ring: #9bb8ff;
  --surface-hover: #f7f9fd;
  --surface-muted: #f7f9fc;
  --muted-on-surface: #60718b;
}

::selection { background: #dce6ff; color: var(--ink); }
a { text-underline-offset: .18em; text-decoration-thickness: 1px; }
:where(input, textarea) { caret-color: var(--blue); }
.decision-dialog{width:min(480px,calc(100vw - 32px));max-height:calc(100dvh - 48px);padding:0;border:0;border-radius:18px;box-shadow:0 16px 48px #172c4633}.decision-dialog>form{margin:0}.decision-dialog .dialog-header{padding:20px 24px}.decision-dialog .dialog-body{padding:20px 24px}.decision-dialog .dialog-body>p{margin:0 0 20px;line-height:1.5;max-width:55ch}.decision-dialog .dialog-footer{padding-top:16px;margin-top:20px;display:flex;justify-content:flex-end;gap:10px}.decision-dialog textarea{font-size:16px;resize:vertical;min-height:96px}.decision-dialog::backdrop{background:#172c4659}@media(max-width:760px){.decision-dialog .dialog-header,.decision-dialog .dialog-body{padding:18px}.decision-dialog .dialog-footer>button{min-height:44px}}
.page :is(input, textarea)::placeholder,
.page .search input::placeholder,
.dialog-body :is(input, textarea)::placeholder,
.login-card :is(input, textarea)::placeholder { color: var(--muted-on-surface); opacity: 1; }
:where(button, a, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--focus-line);
  outline-offset: 3px;
}
:where(input, select, textarea):focus {
  outline-color: var(--focus-ring);
  border-color: var(--focus-line);
}
:where(input, select, textarea)[aria-invalid="true"] { border-color: var(--danger); }
:where(input, select, textarea)[aria-invalid="true"]:focus { outline-color: var(--danger); }

/* Keep the familiar shell and its existing collapsed/mobile navigation. */
.page-title-row h1 { letter-spacing: -.035em; }
.page-title-row { row-gap: 10px; }
.sidebar .nav-link:focus-visible,
.more-navigation .nav-link:focus-visible { outline-offset: -2px; }
.sidebar .nav-link:not(.active):hover,
.more-navigation .nav-link:not(.active):hover { background: var(--surface-hover); color: var(--ink); }
.sidebar .nav-link.active,
.more-navigation .nav-link.active { font-weight: 600; }
.sidebar .count { font-variant-numeric: tabular-nums; }

/* The register toolbars share a 40px desktop control rhythm. These selectors
   intentionally do not include the CRM composer, field editors or board. */
.page :is(.unified-order-toolbar, .fabric-toolbar, .settlement-toolbar, .certificates-toolbar) {
  padding: 12px;
  gap: 10px;
}
.page :is(.unified-order-toolbar, .fabric-toolbar, .settlement-toolbar, .certificates-toolbar) .search input {
  min-height: 40px;
  height: 40px;
  font-size: 14px;
  background: var(--surface-muted);
  border-color: var(--field-line);
}
.page :is(.unified-order-toolbar, .fabric-toolbar, .settlement-toolbar, .certificates-toolbar) .search svg {
  top: 10px;
  pointer-events: none;
}
.page :is(.unified-order-toolbar, .fabric-toolbar, .settlement-toolbar, .certificates-toolbar) > button,
.page .receipt-actions > button,
.page .desktop-order-filters select,
.page-actions > button {
  min-height: 40px;
  font-size: 13px;
}
.page .receipt-actions { gap: 8px; }
.page .desktop-order-filters select { padding-top: 8px; padding-bottom: 8px; }
.page :is(.archive-filters, .history-filters) { gap: 10px; }
.page :is(.archive-filters, .history-filters) :is(input, select) {
  min-height: 40px;
  font-size: 14px;
  border-color: var(--field-line);
}
.page .tabs > button { border-radius: 8px; }
.page .tabs > button.active { background: var(--soft); color: var(--blue); }

/* Density changes only where a register was still taller than its neighbours.
   Row-to-card breakpoints and warehouse horizontal scrolling remain untouched. */
.page :is(.compact-orders-list, .compact-fabric-list, .compact-catalog-list, .certificate-table) thead th,
.page .stock-workbench .stock-table thead th,
#finance-page .finance-table thead th {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  background: var(--surface-muted);
  color: var(--muted-on-surface);
}
.page :is(.compact-orders-list, .compact-fabric-list, .compact-catalog-list, .certificate-table) tbody tr:hover,
.page .stock-workbench .stock-table tbody tr:hover,
#finance-page .finance-table tbody tr:hover { background: var(--surface-hover); }
.page .certificate-table .list-title { font-weight: 600; }
.page .stock-workbench .stock-table { font-size: 14px; }
.page .stock-workbench .stock-table :is(th, td) { border-bottom-color: var(--line); }
.page .stock-workbench :is(.stock-list-meta, .stock-info dt, .stock-product-intro, .stock-totals span) {
  color: var(--muted);
}
.page .stock-workbench .stock-matrix td button.active { background: var(--soft); color: var(--blue); }
.page .stock-workbench .stock-toolbar :is(button, select),
.page .stock-workbench .stock-filter-menu > summary { font-size: 13px; }
.page .stock-workbench .stock-filter-menu > summary { min-height: 40px; padding: 10px 12px; }
.page .stock-workbench .stock-toolbar .crm-segmented button.active { background: var(--soft); color: var(--blue); }
.page .stock-workbench .stock-work-header h2 { font-size: 22px; line-height: 1.3; letter-spacing: -.025em; }
.page .stock-workbench .stock-document-footer { background: var(--bg); }
.page .payment-paybar { border-radius: 12px; }
.page .payment-paybar strong { font-variant-numeric: tabular-nums; }
.page .history-list { padding-right: 20px; padding-left: 20px; }
.page .history-list .history-row { padding-top: 16px; padding-bottom: 16px; }
.page .history-title { line-height: 1.45; }
.page .history-change { color: var(--muted); }
.page .history-time { font-variant-numeric: tabular-nums; }
.page > .panel > .empty { padding: 44px 20px; font-size: 14px; line-height: 1.6; }

@media (min-width: 851px) {
  .page .certificate-table :is(th, td),
  #finance-page .finance-table :is(th, td) { padding: 12px 14px; }
  .page .certificate-table .certificate-chevron { width: 38px; }
}
@container (min-width: 721px) {
  .users-table :is(th, td) { padding: 13px 16px; }
  .users-table th { font-size: 12px; font-weight: 600; background: var(--surface-muted); }
  .users-table .employee-action button { min-height: 38px; font-size: 13px; }
}

/* Scoped IDs deliberately outrank later lazy module rules, only for shared
   typography/control presentation. Their grid and overflow rules still win. */
#finance-page .finance-journal-toolbar { gap: 10px; }
#finance-page .finance-search input { background: var(--surface-muted); border-color: var(--field-line); }
#finance-page .finance-tabs > button { border-radius: 8px; }
#finance-page .finance-tabs > button.active { background: var(--soft); color: var(--blue); }
#finance-page .finance-journal-toolbar > button { font-size: 13px; }
#sales-reports-page .sales-reports-controls > button { font-size: 13px; }
#sales-reports-page .sales-report-list-item.active { background: var(--soft); color: var(--blue); box-shadow: none; }
#sales-reports-page .sales-report-list-item.active > strong { font-weight: 650; }
#sales-reports-page .sales-report-list-item.active > span:last-child { color: #45618b; }
#sales-reports-page .sales-review-case :is(textarea, select, input) { border-color: var(--field-line); border-radius: 9px; }

/* Compact, legible form labels and actions; retain native dialog geometry,
   sticky header/footer, dirty guards, module widths and safe-area bounds. */
.dialog-header h2 { font-size: 18px; line-height: 1.4; letter-spacing: -.025em; overflow-wrap: anywhere; }
.dialog-header > button { flex-shrink: 0; width: 44px; min-height: 44px; border-radius: 10px; }
.dialog-footer { gap: 8px; }
.dialog-footer > button { font-size: 14px; min-height: 44px; }
.dialog-body label.field { font-size: 13px; line-height: 1.45; }
.dialog-body .hint { line-height: 1.5; }
.dialog-body .form-error { font-size: 13px; line-height: 1.5; }
.dialog-body :is(input, select, textarea) { border-color: var(--field-line); }
.dialog-body :is(input, select, textarea):focus { border-color: var(--focus-line); }
.dialog-body :is(input, select, textarea)[aria-invalid="true"] { border-color: var(--danger); }
.dialog-body .link-button { text-underline-offset: .18em; }

@media (min-width: 761px) {
  .dialog-header { padding: 18px 24px; }
  .dialog-body { padding: 22px 24px; }
  .dialog-body > form:not([id^="crm-"]):not([id^="wb-"]) label.field > :is(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea) {
    font-size: 14px;
    padding: 10px 12px;
  }
}
@media (max-width: 760px) {
  .page :is(.unified-order-toolbar, .fabric-toolbar, .settlement-toolbar, .certificates-toolbar) { gap: 8px; }
  .page :is(.unified-order-toolbar, .fabric-toolbar, .settlement-toolbar, .certificates-toolbar) .search input {
    min-height: 44px;
    height: 44px;
    font-size: 16px;
  }
  .page :is(.unified-order-toolbar, .fabric-toolbar, .settlement-toolbar, .certificates-toolbar) .search svg { top: 12px; }
  .page :is(.unified-order-toolbar, .fabric-toolbar, .settlement-toolbar, .certificates-toolbar) > button,
  .page .receipt-actions > button,
  .page-actions > button,
  .page .tabs > button,
  .page :is(.archive-filters, .history-filters) :is(button, input, select) { min-height: 44px; }
  .page .receipt-actions .receipts-history-button { min-width: 44px; }
  .page :is(.archive-filters, .history-filters) :is(input, select) { font-size: 16px; }
  .page .stock-workbench .stock-filter-menu > summary { min-height: 44px; padding: 12px; }
  .page .stock-workbench .stock-toolbar select { font-size: 16px; }
  .page .stock-workbench .stock-work-header h2 { font-size: 20px; }
  .page .history-list { padding-left: 14px; padding-right: 14px; }
  .page .history-list .history-row { padding-top: 14px; padding-bottom: 14px; }
  #finance-page .finance-tabs > button,
  #finance-page .finance-journal-toolbar > button,
  #finance-page .finance-period-controls > button,
  #finance-page .finance-period-controls select,
  #sales-reports-page .sales-reports-controls > button { min-height: 44px; }
  #finance-page .finance-search input { min-height: 44px; height: 44px; font-size: 16px; }
  #finance-page .finance-search > .icon { top: 12px; }
  .dialog-body :is(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea) { font-size: 16px; }
  .dialog-body .certificate-quick-nominals > button,
  .dialog-body .certificate-period-presets > button { min-height: 44px; }
  .dialog-footer { padding-bottom: max(12px, env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 400px) {
  .page :is(.unified-order-toolbar, .fabric-toolbar, .certificates-toolbar) { padding: 8px; gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .nav-crm-chevron > .icon,
  .fabric-group > summary::before,
  .receipt-batch > summary::before { transition: none; }
}

/* Final contrast/readability correction from the single design check. The
   existing slate shade also clears the tinted board and outgoing surfaces. */
:root { --muted: #5d6c83; }
.crm-deal-workspace .wb-save-state,
.crm-deal-workspace .wb-note footer,
.crm-deal-workspace .wb-note footer button,
.crm-deal-workspace .crm-composer-actions > .minor { font-size: 11px; }
/* Only these two declarations need priority over incumbent compact !important. */
.crm-deal-workspace .crm-message footer,
.crm-deal-workspace .crm-message-context { font-size: 11px !important; }
.crm-deal-workspace .crm-thread #crm-composer-status,
.crm-deal-workspace .crm-thread #crm-composer-status span { font-size: 11px; }
.crm-deal-workspace .crm-thread #crm-composer-status strong,
.crm-deal-workspace .crm-thread #crm-composer-status .wb-recipient { font-size: 12px; }
.crm-deal-workspace .wb-quote { border-left-width: 1px; }

.finance-filter-totals{display:flex;flex-wrap:wrap;gap:8px 20px;padding:0 18px 14px;font-size:13px;line-height:1.5;border-bottom:1px solid var(--line)}.finance-filter-totals>strong{font-weight:600}.finance-filter-totals>span{font-variant-numeric:tabular-nums}
