@font-face { font-family: "ERP Arabic"; font-style: normal; font-weight: 400; font-display: swap; src: url("/assets/fonts/NotoSansArabic-Regular.woff2") format("woff2"); }
@font-face { font-family: "ERP Arabic"; font-style: normal; font-weight: 700; font-display: swap; src: url("/assets/fonts/NotoSansArabic-Bold.woff2") format("woff2"); }
/* Auto Parts ERP design system: tokens and base. Material-style layout, Arabic, RTL.
   Every custom widget page is built as tokens.css + components.css + its own style.css. */
:root {
  --primary: #176b45; --primary-hover: #115334; --primary-soft: #dceee2; --on-primary: #fff;
  --ink: #202b24; --on-ink: #fff; --on-ink-soft: #ffffff60; --muted: #657269;
  --surface: #fff; --background: #f4f7f2; --border: #dde5dc;
  --danger: #a32b28; --danger-hover: #852320;
  --success: #176b45; --success-soft: #dceee2;
  --warning: #7a4900; --warning-soft: #fff0cc;
  --danger-soft: #ffdad6; --info: #155b83; --info-soft: #dcedff;
  --neutral: #526057; --neutral-soft: #e8ede7;
  --scrim: #10201880; --shadow: 0 8px 24px #202b2420;
  --radius: 24px; --small-radius: 16px; --pill: 28px; --space: 16px;
  --touch: 48px; --viewport-height: 100dvh;
  --font-ui: "ERP Arabic", system-ui, Tahoma, sans-serif;
  --type-display-size: 57px; --type-display-weight: 400; --type-display-line: 64px;
  --type-headline-size: 32px; --type-headline-weight: 400; --type-headline-line: 40px;
  --type-title-size: 22px; --type-title-weight: 700; --type-title-line: 28px;
  --type-body-size: 16px; --type-body-weight: 400; --type-body-line: 24px;
  --type-label-size: 14px; --type-label-weight: 700; --type-label-line: 20px;
  --feedback-bottom: 112px;
  font-family: var(--font-ui); color: var(--ink);
  background: var(--background); font-size: var(--type-body-size); font-weight: var(--type-body-weight); line-height: var(--type-body-line);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { height: var(--viewport-height); overflow: auto; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: inherit; border-radius: var(--small-radius); min-height: var(--touch); padding: 10px 16px; }
button:hover { background: var(--primary-soft); }
button:disabled { cursor: wait; opacity: .55; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
h1 { font-size: var(--type-headline-size); font-weight: var(--type-headline-weight); line-height: var(--type-headline-line); }
h2, h3 { font-size: var(--type-title-size); font-weight: var(--type-title-weight); line-height: var(--type-title-line); }
input { min-width: 0; width: 100%; border: 0; background: transparent; color: var(--ink); min-height: var(--touch); }
input::placeholder { color: var(--muted); opacity: 1; }

/* Auto Parts ERP design system: shared components. Page files only lay them out. */
.title-row, .section-heading, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--space); }
.title-row { margin-bottom: 24px; }
.section-heading { margin-bottom: var(--space); }
.eyebrow, .muted { color: var(--muted); font-size: var(--type-label-size); line-height: var(--type-label-line); }
.eyebrow { margin-bottom: 2px; }
.danger { color: var(--danger); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }

/* Buttons */
.icon-button { width: var(--touch); height: var(--touch); padding: 0; flex-shrink: 0; display: grid; place-items: center; font-size: 28px; border-radius: 50%; }
.primary-button { min-height: 56px; background: var(--primary); color: var(--on-primary); font-weight: var(--type-label-weight); border: 0; border-radius: var(--pill); }
.primary-button:hover { background: var(--primary-hover); }
.danger-button { color: var(--on-primary); background: var(--danger); border: 0; border-radius: 24px; font-weight: var(--type-label-weight); }
.danger-button:hover { background: var(--danger-hover); }
.text-button { color: var(--primary); border: 0; background: transparent; padding-inline: 4px; margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border-radius: 24px; padding: 8px 16px; min-height: var(--touch); }
.chip[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

/* Quantity stepper: + count − (− becomes .trash at count 1) */
.stepper { display: flex; align-items: center; gap: 6px; }
.step-button { width: 44px; height: 44px; min-height: 44px; border-radius: 50%; font-size: 22px; line-height: 1; display: grid; place-items: center; padding: 0; }
.step-quantity { min-width: 32px; text-align: center; font-size: 18px; font-weight: var(--type-label-weight); }
.trash { font-size: 18px; color: var(--muted); }
.trash svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; }

