/* Shared workspace presentation. Printed documents keep their own layout. */
@media screen {
  html.ui-workspace body.editor-document-page :is(.contract-shell, .invoice-shell) {
    grid-template-rows: auto minmax(0, 1fr); border: 0; border-radius: 12px;
    background: var(--ui-color-surface); box-shadow: var(--ui-shadow-soft);
  }
  html.ui-workspace body.editor-document-page :is(.contract-workspace, .invoice-workspace) { background: var(--ui-color-background, #f3f5f4); }
  html.ui-workspace body.editor-tool-page :is(.app, .certificate-app) {
    grid-template-rows: auto minmax(0, 1fr); border: 0; border-radius: 12px;
    background: var(--ui-color-surface); box-shadow: var(--ui-shadow-soft);
  }
  html.ui-workspace body.editor-tool-page,
  html.ui-workspace body.editor-tool-page :is(.workspace, .app-workspace) { background: var(--ui-page-background); }
  html.ui-workspace body.editor-tool-page .ui-workspace-header a {
    position: static; inset: auto; transform: none;
  }
  html.ui-workspace body { font-family: var(--ui-font-family); font-size: 14px; line-height: 1.65; }
  html.ui-workspace body [hidden] { display: none !important; }
  html.ui-workspace body :is(.container, .page-container, main) { scroll-padding-block: 20px; }
  html.ui-workspace body :is(.header, .invoice-header, .contract-header, .app-header).ui-workspace-header {
    display: flex !important; flex-wrap: wrap; align-items: center !important; justify-content: space-between !important;
    gap: 12px 24px; min-height: 88px !important; height: auto !important; flex: 0 0 auto;
    padding: 16px 24px !important; border: 0 !important; border-radius: 12px 12px 0 0 !important;
    background: var(--ui-color-surface) !important; color: var(--ui-color-primary-deep) !important;
    border-bottom: 1px solid var(--ui-color-line) !important; box-shadow: none !important;
    text-align: start;
  }
  .ui-workspace-identity { display: grid; gap: 4px; min-width: 0; }
  html.ui-workspace .ui-workspace-identity :is(h1, .header-title) {
    margin: 0 !important; color: var(--ui-color-primary-deep) !important; font-size: 22px !important;
    font-weight: 800 !important; line-height: 1.45; text-align: start !important;
  }
  .ui-breadcrumbs { display: flex; flex-wrap: wrap; gap: 6px; color: var(--ui-color-muted); font-size: 12px; font-weight: 500; }
  .ui-breadcrumbs a { color: var(--ui-color-primary-strong); text-decoration: none; }
  .ui-breadcrumbs > * + *::before { content: '/'; color: var(--ui-color-muted); margin-inline-end: 6px; }
  .ui-workspace-header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
  html.ui-workspace body .topbar { background: var(--ui-color-surface) !important; border-top: 0 !important; }
  html.ui-workspace body :is(.section, .panel, .card, .filter-box, .summary-box) { border-color: var(--ui-color-line) !important; box-shadow: var(--ui-shadow-soft) !important; }
  html.ui-workspace body :is(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, .smart-select-trigger) {
    min-height: 44px !important; height: auto !important; padding: 9px 12px !important; font-size: 14px !important; line-height: 1.5 !important;
  }
  html.ui-workspace body textarea { min-height: 88px !important; max-height: none !important; padding: 10px 12px !important; font-size: 14px !important; resize: vertical; }
  html.ui-workspace body :is(.field, .form-group, .form-field) > label { font-size: 13px !important; line-height: 1.6; margin-bottom: 5px; }
  html.ui-workspace body :is(button, .btn, .button, .ui-navigation__back, summary) { min-height: 44px !important; font-size: 13px !important; line-height: 1.5; }
  html.ui-workspace body :is(.form-grid, .fields-grid) { gap: 16px !important; }
  html.ui-workspace body :is(.form-grid, .fields-grid) > * { min-width: 0; }
  html.ui-workspace body :is(.btn-danger, .delete, .delete-btn, .action-delete) { background: var(--ui-color-danger-soft) !important; color: #a51d2d !important; border: 1px solid var(--ui-color-danger-line) !important; box-shadow: none !important; }
  html.ui-workspace body :is(.btn-secondary, .btn-ghost, .btn-light, .btn-cancel) { background: #fff !important; color: var(--ui-color-primary-strong) !important; border: 1px solid var(--ui-color-line) !important; box-shadow: none !important; }
  html.ui-workspace body :is(.transaction-view-button.active, .definition-view-button.active, .tab-button.active, .approval-tab-button.active, .approval-tab-button[aria-selected="true"]) {
    background: var(--ui-color-primary) !important; color: #fff !important; box-shadow: none !important; border-color: var(--ui-color-primary) !important;
  }
  html.ui-workspace body :is(.shares-entry-guide, .definition-entry-guide, .transactions-entry-intro, .voucher-entry-intro, .entry-frame-wrap, .record-frame-wrap, .package-grid) {
    background: var(--ui-color-surface-soft) !important; border-color: var(--ui-color-line) !important; box-shadow: var(--ui-shadow-soft) !important;
  }
  html.ui-workspace body :is(.shares-entry-step-number, .definition-entry-steps b, .transactions-entry-steps b) { background: var(--ui-color-primary) !important; box-shadow: none !important; }
  html.ui-workspace body :is(#expense-form-panel, #expense-subtypes-manager, #definition-form .panel-body, #definition-form form, #definition-form .definition-fields-stage) {
    background: var(--ui-color-surface) !important; border-color: var(--ui-color-line) !important;
  }
  html.ui-workspace body .ui-data-table { font-size: 14px !important; border: 1px solid var(--ui-color-table-header-line) !important; border-spacing: 0; }
  html.ui-workspace body .ui-data-table :is(th, td) {
    font-size: 14px !important; line-height: 1.65 !important; padding: 10px 12px !important;
    border: 1px solid var(--ui-color-table-header-line) !important;
  }
  html.ui-workspace body .ui-data-table thead th { position: sticky; top: 0; z-index: 5; background: #edf2ef !important; color: #203e32 !important; font-weight: 800 !important; box-shadow: 0 1px 0 var(--ui-color-line); }
  html.ui-workspace body .ui-data-table td:is(.ui-money, .ui-date) { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; white-space: nowrap !important; text-align: center; }
  html.ui-workspace body .ui-data-table .ui-money { font-weight: 700; }
  .ui-form-section { grid-column: 1 / -1; margin: 8px 0 0; padding-block: 8px; border-bottom: 1px solid var(--ui-color-line); color: var(--ui-color-primary-deep); font-size: 16px; }
  html.ui-workspace body .ui-form-group { min-width: 0; margin: 0 0 20px; padding: 12px 0 0; border: 0; border-top: 1px solid var(--ui-color-line); }
  html.ui-workspace body .ui-form-group > legend { padding-inline-end: 12px; color: var(--ui-color-primary-deep); font-size: 16px; font-weight: 700; }
  html.ui-workspace body .ui-form-actions { position: sticky; bottom: 0; z-index: 8; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; padding: 12px 0; background: var(--ui-color-surface); border-top: 1px solid var(--ui-color-line); }
  html.ui-workspace body .ui-form-actions .btn-row { display: flex; flex-direction: row-reverse; gap: 8px; margin-inline-start: auto; }
  .ui-field-error { display: block; margin-top: 5px; font-size: 13px; color: #a51d2d; font-weight: 600; }
  html.ui-workspace body [aria-invalid="true"] { border-color: #b42337 !important; }
  .ui-row-toggle { display: none !important; }
  html.ui-workspace body .ui-action-menu { display: inline-block; text-align: start; }
  html.ui-workspace body .ui-action-menu > summary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; list-style: none; padding: 8px 12px; border: 1px solid var(--ui-color-line); border-radius: 8px; color: var(--ui-color-primary-strong); background: #fff; font-weight: 700; box-sizing: border-box; }
  .ui-action-menu > summary::after { content: '⌄'; }
  .ui-action-menu > summary::-webkit-details-marker { display: none; }
  html.ui-workspace body .ui-action-menu-panel { position: fixed; z-index: 20000; min-width: 180px; max-width: calc(100vw - 16px); padding: 8px; border: 1px solid var(--ui-color-line); border-radius: 10px; background: #fff; box-shadow: 0 8px 28px #153c2526; }
  html.ui-workspace body .ui-action-menu:not([open]) .ui-action-menu-panel { display: none; }
  html.ui-workspace body .ui-action-menu-panel :is(a, button, form) { display: block; width: 100%; margin: 0; box-sizing: border-box; }
  html.ui-workspace body .ui-action-menu-panel :is(a, button) { padding: 10px 12px; text-decoration: none; min-height: 44px !important; text-align: start; }
  html.ui-workspace body .ui-action-menu-panel > * + * { margin-top: 6px; }
  html.ui-workspace body .ui-navigation-row[hidden] { display: none !important; }
  html.ui-workspace body :is(a, button, input, select, textarea, summary):focus-visible { outline: 3px solid var(--ui-color-primary) !important; outline-offset: 3px !important; }
}
@media screen and (max-width: 768px), screen and (max-width: 1000px) and (max-height: 600px) {
  html.ui-workspace body :is(.header, .invoice-header, .contract-header, .app-header).ui-workspace-header { padding: 14px 16px !important; border-radius: 0 !important; gap: 12px; }
  .ui-workspace-header-actions { width: 100%; justify-content: space-between; }
  html.ui-workspace body .ui-workspace-header-actions .ui-navigation { width: auto; flex: 1; }
  html.ui-workspace body :is(button, .btn, summary, .ui-navigation__back) { min-height: 44px !important; }
  html.ui-workspace body :is(input:not([type="hidden"]), select, textarea) { font-size: 16px !important; }
  html.ui-workspace body #definition-form .definition-manual-fields:not([hidden]) { grid-template-columns: minmax(0, 1fr) !important; grid-template-rows: none !important; height: auto !important; }
  html.ui-workspace body #definition-form .definition-fields-stage { overflow: visible !important; }
  html.ui-workspace body #definition-form .definition-manual-fields > .field.full { grid-column: 1 !important; }
  html.ui-workspace body .ui-data-table:has(.ui-expandable-row) { display: block; width: 100% !important; min-width: 0 !important; table-layout: auto !important; }
  html.ui-workspace body .ui-data-table:has(.ui-expandable-row) thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  html.ui-workspace body .ui-data-table:has(.ui-expandable-row) tbody { display: grid; gap: 12px; width: 100%; }
  html.ui-workspace body .ui-data-table .ui-expandable-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--ui-color-line); border-radius: 10px; overflow: hidden; background: #fff; }
  html.ui-workspace body .ui-data-table .ui-expandable-row > td { display: none; width: auto !important; min-width: 0 !important; max-width: none !important; white-space: normal !important; overflow-wrap: anywhere !important; word-break: normal !important; text-align: start; }
  html.ui-workspace body .ui-data-table .ui-expandable-row > :is(.ui-cell-primary, .ui-cell-actions),
  html.ui-workspace body .ui-data-table .ui-expandable-row.ui-row-expanded > td { display: block; }
  html.ui-workspace body .ui-data-table .ui-expandable-row > td::before { content: attr(data-ui-label); display: block; margin-bottom: 4px; font-size: 12px; font-weight: 500; color: var(--ui-color-muted); direction: rtl; }
  html.ui-workspace body .ui-data-table .ui-expandable-row > .ui-cell-actions { grid-column: 1 / -1; }
  html.ui-workspace body .ui-data-table .ui-cell-actions > .ui-row-toggle { display: inline-flex !important; align-items: center; margin-top: 8px; background: #fff !important; color: var(--ui-color-primary) !important; border: 1px solid var(--ui-color-line) !important; box-shadow: none !important; }
  html.ui-workspace body td :is(.actions, .row-actions, .table-actions) { display: flex !important; flex-wrap: wrap; gap: 8px !important; }
}
@media print {
  .ui-row-toggle, .ui-workspace-header-actions, .ui-breadcrumbs { display: none !important; }
  .ui-action-menu { display: none !important; }
}

/* Canonical shared surface and state colors, using the single token palette. */
@media screen {


  html body {
    background: var(--ui-page-background) !important;
    color: var(--ui-color-text) !important;
  }
  html body :is(.app-shell, .report-view, .reports-center, .settings-content, .module-workspace) {
    background: var(--ui-color-surface-soft);
  }
  html body :is(.invoice-panel, .contract-panel, .editor-panel, .app-panel, .form-panel, .content-panel) {
    background: var(--ui-color-surface) !important;
    border-color: var(--ui-color-line) !important;
  }
  html body.editor-document-page :is(.invoice-tabs, .contract-tabs) {
    background: var(--ui-color-surface-soft) !important;
  }
  html body.editor-document-page :is(.invoice-tabs, .contract-tabs) a {
    background: var(--ui-color-surface) !important;
    color: var(--ui-color-primary-strong) !important;
  }
  html body.editor-document-page :is(.invoice-tabs, .contract-tabs) a.active {
    background: var(--ui-gradient-brand) !important;
    color: #fff9e9 !important;
    border-color: var(--ui-color-primary) !important;
  }
  html.ui-workspace body :is(.header, .invoice-header, .contract-header, .app-header).ui-workspace-header {
    background: var(--ui-gradient-brand) !important;
    color: #fff9e9 !important;
    border-bottom: 3px solid var(--ui-color-gold) !important;
    box-shadow: var(--ui-shadow-header) !important;
  }
  html.ui-workspace body .ui-workspace-header :is(h1, .header-title, .dashboard-brand h1) {
    color: #fff9e9 !important;
  }
  html.ui-workspace body .ui-workspace-header :is(.ui-breadcrumbs, .dashboard-brand-caption, .user-badge-text, .user-badge-name) {
    color: #e0ebd9 !important;
  }
  html.ui-workspace body .ui-workspace-header :is(button, a, .smart-select-trigger) {
    color: #184535 !important;
    background: #e9efdf !important;
    border-color: #bbcdb8 !important;
  }
  html.ui-workspace body .ui-workspace-header :is(button, a):hover {
    background: var(--ui-color-gold-soft) !important;
    border-color: #c2a366 !important;
  }
  html body .topbar {
    background: #d9e7d8 !important;
    border-color: var(--ui-color-line) !important;
  }
  html body :is(.user-badge-role, .user-badge-type) {
    color: var(--ui-color-primary-strong) !important;
    background: #d7e6d4 !important;
    border-color: #abc2ad !important;
  }
  html body .ui-workspace-header .user-badge-role {
    color: #f9edc8 !important;
    background: #265d48 !important;
    border-color: #6e9278 !important;
  }

  html body :is(.report-filters, .filter-box, .filter-bar, .filters-bar, .search-panel, .ui-form-group) {
    background: #e2ecdf !important;
    border-color: var(--ui-color-line) !important;
  }
  html body :is(.report-overview-box, .report-title-row, .summary-box, .table-summary, .summary-card) {
    background: var(--ui-color-gold-soft) !important;
    border-color: #d5c59b !important;
  }
  html.ui-workspace body :is(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea, .smart-select-trigger, .report-company-picker > summary) {
    background: var(--ui-color-field) !important;
    color: var(--ui-color-text) !important;
    border-color: #a9bda9 !important;
  }
  html body :is(input, textarea)::placeholder { color: #657465 !important; opacity: 1; }
  html body :is(.settings-entry-content > small, .summary-card > span, .report-overview-copy > p) {
    color: var(--ui-color-muted) !important;
  }
  html.ui-workspace body :is(input:disabled, select:disabled, textarea:disabled) {
    background: #dce4d7 !important;
    color: #526052 !important;
  }
  html.ui-workspace body :is(.btn-secondary, .btn-ghost, .btn-light, .btn-cancel, .ui-action-menu > summary) {
    background: #e5ecdc !important;
    color: var(--ui-color-primary-strong) !important;
    border-color: var(--ui-color-line) !important;
  }
  html.ui-workspace body :is(.ui-action-menu-panel, .report-company-panel, .smart-select-list, .modal-content, dialog) {
    background: var(--ui-color-surface) !important;
    border-color: var(--ui-color-line) !important;
  }
  html body :is(.ui-table-shell, .table-wrap, .table-scroll, .report-table-shell, .report-table-scroll, .directory-table) {
    background: var(--ui-color-surface) !important;
  }
  html.ui-workspace body .ui-data-table thead th {
    background: var(--ui-gradient-table-header) !important;
    color: #fff9e9 !important;
    border-color: #789e86 !important;
  }
  html.ui-workspace body .ui-data-table tbody td {
    background: var(--ui-color-surface) !important;
    border-color: var(--ui-color-table-line) !important;
  }
  html.ui-workspace body .ui-data-table tbody tr:nth-child(even) td {
    background: var(--ui-color-row-alt) !important;
  }
  html.ui-workspace body .ui-data-table tbody tr:hover td {
    background: var(--ui-color-row-hover) !important;
  }
  html.ui-workspace body .ui-data-table tfoot :is(th, td) {
    background: #dce8d6 !important;
  }
  html.ui-workspace body .ui-data-table tfoot :is(th, td):not(.balance-value) {
    color: var(--ui-color-primary-deep) !important;
  }
  html.ui-workspace body .ui-data-table .ui-expandable-row {
    background: var(--ui-color-surface) !important;
    border-color: var(--ui-color-line) !important;
  }

  html body.company-dashboard-page { --dashboard-deep: #103d30; --dashboard-gold: var(--ui-color-gold); }
  html body.company-dashboard-page .dashboard-packages-box { background: var(--ui-color-surface-soft) !important; }
  html body.company-dashboard-page .dashboard-welcome { background: var(--ui-gradient-brand) !important; }
  html body.company-dashboard-page .dashboard-brand-mark { background: #f0dfb0; color: #164532; }
  html body.company-dashboard-page .dashboard-packages-box .card {
    background: #f3f0df !important;
    border-color: #b8cbb5 !important;
    box-shadow: 0 3px 10px rgba(24, 59, 39, .05) !important;
  }
  html body.company-dashboard-page .dashboard-packages-box .card:nth-child(3n + 2) { background: #deebdc !important; }
  html body.company-dashboard-page .dashboard-packages-box .card:nth-child(3n) { background: #e8eddb !important; }
  html body.company-dashboard-page .dashboard-packages-box .card:hover {
    background: var(--ui-color-gold-soft) !important;
    border-color: #a58c54 !important;
  }
  html body.company-dashboard-page .dashboard-packages-box .card-icon { background: #c9ddc7; color: #164d38; }
  html body.company-dashboard-page .stats-grid { background: #d4e2d1; border-color: #a8c0a5; }
  html body.company-dashboard-page :is(.stat-label, .stat-value small, .card p, .dashboard-footer, .dashboard-section-heading span) { color: #48614e; }

  html body.auth-page :is(.card, .login-card, .auth-card, .login-panel) { background: var(--ui-color-surface) !important; }
  html body.auth-page .hero { background: var(--ui-gradient-brand) !important; }
  html body.auth-page :is(.hero h1, .hero p) { color: #fff9e9 !important; }
}
