/*
 * Shared visual language for the accounting workspace.
 * Screen-only on purpose: invoice/report print layouts keep their own rules.
 * No data, document state, permissions or form behavior is defined here.
 */
@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn-Variable.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

@media screen {
  :root {
    --ui-font: "Vazirmatn", Tahoma, Arial, sans-serif;
    --ui-canvas: #f5f7f3;
    --ui-surface: #ffffff;
    --ui-surface-muted: #f8faf7;
    --ui-surface-raised: #fcfdfb;
    --ui-ink: #182d27;
    --ui-muted: #617169;
    --ui-line: #dfe7df;
    --ui-line-strong: #c6d3c9;
    --ui-field-line: #81988a;
    --ui-field-hover: #6e8978;
    --ui-accent: #0c6655;
    --ui-accent-hover: #084e41;
    --ui-accent-soft: #eaf4ee;
    --ui-accent-line: #c1dacc;
    --ui-danger: #b23137;
    --ui-danger-soft: #fff2f1;
    --ui-warning: #865b16;
    --ui-warning-soft: #fff8e9;
    --ui-success: #256745;
    --ui-success-soft: #edf7ee;
    --ui-radius: 16px;
    --ui-radius-sm: 10px;
    --ui-shadow-sm: 0 2px 5px rgb(25 48 35 / 3%);
    --ui-shadow: 0 4px 18px rgb(25 48 35 / 4%);
    --ui-shadow-raised: 0 12px 32px rgb(25 48 35 / 8%);
    --ui-focus: 0 0 0 3px rgb(12 102 85 / 13%);
    --ui-space-1: 4px;
    --ui-space-2: 8px;
    --ui-space-3: 12px;
    --ui-space-4: 16px;
    --ui-space-5: 20px;
    --ui-space-6: 24px;
    --ui-space-8: 32px;

    /* Existing modules consume these aliases without business-code changes. */
    --bg: var(--ui-canvas);
    --card: var(--ui-surface);
    --surface: var(--ui-surface);
    --text: var(--ui-ink);
    --muted: var(--ui-muted);
    --line: var(--ui-line);
    --primary: var(--ui-accent);
    --primary2: var(--ui-accent-hover);
    --danger: var(--ui-danger);
    --ok: var(--ui-success);
    --warn: var(--ui-warning);
    --shadow: var(--ui-shadow);
  }

  body {
    font-family: var(--ui-font);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  body.erp-body {
    background: var(--ui-canvas);
    color: var(--ui-ink);
    font-size: 14px;
    line-height: 1.85;
    accent-color: var(--ui-accent);
  }

  body.erp-body :where(input, select, textarea, button) {
    font-family: inherit;
  }

  body.erp-body :where(h1, h2, h3, h4, p) {
    text-wrap: pretty;
  }

  body.erp-body h1 {
    font-size: clamp(24px, 1.7vw, 30px);
    font-weight: 800;
    line-height: 1.65;
    letter-spacing: normal;
    margin-block: 0 6px;
  }

  body.erp-body h2 {
    font-size: 20px;
    font-weight: 750;
    line-height: 1.7;
  }

  body.erp-body h3 {
    font-size: 16px;
    font-weight: 750;
    line-height: 1.8;
  }

  body.erp-body h4 {
    font-size: 14px;
    font-weight: 750;
    line-height: 1.8;
  }

  body.erp-body :where(p.muted, .page-head > div > p, .section-heading > div > p) {
    font-size: 12px;
    line-height: 1.9;
  }

  body.erp-body .page-head {
    gap: 16px 24px;
    margin-block-end: 24px;
    align-items: center;
  }

  body.erp-body .section-heading {
    gap: 16px;
    margin-block-end: 20px;
  }

  body.erp-body .section-title {
    gap: 12px;
    margin-block: 18px 14px;
  }

  body.erp-body :where(.card, .purchase-card) {
    border-radius: var(--ui-radius);
    border-color: var(--ui-line);
    box-shadow: var(--ui-shadow);
    padding: 24px;
  }

  /* Financial exception cards retain their warning/positive distinction. */
  body.erp-body .card.debt-card {
    border-color: #edc6c4;
  }

  body.erp-body .card.att-review {
    border-color: #dc2626;
  }

  body.erp-body .card.profit-card {
    border-color: #c8dfc9;
  }

  body.erp-body .card.expense-card,
  body.erp-body .card.correction-box {
    border-color: #e8d7b4;
  }

  body.erp-body .card > h3:first-child,
  body.erp-body .purchase-card > h3:first-child {
    margin-block-end: 18px;
  }

  body.erp-body :where(.form-grid, .modal-grid) {
    gap: 18px 20px;
  }

  body.erp-body :where(.header-grid, .sales-header-grid) {
    padding: 20px;
    gap: 18px;
    background: var(--ui-surface-muted);
    border: 1px solid var(--ui-line);
    border-radius: 12px;
  }

  body.erp-body :where(.form-grid > label, .modal-grid > label, .card label, .cashdesk-group label) {
    color: var(--ui-ink);
    font-size: 12px;
    font-weight: 650;
    line-height: 1.8;
    gap: 8px;
  }

  body.erp-body :where(label > small, .form-note, .form-help, .field-help) {
    font-size: 11px;
    font-weight: 400;
    line-height: 1.9;
  }

  body.erp-body input:where(:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"])),
  body.erp-body select,
  body.erp-body textarea {
    min-height: 44px;
    border: 1px solid var(--ui-field-line);
    border-radius: var(--ui-radius-sm);
    background-color: var(--ui-surface);
    color: var(--ui-ink);
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 450;
    line-height: 1.65;
    box-shadow: inset 0 1px 2px rgb(23 44 31 / 2%);
    transition: border-color .15s ease, box-shadow .15s ease;
    scroll-margin-block: 90px 100px;
  }

  body.erp-body textarea {
    min-height: 88px;
    line-height: 1.9;
    resize: vertical;
  }

  body.erp-body input::placeholder,
  body.erp-body textarea::placeholder {
    color: #68766c;
    opacity: 1;
    font-weight: 400;
  }

  body.erp-body input:where(:not([type="checkbox"]):not([type="radio"]):not([type="hidden"])):hover:where(:not(:disabled):not([readonly])),
  body.erp-body select:hover:not(:disabled),
  body.erp-body textarea:hover:not(:disabled):not([readonly]) {
    border-color: var(--ui-field-hover);
  }

  body.erp-body input:where(:not([type="checkbox"]):not([type="radio"]):not([type="hidden"])):focus,
  body.erp-body select:focus,
  body.erp-body textarea:focus {
    border-color: var(--ui-accent);
    outline: 0;
    box-shadow: var(--ui-focus);
  }

  body.erp-body input[readonly],
  body.erp-body textarea[readonly] {
    background-color: var(--ui-surface-muted);
    color: #52655b;
  }

  body.erp-body :where(input, select, textarea):disabled {
    background-color: #f0f3ee;
    color: #6b7971;
    cursor: not-allowed;
  }

  body.erp-body input[aria-invalid="true"],
  body.erp-body textarea[aria-invalid="true"],
  body.erp-body select[aria-invalid="true"] {
    border-color: var(--ui-danger);
  }

  body.erp-body :where(input[type="checkbox"], input[type="radio"]) {
    min-height: 16px;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin: 0;
    accent-color: var(--ui-accent);
    cursor: pointer;
  }

  body.erp-body :where(input[type="number"], input[data-numeric], .cell-number, .metric strong) {
    font-variant-numeric: tabular-nums;
  }

  body.erp-body input[type="file"] {
    max-width: 100%;
    border: 1px dashed var(--ui-field-line);
    background: var(--ui-surface-muted);
    border-radius: var(--ui-radius-sm);
    padding: 8px;
    font-size: 12px;
  }

  body.erp-body input[type="file"]::file-selector-button {
    min-height: 34px;
    margin-inline-end: 12px;
    padding: 6px 12px;
    border: 1px solid var(--ui-accent-line);
    border-radius: 7px;
    background: var(--ui-accent-soft);
    color: var(--ui-accent-hover);
    font: 650 12px var(--ui-font);
    cursor: pointer;
  }

  body.erp-body .btn {
    min-height: 42px;
    padding: 9px 16px;
    gap: 7px;
    border: 1px solid var(--ui-line-strong);
    border-radius: var(--ui-radius-sm);
    background: var(--ui-surface);
    color: var(--ui-ink);
    font-family: var(--ui-font);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.7;
    text-decoration: none;
    box-shadow: var(--ui-shadow-sm);
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
  }

  body.erp-body .btn:hover:not(:disabled):not([aria-disabled="true"]) {
    border-color: #91ab9b;
    background-color: var(--ui-surface-muted);
    box-shadow: 0 2px 8px rgb(25 48 35 / 6%);
  }

  body.erp-body .btn.primary {
    border-color: var(--ui-accent);
    background: var(--ui-accent);
    color: #fff;
    box-shadow: 0 2px 4px rgb(12 102 85 / 12%);
  }

  body.erp-body .btn.primary:hover:not(:disabled) {
    border-color: var(--ui-accent-hover);
    background: var(--ui-accent-hover);
    color: #fff;
  }

  body.erp-body .btn.danger-outline {
    border-color: #e7bbbb;
    background: #fff7f5;
    color: #a62c33;
  }

  body.erp-body .btn.danger-outline:hover:not(:disabled) {
    border-color: #d5979a;
    background: #ffefee;
  }

  body.erp-body .btn:disabled,
  body.erp-body .btn[aria-disabled="true"] {
    opacity: .52;
    box-shadow: none;
    cursor: not-allowed;
  }

  body.erp-body :where(a, button, summary, input, select, textarea):focus-visible {
    outline: 2px solid var(--ui-accent);
    outline-offset: 3px;
  }

  body.erp-body input:focus-visible,
  body.erp-body select:focus-visible,
  body.erp-body textarea:focus-visible {
    outline: 2px solid var(--ui-accent);
    outline-offset: 3px;
  }

  body.erp-body :where(.page-actions, .actions, .dialog-actions) {
    gap: 10px;
    align-items: center;
  }

  body.erp-body .sticky-actions {
    padding: 14px;
    border: 1px solid var(--ui-line-strong);
    border-radius: 14px;
    background: rgb(255 255 255 / 96%);
    box-shadow: 0 -4px 24px rgb(25 48 35 / 5%);
    backdrop-filter: blur(12px);
  }

  body.erp-body .badge {
    padding: 4px 9px;
    border-radius: 7px;
    font-size: 11px;
    font-weight: 650;
    line-height: 1.7;
  }

  body.erp-body .badge.ok {
    background: var(--ui-success-soft);
    color: #225e3e;
  }

  body.erp-body .badge.danger {
    background: var(--ui-danger-soft);
    color: #a62c33;
  }

  body.erp-body .alert {
    padding: 14px 16px;
    border-radius: 11px;
    font-size: 12px;
    line-height: 1.95;
    margin-block-end: 18px;
  }

  body.erp-body .alert.info {
    border: 1px solid var(--ui-accent-line);
    background: #f0f7f1;
    color: #2f5b46;
  }

  body.erp-body .alert.success {
    border-color: #c8dfc9;
    background: var(--ui-success-soft);
    color: #245b37;
  }

  body.erp-body .alert.warn {
    border-color: #e8d7b4;
    background: var(--ui-warning-soft);
    color: #78500f;
  }

  body.erp-body .alert.error {
    border-color: #edc6c4;
    background: var(--ui-danger-soft);
    color: #9c2931;
  }

  body.erp-body .pagination-bar {
    padding: 12px 16px;
    border-color: var(--ui-line);
    border-radius: 12px;
    background: var(--ui-surface);
    box-shadow: var(--ui-shadow-sm);
  }

  body.erp-body :where(.pagination-page, .pagination-nav, .pagination-size-item) {
    min-width: 34px;
    min-height: 34px;
    height: auto;
    border-color: var(--ui-line);
    border-radius: 8px;
    font-size: 11px;
  }

  body.erp-body :where(.pagination-page, .pagination-nav, .pagination-size-item):hover {
    border-color: var(--ui-accent-line);
    background: var(--ui-accent-soft);
    color: var(--ui-accent);
  }

  body.erp-body .pagination-page.current,
  body.erp-body .pagination-size-item.current {
    border-color: var(--ui-accent);
    background: var(--ui-accent);
    color: #fff;
  }

  body.erp-body :where(.pagination-summary, .pagination-size) {
    font-size: 11px;
    line-height: 1.8;
  }

  body.erp-body :where(.quick-dialog, .jalali-picker, .erp-command-dialog, .erp-shortcuts-dialog) {
    border: 1px solid var(--ui-line);
    border-radius: 18px;
    box-shadow: 0 28px 80px rgb(19 43 30 / 18%);
  }

  body.erp-body :where(.quick-dialog, .jalali-picker, .erp-command-dialog, .erp-shortcuts-dialog)::backdrop {
    background: rgb(16 33 26 / 48%);
    backdrop-filter: blur(4px);
  }

  body.erp-body :where(.quick-dialog-card, .jalali-card) {
    padding: 24px;
    border-radius: 18px;
    background: var(--ui-surface);
  }

  body.erp-body .dialog-head {
    gap: 16px;
    margin-block-end: 22px;
    padding-block-end: 16px;
    border-block-end: 1px solid var(--ui-line);
  }

  body.erp-body .dialog-close {
    border-color: var(--ui-line);
    border-radius: 10px;
    color: var(--ui-muted);
    background: var(--ui-surface-muted);
  }

  body.erp-body .dialog-actions {
    padding-block-start: 18px;
    margin-block-start: 20px;
    border-color: var(--ui-line);
  }

  body.erp-body .erp-command-result:hover,
  body.erp-body .erp-command-result.active {
    background: var(--ui-accent-soft);
    border-color: var(--ui-accent-line);
  }

  body.erp-body .jalali-grid button.selected {
    background: var(--ui-accent);
    color: #fff;
  }

  body.erp-body .jalali-grid button:hover:not(.selected) {
    background: var(--ui-accent-soft);
  }

  body.erp-body .date-picker-btn {
    border-color: var(--ui-line-strong);
    border-radius: var(--ui-radius-sm);
    color: var(--ui-accent);
    background: var(--ui-surface);
  }

  body.erp-body hr {
    border-color: var(--ui-line);
    margin-block: 24px;
  }

  body.erp-body code,
  body.erp-body pre,
  body.erp-body kbd {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  }
}

@media screen and (max-width: 900px) {
  body.erp-body .page-head {
    margin-block-end: 20px;
  }

  body.erp-body :where(.card, .purchase-card) {
    padding: 20px;
  }
}

@media screen and (max-width: 760px) {
  body.erp-body .page-head {
    gap: 12px;
    align-items: stretch;
  }

  body.erp-body h1 {
    font-size: 23px;
    letter-spacing: normal;
  }

  body.erp-body h3 {
    font-size: 15px;
  }

  body.erp-body :where(.card, .purchase-card) {
    padding: 17px;
    border-radius: 14px;
  }

  body.erp-body :where(.header-grid, .sales-header-grid) {
    padding: 16px;
    gap: 15px;
  }

  body.erp-body :where(.form-grid, .modal-grid) {
    gap: 16px;
  }

  body.erp-body .btn {
    min-height: 44px;
    padding: 10px 14px;
    line-height: 1.7;
    white-space: normal;
  }

  body.erp-body input:where(:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"])),
  body.erp-body select,
  body.erp-body textarea {
    min-height: 46px;
    font-size: 16px;
  }

  body.erp-body :where(.quick-dialog-card, .jalali-card) {
    padding: 18px;
  }

  body.erp-body :where(.pagination-page, .pagination-nav, .pagination-size-item) {
    min-width: 40px;
    min-height: 40px;
  }

  body.erp-body .sticky-actions {
    padding: 12px;
    border-radius: 12px;
  }
}

@media screen and (prefers-reduced-motion: reduce) {
  body.erp-body *,
  body.erp-body *::before,
  body.erp-body *::after,
  body.login-body *,
  body.login-body *::before,
  body.login-body *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

@media screen and (forced-colors: active) {
  body.erp-body .btn,
  body.erp-body :where(input, select, textarea),
  body.erp-body .alert {
    border: 1px solid CanvasText;
  }

  body.erp-body .btn.primary {
    background: Highlight;
    color: HighlightText;
  }
}