/* Overflow menu (⋮) */
.menu-anchor { position: relative; }
.menu { position: absolute; inset-inline-end: 0; top: 56px; width: 220px; padding: 8px; border: 1px solid var(--border); border-radius: var(--small-radius); background: var(--surface); box-shadow: var(--shadow); z-index: 3; }
.menu button { display: block; width: 100%; border: 0; text-align: start; }

/* Fields */
.search-box { display: flex; align-items: center; gap: 10px; padding: 8px 20px; min-height: 64px; border: 1px solid var(--border); border-radius: 32px; background: var(--surface); margin-bottom: 24px; }
.search-box span { font-size: 30px; color: var(--primary); }
.amount-field { display: block; color: var(--muted); font-size: var(--type-label-size); line-height: var(--type-label-line); }
.amount-field input { display: block; border: 1px solid var(--border); border-radius: var(--small-radius); padding-inline: 16px; margin-top: 6px; font-size: 18px; }

/* Lists and states */
.count { color: var(--primary); background: var(--primary-soft); border-radius: 20px; padding: 4px 12px; font-size: var(--type-label-size); line-height: var(--type-label-line); white-space: nowrap; }
.empty { color: var(--muted); padding: 28px 16px; text-align: center; border: 1px dashed var(--border); border-radius: var(--small-radius); }
.scroll-list { display: grid; min-height: 0; overflow-y: auto; overscroll-behavior: contain; align-content: start; }

/* Feedback: busy pill, notice pill, spinner */
.progress, .notice { position: fixed; bottom: calc(var(--feedback-bottom) + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--on-ink); border-radius: 24px; padding: 8px 16px; z-index: 5; font-size: var(--type-label-size); line-height: var(--type-label-line); max-width: 90%; }
.progress { display: flex; gap: 8px; align-items: center; }
.progress { bottom: calc(var(--feedback-bottom) + 64px + env(safe-area-inset-bottom)); }
.spinner { width: 16px; height: 16px; border: 2px solid var(--on-ink-soft); border-top-color: var(--on-ink); border-radius: 50%; animation: spin .8s linear infinite; }
.search-box .search-spinner { flex-shrink: 0; width: 18px; height: 18px; border-color: var(--primary-soft); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* Confirmation dialog */
dialog { color: var(--ink); background: var(--surface); border: 0; border-radius: var(--pill); padding: 28px; width: min(420px, calc(100% - 32px)); }
dialog::backdrop { background: var(--scrim); }
dialog p { margin-block: 12px 24px; color: var(--muted); }
.dialog-actions button { flex: 1; }

/* Record browser and editor: reusable catalog components. */
.record-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space); text-align: start; min-height: 88px; padding: 16px; }
.record-row[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); }
.record-info { min-width: 0; overflow-wrap: anywhere; }
.record-info strong, .record-info small { display: block; }
.record-info small { color: var(--muted); font-size: var(--type-label-size); line-height: var(--type-label-line); margin-top: 4px; }
.record-meta { display: grid; justify-items: end; gap: 6px; flex-shrink: 0; }
.record-meta strong { font-variant-numeric: tabular-nums; }
.status-badge { color: var(--primary); background: var(--primary-soft); border-radius: var(--pill); font-size: var(--type-label-size); line-height: var(--type-label-line); padding: 2px 10px; }
.status-badge.stopped { color: var(--muted); background: var(--background); }
.form-field { display: grid; gap: 6px; color: var(--muted); font-size: var(--type-label-size); line-height: var(--type-label-line); min-width: 0; }
.form-field input, .form-field select, .form-field textarea { width: 100%; min-width: 0; min-height: var(--touch); font: inherit; font-size: var(--type-body-size); color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: var(--small-radius); padding: 12px; }
.form-field textarea { resize: vertical; }
.toggle-control { display: flex; justify-content: space-between; align-items: center; gap: var(--space); }
.toggle-track { flex-shrink: 0; display: block; width: 56px; height: 28px; padding: 4px; border-radius: var(--pill); background: var(--muted); }
.toggle-track::after { content: ''; display: block; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); }
.toggle-control[aria-checked="true"] .toggle-track { background: var(--primary); }
.toggle-control[aria-checked="true"] .toggle-track::after { margin-inline-start: 20px; }
/* Fixed action surface, shared by phone editors. */
.action-surface { background: var(--surface); border-top: 1px solid var(--border); }

/* Read-only metrics, expandable records and signed bar charts. */
.kpi-tile { padding: 16px; overflow-wrap: anywhere; }
.kpi-tile strong { display: block; font-size: var(--type-title-size); line-height: var(--type-title-line); font-variant-numeric: tabular-nums; margin-top: 8px; }
.data-record { border: 1px solid var(--border); border-radius: var(--small-radius); padding: 12px; overflow-wrap: anywhere; }
.data-record summary { cursor: pointer; min-height: var(--touch); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.data-record .disclosure-icon { color: var(--primary); }
.data-record[open] .disclosure-icon { transform: rotate(45deg); }
.data-record summary > strong { font-variant-numeric: tabular-nums; }
.data-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 8px 16px; border-top: 1px solid var(--border); padding-top: 16px; }
.data-fields dt { color: var(--muted); }
.data-fields dd { margin: 0; overflow-wrap: anywhere; }
.metric-chart { margin: 0; }
.metric-chart figcaption { font-size: var(--type-title-size); line-height: var(--type-title-line); font-weight: var(--type-label-weight); margin-bottom: var(--space); }
.metric-chart .scroll-list { gap: 16px; }
.chart-record .section-heading { margin-bottom: 4px; font-size: var(--type-label-size); line-height: var(--type-label-line); overflow-wrap: anywhere; }
.chart-record svg { display: block; width: 100%; height: 18px; direction: ltr; background: var(--background); border-radius: var(--small-radius); }
.chart-bar { fill: var(--primary); }
.chart-bar.negative { fill: var(--danger); }
.chart-axis { stroke: var(--muted); stroke-width: 2px; }

/* Material 3 type roles, shared by screens and the gallery. */
.type-display { font-size: var(--type-display-size); font-weight: var(--type-display-weight); line-height: var(--type-display-line); }
.type-headline { font-size: var(--type-headline-size); font-weight: var(--type-headline-weight); line-height: var(--type-headline-line); }
.type-title { font-size: var(--type-title-size); font-weight: var(--type-title-weight); line-height: var(--type-title-line); }
.type-body { font-size: var(--type-body-size); font-weight: var(--type-body-weight); line-height: var(--type-body-line); }
.type-label, button, .count, .status-badge { font-weight: var(--type-label-weight); }
.type-label { font-size: var(--type-label-size); line-height: var(--type-label-line); }
.ui-icon { display: inline-block; width: 24px; height: 24px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
[data-icon] { display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; }
.status-badge .ui-icon { width: 18px; height: 18px; }
.status-badge[data-status="success"] { color: var(--success); background: var(--success-soft); }
.status-badge[data-status="warning"], .status-badge.warning { color: var(--warning); background: var(--warning-soft); }
.status-badge[data-status="danger"] { color: var(--danger); background: var(--danger-soft); }
.status-badge[data-status="info"] { color: var(--info); background: var(--info-soft); }
.status-badge[data-status="neutral"] { color: var(--neutral); background: var(--neutral-soft); }
.feedback-region { position: fixed; inset: auto 0 0; z-index: 5; pointer-events: none; }
.feedback-region > * { pointer-events: auto; }
@media (max-width: 839px) {
  .progress, .notice { max-width: calc(100% - 32px); width: max-content; max-height: 96px; overflow: auto; }
}

.warning-chart .chart-bar { fill: var(--warning); }

.notice { color: var(--info); background: var(--info-soft); }
.notice .ui-icon { margin-inline-end: 8px; }

/* Shared interactive chart and review progress. */
.chart-record { width: 100%; text-align: start; display: block; }
.chart-target { fill: var(--warning-soft); }
.review-progress { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 16px; list-style: none; }
.review-progress li { display: flex; align-items: center; gap: 12px; }
.review-progress li + li::before { content: "←"; }
.review-progress [aria-current="step"] { color: var(--primary); font-weight: var(--type-label-weight); }

/* Shared RTL timelines: chronological order runs from right to left. */
.time-series-chart { min-width: 0; }
.chart-legend, .chart-legend-item, .chart-date-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; }
.chart-legend { font-size: var(--type-label-size); }
.chart-swatch { display: inline-block; width: 16px; height: 12px; border-radius: 3px; }
.series-primary { fill: var(--primary); background: var(--primary); }
.series-danger { fill: var(--danger); background: var(--danger); }
.series-info { fill: var(--info); background: var(--info); }
.line-swatch { height: 3px; }
.chart-frequency { margin-block: 8px; font-size: var(--type-label-size); }
.time-series-svg { display: block; width: 100%; height: auto; direction: ltr; overflow: visible; }
.chart-gridline { stroke: var(--border); stroke-width: 1px; }
.chart-x-label, .chart-y-label { fill: var(--muted); font-family: var(--font-ui); font-size: 17px; direction: ltr; unicode-bidi: isolate; }
.chart-line { fill: none; stroke-width: 3px; stroke-linejoin: round; }
.chart-line.series-info { stroke: var(--info); }
.chart-hit { fill: transparent; cursor: pointer; }
.chart-hit:hover, .chart-hit[aria-pressed="true"] { fill: var(--scrim); fill-opacity: .12; }
.chart-hit:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.chart-tooltip { min-height: 72px; padding: 12px; margin-top: 8px; background: var(--background); border-radius: var(--small-radius); font-size: var(--type-label-size); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.chart-date-controls { justify-content: flex-end; gap: 8px; margin-top: 8px; }
.chart-empty { margin-top: 8px; }
@media (width < 840px) { .chart-x-label, .chart-y-label { font-size: 32px; } }

/* Shared assistant: kept inside the screen iframe, above phone action bars. */
.assistant-launcher { position: fixed; top: auto; inset-inline-end: 24px; bottom: calc(112px + env(safe-area-inset-bottom)); z-index: 80; display: flex; align-items: center; gap: 8px; background: var(--primary); color: var(--on-primary); border: 0; border-radius: var(--pill); box-shadow: var(--shadow); }
.assistant-launcher:hover, .assistant-send:hover { background: var(--primary-hover); }
.assistant-panel { position: fixed; inset-block: 16px; inset-inline-end: 16px; width: min(440px, calc(100% - 32px)); z-index: 100; display: flex; flex-direction: column; gap: 12px; padding: 20px; background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.assistant-header { display: flex; align-items: center; gap: 12px; }
.assistant-header h2 { flex: 1; }
.assistant-header .icon-button { flex-shrink: 0; }
.assistant-panel > .muted { font-size: var(--type-label-size); line-height: var(--type-label-line); }
.assistant-context { display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid var(--border); border-radius: var(--small-radius); padding-inline: 12px 0; background: var(--primary-soft); }
.assistant-context span { overflow-wrap: anywhere; }
.assistant-messages { flex: 1; min-height: 44px; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 16px; padding: 4px; }
.assistant-message { padding: 12px 16px; border-radius: var(--small-radius); background: var(--background); overflow-wrap: anywhere; }
.assistant-message p { white-space: pre-wrap; }
.assistant-message small { display: block; color: var(--muted); font-size: var(--type-label-size); margin-bottom: 4px; }
.assistant-user { background: var(--primary-soft); margin-inline-start: 32px; }
.assistant-assistant { margin-inline-end: 16px; }
.assistant-confirmation { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; display: grid; gap: 12px; }
.assistant-confirm-actions { display: flex; gap: 12px; }
.assistant-confirm-actions button { flex: 1; }
.assistant-status { font-size: var(--type-label-size); color: var(--muted); }
.assistant-status:empty { display: none; }
.assistant-compose { display: flex; align-items: end; gap: 8px; border-top: 1px solid var(--border); padding-top: 12px; }
.assistant-compose textarea { width: 100%; min-width: 0; min-height: 56px; max-height: 140px; resize: vertical; border: 1px solid var(--border); border-radius: var(--small-radius); padding: 12px; color: var(--ink); background: var(--surface); }
.assistant-send { background: var(--primary); color: var(--on-primary); border: 0; }
@media (max-width: 599px) {
  .assistant-panel { inset: 0; width: 100%; height: var(--viewport-height); border: 0; border-radius: 0; padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .assistant-launcher { inset-inline-end: 16px; }
}
