@font-face {
  font-family: "Public Sans";
  src: url("fonts/public-sans-latin-v21.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
}
@font-face {
  font-family: Chivo;
  src: url("fonts/chivo-latin-v21.woff2") format("woff2");
  font-style: normal;
  font-weight: 600 800;
  font-display: swap;
}
/* ==== Design tokens (2026-11 redesign). Change values here, not in components. ==== */
:root {
  /* Neutrals */
  --canvas: #f5f6fb;
  --surface: #fff;
  --subtle: #f6f7fb;
  --sidebar: #f6f7fb;            /* light panel surface (legacy name, used by phone order cards) */
  --border: #e7e9f1;
  --control-border: #d5d9e5;
  --ink: #1b1f33;
  --muted: #5c6378;
  --faint: #8b91a7;
  /* Brand */
  --accent: #6c3ce1;
  --accent-hover: #5a2ec6;
  --accent-soft: #f1ecff;
  --active: #f1ecff;
  --ring: #7c4dff;
  --ring-soft: rgb(124 77 255 / .18);
  /* Semantic */
  --success: #15803d;
  --success-surface: #e9f7ef;
  --success-border: #bfe5cf;
  --warning: #b45309;
  --warning-surface: #fff5e6;
  --danger: #c0352b;
  --danger-surface: #fdeeed;
  --info: #2563eb;
  --info-surface: #ebf2ff;
  /* Repair statuses (keyed by stable status IDs) */
  --status-accepted: #2563eb;
  --status-in-repair: #ea580c;
  --status-waiting: #d4a106;
  --status-repaired: #15803d;
  --status-handed: #7c3aed;
  --status-not-repaired: #dc2626;
  /* Shell */
  --nav-bg: #191736;
  --nav-bg-end: #23194d;
  --nav-ink: #c9cbe4;
  --nav-muted: #9093ba;
  --nav-hover: rgb(255 255 255 / .07);
  --nav-active: linear-gradient(135deg, #8257ff, #6c3ce1);
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 64px;
  /* Shape and depth */
  --radius-sm: 7px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgb(16 24 40 / .04), 0 1px 3px rgb(16 24 40 / .06);
  --shadow-md: 0 8px 24px rgb(20 16 60 / .1), 0 2px 6px rgb(20 16 60 / .05);
  --dialog-shadow: 0 24px 64px rgb(20 16 60 / .22), 0 4px 12px rgb(20 16 60 / .1);
  /* Spacing and type */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px; --space-6: 24px; --space-8: 32px;
  --text-xs: 12px; --text-sm: 13px; --text-md: 14px; --text-lg: 16px; --text-xl: 20px; --text-2xl: 26px;
  --shell-inline: clamp(14px, 2.2vw, 28px);
  --control-height: 38px;
  /* Motion */
  --motion-fast: 120ms;
  --motion: 200ms;
  --ease: cubic-bezier(.2, .7, .3, 1);
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 "CRM Arabic", "Public Sans", system-ui, sans-serif; }
h1, h2, h3, p { margin: 0 0 12px; }
h1, h2, h3 { line-height: 1.2; }

h3 { font-size: 16px; }
a { text-underline-offset: 3px; }
small, dt { color: var(--muted); font-size: 12px; font-weight: 600; }
.bar, dialog header, footer, .tools, nav {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.bar {
  min-block-size: 60px; padding: 10px var(--shell-inline); background: var(--surface);
  border-block-end: 1px solid var(--border);
}
.bar strong { font-family: "CRM Arabic", Chivo, system-ui, sans-serif; font-size: 16px; }
.bar form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.tools { margin-block-end: 16px; align-items: end; }
.tools select { min-inline-size: 10rem; }
label { display: block; min-inline-size: 0; font-size: 13px; font-weight: 600; }
input, select, textarea { display: block; width: 100%; margin-block-start: 4px; color: inherit; font: inherit; font-weight: 400; border: 1px solid var(--control-border); padding: 6px 10px; background: var(--surface); }
input:is([type=checkbox], [type=radio]) { width: auto; min-block-size: 0; accent-color: var(--accent); }
textarea { resize: vertical; min-block-size: 72px; }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; text-align: center; border: 1px solid transparent; color: white; cursor: pointer; text-decoration: none; }
button:disabled { opacity: .55; cursor: default; }
button:not(:disabled):active, .button:active { filter: brightness(.94); }

.secondary { background: var(--surface); border-color: var(--control-border); color: var(--ink); }

.icon-button { inline-size: var(--control-height); padding: 0; font-size: 20px; line-height: 1; }
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--ring); outline-offset: 2px;
}
.sheet, article, .login form, .inset-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.sheet { overflow: auto; }
.sheet p { text-align: center; padding: 16px; }
.sheet p:empty { display: none; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: start; border-block-end: 1px solid var(--border); vertical-align: middle; }
th { white-space: nowrap; }
tbody tr:last-child > td { border-block-end: 0; }
dialog { border: 1px solid var(--border); padding: 0; width: min(860px, 96vw); color: inherit; background: var(--surface); }

dialog form { display: flex; flex-direction: column; max-height: 90dvh; }
dialog header, dialog footer { padding: 12px 20px; background: var(--surface); }
dialog header { border-block-end: 1px solid var(--border); flex-wrap: wrap; }
dialog h2 { margin: 0; font-size: clamp(18px, 2.2vw, 24px); }
.sections { overflow: auto; padding: 0 20px 16px; }
.sections h3, article h3 { border-block-start: 1px solid var(--border); padding-block-start: 14px; margin-block-start: 16px; }
.grid, dl { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.wide { grid-column: 1/-1; }
fieldset { min-inline-size: 0; margin: 0; border: 1px solid var(--border); border-radius: var(--radius); }
fieldset label:has(input[type=checkbox]) { display: inline-flex; align-items: center; margin-inline-end: 14px; gap: 5px; }
.add { justify-self: start; }
.drop { border: 1px dashed var(--control-border); padding: 12px; border-radius: var(--radius); }
.drop.active { background: var(--active); }
footer { justify-content: flex-end; border-block-start: 1px solid var(--border); }
[role=alert] { color: var(--danger); }
.record { max-width: 900px; margin: auto; }
.record article, .login form { padding: clamp(20px, 4vw, 42px); }
nav { margin-block-end: 16px; }
dd { margin: 3px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.login { display: grid; place-items: center; }
.login form { width: min(390px,95vw); }
.login-brand { display: flex; align-items: center; gap: 9px; margin-block-end: 18px; }
.login label { margin-block-end: 16px; }
.login button { width: 100%; }
[hidden] { display: none !important; }
.file { display: block; }
@media (max-width: 640px) {
  .grid, dl { grid-template-columns: 1fr; }
  .tools { align-items: stretch; flex-direction: column; }
  dialog header, dialog footer, .sections { padding-inline: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  button, .button { transition: none; }
}
@media print {
  body { background: white; }
  nav { display: none; }
  main.record, main article { padding: 0; border: 0; }
  dl div { break-inside: avoid; }
}
#receipt-preview { inline-size: min(760px, calc(100% - 24px)); }
.receipt-preview-layout { display: flex; flex-direction: column; max-block-size: 90dvh; }
.receipt-preview-body { overflow: auto; min-block-size: 0; }
#receipt-preview [data-receipt-document] { padding: 16px 20px; }
#receipt-preview footer { display: flex; justify-content: flex-end; gap: 8px; }
@media print {
  html.crm-receipt-print body > :not(#receipt-preview) { display: none !important; }
  html.crm-receipt-print #receipt-preview {
    display: block; position: static; inset: auto; margin: 0; padding: 0; inline-size: auto;
    max-inline-size: none; max-block-size: none; overflow: visible; border: 0; box-shadow: none; color: black;
  }
  html.crm-receipt-print #receipt-preview .receipt-preview-layout { display: block; max-block-size: none; }
  html.crm-receipt-print #receipt-preview .receipt-preview-body { overflow: visible; }
  html.crm-receipt-print #receipt-preview [data-receipt-document] { padding: 0; }
  html.crm-receipt-print #receipt-preview :is(header, footer, [data-receipt-feedback]) { display: none; }
  html.crm-receipt-print #receipt-preview::backdrop { display: none; }
}
@font-face {
  font-family: "CRM Arabic";
  src: url("/static/arabic.ttf") format("truetype");
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
.bar bdi { margin-inline-end: 8px; }
.bar { flex-wrap: wrap; }
.bar .language { margin-inline-start: auto; }
.login-header { display: flex; justify-content: flex-end; padding: 16px 4vw; }
.login { min-height: calc(100dvh - 70px); }
.language { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.language button { background: var(--subtle); color: var(--ink); padding: 3px 8px; font-size: 13px; min-block-size: 30px; }
.language button[aria-pressed=true] { background: var(--active); border-color: var(--ring); color: var(--accent); }
.language-error { flex-basis: 100%; font-size: 13px; }
.language-error:empty { display: none !important; }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.filters h1 { flex-basis: 100%; margin-block-end: 0; }
.draft-header .language { margin-inline-start: auto; }
.drop button { margin-inline-start: 8px; }
#filelist ul { margin-block: 4px 0; }
.received-item + .received-item::before { content: " · "; }
@media (max-width: 640px) {
  .filters { display: block; }
  .filters label { margin-block-end: 8px; }
  .tools select { min-width: 0; }
  .bar bdi { display: none; }
}

.order-actions, #condition-editor, .tags, .tags li, #filelist li, #existing-files li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
#condition-editor { align-items: end; margin-block: 8px; }
#condition-editor label { flex: 1 1 12rem; }
.tags, #existing-files, #filelist ul { list-style: none; padding: 0; }
.tags:empty, #existing-files:empty { display: none; }
.tags li { background: var(--subtle); padding: 4px 8px; border-radius: 6px; }
.inline-action { padding: 2px 6px; min-block-size: 28px; }
.save-feedback { flex: 1; }
#latest-version { display: block; }
#history { margin-block-start: 24px; }
.history-event { margin-block: 12px; }
.history-event h3 { margin: 0; padding: 0; border: 0; }
.history-event p { margin-block: 8px; }
.history-changes { grid-template-columns: 1fr; }
.history-field { border-block-start: 1px solid var(--border); padding-block-start: 8px; }
.history-field ul { padding-inline-start: 1.5rem; }
@media print { #history { display: none; } }

.intake-layout {
  flex: 1 1 auto;
  min-block-size: 0;
  overflow: auto;
}
.intake-layout .sections { overflow: visible; }
#panel.edit-panel { width: min(1320px, 96vw); }
.intake-history {
  min-inline-size: 0;
  padding: 12px 16px;
  background: var(--subtle);
  border-block: 1px solid var(--border);
}
.intake-history h2 { display: none; }
.history-list { margin-block-start: 8px; max-block-size: 40dvh; overflow: auto; }
#edit-history-toggle[aria-expanded=false] + .history-list { display: none; }
.history-event { padding: 12px 14px; }
.history-pair { display: grid; grid-template-columns: minmax(0, 6em) minmax(0, 1fr); gap: 8px; align-items: baseline; }
.history-label { color: #38505a; font-size: .85em; font-weight: 600; }
.history-pair + .history-pair { border-block-start: 1px solid #edf1f2; }
.print-offer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-block-end: 12px;
  padding: 10px 12px;
  border: 1px solid var(--success-border);
  border-radius: 8px;
  background: var(--success-surface);
}
.print-offer p { margin: 0; flex: 1 1 14em; }
#edit-print-offer { margin: 8px 16px; }
@media (min-width: 1000px) {
  .edit-panel .intake-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(20rem, 1fr);
    grid-template-areas: "form history";
    overflow: hidden;
  }
  .edit-panel .sections { grid-area: form; overflow: auto; }
  .intake-history {
    grid-area: history;
    display: flex;
    flex-direction: column;
    min-block-size: 0;
    border-block: 0;
    border-inline-start: 1px solid var(--border);
  }
  .intake-history h2 { display: block; font-size: 18px; }
  #edit-history-toggle { display: none; }
  #edit-history-toggle[aria-expanded=false] + .history-list { display: block; }
  .history-list { flex: 1; min-block-size: 0; max-block-size: none; }
}

.customer-autocomplete { position: relative; min-inline-size: 0; }
.autocomplete-list {
  position: absolute;
  inset-block-start: 100%;
  inset-inline: 0;
  z-index: 2;
  max-block-size: 10rem;
  overflow: auto;
  margin: 2px 0 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--control-border);
  border-radius: 8px;
  background: white;
  box-shadow: 0 6px 16px #182e3626;
  touch-action: pan-y;
}
.autocomplete-list [role=option] {
  padding: 5px 8px;
  border-radius: 4px;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.autocomplete-list [role=option]:hover,
.autocomplete-list [aria-selected=true] { background: var(--success-surface); }

.status-cell p { margin: 6px 0 0; text-align: start; padding: 0; font-size: .85em; }
#status-feedback:empty { display: none; }
.orders-pages { margin-block: 14px; justify-content: center; }
.completion-body { overflow: auto; min-block-size: 0; padding: 0 24px 16px; }
.completion-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.completion-summary { margin-block: 14px; }
.repair-part {
  display: grid;
  grid-template-columns: minmax(8rem,2fr) minmax(4rem,1fr) minmax(6rem,1fr) minmax(6rem,1fr);
  align-items: start;
  gap: 8px;
  margin-block-end: 12px;
  min-inline-size: 0;
}
.repair-part output { display: block; }
.repair-part button { justify-self: start; }
#completion-error { margin-inline-end: auto; }
.repair-result h4 { margin-block: 10px; }
@media (max-width: 640px) {
  .repair-part { grid-template-columns: 1fr 1fr; }
  .repair-part label:first-of-type { grid-column: 1/-1; }
  .completion-body { padding-inline: 14px; }
  .orders-pages button { padding-inline: 8px; }
}

#workspace .sheet th { background: var(--subtle); color: var(--muted); }
#workspace .sheet th, #workspace .sheet td { padding: 6px 8px; line-height: 1.3; }

#workspace .sheet td:first-child a { font-weight: 700; }
#workspace .sheet .row-secondary { display: block; margin-block-start: 2px; color: var(--muted); font-size: .9em; }
.row-money { min-inline-size: 9rem; }
.money-label { display: block; color: var(--muted); font-size: .8em; }

.status-badge { vertical-align: middle; padding: 3px 7px; border: 1px solid transparent; font-size: .78rem; line-height: 1.25; }

button.status-badge.row-status { min-block-size: 28px; min-inline-size: 0; max-inline-size: 13rem; white-space: nowrap; text-align: start; }
button.status-badge.row-status::after { content: "▾"; }
.status-menu {
  position: fixed;
  inset: auto;
  margin: 0;
  padding: 5px;
  border: 1px solid #a8bdbb;
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 8px 22px #18343b30;
}
.status-menu-option { display: block; width: 100%; text-align: start; padding: 5px 7px; background: transparent; color: var(--ink); }
.status-menu-option:not(:disabled):hover, .status-menu-option:focus-visible { background: var(--active); }
.branch-counts { padding: 10px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; }
#status-counts { display: flex; gap: 6px 12px; flex-wrap: wrap; }
#status-counts > span { display: inline-flex; align-items: center; gap: 5px; }
.orders-screen #workspace { display: flex; flex-direction: column; min-block-size: 0; }
.orders-screen .tools, .orders-screen .branch-counts { flex: none; }
.orders-screen #workspace > .sheet { flex: 1 1 auto; min-block-size: 12rem; overflow: auto; }
.orders-screen #workspace thead th { position: sticky; inset-block-start: 0; z-index: 1; }
.orders-screen .branch-counts { margin-block-start: 6px; background: var(--surface); border: 1px solid var(--border); font-variant-numeric: tabular-nums; align-items: center; }
.orders-screen .filters label { flex: 1 1 10rem; }
.orders-screen .filters select { min-inline-size: 0; }
.orders-screen #new { flex: none; }
#order-batch-loading, .order-batch-message { padding: 12px; margin: 0; text-align: center; }
.order-batch-message button { margin-inline-start: 8px; }
@media (min-width: 960px) and (min-height: 620px) {
  .orders-screen { block-size: 100dvh; display: flex; flex-direction: column; }
  .orders-screen > .bar { flex: none; }
  .orders-screen > .app-layout { flex: 1 1 auto; min-block-size: 0; }
}
@media (max-width: 959px), (max-height: 619px) {
  .orders-screen #workspace > .sheet { flex: none; max-block-size: min(65dvh, 32rem); }
}

#panel.order-workspace { max-height: 96dvh; width: min(1380px, 97vw); }
#panel.order-workspace form { height: 92dvh; max-height: none; }
.workspace-tabs { display: flex; flex-wrap: wrap; border-block-end: 1px solid var(--border); }
.workspace-tabs button:not(:disabled) { background: transparent; }
.workspace-tabs button:not(:disabled):is(:hover,[aria-selected=true]) { background: var(--active); color: var(--accent); }

.workspace-actions { display: flex; margin: 0; gap: 8px; }
.order-review { padding: 0; }
.order-review article { border: 0; padding: 0; }
.order-review dl { margin: 8px 0; }
.order-review h3, #intake-fields h3 { padding-top: 12px; margin: 12px 0 8px; }
#intake-fields .grid { gap: 10px 16px; }
#intake-fields input, #intake-fields select, #intake-fields textarea { padding: 6px 8px; }
#order-work { padding-block: 14px; }
.work-heading, .work-buttons { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; }
.work-heading { margin-block-end: 12px; }
.work-heading label { flex: 1 1 12rem; }
#tech-feedback { flex-basis: 100%; order: 3; margin: 0; }
#tech-feedback:empty { display: none; }
.work-table { overflow: auto; margin: 0 0 14px; border: 1px solid var(--border); border-radius: 8px; }
.work-table table { font-size: .9rem; }
.work-table th, .work-table td { padding: 7px 9px; }
.work-table th { background: var(--subtle); }
.work-table input { margin: 0; padding: 6px; }
.work-table input.line-description { min-inline-size: 9rem; }
.work-table input[type=number] { min-inline-size: 4.5rem; }
.work-empty-materials { color: var(--muted); }
.work-recommendations { margin-block: 12px; }
.work-financials { padding: 12px; background: var(--subtle); border-radius: 8px; }
.work-financials dd { font-weight: 650; }
.work-financials output { display: block; }
.history-line + .history-line { margin-block-start: 8px; border-block-start: 1px solid #d8e5e4; }
@media (max-width: 640px) {
  .workspace-tabs { padding-inline: 10px; }
  .workspace-tabs button { padding-inline: 9px; }
  #panel.order-workspace form { height: 94dvh; }
  #panel.order-workspace footer { flex-wrap: wrap; }
  #panel.order-workspace footer .save-feedback:has(:empty) { min-inline-size: 0; }
  .work-heading { align-items: stretch; }
}

.history-field dd { white-space: normal; }
.history-field .history-value { white-space: pre-wrap; }
.history-pair { padding-block: 3px; }
.history-line { padding-block: 4px; }
#tech-feedback { display: block; margin-block-start: 4px; }
#draft-title:focus { outline: none; }

#edit-work-estimate { margin-block-start: 6px; }
#historical-charge-notice { color: #79521d; }
#cost-feedback { border-inline-start: 3px solid #a52f25; padding-inline-start: 8px; margin-block: 10px; }
#order-work[data-cost-conflict=true] #work-charge-display,
#order-work[data-cost-conflict=true] #work-cost,
#order-work[data-cost-conflict=true] #work-profit { color: #a52f25; }

.status-menu { overflow-y: auto; overscroll-behavior: contain; }
.status-menu-option .status-badge { white-space: normal; }

#workspace { min-inline-size: 0; }
#workspace .sheet th { block-size: 36px; }
#workspace .sheet tbody tr.order-row { cursor: pointer; }
#workspace .sheet tbody tr.order-row:hover,
#workspace .sheet tbody tr.order-row:focus-within { background: var(--active); }
#workspace .sheet .row-money { text-align: end; }
.row-money bdi[data-amount] { direction: ltr; unicode-bidi: isolate; }

.history-day { position: relative; padding-inline-start: 14px; border-inline-start: 1px solid #a7c1b8; margin-inline-start: 5px; }
.history-day-title { font-size: .84rem; font-weight: 600; margin: 6px 0 8px; }
.history-day .history-event { position: relative; background: transparent; border: 0; border-radius: 0;
  padding: 3px 0 12px; margin: 0 0 9px; min-inline-size: 0; }
.history-day .history-event::before { content: ""; position: absolute; inset-inline-start: -19px; inset-block-start: 8px; inline-size: 9px; block-size: 9px; border-radius: 50%; }
.history-event[data-action=created]::before { background: #4d79b6; }
.history-event[data-action=payment]::before { background: #6c50aa; }
.history-event[data-action=handover]::before, .history-event[data-action=completed]::before { background: #207863; }
.history-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.history-heading h3 { font-size: .95rem; font-weight: 600; }
.history-heading time, .history-employee { color: var(--muted); font-size: .82rem; }
.history-event .history-employee { margin: 2px 0 6px; }
.history-day .history-changes { margin: 6px 0 0; gap: 4px; }
.history-day .history-field { padding-block-start: 4px; }
.payment-body { padding: 0 24px 16px; overflow: auto; min-block-size: 0; }
.payment-quote { grid-template-columns: repeat(3,minmax(0,1fr)); padding: 12px; background: var(--subtle); }
.payment-quote dd { font-weight: 600; }
.payment-options { display: flex; flex-wrap: wrap; gap: 8px; padding-block: 4px; }
.payment-options label { display: flex; align-items: center; gap: 8px; min-block-size: 36px; border: 1px solid var(--control-border); border-radius: 6px; padding: 6px 10px; }
.payment-options input { width: auto; margin: 0; }
.payment-options label:has(input:checked) { background: var(--active); border-color: var(--ring); color: var(--accent); }
#payment-mixed { margin-block: 10px; }
#payment-unallocated { font-weight: 600; }
#payment-single, #payment-nothing { margin: 12px 0 0; }
#payment-feedback:empty { display: none; }
@media(max-width:640px) {
  .payment-quote { grid-template-columns: 1fr; gap: 6px; }
  .payment-body { padding-inline: 14px; }
  #payment-dialog header { flex-wrap: wrap; }
}

.row-money > div { display: flex; align-items: baseline; justify-content: flex-end; gap: 7px; }
.row-money .money-label { white-space: nowrap; }
.row-money > div + div { margin-block-start: 4px; }
.history-payment { display: block; margin: 0 0 5px; }
.history-payment > div { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 3px 0; }
.history-payment dd { margin: 0; }

.app-layout { grid-template-columns: clamp(10.5rem, 15vw, 13rem) minmax(0, 1fr); }
.session-recheck body { visibility: hidden; }
.crm-identity { display: flex; align-items: center; gap: 9px; min-inline-size: 0; }
.crm-icon { flex: 0 0 auto; }
.crm-logo { display: grid; place-items: center; flex: 0 0 auto; color: white; }
.bar .crm-identity strong { font-size: .95rem; }
.crm-tenant {
  flex: 0 1 auto; min-inline-size: 0; padding-inline-start: 9px;
  border-inline-start: 1px solid var(--border); color: var(--muted);
  font-size: .83rem; overflow-wrap: anywhere;
}
.bar .crm-tenant bdi { display: inline; margin: 0; }
.app-sidebar { border-inline-end: 1px solid var(--border); min-inline-size: 0; min-block-size: 0; overflow: auto; }
.app-sidebar nav { align-content: start; }
.app-sidebar :is(a, summary) { text-decoration: none; }
.app-sidebar :is(.nav-item, .nav-mobile-toggle) {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px; min-block-size: 36px; font-weight: 630;
}
.app-sidebar summary { cursor: pointer; list-style: none; }
.app-sidebar summary::-webkit-details-marker { display: none; }

.app-sidebar :is(a[aria-current=page], .sidebar-group:has([aria-current=page]) > summary) {
  background: var(--active); color: var(--accent);
}
.app-sidebar .nav-child { margin-block: 3px; border-inline-start: 1px solid var(--border); border-start-start-radius: 0; border-end-start-radius: 0; }
.app-sidebar .nav-child[aria-current=page] { border-inline-start-color: var(--accent); font-weight: 680; }
.sidebar-group > summary::after {
  content: ""; inline-size: 6px; block-size: 6px; margin-inline-start: auto; flex: none;
  border-inline-end: 1px solid; border-block-end: 1px solid; transform: rotate(45deg);
}
.sidebar-group[open] > summary::after { transform: rotate(225deg); }

.salary { min-inline-size: 0; padding-block-end: 36px; }
.salary-header { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.salary-header h1 { font-size: clamp(24px, 3vw, 32px); }
.salary-header p { color: var(--muted); margin: 5px 0; }
.salary-filter { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.salary-filter select { min-inline-size: 12rem; }
.salary-period-controls { display: grid; gap: 12px; padding: 12px; margin-block: 14px; }
#salary-month select, #salary-range input { min-inline-size: 8rem; }
#salary-range input { inline-size: 10rem; max-inline-size: 100%; }
#salary-period-error { color: #a02323; margin: 0; }
#salary-period-error:empty { display: none; }
.salary-active-period { margin: 0 0 10px; }
.salary-qualifying { margin: 8px 0 0; }
.salary-scope { color: var(--muted); margin-block: 12px; }
.salary-totals { background: var(--success-surface); border: 1px solid var(--success-border); padding: 12px 16px; margin-block: 14px; }
.salary-employee-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: 14px 22px; }
.salary-employee-summary p { margin-block: 6px; }
.salary-totals h2 { margin: 0; font-size: 1rem; font-weight: 600; }
.salary-totals ul { display: flex; gap: 18px; flex-wrap: wrap; list-style: none; margin: 5px 0 0; padding: 0; font-size: 1.5rem; font-weight: 650; }
.salary-sheet th, .salary-sheet td { padding: 9px 11px; }
.salary-sheet th:nth-child(n+4), .salary-sheet td:nth-child(n+4) { text-align: end; white-space: nowrap; }
.salary-credit { color: #185745; font-weight: 650; }
.salary-empty { background: white; border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
@media (max-width: 760px) {
  .app-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .app-sidebar { padding: 3px var(--shell-inline); border-inline-end: 0; border-block-end: 1px solid var(--border); }
  .app-sidebar .nav-mobile-toggle { display: flex; min-block-size: 42px; }
  .app-sidebar nav { padding-block-end: 5px; }
  .salary-filter select { min-inline-size: 0; }
}

.loading-feedback {
  position: fixed; z-index: 2; inset-block-end: 16px; inset-inline-end: var(--shell-inline);
  min-block-size: 32px; padding: 6px 10px; background: var(--active); color: var(--accent);
  border: 1px solid var(--control-border); border-radius: 6px;
}
[aria-busy=true] :is(#save, #save-work, #payment-confirm) { cursor: progress; }
.money-label, .row-money, .salary-totals, .salary-sheet, .work-financials, .payment-quote { font-variant-numeric: tabular-nums; }

.workspace-save-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.handover-save-offer {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px;
  margin: 8px 16px; background: var(--active); border: 1px solid var(--control-border);
  border-radius: var(--radius);
}
.handover-save-offer p { margin: 0; flex: 1 1 14em; }

.column-filter {
  background: transparent; color: var(--ink); padding: 4px; margin-inline-start: -4px;
  justify-content: flex-start; min-block-size: 30px; text-align: start; gap: 5px;
}
.column-filter:not(:disabled):hover, .column-filter[data-active] {
  background: var(--active); color: var(--accent);
}
.column-filter-indicator { display: inline-flex; color: var(--muted); }
.column-filter[data-active] .column-filter-indicator { color: var(--accent); }
.column-filter-value {
  display: inline-block; max-inline-size: 12rem; overflow: hidden; text-overflow: ellipsis; vertical-align: middle;
}
.column-filter-value::before { content: "· "; }
.order-filter-popover {
  position: fixed; inset: auto; margin: 0; inline-size: 19rem; overflow: auto;
  overscroll-behavior: contain; padding: 12px; border: 1px solid var(--control-border);
  border-radius: var(--radius); background: var(--surface); color: var(--ink); box-shadow: var(--dialog-shadow);
}
.order-filter-popover:popover-open { display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.order-filter-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: none; }
.order-filter-popover h2 { font-size: 15px; margin: 0; min-inline-size: 0; overflow-wrap: anywhere; }
#order-filter-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 6px; }
#order-filter-input-label { grid-column: 1/-1; }
#order-filter-input { margin: 0; }
.order-filter-options {
  display: grid; align-content: start; gap: 3px; flex: 1 1 auto; min-block-size: 0; max-block-size: min(22rem, 55dvh);
  overflow-y: auto; overscroll-behavior: contain; margin: 0; padding-inline-end: 2px;
}
.order-filter-options:empty { display: none; }
.order-filter-options button {
  background: transparent; color: var(--ink); text-align: start; justify-content: space-between;
  white-space: normal; overflow-wrap: anywhere; padding-inline: 6px;
}
.order-filter-options button:not(:disabled):hover, .order-filter-options button[aria-pressed=true] {
  background: var(--active); color: var(--accent);
}
.order-filter-options small { flex: none; }
#order-filter-form { flex: none; }
#order-filter-feedback { margin: 0; flex: none; }
#order-filter-clear { flex: none; min-block-size: 30px; padding: 2px 10px; font-size: var(--text-sm); }
.order-filter-more { flex: none; }
.order-filter-options button[aria-pressed=true] { font-weight: 650; box-shadow: inset 3px 0 0 var(--accent); }
[dir=rtl] .order-filter-options button[aria-pressed=true] { box-shadow: inset -3px 0 0 var(--accent); }
.order-filter-options .status-badge { pointer-events: none; }

/* Quick clear beside an active heading filter: one click removes only that column's condition. */
.column-filter-group { display: inline-flex; align-items: center; gap: 2px; max-inline-size: 100%; }
.column-filter-clear {
  position: relative; flex: none; display: inline-grid; place-items: center; inline-size: 24px; block-size: 24px;
  min-block-size: 24px; min-inline-size: 24px; padding: 0; border: 0; border-radius: var(--radius-pill);
  background: var(--accent-soft); color: var(--accent);
}
.column-filter-clear[hidden] { display: none; }
.column-filter-clear:not(:disabled):hover, .column-filter-clear:focus-visible { background: var(--accent); color: var(--surface); }
.column-clear-tip {
  position: absolute; inset-block-start: calc(100% + 6px); inset-inline-end: 0; z-index: 4; padding: 5px 8px;
  border-radius: var(--radius-sm); background: var(--ink); color: var(--surface); font-size: var(--text-xs);
  font-weight: 500; white-space: nowrap; box-shadow: var(--shadow-md); opacity: 0; pointer-events: none;
  transition: opacity var(--motion-fast) ease;
}
.column-filter-clear:is(:hover, :focus-visible) .column-clear-tip { opacity: 1; }
.orders-table th[data-filter-active] { box-shadow: inset 0 -2px 0 var(--accent); }
#order-filter-feedback:empty { display: none; }

.retail-nav summary, .retail-groups summary, #product-dialog summary { cursor: pointer; }
.retail-nav summary { color: var(--muted); font-weight: 650; padding: 5px 10px; }
.retail-workspace { min-inline-size: 0; }
.retail-toolbar, .retail-search, .retail-cart-total, .retail-pages {
  display: flex; gap: 12px; align-items: end; flex-wrap: wrap;
}
.retail-toolbar { margin-block-end: 14px; justify-content: space-between; }
.retail-toolbar select { min-inline-size: 11rem; }
.retail-search { flex: 1 1 18rem; max-inline-size: 37rem; }
.retail-search label { flex: 1 1 15rem; }
.retail-search p { flex-basis: 100%; margin: 0; color: var(--muted); }
#retail-feedback:empty, #product-error:empty, #retail-quantity-error:empty { display: none; }
#retail-feedback { margin-block: 8px; }
.retail-grid { display: grid; grid-template-columns: minmax(11rem,.28fr) minmax(0,1fr); gap: 14px; align-items: start; }
.retail-sales-grid { grid-template-columns: minmax(0,1.25fr) minmax(19rem,1fr); }
.retail-groups, .retail-cart { min-inline-size: 0; }

#retail-groups { display: grid; gap: 5px; margin-block-end: 10px; }
#retail-groups .secondary { text-align: start; justify-content: start; overflow-wrap: anywhere; }
#retail-groups button[aria-pressed=true] { background: var(--active); color: var(--accent); }
#retail-group-form button, .retail-cart > .button { margin-block-start: 8px; }
.retail-product-button { background: transparent; color: var(--accent); text-align: start; justify-content: flex-start; border: 0; }
.retail-product-button:not(:disabled):hover { color: var(--accent); }
.retail-catalog tbody tr:hover { background: var(--subtle); cursor: pointer; }

.retail-pages { justify-content: center; margin-block: 12px; }
.retail-cart-total { justify-content: space-between; align-items: baseline; margin-block: 12px; }
.retail-cart-total output { font-size: 18px; font-weight: 700; }
#cart-lines input { min-inline-size: 4rem; margin: 0; padding-inline: 6px; }
#product-dialog fieldset, #product-secondary, #product-movements { padding: 12px; margin-block: 12px; }
#product-secondary, #product-movements { border: 1px solid var(--border); border-radius: var(--radius); }
#product-dialog summary { margin-block-end: 6px; }
#product-dialog legend { font-weight: 650; }
#product-dialog p { margin: 6px 0 0; }
#product-dialog .retail-product-name { position: relative; min-inline-size: 0; }
#product-suggestions { z-index: 4; }
#product-suggestions button {
  display: flex; width: 100%; justify-content: space-between; text-align: start;
  white-space: normal; overflow-wrap: anywhere; margin-block-end: 3px;
}
#product-dialog footer { flex-wrap: wrap; }
#product-error { flex: 1 1 13rem; }
#retail-quantity-dialog { max-inline-size: 22rem; }
.retail-quantity-body { padding-block: 14px; }
.retail-summary { display: flex; flex-wrap: wrap; gap: 12px; margin-block: 14px; }
.retail-summary > div { flex: 1 1 10rem; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.retail-summary h3 { margin: 0 0 6px; font-size: 15px; }
.salary-sales { margin-block: 22px; }
.salary-sales h2 { font-size: 18px; }
.retail-receipt table { margin-block: 16px; }
@media (max-width: 850px) {
  .retail-grid, .retail-sales-grid { grid-template-columns: minmax(0,1fr); }
  #retail-groups { display: flex; flex-wrap: wrap; gap: 6px; }
  #retail-group-form { display: flex; align-items: end; gap: 8px; flex-wrap: wrap; }
  .retail-search { max-inline-size: none; }
}

.admin-workspace { min-inline-size: 0; }
.admin-heading h2 { margin-block: 8px; }
.admin-heading { margin-block-end: 14px; }
.admin-quota { display: flex; flex-wrap: wrap; gap: 12px; margin-block-end: 14px; }
.admin-quota > div, .admin-card { padding: 12px; border-radius: var(--radius); }
.admin-quota > div { background: var(--surface); border: 1px solid var(--border); }
.quota-value { padding-inline-start: 6px; font-weight: 650; }
.quota-over { color: var(--danger); padding-inline-start: 6px; }
.admin-card { margin-block-end: 14px; max-inline-size: 43rem; }
.admin-card summary { cursor: pointer; font-weight: 650; }
.admin-card details, details.admin-card[open] form, .admin-card form + form { margin-block-start: 12px; }
.admin-card form button, form.admin-card button { justify-self: start; }
.admin-card p:empty, #payout-feedback:empty, #payout-dialog-error:empty { display: none; }
.admin-assignments legend { font-weight: 650; }
.admin-assignments label { padding-block: 4px; }
.admin-audit, .payroll-section { margin-block: 22px; }
.admin-audit h2, .payroll-section h2 { font-size: 18px; }
.payroll-metrics [data-payroll-metric] { font-weight: 650; }
.payroll-metrics [data-payroll-metric] bdi { display: block; }
#salary-payout-dialog { max-inline-size: 32rem; }
.payout-body { padding-block: 14px; }

.salary-list-scroll { max-block-size: min(44dvh, 21rem); overflow: auto; overscroll-behavior-block: contain; }
.salary-list-scroll thead th { position: sticky; inset-block-start: 0; z-index: 1; }
.salary-list-scroll th, .salary-list-scroll td { padding: 8px 11px; }
.salary-payout-period time { white-space: nowrap; }
.salary-payout-period > span { display: inline-block; margin-inline: 3px; }
[dir=rtl] .salary-payout-period > span[aria-hidden=true] { transform: scaleX(-1); }
.salary-period-rule { margin-block-end: 8px; color: var(--muted); }
.salary-list-feedback { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 5px 10px; }
.salary-list-feedback p { padding: 8px; margin: 0; }
@media (max-width: 640px) {
  .salary-list-scroll { max-block-size: min(48dvh, 20rem); }
}

.employee-profile { max-inline-size: 56rem; }
.employee-pay { display: grid; gap: 10px; }
.employee-pay :is(h3,p) { margin: 0; }
.employee-pay fieldset { display: grid; gap: 8px; }
.employee-pay-inputs { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.employee-pay-agreement { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.employee-password { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: end; gap: 8px; }
.profile-field-error { color: var(--danger); }
[data-employee-form] [aria-invalid=true] { border-color: var(--danger); }
#delete-employee-dialog { max-inline-size: 32rem; }
button.employee-delete:not(.secondary) { background: var(--danger); border-color: var(--danger); }
button.employee-delete.secondary { color: var(--danger); border-color: var(--danger); }
@media (max-width: 640px) {
  .employee-pay-inputs, .employee-password { grid-template-columns: minmax(0,1fr); }
  .employee-password button { justify-self: start; }
}

.dashboard { min-inline-size: 0; display: grid; align-content: start; }
.dashboard h1 { margin-block: 0 6px; }
.dashboard-scope { display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px 12px; color: var(--muted); }
.dashboard-scope strong { color: var(--ink); }
.dashboard-header .button { display: inline-flex; margin-block-end: 10px; }
.dashboard-controls { display: flex; align-items: end; flex-wrap: wrap; gap: 8px 12px; padding: 10px 12px; }
.dashboard-controls > p { flex-basis: 100%; margin: 0; }
.dashboard-dates { display: flex; gap: 8px; flex-wrap: wrap; }
.dashboard-branch-chooser { position: relative; }
.dashboard-branch-chooser summary { cursor: pointer; padding: 7px 10px; border: 1px solid var(--control-border); border-radius: var(--radius); }
.dashboard-branch-list { display: grid; gap: 6px; position: absolute; inset-inline-start: 0; inset-block-start: calc(100% + 4px);
  z-index: 3; padding: 10px; inline-size: max-content; min-inline-size: 100%; max-inline-size: min(70vw, 24rem);
  max-block-size: min(40vh, 18rem); overflow: auto; box-shadow: var(--dialog-shadow); }
.dashboard-branch-list label { display: block; }
.dashboard-branch-list button { justify-self: start; }
.dashboard-section { padding: 12px; min-inline-size: 0; }
.dashboard-section h2 { font-size: 17px; margin-block: 0 10px; }
.dashboard-section-heading { display: flex; align-items: baseline; gap: 8px 12px; flex-wrap: wrap; }
.dashboard-section-heading p, .dashboard-note { margin-block: 0; color: var(--muted); }
.dashboard-note { margin-block-start: 8px; font-size: 12px; }
.dashboard-money-grid, .dashboard-count-grid, .dashboard-attention { display: grid; gap: 7px; }
.dashboard-money-grid, .dashboard-attention { grid-template-columns: repeat(3,minmax(0,1fr)); }
.dashboard-collected-grid { grid-template-columns: repeat(4,minmax(0,1fr)); }
.dashboard-count-grid { grid-template-columns: repeat(5,minmax(0,1fr)); }
.dashboard-metric { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; background: var(--subtle); }
.dashboard-metric h3, .dashboard-attention-heading { font-size: 13px; margin: 0 0 5px; }
.dashboard-attention-heading { margin-block-start: 10px; }
.dashboard-metric bdi { display: block; font-variant-numeric: tabular-nums; font-weight: 650; font-size: 1.02rem; overflow-wrap: anywhere; }
.dashboard-metric[data-dashboard-money=collected] { background: var(--active); }
.dashboard-attention a { color: var(--accent); text-decoration: none; }
.dashboard-attention a:hover { border-color: var(--accent); }
.dashboard-attention a[data-drill=overdue] { color: var(--danger); }
.dashboard-table tbody th { background: var(--surface); }
.dashboard-table :is(td,th) { white-space: nowrap; }
.dashboard-table td bdi[data-amount] { display: block; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .dashboard-money-grid, .dashboard-count-grid, .dashboard-attention { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .dashboard-branch-chooser[open] { flex-basis: 100%; }
  .dashboard-branch-list { position: static; inline-size: auto; max-inline-size: none; box-shadow: none; margin-block-start: 5px; }
}

.platform-list-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-block: 14px; }
.platform-list-tabs [aria-current=page] { border-color: var(--accent); background: var(--active); }
.platform-subscription { padding: 14px; margin-block-end: 14px; }
.platform-subscription h2, .platform-dialog h2 { margin: 0; }
.platform-subscription header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.platform-subscription details { margin-block: 12px; }
.platform-subscription summary { cursor: pointer; }
.platform-subscription-form { max-inline-size: 42rem; margin-block-start: 10px; }
.platform-subscription-form [data-admin-feedback], .platform-dialog [role=alert] { margin-block: 6px; }
.platform-dates, .platform-impact { display: flex; flex-wrap: wrap; gap: 10px 20px; margin-block: 12px; }
.platform-dates dt, .platform-impact dt { color: var(--muted); }
.platform-dates dd, .platform-impact dd { font-weight: 650; margin: 4px 0 0; }
.platform-dialog { max-inline-size: 34rem; }
.platform-dialog > form > :is(label, dl, p), .platform-dialog-target { margin-inline: 18px; }
.platform-dialog-target { margin-block-start: 12px; }
.platform-dialog > form > label { margin-block-start: 12px; }
.platform-dialog p:empty, .platform-account p:empty { display: none; }
.platform-account > :is(form,button) { margin-block-start: 8px; }
.platform-danger.secondary { color: var(--danger); border-color: var(--danger); }
.platform-danger:not(.secondary) { color: white; background: var(--danger); border-color: var(--danger); }
[data-plan=expiring] { color: #80550d; }
[data-plan=expired], [data-plan=archived] { color: var(--danger); }
.subscription-notice { padding: 7px 12px; border: 1px solid #e1c579; background: #fff4d7; color: #51380c; }
.subscription-notice :is(strong,time,bdi) { font-weight: 650; }
.subscription-notice[data-state=expired], .subscription-notice[data-state=archived] { color: #852520; background: #fce6db; border-color: #dfa99b; }
.subscription-access .platform-subscription { max-inline-size: 32rem; }

.salary-sale-breakdown { min-inline-size: min(22rem, 64vw); white-space: normal; }
.salary-sale-breakdown summary { cursor: pointer; color: var(--accent); }
.salary-sale-line { margin-block: 6px; padding-block: 5px; border-block-start: 1px solid var(--border); }
.salary-sale-line dl { margin-block: 5px 0; gap: 5px 10px; }
.salary-sale-line dl > div { min-inline-size: 0; }
.salary-sale-line dd { margin: 0; }
.salary-cost-review { color: var(--danger); }

.dashboard-sales-table :is(th,td) { padding: 9px 10px; white-space: normal; }
.dashboard-sales-table th[scope=row] { background: var(--surface); color: var(--ink); white-space: normal; }
.dashboard-sales-table :is(.dashboard-sales-direct_cost, .dashboard-sales-direct_cost bdi) { color: var(--danger); }
.dashboard-sales-table .dashboard-sales-profit { background: var(--active); color: var(--ink); }
.dashboard-sales-table td bdi[data-amount] { display: block; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.dashboard-sales-table .dashboard-sales-profit bdi[data-amount] { font-size: 1.15rem; font-weight: 750; }
.dashboard-sales-table [data-sales-row=total] { font-weight: 650; }
.dashboard-sales-table [data-sales-row=total] .dashboard-sales-profit bdi[data-amount] { font-size: 1.32rem; }
.dashboard-sales-mobile-label { display: none; }
.dashboard-amount-unavailable { display: block; color: var(--muted); font-weight: 550; }
.dashboard-sales-incomplete { color: var(--danger); }
@media (max-width: 700px) {
  .dashboard-sales-table, .dashboard-sales-table tbody { display: block; }
  .dashboard-sales-table thead { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); }
  .dashboard-sales-table tbody tr { display: grid; grid-template-columns: repeat(2,minmax(0,1fr));
    border-block-end: 1px solid var(--border); padding-block: 4px; }
  .dashboard-sales-table tbody :is(th,td) { border: 0; }
  .dashboard-sales-table th[scope=row] { grid-column: 1/-1; }
  .dashboard-sales-mobile-label { display: block; font-size: .77rem; font-weight: 650; }
}

.order-assignee, .order-source-picker { display: grid; gap: 5px; align-content: start; min-inline-size: 0; }
.order-assignee label, .order-source-picker label { min-inline-size: 0; }
.order-assignee small:empty, .order-source-picker small:empty { display: none; }
.order-assignee button, .order-source-picker button { justify-self: start; }
.acquisition-settings-table td form { display: flex; align-items: end; flex-wrap: wrap; gap: 6px; margin-block: 4px; }
.acquisition-settings-table [data-admin-feedback] { margin: 0; padding: 0; }
.acquisition-archived { margin-inline-start: 8px; color: var(--muted); }

/* Orders shares its rows and filter controls between the table and phone cards. */
.orders-title { margin-block-end: 10px; }
.orders-tools { justify-content: start; gap: 10px; }
.orders-tools .filters { justify-content: start; }

.orders-table [data-order-cell="number"] a { white-space: nowrap; }
.orders-table .row-money { font-variant-numeric: tabular-nums; }
.order-card-label { display: none; }

@media (max-width: 760px) {
  .bar { gap: 6px 10px; }
  .crm-identity { flex-basis: 100%; }
  .bar .language { margin-inline-start: 0; }
  .bar form { margin-inline-start: auto; }
  .orders-screen #workspace { padding-block: 16px; }
  .orders-tools { display: block; }
  .orders-tools .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-block-start: 9px; }
  .orders-screen .orders-tools .filters label { max-inline-size: none; margin-block-end: 0; }
  .orders-tools :is(button,input,select) { min-block-size: 40px; }
  .orders-screen #workspace > .sheet { max-block-size: min(65dvh, 32rem); background: var(--sidebar); }
  .orders-table, .orders-table tbody, .orders-table thead { display: block; min-inline-size: 0; }
  .orders-table thead { position: sticky; inset-block-start: 0; z-index: 1; border-block-end: 1px solid var(--border); background: var(--subtle); }
  .orders-table thead tr { display: flex; flex-wrap: wrap; gap: 3px; padding: 5px; }
  .orders-screen #workspace .orders-table th { position: static; padding: 0; border: 0; }
  .orders-table .card-filter-label { display: none; }
  .orders-table .column-filter {
    min-block-size: 32px; margin: 0; padding: 4px 6px; border-color: var(--border); background: var(--surface);
  }
  .orders-table .column-filter[data-active] { background: var(--active); border-color: var(--control-border); }
  .orders-table .column-filter-value { max-inline-size: min(8rem, 25vw); }
  .orders-table tbody { padding: 8px; }
  .orders-table .order-row {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 10px;
    grid-template-areas: "number status" "model model" "fault fault" "deadline amount" "customer customer";
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 8px 10px; align-items: start; cursor: pointer;
  }
  .orders-table .order-row + .order-row { margin-block-start: 7px; }
  #workspace .orders-table .order-row td { border: 0; padding: 0; min-inline-size: 0; }
  .orders-table [data-order-cell="number"] { grid-area: number; align-self: center; }
  .orders-table [data-order-cell="status"] { grid-area: status; justify-self: end; max-inline-size: 100%; }
  .orders-table button.status-badge.row-status { min-block-size: 40px; max-inline-size: 100%; white-space: normal; }
  .orders-table [data-order-cell="model"] { grid-area: model; font-size: 1rem; font-weight: 700; overflow-wrap: anywhere; }
  .orders-table [data-order-cell="model"] .row-secondary { font-weight: 450; font-size: .75rem; }
  .orders-table [data-order-cell="fault"] { grid-area: fault; overflow-wrap: anywhere; }
  .orders-table [data-order-cell="deadline"] { grid-area: deadline; }
  .orders-table [data-order-cell="amount"] { grid-area: amount; text-align: end; }
  .orders-table .row-money > div { flex-wrap: wrap; gap: 0 5px; }
  #workspace .orders-table .order-row [data-order-cell="customer"] { grid-area: customer; border-block-start: 1px solid var(--border); padding-block-start: 5px; margin-block-start: 3px; }
  .orders-table :is([data-order-cell="intake"], [data-order-cell="kind"], [data-order-cell="type"]) { display: none; }
  .order-card-label { display: block; color: var(--muted); font-size: .73rem; font-weight: 600; }
}

#order-work .work-heading { align-items: end; }
#order-work .work-heading label { flex: 0 1 17rem; }
.repair-work-group {
  padding: 12px; margin-block-end: 12px; min-inline-size: 0;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.repair-work-heading { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; margin-block-end: 8px; }
.repair-work-heading label { flex: 1 1 12rem; }
.repair-work-heading h3 { margin: 0; padding: 0; border: 0; }
.repair-work-subtotal { margin: 7px 0 0; text-align: end; font-weight: 650; }
.repair-work-group .work-table { margin-block: 8px 0; }
.repair-line-actions { min-inline-size: 10rem; }
.repair-line-actions select { margin: 0 0 4px; min-block-size: 30px; }
.repair-work-group :is(output, .material-quantity) { font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .repair-work-group { padding: 9px; }
  .repair-work-heading label { flex-basis: 100%; }
}

.optional-event-comment {
  padding: 6px 10px; margin-block: 5px; border: 1px solid var(--border); border-radius: var(--radius);
}
#order-save-comment { margin-inline: 12px; }
.optional-event-comment summary { cursor: pointer; font-weight: 600; }
.event-comments { margin-block-start: 8px; padding-block-start: 6px; border-block-start: 1px solid var(--border); }
.event-note { margin-block-end: 7px; padding-inline-start: 8px; border-inline-start: 2px solid var(--control-border); }
.event-note > div { color: var(--muted); font-size: .85rem; }
.event-note p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
[data-comment-editor] button { margin-block-start: 5px; }
[data-comment-feedback]:empty, #product-history-feedback:empty { display: none; }
.product-action-modes { display: flex; flex-wrap: wrap; gap: 6px; margin-block: 8px; }
.product-action-modes [aria-pressed=true] { background: var(--active); color: var(--accent); }
.product-barcode-field { display: flex; gap: 6px; align-items: end; }
.product-barcode-field label { flex: 1; }
.stock-history { min-inline-size: 0; background: var(--subtle); border-radius: var(--radius); padding: 10px; margin-block: 10px; }
.stock-history h3 { margin: 0 0 5px; padding: 0; border: 0; }
.stock-history .history-list { max-block-size: 51dvh; overflow: auto; }
.inventory-movement { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-block: 6px; }
.inventory-catalog-scope { margin-block: 4px; color: var(--muted); }
#product-balance output { font-variant-numeric: tabular-nums; unicode-bidi: isolate; }
@media (min-width: 960px) {
  #product-dialog { width: min(1180px, 96vw); }
  .product-card-layout:has(.stock-history:not([hidden])) { display:grid; grid-template-columns:minmax(0, 1.4fr) minmax(16rem, 1fr); gap:10px; }
}

.sales-tabs { margin-block: 6px 12px; }
.sales-scanner-result { grid-column: 1/-1; display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.sales-scanner-result:not(:has(#retail-feedback:not(:empty),#retail-scan-retry:not([hidden]))) { display:none; }
.sales-scanner-result p:not(:empty) { margin:0; padding:8px 10px; border:1px solid var(--border);
  border-radius:var(--radius); background:var(--subtle); overflow-wrap:anywhere; }
.sales-history-filter { display:flex; flex-wrap:wrap; align-items:end; gap:8px; margin-block-end:8px; }
.sales-history-filter input { min-inline-size:9rem; }
#sales-history-error { margin:0; flex-basis:100%; }
#sales-history-error:empty, #sales-history-status:empty { display:none; }
.sales-history-summary { display:flex; flex-wrap:wrap; align-items:baseline; gap:6px 18px; padding:8px 0; }
.sales-history-summary p { margin:0; }
#sales-history-amount { display:inline-flex; flex-wrap:wrap; gap:9px; margin-inline-start:3px; }
.sales-history-sheet { max-block-size:65dvh; overflow:auto; }
.sales-history-table th { position:sticky; inset-block-start:0; z-index:1; }
.sales-history-table tbody tr { cursor:pointer; }
.sales-history-table tbody tr:hover, .sales-history-table tbody tr:focus-within { background:var(--active); }
.sales-history-item { white-space:normal; overflow-wrap:anywhere; }
.sales-history-ref a { font-weight:700; }
.sales-history-more { padding:4px 8px; }
.sales-history-more:has([hidden]) { display:none; }
.sales-mobile-label { display:none; }
#sales-history-detail { width:min(720px,95vw); }
#sales-history-detail-body { max-block-size:70dvh; padding-block:12px; }
#sales-history-detail-body :is(table,dl) { margin-block-end:14px; }
@media (max-width:640px) {
  .sales-scanner-result p { inline-size:100%; }
  .sales-history-filter label { flex:1 1 8rem; }
  .sales-history-filter input { min-inline-size:0; }
  .sales-history-table, .sales-history-table tbody { display:block; }
  .sales-history-table thead { position:absolute; inline-size:1px; block-size:1px; overflow:hidden; clip-path:inset(50%); }
  .sales-history-table tbody { padding:6px; }
  .sales-history-table tbody tr { display:grid; align-items:baseline; gap:4px 8px;
    grid-template-columns:minmax(0,1fr) minmax(0,1fr);
    grid-template-areas:"ref date" "products products" "seller method" "total method";
    padding:8px; margin-block-end:5px; border:1px solid var(--border); border-radius:var(--radius); }
  .sales-history-table td { border:0; padding:0; min-inline-size:0; }
  .sales-history-ref { grid-area:ref; }
  .sales-history-date { grid-area:date; text-align:end; color:var(--muted); font-size:.85rem; }
  .sales-history-products { grid-area:products; }
  .sales-history-seller { grid-area:seller; }
  .sales-history-method { grid-area:method; text-align:end; }
  .sales-history-total { grid-area:total; font-weight:700; }
  .sales-mobile-label { display:block; color:var(--muted); font-size:.8rem; }
}

.button.danger, button.danger { background:#a22131; color:#fff; }
.button.danger:hover, button.danger:not(:disabled):hover { background:#7f1926; }
[data-security-flow] p[data-security-feedback]:empty { display:none; }
[data-security-flow] p[data-security-feedback] { color:var(--danger); }

.checkout-discount-fields { display: flex; align-items: end; flex-wrap: wrap; gap: 8px; margin-block: 8px; }
.checkout-discount-fields label { flex: 1 1 8rem; min-inline-size: 0; }
.checkout-discount-fields input, .checkout-discount-fields select { inline-size: 100%; }
.checkout-discount-error { color: var(--danger); }
.cart-checkout-totals { margin-block: 8px 14px; }
.cart-checkout-totals div { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cart-checkout-totals dd { margin: 0; font-weight: 650; }
#delete-group { margin-block-end: 10px; }
#delete-group-dialog { inline-size: min(29rem, calc(100vw - 24px)); }
#delete-group-name { font-weight: 650; overflow-wrap: anywhere; }

#product-price-change { padding: 10px; margin-block-start: 10px; }
#product-price-change h3 { margin-block: 0 6px; font-size: 1rem; }
#product-price-branches { display: flex; gap: 4px 12px; flex-wrap: wrap; margin-block-end: 0; }
#product-price-branches bdi { overflow-wrap: anywhere; }
.sales-exceptions h4 { margin-block: 12px 6px; }
.sales-exception-list { margin-block: 8px; padding-inline-start: 0; list-style: none; }
.sales-exception-list li { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding-block: 8px; border-block-end: 1px solid var(--control-border); }
.sales-exception-list small { display: block; color: var(--muted); overflow-wrap: anywhere; }
.sales-exception-actions { display: flex; gap: 6px; }
.sales-exception-suggestions { display: grid; gap: 4px; max-block-size: 12rem; overflow: auto; }
.sales-exception-suggestions button { justify-content: space-between; gap: 12px; text-align: start; }
#sales-exception-dialog { inline-size: min(34rem, calc(100vw - 24px)); }

/* ==========================================================================
   Design system layer (2026-11 redesign, phase 2: base components + app shell).
   Uses only the tokens above. Later phases move page rules into this layer.
   ========================================================================== */

/* ---- Base ---- */
body { background: var(--canvas); color: var(--ink); font-size: var(--text-md); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: "CRM Arabic", "Public Sans", system-ui, sans-serif; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: clamp(22px, 2.2vw, var(--text-2xl)); }
h2 { font-size: var(--text-xl); }
a { color: var(--accent); }
::selection { background: var(--accent-soft); }

/* ---- Controls ---- */
input, select, textarea {
  min-block-size: var(--control-height); border-radius: var(--radius-sm); border-color: var(--control-border);
  transition: border-color var(--motion-fast) ease, box-shadow var(--motion-fast) ease;
}
input:hover, select:hover, textarea:hover { border-color: #c3c8d8; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px var(--ring-soft);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
button, .button {
  min-block-size: var(--control-height); border-radius: var(--radius-sm); padding: 7px 14px; font-weight: 600;
  background: var(--accent); box-shadow: 0 1px 2px rgb(76 29 149 / .18);
  transition: background-color var(--motion-fast) ease, border-color var(--motion-fast) ease, box-shadow var(--motion-fast) ease;
}
button:not(:disabled):hover, .button:hover { background: var(--accent-hover); }
.secondary, button.secondary { background: var(--surface); border-color: var(--control-border); color: var(--ink); box-shadow: var(--shadow-sm); }
.secondary:not(:disabled):hover { background: var(--subtle); border-color: #c3c8d8; }
.ghost, button.ghost { background: transparent; border-color: transparent; color: var(--muted); box-shadow: none; }
.ghost:not(:disabled):hover { background: var(--subtle); color: var(--ink); }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* ---- Surfaces ---- */
.sheet, article, .login form, .inset-panel, .card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.card { padding: var(--space-5); }
.card-title { margin: 0 0 var(--space-4); font-size: var(--text-lg); }
.page-header { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--space-3); margin-block-end: var(--space-5); }
.page-header h1 { margin: 0; }
.page-subtitle { margin: 4px 0 0; color: var(--muted); }

/* ---- Tables ---- */
table { font-size: var(--text-sm); }
th, td { padding: 10px 12px; border-block-end-color: var(--border); }
th { background: #f8f9fc; color: var(--muted); font-size: var(--text-xs); font-weight: 650; letter-spacing: .01em; }
tbody tr { transition: background-color var(--motion-fast) ease; }
tbody tr:hover > td { background: #fbfaff; }
.tabular, td.amount, .amount { font-variant-numeric: tabular-nums; }

/* ---- Status badges (stable status IDs) ---- */
.status-badge { border-radius: var(--radius-pill); font-weight: 600; }
.status-badge[data-status=accepted] { background: #eaf2ff; color: #1d4ed8; border-color: #cfe0ff; }
.status-badge[data-status=in_repair] { background: #fff1e6; color: #c2410c; border-color: #fed7b5; }
.status-badge[data-status=waiting_approval] { background: #fef8e1; color: #a16207; border-color: #f9e7a6; }
.status-badge[data-status=repaired] { background: #e8f8ee; color: #15803d; border-color: #c4ebd2; }
.status-badge[data-status=handed_over] { background: #f3edff; color: #6d28d9; border-color: #e0d2ff; }
.status-badge[data-status=not_repaired] { background: #fdeeed; color: #b42318; border-color: #f6cfcb; }

/* ---- Dialogs and tabs ---- */
dialog { border-radius: 16px; border-color: var(--border); box-shadow: var(--dialog-shadow); }
dialog::backdrop { background: rgb(17 13 46 / .45); }
.workspace-tabs { gap: var(--space-4); padding: 0 20px; background: var(--surface); }
.workspace-tabs button:not(:disabled) {
  border: 0; border-radius: 0; box-shadow: none; padding: 12px 2px; min-block-size: 0;
  border-block-end: 2px solid transparent; color: var(--muted);
}
.workspace-tabs button:not(:disabled):is(:hover, [aria-selected=true]) { background: transparent; color: var(--accent); }
.workspace-tabs button[aria-selected=true] { border-color: transparent; border-block-end-color: var(--accent); }

/* ---- Feedback components ---- */
.empty-state { display: grid; place-items: center; gap: var(--space-2); padding: var(--space-8) var(--space-4); color: var(--muted); text-align: center; }
.skeleton { display: block; border-radius: var(--radius-sm); background: linear-gradient(90deg, #eef0f6 25%, #f6f7fb 37%, #eef0f6 63%); background-size: 400% 100%; animation: skeleton 1.4s ease infinite; min-block-size: 1em; }
@keyframes skeleton { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
.toast { position: fixed; inset-block-end: var(--space-5); inset-inline-end: var(--space-5); z-index: 80; padding: 12px 16px; border-radius: var(--radius); background: var(--ink); color: white; box-shadow: var(--shadow-md); }

/* ---- App shell: layout ---- */
.app-layout { display: block; background: transparent; min-block-size: 0; }
body:has(.app-sidebar) { padding-inline-start: var(--sidebar-w); transition: padding var(--motion) var(--ease); }
.sidebar-collapsed body:has(.app-sidebar) { padding-inline-start: var(--sidebar-w-collapsed); }
main { padding: var(--space-6) var(--shell-inline); }

/* ---- App shell: top bar ---- */
.topbar {
  position: sticky; inset-block-start: 0; z-index: 30; min-block-size: var(--topbar-h);
  display: flex; align-items: center; justify-content: flex-start; gap: var(--space-3); flex-wrap: nowrap;
  padding: 10px var(--shell-inline); background: rgb(255 255 255 / .92); border-block-end: 1px solid var(--border);
}
.topbar .crm-identity { flex: 0 1 auto; flex-basis: auto; min-inline-size: 0; }
.topbar-identity { display: none; }
.topbar-menu { display: none; inline-size: 40px; block-size: 40px; padding: 0; }
.topbar-actions { display: flex; align-items: center; gap: var(--space-2); margin-inline-start: auto; }
.topbar bdi { margin: 0; }
.crm-logo { inline-size: 36px; block-size: 36px; border-radius: 11px; background: var(--nav-active); box-shadow: 0 6px 16px rgb(108 60 225 / .35); }
.crm-icon { inline-size: 20px; block-size: 20px; }

/* Disclosure menus (language, account) */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-trigger {
  display: inline-flex; align-items: center; gap: var(--space-2); min-block-size: 40px; padding: 4px 10px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--ink); font-weight: 600;
  transition: background-color var(--motion-fast) ease, border-color var(--motion-fast) ease;
}
.menu-trigger:hover { background: var(--subtle); border-color: var(--control-border); }
.menu-trigger > .crm-icon:last-child { inline-size: 16px; block-size: 16px; color: var(--faint); }
.menu[open] > .menu-trigger { border-color: var(--ring); box-shadow: 0 0 0 3px var(--ring-soft); }
.menu-panel {
  position: absolute; inset-block-start: calc(100% + 6px); inset-inline-end: 0; z-index: 60; min-inline-size: 220px;
  display: grid; gap: 2px; padding: 6px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
}
.language-current > span { display: none; }
html[lang=ar] .language-current > [lang=ar], html[lang=en] .language-current > [lang=en], html[lang=ru] .language-current > [lang=ru] { display: inline; }
.menu-panel .language { display: grid; gap: 2px; margin: 0; }
.menu-panel .language button, .menu-item {
  display: flex; align-items: center; justify-content: flex-start; gap: 10px; inline-size: 100%; min-block-size: 38px;
  padding: 8px 10px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink);
  font-size: var(--text-md); font-weight: 500; text-align: start; text-decoration: none; box-shadow: none;
}
.menu-panel .language button:not(:disabled):hover, .menu-item:hover, button.menu-item:not(:disabled):hover { background: var(--subtle); }
.menu-panel .language button[aria-pressed=true] { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.menu-item .crm-icon { color: var(--faint); }
.menu-item-danger, button.menu-item-danger { color: var(--danger); }
.menu-item-danger .crm-icon { color: currentColor; }
.user-menu form { display: block; margin: 0; padding-block-start: 4px; border-block-start: 1px solid var(--border); }
.user-trigger { padding-inline-start: 5px; border-color: transparent; background: transparent; }
.avatar {
  display: grid; place-items: center; inline-size: 32px; block-size: 32px; border-radius: 50%;
  background: var(--nav-active); color: white; font-size: 14px; font-weight: 700; flex: none;
}
.user-meta { display: grid; line-height: 1.2; text-align: start; }
.user-name { font-size: var(--text-sm); font-weight: 650; max-inline-size: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { color: var(--muted); font-size: var(--text-xs); font-weight: 500; }

/* ---- App shell: sidebar ---- */
.app-sidebar {
  position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 40; inline-size: var(--sidebar-w);
  display: flex; flex-direction: column; gap: var(--space-2); padding: 0 12px 12px; overflow-y: auto; overscroll-behavior: contain;
  background: linear-gradient(180deg, var(--nav-bg) 0%, var(--nav-bg-end) 100%); border: 0; color: var(--nav-ink);
  transition: inline-size var(--motion) var(--ease), transform var(--motion) var(--ease);
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; min-block-size: var(--topbar-h); padding: 14px 6px; margin-block-end: 6px; }
.sidebar-brand-text { display: grid; min-inline-size: 0; line-height: 1.25; }
.sidebar-brand strong { color: white; font-size: 15px; font-weight: 700; }
.sidebar-tenant { color: var(--nav-muted); font-size: var(--text-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-sidebar .crm-navigation { flex: 1 1 auto; }
.app-sidebar .nav-mobile-toggle { display: none; }
.app-sidebar nav { display: grid; grid-template-columns: minmax(0, 1fr); justify-content: stretch; gap: 4px; margin: 0; }
.app-sidebar :is(a, summary) { color: var(--nav-ink); border-radius: var(--radius); }
.app-sidebar :is(.nav-item) {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 9px 12px; min-block-size: 42px;
  font-weight: 560; transition: background-color var(--motion-fast) ease, color var(--motion-fast) ease;
}
.app-sidebar .nav-item .crm-icon { color: var(--nav-muted); }
.app-sidebar :is(a, summary):hover { background: var(--nav-hover); color: white; }
.app-sidebar :is(a, summary):hover .crm-icon { color: white; }
.app-sidebar :is(a.nav-item[aria-current=page], .sidebar-group:has([aria-current=page]) > summary) {
  background: var(--nav-active); color: white; box-shadow: 0 8px 20px rgb(108 60 225 / .35);
}
.app-sidebar :is(a.nav-item[aria-current=page], .sidebar-group:has([aria-current=page]) > summary) .crm-icon { color: white; }
.app-sidebar .nav-child {
  display: block; margin: 2px 0; margin-inline-start: 32px; padding: 7px 12px; border: 0; border-radius: var(--radius-sm);
  color: var(--nav-muted); font-size: var(--text-sm);
}
.app-sidebar nav a.nav-child[aria-current=page] { color: white; background: rgb(255 255 255 / .1); font-weight: 650; }
.sidebar-group > summary::after { opacity: .7; }
.app-sidebar :focus-visible { outline: 2px solid #b9a3ff; outline-offset: -2px; }
.sidebar-collapse {
  display: flex; align-items: center; gap: 12px; justify-content: flex-start; min-block-size: 40px; padding: 8px 12px;
  background: transparent; color: var(--nav-muted); border: 1px solid rgb(255 255 255 / .08); box-shadow: none; font-weight: 500;
}
.sidebar-collapse:not(:disabled):hover { background: var(--nav-hover); color: white; }
[dir=rtl] .sidebar-collapse .crm-icon, .sidebar-collapsed .sidebar-collapse .crm-icon { transform: scaleX(-1); }
.sidebar-collapsed[dir=rtl] .sidebar-collapse .crm-icon { transform: none; }
.sidebar-scrim { position: fixed; inset: 0; z-index: 35; background: rgb(17 13 46 / .45); }

/* Collapsed (desktop): icons only, labels as tooltips */
@media (min-width: 1024px) {
  .sidebar-collapsed .app-sidebar { inline-size: var(--sidebar-w-collapsed); padding-inline: 10px; overflow: visible; }
  .sidebar-collapsed .sidebar-brand { justify-content: center; padding-inline: 0; }
  .sidebar-collapsed :is(.sidebar-brand-text, .nav-child, .sidebar-collapse span) { display: none; }
  .sidebar-collapsed .sidebar-group > summary::after { display: none; }
  .sidebar-collapsed .app-sidebar .nav-item { justify-content: center; padding-inline: 0; }
  .sidebar-collapsed .app-sidebar .nav-item > [data-i18n] {
    position: absolute; inset-inline-start: calc(100% + 12px); z-index: 70; padding: 6px 10px; border-radius: var(--radius-sm);
    background: var(--ink); color: white; font-size: var(--text-sm); white-space: nowrap; box-shadow: var(--shadow-md);
    opacity: 0; pointer-events: none; transition: opacity var(--motion-fast) ease;
  }
  .sidebar-collapsed .app-sidebar .nav-item:is(:hover, :focus-visible) > [data-i18n] { opacity: 1; }
  .sidebar-collapsed .sidebar-collapse { justify-content: center; padding-inline: 0; }
}

/* Drawer (tablet and phone) */
@media (max-width: 1023px) {
  body:has(.app-sidebar), .sidebar-collapsed body:has(.app-sidebar) { padding-inline-start: 0; }
  .app-sidebar { transform: translateX(-100%); box-shadow: none; inline-size: min(var(--sidebar-w), 84vw); }
  [dir=rtl] .app-sidebar { transform: translateX(100%); }
  .nav-open .app-sidebar { transform: none; box-shadow: 0 0 40px rgb(17 13 46 / .4); }
  .sidebar-collapse { display: none; }
  .topbar-menu, .topbar-identity { display: flex; }
  .topbar-identity strong { font-size: var(--text-md); }
}
@media (max-width: 640px) {
  .topbar { gap: var(--space-2); padding-inline: 10px; }
  .topbar .crm-tenant, .user-meta, .language-current, .menu-trigger > .crm-icon:last-child { display: none; }
  .topbar-identity strong { max-inline-size: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .menu-trigger { padding-inline: 8px; }
  main { padding-block: var(--space-4); }
}

/* ---- Login ---- */
.login { background: radial-gradient(1200px 500px at 50% -10%, #ece6ff, transparent 60%), var(--canvas); }
.login form { box-shadow: var(--shadow-md); border-radius: 18px; }
.login-header { position: absolute; inset-inline-end: var(--shell-inline); inset-block-start: var(--space-4); }
.login-header .language button { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: none; }
.login-header .language button[aria-pressed=true] { border-color: var(--ring); color: var(--accent); background: var(--accent-soft); }

/* ---- Motion preferences ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}

/* Orders keeps its full-height layout (toolbar and summary fixed, table scrolls inside) with the fixed sidebar. */
@media (min-width: 960px) and (min-height: 620px) {
  .orders-screen > .app-layout { display: flex; flex-direction: column; }
  .orders-screen > .app-layout > #workspace { flex: 1 1 auto; }
}

/* ==========================================================================
   Dashboard (UI modernization phase 3)
   KPI cards, revenue/profit chart, status ring. Series colors validated for
   colorblind separation (dataviz validator, light surface).
   ========================================================================== */
:root {
  --chart-revenue: #6c3ce1;
  --chart-profit: #0d9488;
  --chart-grid: #eceef4;
  --chart-axis: #c9cdd9;
}
.visually-hidden { position: absolute !important; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.dashboard { gap: var(--space-5); padding-block-end: var(--space-8); }
.dashboard-header { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--space-3) var(--space-5); }
.dashboard-title h1 { margin: 0 0 4px; }
.dashboard-header .dashboard-controls { background: none; border: 0; box-shadow: none; padding: 0; gap: var(--space-2) var(--space-3); }
.dashboard-header .dashboard-controls label { display: grid; gap: 4px; color: var(--muted); font-size: var(--text-xs); font-weight: 600; }
.dashboard-header .dashboard-branch-chooser summary {
  display: inline-flex; align-items: center; min-block-size: var(--control-height); padding: 0 12px;
  border-radius: var(--radius-sm); background: var(--surface); font-weight: 600;
}
.dashboard-header .dashboard-branch-list { z-index: 20; border-radius: var(--radius); box-shadow: var(--shadow-md); }

.dashboard .card, .dashboard .card.dashboard-section { margin: 0; padding: var(--space-5); min-inline-size: 0; }
.dashboard-section h2, .card-header h2 { margin: 0 0 var(--space-4); font-size: var(--text-lg); }
.card-header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px var(--space-3); margin-block-end: var(--space-4); }
.card-header h2 { margin: 0; }
.card-subtitle { margin: 0; color: var(--muted); font-size: var(--text-xs); }
/* The chart covers a wider period than the selected one (a single day draws the week ending on it). */
.chart-period-note { flex-basis: 100%; margin: 0; padding: 6px 10px; border-radius: 8px; background: var(--accent-soft); color: var(--ink); font-size: var(--text-xs); }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: var(--space-4); margin: 0; }
.kpi-card { display: grid; align-content: start; gap: var(--space-2); margin: 0; padding: var(--space-5); }
.kpi-head { display: flex; align-items: center; gap: var(--space-3); margin-block-end: var(--space-1); }
.kpi-head h3 { margin: 0; padding: 0; border: 0; color: var(--muted); font-size: var(--text-sm); font-weight: 600; }
.kpi-icon { display: grid; place-items: center; flex: none; inline-size: 40px; block-size: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.kpi-icon .crm-icon { inline-size: 22px; block-size: 22px; }
.kpi-icon[data-kpi-icon=profit] { background: #e3f5f2; color: #0f766e; }
.kpi-icon[data-kpi-icon=retail] { background: #e8f0ff; color: #1d4ed8; }
.kpi-icon[data-kpi-icon=repairs] { background: #fff0e5; color: #c2410c; }
.kpi-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.kpi-value { margin: 0; font-size: 26px; font-weight: 700; line-height: 1.2; letter-spacing: -.01em; overflow-wrap: anywhere; }
.kpi-value bdi { display: inline; }
.kpi-value .dashboard-amount-unavailable { display: inline; font-size: var(--text-lg); }
.trend { display: inline-flex; align-items: center; gap: 2px; padding: 2px 8px 2px 6px; border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: 650; white-space: nowrap; }
.trend .crm-icon { inline-size: 14px; block-size: 14px; }
.trend[data-trend=up] { background: var(--success-surface); color: var(--success); }
.trend[data-trend=down] { background: var(--danger-surface); color: var(--danger); }
.trend[data-trend=flat] { background: var(--subtle); color: var(--muted); }
.kpi-previous { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--space-2); margin: 0; color: var(--muted); font-size: var(--text-xs); }
.kpi-previous :is(bdi, .dashboard-amount-unavailable) { display: inline; color: var(--ink); font-weight: 600; }
.kpi-compare { grid-column: 1 / -1; margin: calc(-1 * var(--space-2)) 0 0; color: var(--muted); font-size: var(--text-xs); }

/* Layout rows */
.dashboard-split, .dashboard-pair { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
@media (min-width: 1180px) {
  .dashboard-split { grid-template-columns: minmax(0, 1.85fr) minmax(320px, 1fr); }
  .dashboard-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.dashboard-pair .dashboard-collected-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dashboard-pair .dashboard-count-grid { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
.dashboard .dashboard-metric { border: 0; border-radius: var(--radius); padding: 12px; background: var(--subtle); }
.dashboard .dashboard-metric h3 { margin: 0 0 6px; color: var(--muted); font-size: var(--text-xs); font-weight: 600; }
.dashboard .dashboard-metric bdi { font-size: var(--text-lg); font-weight: 700; }
.dashboard .dashboard-metric[data-dashboard-money=collected] { background: var(--accent-soft); }

/* Revenue and owner profit chart */
.trend-chart { display: grid; gap: var(--space-3); margin: 0; container-type: inline-size; }
.trend-chart + .trend-chart { border-block-start: 1px solid var(--border); padding-block-start: var(--space-4); }
.chart-legend { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-5); color: var(--muted); font-size: var(--text-sm); }
.chart-currency { font-weight: 700; color: var(--ink); }
.legend-item { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px var(--space-2); }
.legend-item strong { color: var(--ink); font-weight: 650; }
.legend-item strong :is(bdi, .dashboard-amount-unavailable) { display: inline; }
.legend-key { flex: none; inline-size: 12px; block-size: 12px; border-radius: 3px; background: var(--chart-revenue); }
.legend-item[data-series=profit] .legend-key { inline-size: 18px; block-size: 3px; border-radius: 2px; background: var(--chart-profit); }
/* Same heights as dashboard.js draws, reserved before it runs so nothing below shifts. */
.chart-plot { position: relative; block-size: 290px; }
@container (max-width: 519px) { .chart-plot { block-size: 210px; } }
.chart-svg { display: block; max-inline-size: 100%; overflow: visible; touch-action: pan-y; }
.chart-svg:focus-visible { outline: 2px solid var(--ring); outline-offset: 4px; border-radius: 4px; }
.chart-grid { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart-baseline { stroke: var(--chart-axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart-tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-bar { fill: var(--chart-revenue); transition: opacity .15s; }
.chart-bar.is-dim { opacity: .35; }
.chart-line { fill: none; stroke: var(--chart-profit); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart-dot { fill: var(--chart-profit); stroke: var(--surface); stroke-width: 2; }
.chart-crosshair { stroke: var(--muted); stroke-opacity: .45; stroke-width: 1; }
.chart-hit { fill: transparent; cursor: crosshair; }
.chart-tooltip {
  position: absolute; z-index: 5; display: grid; gap: 4px; min-inline-size: 180px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-md);
  color: var(--muted); font-size: var(--text-xs); pointer-events: none;
}
.chart-tooltip strong { color: var(--ink); font-size: var(--text-sm); }
.chart-tooltip-row { display: flex; align-items: center; gap: var(--space-2); }
.chart-tooltip-row::before { content: ""; flex: none; inline-size: 10px; block-size: 10px; border-radius: 3px; background: var(--chart-revenue); }
.chart-tooltip-row[data-series=profit]::before { block-size: 3px; background: var(--chart-profit); }
.chart-tooltip-row bdi { margin-inline-start: auto; color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.chart-empty { margin: 0; color: var(--muted); font-size: var(--text-sm); text-align: center; }
.chart-table summary { inline-size: fit-content; color: var(--accent); cursor: pointer; font-size: var(--text-sm); font-weight: 600; }
.chart-table .sheet { max-block-size: 320px; margin-block-start: var(--space-3); overflow: auto; }
.chart-table :is(td, th) bdi { display: inline; font-variant-numeric: tabular-nums; }

/* Orders by status ring */
.donut-layout { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-5); }
.donut { position: relative; flex: none; inline-size: 168px; aspect-ratio: 1; margin-inline: auto; }
.donut svg { display: block; inline-size: 100%; block-size: 100%; }
.donut-track { fill: none; stroke: var(--subtle); stroke-width: 5.5; }
.donut-segment { fill: none; stroke-width: 5.5; transition: opacity .15s; }
.donut-segment[data-status-key=accepted] { stroke: var(--status-accepted); }
.donut-segment[data-status-key=in_repair] { stroke: var(--status-in-repair); }
.donut-segment[data-status-key=waiting_approval] { stroke: var(--status-waiting); }
.donut-segment[data-status-key=repaired] { stroke: var(--status-repaired); }
.donut-segment[data-status-key=not_repaired] { stroke: var(--status-not-repaired); }
.donut-center { position: absolute; inset: 22%; display: grid; place-content: center; justify-items: center; gap: 2px; margin: 0; text-align: center; }
.donut-center strong { font-size: 28px; font-weight: 700; line-height: 1; }
.donut-center strong bdi { display: inline; }
.donut-center span { color: var(--muted); font-size: 11px; line-height: 1.25; }
.donut-legend { display: grid; flex: 1 1 210px; gap: 2px; margin: 0; padding: 0; list-style: none; }
.donut-legend li {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto 3.4em; align-items: center; gap: var(--space-2);
  padding: 6px 8px; border-radius: var(--radius-sm); font-size: var(--text-sm); transition: opacity .15s;
}
.donut-legend li:hover { background: var(--subtle); }
.legend-dot { inline-size: 10px; block-size: 10px; border-radius: 50%; background: var(--status-handed); }
[data-status-key=accepted] > .legend-dot { background: var(--status-accepted); }
[data-status-key=in_repair] > .legend-dot { background: var(--status-in-repair); }
[data-status-key=waiting_approval] > .legend-dot { background: var(--status-waiting); }
[data-status-key=repaired] > .legend-dot { background: var(--status-repaired); }
[data-status-key=not_repaired] > .legend-dot { background: var(--status-not-repaired); }
.legend-count { font-weight: 650; font-variant-numeric: tabular-nums; }
.legend-count bdi { display: inline; }
.legend-share { color: var(--muted); font-size: var(--text-xs); text-align: end; font-variant-numeric: tabular-nums; }
.donut-legend .legend-muted { margin-block-start: 4px; padding-block-start: 10px; border-block-start: 1px solid var(--border); border-radius: 0; color: var(--muted); }
[data-donut] .is-dim { opacity: .3; }
.attention-card { display: grid; gap: var(--space-3); }
.attention-card .card-header { margin: 0; }
.attention-card .dashboard-attention { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: var(--space-3); }
@media (min-width: 900px) {
  .attention-card { grid-template-columns: minmax(150px, auto) minmax(0, 1fr); align-items: center; gap: var(--space-6); }
  .attention-card .card-header { display: grid; gap: 2px; }
}
.dashboard .dashboard-attention a.dashboard-metric {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 10px 12px;
  border: 1px solid transparent; color: var(--ink); font-weight: 550;
}
.dashboard .dashboard-attention a.dashboard-metric bdi { display: inline; color: var(--accent); font-size: var(--text-lg); }
.dashboard .dashboard-attention a[data-drill=overdue] bdi { color: var(--danger); }
.dashboard .dashboard-attention a.dashboard-metric:hover { border-color: var(--accent); background: var(--accent-soft); }

@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
  .kpi-card { padding: var(--space-3); }
  .kpi-icon { inline-size: 32px; block-size: 32px; border-radius: 10px; }
  .kpi-icon .crm-icon { inline-size: 18px; block-size: 18px; }
  .kpi-head { align-items: flex-start; flex-direction: column; gap: var(--space-2); }
  .kpi-value { font-size: 19px; }
  .dashboard .card, .dashboard .card.dashboard-section { padding: var(--space-4); }
  .donut { inline-size: 144px; }
  .dashboard-header .dashboard-controls { inline-size: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .chart-bar, .donut-segment, .donut-legend li { transition: none; }
}

/* ==========================================================================
   Orders (UI modernization phase 4)
   ========================================================================== */
.orders-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); margin-block-end: var(--space-4); }
.orders-header .orders-title { margin: 0; }
.orders-screen .orders-header { flex: none; }
.orders-header #new { flex: none; }
.orders-tools {
  padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow-sm); margin-block-end: var(--space-4);
}
.orders-tools .filters { inline-size: 100%; gap: var(--space-3); }
.orders-tools .filters label { display: grid; gap: 4px; color: var(--muted); font-size: var(--text-xs); font-weight: 600; }
.orders-screen .orders-tools .filters label { flex: 1 1 10rem; max-inline-size: 18rem; }
.search-field { position: relative; display: block; }
.search-field .crm-icon {
  position: absolute; inset-inline-start: 10px; inset-block-start: 50%; translate: 0 -50%;
  inline-size: 16px; block-size: 16px; color: var(--muted); pointer-events: none;
}
.search-field input { inline-size: 100%; padding-inline-start: 34px; }

/* Status pills carry a dot in the badge's own ink, so the state never relies on the fill alone. */
.status-badge { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.status-badge::before { content: ""; flex: none; inline-size: 6px; block-size: 6px; border-radius: 50%; background: currentColor; }
button.status-badge.row-status::after { margin-inline-start: 0; }

.orders-table [data-order-cell="number"] a { color: var(--accent); font-weight: 700; text-decoration: none; }
.orders-table [data-order-cell="number"] a:hover { text-decoration: underline; }
#workspace .orders-table td { padding: 10px 8px; vertical-align: top; }
#workspace .orders-table th { padding-inline: 8px; }
.orders-table :is([data-order-cell="model"], [data-order-cell="customer"]) > bdi:first-of-type { font-weight: 600; }
.orders-table :is(.status-badge, button.status-badge.row-status) { max-inline-size: 100%; white-space: normal; text-align: start; }
#workspace .sheet tbody tr.order-row:is(:hover, :focus-within) { background: #faf8ff; }
.orders-screen .branch-counts { border-radius: var(--radius-lg); }

@media (max-width: 760px) {
  .orders-tools { padding: var(--space-3); }
  .orders-screen .orders-tools .filters label { max-inline-size: none; }
}

/* Dashboard tiles: long labels wrap instead of clipping (e.g. Russian status names). */
.dashboard .dashboard-metric h3 { overflow-wrap: anywhere; hyphens: auto; }

/* Order workspace dialog */
#intake-fields > h3:first-child { margin-block-start: 0; padding-block-start: 0; border-block-start: 0; }
#intake-fields h3, #order-work h3 { color: var(--ink); font-size: var(--text-md); font-weight: 700; }
.history-day { border-inline-start-color: var(--border); }
.history-day-title { color: var(--muted); }
.history-day .history-event::before { background: var(--muted); }
.history-day .history-event[data-action=created]::before { background: var(--status-accepted); }
.history-day .history-event[data-action=payment]::before { background: var(--accent); }
.history-day .history-event:is([data-action=handover], [data-action=completed])::before { background: var(--status-repaired); }

/* ==========================================================================
   Sales and inventory (UI modernization phase 5)
   ========================================================================== */
.retail-groups, .retail-cart { padding: var(--space-5); }
.retail-groups h2, .retail-cart h2 { margin-block: 0 var(--space-3); font-size: var(--text-lg); }
.retail-product-button { padding: 0; min-block-size: 0; box-shadow: none; font-weight: 600; }
.retail-product-button:not(:disabled):hover { background: transparent; text-decoration: underline; }
/* Quantities and prices line up on the end edge: alignment comes from the column definition (data-align on the
   header, copied to every cell), never from the cell content or its position. */
/* Existing rule: a row is flagged when stock is below its minimum. */
.retail-catalog [data-low-stock] { background: var(--warning-surface); color: var(--ink); }
.retail-catalog [data-low-stock] td[data-col=quantity] bdi { color: var(--warning); font-weight: 700; }
.retail-catalog [data-low-stock] td[data-col=quantity] bdi::before { content: "▼ " / ""; font-size: .75em; }

/* ==========================================================================
   Finance, employees, settings, platform (UI modernization phase 6)
   ========================================================================== */
main .sheet :is(td, th) a { font-weight: 600; text-decoration: none; }
main .sheet :is(td, th) a:hover, main .sheet :is(td, th) a:focus-visible { text-decoration: underline; }
main .sheet td .row-secondary, main .sheet td small { color: var(--muted); }
.salary-totals { border-radius: var(--radius-lg); }

/* ==========================================================================
   Business modules (UI phase 7): Clients, Reports, Expenses, Order statuses, Roles, Backups
   ========================================================================== */
/* Status colours a business can choose (Settings → Order statuses). Each palette entry keeps text contrast >= 4.5:1. */
html[data-color-accepted=blue] { --st-accepted-bg: #eaf2ff; --st-accepted-fg: #1d4ed8; --st-accepted-line: #cfe0ff; --status-accepted: #2563eb; }
html[data-color-accepted=orange] { --st-accepted-bg: #fff1e6; --st-accepted-fg: #c2410c; --st-accepted-line: #fed7b5; --status-accepted: #ea580c; }
html[data-color-accepted=amber] { --st-accepted-bg: #fef8e1; --st-accepted-fg: #a16207; --st-accepted-line: #f9e7a6; --status-accepted: #d4a106; }
html[data-color-accepted=green] { --st-accepted-bg: #e8f8ee; --st-accepted-fg: #15803d; --st-accepted-line: #c4ebd2; --status-accepted: #15803d; }
html[data-color-accepted=violet] { --st-accepted-bg: #f3edff; --st-accepted-fg: #6d28d9; --st-accepted-line: #e0d2ff; --status-accepted: #7c3aed; }
html[data-color-accepted=teal] { --st-accepted-bg: #e3f5f2; --st-accepted-fg: #0f766e; --st-accepted-line: #bfe6df; --status-accepted: #0d9488; }
html[data-color-accepted=red] { --st-accepted-bg: #fdeeed; --st-accepted-fg: #b42318; --st-accepted-line: #f6cfcb; --status-accepted: #dc2626; }
html[data-color-accepted=slate] { --st-accepted-bg: #eef1f4; --st-accepted-fg: #414f62; --st-accepted-line: #dee4ec; --status-accepted: #64748b; }
html[data-color-in-repair=blue] { --st-in-repair-bg: #eaf2ff; --st-in-repair-fg: #1d4ed8; --st-in-repair-line: #cfe0ff; --status-in-repair: #2563eb; }
html[data-color-in-repair=orange] { --st-in-repair-bg: #fff1e6; --st-in-repair-fg: #c2410c; --st-in-repair-line: #fed7b5; --status-in-repair: #ea580c; }
html[data-color-in-repair=amber] { --st-in-repair-bg: #fef8e1; --st-in-repair-fg: #a16207; --st-in-repair-line: #f9e7a6; --status-in-repair: #d4a106; }
html[data-color-in-repair=green] { --st-in-repair-bg: #e8f8ee; --st-in-repair-fg: #15803d; --st-in-repair-line: #c4ebd2; --status-in-repair: #15803d; }
html[data-color-in-repair=violet] { --st-in-repair-bg: #f3edff; --st-in-repair-fg: #6d28d9; --st-in-repair-line: #e0d2ff; --status-in-repair: #7c3aed; }
html[data-color-in-repair=teal] { --st-in-repair-bg: #e3f5f2; --st-in-repair-fg: #0f766e; --st-in-repair-line: #bfe6df; --status-in-repair: #0d9488; }
html[data-color-in-repair=red] { --st-in-repair-bg: #fdeeed; --st-in-repair-fg: #b42318; --st-in-repair-line: #f6cfcb; --status-in-repair: #dc2626; }
html[data-color-in-repair=slate] { --st-in-repair-bg: #eef1f4; --st-in-repair-fg: #414f62; --st-in-repair-line: #dee4ec; --status-in-repair: #64748b; }
html[data-color-waiting-approval=blue] { --st-waiting-approval-bg: #eaf2ff; --st-waiting-approval-fg: #1d4ed8; --st-waiting-approval-line: #cfe0ff; --status-waiting: #2563eb; }
html[data-color-waiting-approval=orange] { --st-waiting-approval-bg: #fff1e6; --st-waiting-approval-fg: #c2410c; --st-waiting-approval-line: #fed7b5; --status-waiting: #ea580c; }
html[data-color-waiting-approval=amber] { --st-waiting-approval-bg: #fef8e1; --st-waiting-approval-fg: #a16207; --st-waiting-approval-line: #f9e7a6; --status-waiting: #d4a106; }
html[data-color-waiting-approval=green] { --st-waiting-approval-bg: #e8f8ee; --st-waiting-approval-fg: #15803d; --st-waiting-approval-line: #c4ebd2; --status-waiting: #15803d; }
html[data-color-waiting-approval=violet] { --st-waiting-approval-bg: #f3edff; --st-waiting-approval-fg: #6d28d9; --st-waiting-approval-line: #e0d2ff; --status-waiting: #7c3aed; }
html[data-color-waiting-approval=teal] { --st-waiting-approval-bg: #e3f5f2; --st-waiting-approval-fg: #0f766e; --st-waiting-approval-line: #bfe6df; --status-waiting: #0d9488; }
html[data-color-waiting-approval=red] { --st-waiting-approval-bg: #fdeeed; --st-waiting-approval-fg: #b42318; --st-waiting-approval-line: #f6cfcb; --status-waiting: #dc2626; }
html[data-color-waiting-approval=slate] { --st-waiting-approval-bg: #eef1f4; --st-waiting-approval-fg: #414f62; --st-waiting-approval-line: #dee4ec; --status-waiting: #64748b; }
html[data-color-repaired=blue] { --st-repaired-bg: #eaf2ff; --st-repaired-fg: #1d4ed8; --st-repaired-line: #cfe0ff; --status-repaired: #2563eb; }
html[data-color-repaired=orange] { --st-repaired-bg: #fff1e6; --st-repaired-fg: #c2410c; --st-repaired-line: #fed7b5; --status-repaired: #ea580c; }
html[data-color-repaired=amber] { --st-repaired-bg: #fef8e1; --st-repaired-fg: #a16207; --st-repaired-line: #f9e7a6; --status-repaired: #d4a106; }
html[data-color-repaired=green] { --st-repaired-bg: #e8f8ee; --st-repaired-fg: #15803d; --st-repaired-line: #c4ebd2; --status-repaired: #15803d; }
html[data-color-repaired=violet] { --st-repaired-bg: #f3edff; --st-repaired-fg: #6d28d9; --st-repaired-line: #e0d2ff; --status-repaired: #7c3aed; }
html[data-color-repaired=teal] { --st-repaired-bg: #e3f5f2; --st-repaired-fg: #0f766e; --st-repaired-line: #bfe6df; --status-repaired: #0d9488; }
html[data-color-repaired=red] { --st-repaired-bg: #fdeeed; --st-repaired-fg: #b42318; --st-repaired-line: #f6cfcb; --status-repaired: #dc2626; }
html[data-color-repaired=slate] { --st-repaired-bg: #eef1f4; --st-repaired-fg: #414f62; --st-repaired-line: #dee4ec; --status-repaired: #64748b; }
html[data-color-handed-over=blue] { --st-handed-over-bg: #eaf2ff; --st-handed-over-fg: #1d4ed8; --st-handed-over-line: #cfe0ff; --status-handed: #2563eb; }
html[data-color-handed-over=orange] { --st-handed-over-bg: #fff1e6; --st-handed-over-fg: #c2410c; --st-handed-over-line: #fed7b5; --status-handed: #ea580c; }
html[data-color-handed-over=amber] { --st-handed-over-bg: #fef8e1; --st-handed-over-fg: #a16207; --st-handed-over-line: #f9e7a6; --status-handed: #d4a106; }
html[data-color-handed-over=green] { --st-handed-over-bg: #e8f8ee; --st-handed-over-fg: #15803d; --st-handed-over-line: #c4ebd2; --status-handed: #15803d; }
html[data-color-handed-over=violet] { --st-handed-over-bg: #f3edff; --st-handed-over-fg: #6d28d9; --st-handed-over-line: #e0d2ff; --status-handed: #7c3aed; }
html[data-color-handed-over=teal] { --st-handed-over-bg: #e3f5f2; --st-handed-over-fg: #0f766e; --st-handed-over-line: #bfe6df; --status-handed: #0d9488; }
html[data-color-handed-over=red] { --st-handed-over-bg: #fdeeed; --st-handed-over-fg: #b42318; --st-handed-over-line: #f6cfcb; --status-handed: #dc2626; }
html[data-color-handed-over=slate] { --st-handed-over-bg: #eef1f4; --st-handed-over-fg: #414f62; --st-handed-over-line: #dee4ec; --status-handed: #64748b; }
html[data-color-accepted] .status-badge[data-status=accepted] { background: var(--st-accepted-bg); color: var(--st-accepted-fg); border-color: var(--st-accepted-line); }
html[data-color-in-repair] .status-badge[data-status=in_repair] { background: var(--st-in-repair-bg); color: var(--st-in-repair-fg); border-color: var(--st-in-repair-line); }
html[data-color-waiting-approval] .status-badge[data-status=waiting_approval] { background: var(--st-waiting-approval-bg); color: var(--st-waiting-approval-fg); border-color: var(--st-waiting-approval-line); }
html[data-color-repaired] .status-badge[data-status=repaired] { background: var(--st-repaired-bg); color: var(--st-repaired-fg); border-color: var(--st-repaired-line); }
html[data-color-handed-over] .status-badge[data-status=handed_over] { background: var(--st-handed-over-bg); color: var(--st-handed-over-fg); border-color: var(--st-handed-over-line); }
html[data-color-not-repaired=blue] { --st-not-repaired-bg: #eaf2ff; --st-not-repaired-fg: #1d4ed8; --st-not-repaired-line: #cfe0ff; --status-not-repaired: #2563eb; }
html[data-color-not-repaired=orange] { --st-not-repaired-bg: #fff1e6; --st-not-repaired-fg: #c2410c; --st-not-repaired-line: #fed7b5; --status-not-repaired: #ea580c; }
html[data-color-not-repaired=amber] { --st-not-repaired-bg: #fef8e1; --st-not-repaired-fg: #a16207; --st-not-repaired-line: #f9e7a6; --status-not-repaired: #d4a106; }
html[data-color-not-repaired=green] { --st-not-repaired-bg: #e8f8ee; --st-not-repaired-fg: #15803d; --st-not-repaired-line: #c4ebd2; --status-not-repaired: #15803d; }
html[data-color-not-repaired=violet] { --st-not-repaired-bg: #f3edff; --st-not-repaired-fg: #6d28d9; --st-not-repaired-line: #e0d2ff; --status-not-repaired: #7c3aed; }
html[data-color-not-repaired=teal] { --st-not-repaired-bg: #e3f5f2; --st-not-repaired-fg: #0f766e; --st-not-repaired-line: #bfe6df; --status-not-repaired: #0d9488; }
html[data-color-not-repaired=red] { --st-not-repaired-bg: #fdeeed; --st-not-repaired-fg: #b42318; --st-not-repaired-line: #f6cfcb; --status-not-repaired: #dc2626; }
html[data-color-not-repaired=slate] { --st-not-repaired-bg: #eef1f4; --st-not-repaired-fg: #414f62; --st-not-repaired-line: #dee4ec; --status-not-repaired: #64748b; }
html[data-color-not-repaired] .status-badge[data-status=not_repaired] { background: var(--st-not-repaired-bg); color: var(--st-not-repaired-fg); border-color: var(--st-not-repaired-line); }

/* Module pages */
.module-page { display: grid; gap: var(--space-5); align-content: start; padding-block-end: var(--space-8); min-inline-size: 0; }
.module-page .page-header { margin: 0; }
.module-page .card { margin: 0; padding: var(--space-5); min-inline-size: 0; }
.module-page .card > h2 { margin: 0 0 var(--space-4); font-size: var(--text-lg); }
.module-intro { margin: 0; max-inline-size: 70ch; color: var(--muted); }
.back-link { inline-size: fit-content; font-size: var(--text-sm); font-weight: 600; text-decoration: none; }
.back-link::before { content: "← "; }
[dir=rtl] .back-link::before { content: "→ "; }
.module-toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-3); }
.module-search { display: grid; flex: 1 1 18rem; gap: 4px; max-inline-size: 28rem; color: var(--muted); font-size: var(--text-xs); font-weight: 600; }
.module-table { inline-size: 100%; }
.module-table :is(th, td).num { text-align: end; font-variant-numeric: tabular-nums; }
.module-table td.num bdi[data-amount] { display: block; }
.module-table tbody th { font-weight: 600; }
.module-table tbody th .row-secondary { display: block; font-weight: 400; }
.module-pager { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-block-start: var(--space-3); }
.module-pager:empty { display: none; }
.module-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: var(--space-4); }
.kpi-label { margin: 0 0 var(--space-2); padding: 0; border: 0; color: var(--muted); font-size: var(--text-sm); font-weight: 600; }
.module-fact { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.kpi-value-sm { font-size: var(--text-xl); }
.module-form { gap: var(--space-3) var(--space-4); }
.module-form label { display: grid; gap: 4px; color: var(--muted); font-size: var(--text-xs); font-weight: 600; }
.module-form button[type=submit] { justify-self: start; align-self: end; }
.module-danger { margin-block-start: var(--space-4); padding-block-start: var(--space-4); border-block-start: 1px solid var(--border); }
button.danger { background: var(--danger); }
button.danger:not(:disabled):hover { background: #9f2a22; }
.form-error { margin: 0; color: var(--danger); font-weight: 600; }
.form-success { margin: 0; color: var(--success); font-weight: 600; }
.module-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.module-history { display: grid; gap: var(--space-2); margin: 0; padding-inline-start: var(--space-5); }
.module-history .row-secondary { display: block; color: var(--muted); font-size: var(--text-xs); }
.category-list { display: grid; gap: var(--space-2); margin: 0 0 var(--space-4); padding: 0; list-style: none; }
.category-row { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-2); }
.category-row input { flex: 1 1 14rem; max-inline-size: 22rem; }
.category-row label { display: grid; gap: 4px; flex: 1 1 14rem; max-inline-size: 22rem; color: var(--muted); font-size: var(--text-xs); font-weight: 600; }
.category-list .is-archived input { color: var(--muted); text-decoration: line-through; }
.status-settings { display: grid; gap: var(--space-4); }
.status-row { border: 1px solid var(--border); }
.status-row legend { padding-inline: 4px; }
.status-row-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: var(--space-3); }
.status-row-fields label { display: grid; gap: 4px; color: var(--muted); font-size: var(--text-xs); font-weight: 600; }
.access-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: 650; white-space: nowrap; }
.access-pill::before { content: ""; inline-size: 6px; block-size: 6px; border-radius: 50%; background: currentColor; }
.access-pill[data-access=all] { background: var(--success-surface); color: var(--success); }
.access-pill:is([data-access=assigned], [data-access=own]) { background: var(--accent-soft); color: var(--accent); }
.access-pill[data-access=none] { background: var(--subtle); color: var(--muted); }
.report-tabs { display: flex; flex-wrap: wrap; gap: var(--space-4); padding: 0; border-block-end: 1px solid var(--border); background: none; }
.report-tabs a { padding: 8px 2px; border-block-end: 2px solid transparent; color: var(--muted); font-weight: 600; text-decoration: none; }
.report-tabs a[aria-current=page] { border-block-end-color: var(--accent); color: var(--accent); }
.report-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.report-actions .button { display: inline-flex; align-items: center; gap: 6px; }
.report-actions .crm-icon { inline-size: 16px; block-size: 16px; }
.net-result { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: var(--space-3); margin: var(--space-4) 0 0; }
.net-result > div { padding: 12px; border-radius: var(--radius); background: var(--subtle); }
.net-result dt { color: var(--muted); font-size: var(--text-xs); font-weight: 600; }
.net-result dd { margin: 4px 0 0; font-size: var(--text-lg); font-weight: 700; }
.net-result .net-total { background: var(--accent-soft); }
@media print {
  .app-sidebar, .topbar, .sidebar-scrim, .dashboard-controls, .report-tabs, .report-actions, .subscription-notice { display: none !important; }
  body:has(.app-sidebar) { padding-inline-start: 0 !important; }
  .report-page .card { box-shadow: none; border: 0; padding: 0; }
  .report-page .sheet { overflow: visible; max-block-size: none; }
}
.platform-search { margin-block: var(--space-3); }
.platform-count { margin: 0; margin-inline-start: auto; color: var(--muted); font-size: var(--text-sm); }

/* ==========================================================================
   Intake and payment windows (UI phase 4 follow-up)
   ========================================================================== */
#intake-fields { padding-block-start: var(--space-4); }
#intake-fields h3 { display: flex; align-items: center; gap: var(--space-2); }
#intake-fields h3::before { content: ""; flex: none; inline-size: 4px; block-size: 1.1em; border-radius: 2px; background: var(--accent); }
#intake-fields fieldset.wide { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); }
#intake-fields fieldset.wide legend { padding-inline: 4px; color: var(--muted); font-size: var(--text-xs); font-weight: 650; }
#payment-dialog .payment-body { display: grid; gap: var(--space-4); }
#payment-dialog .payment-quote { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: var(--space-3); margin: 0; }
#payment-dialog .payment-quote > div { display: grid; gap: 2px; }
#payment-dialog .payment-quote dt { color: var(--muted); font-size: var(--text-xs); font-weight: 600; }
#payment-dialog .payment-quote dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
#payment-dialog .payment-quote > div:last-child { grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between;
  padding: 12px 14px; border-radius: var(--radius); background: var(--accent-soft); }
#payment-dialog .payment-quote > div:last-child dt { color: var(--ink); font-size: var(--text-md); font-weight: 650; }
#payment-dialog .payment-quote > div:last-child dd { font-size: var(--text-2xl); font-weight: 750; }
#payment-dialog .payment-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 120px), 1fr)); gap: var(--space-2); }
#payment-dialog .payment-options label { justify-content: center; min-block-size: 48px; font-weight: 650; }
#payment-dialog #payment-methods { margin: 0; }

/* ==========================================================================
   Dark theme (account menu → Dark theme; cookie crm_theme, rendered server-side)
   ========================================================================== */
html[data-theme=dark] {
  color-scheme: dark;
  --canvas: #0e1016; --surface: #161922; --subtle: #1d212c; --sidebar: #161922; --border: #2a2f3c; --control-border: #3a4051;
  --ink: #e6e8f0; --muted: #a3aabd; --faint: #6d7488;
  --accent: #8467f0; --accent-hover: #9479f5; --accent-soft: #272144; --active: #272144; --ring: #a08bff; --ring-soft: rgb(160 139 255 / .3);
  --success: #4ade80; --success-surface: #11301e; --success-border: #1f5a37;
  --warning: #fbbf24; --warning-surface: #33270d; --danger: #f87171; --danger-surface: #3a1717;
  --info: #60a5fa; --info-surface: #13243d;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .45); --shadow-md: 0 8px 24px rgb(0 0 0 / .55); --dialog-shadow: 0 20px 60px rgb(0 0 0 / .65);
  --chart-revenue: #8467f0; --chart-profit: #2dd4bf; --chart-grid: #262b37; --chart-axis: #3b4152;
}
html[data-theme=dark] a { color: #b3a1ff; }
html[data-theme=dark] :is(input, select, textarea) { background-color: var(--surface); color: var(--ink); }
.theme-to-light, html[data-theme=dark] .theme-to-dark { display: none; }
html[data-theme=dark] .theme-to-light { display: inline; }
html[data-theme=dark] .topbar { background: rgb(22 25 34 / .94); }
html[data-theme=dark] :is(.menu-trigger, .menu-panel) { background: var(--surface); color: var(--ink); }
/* ===== Dark theme (generated) ===== tests/dark_overrides.py remaps literal colours of older rules. */
html[data-theme=dark] .history-label { color: #bbd3dd; }
html[data-theme=dark] .history-pair + .history-pair { border-block-start: 1px solid #313434; }
html[data-theme=dark] .autocomplete-list { background: #161616; }
html[data-theme=dark] .status-menu { border: 1px solid #3f4e4c; background: #161616; }
html[data-theme=dark] .history-line + .history-line { border-block-start: 1px solid #333b3a; }
html[data-theme=dark] #historical-charge-notice { color: #e3bd91; }
html[data-theme=dark] #order-work[data-cost-conflict=true] #work-charge-display, html[data-theme=dark] #order-work[data-cost-conflict=true] #work-cost, html[data-theme=dark] #order-work[data-cost-conflict=true] #work-profit { color: #ffa090; }
html[data-theme=dark] .history-day { border-inline-start: 1px solid #3c4e48; }
html[data-theme=dark] #salary-period-error { color: #ffa196; }
html[data-theme=dark] .salary-credit { color: #a8dcc9; }
html[data-theme=dark] .salary-empty { background: #161616; }
html[data-theme=dark] [data-plan=expiring] { color: #e3ba85; }
html[data-theme=dark] .subscription-notice { border: 1px solid #544100; background: #261f0a; color: #eed4ae; }
html[data-theme=dark] .subscription-notice[data-state=expired], html[data-theme=dark] .subscription-notice[data-state=archived] { color: #ffb2a6; background: #33251d; border-color: #644036; }
html[data-theme=dark] input:hover, html[data-theme=dark] select:hover, html[data-theme=dark] textarea:hover { border-color: #40434d; }
html[data-theme=dark] .secondary:not(:disabled):hover { border-color: #40434d; }
html[data-theme=dark] th { background: #1b1b1d; }
html[data-theme=dark] tbody tr:hover > td { background: #1a191c; }
html[data-theme=dark] .status-badge[data-status=accepted] { background: #1e232b; color: #84bcff; border-color: #303a4e; }
html[data-theme=dark] .status-badge[data-status=in_repair] { background: #271e17; color: #ff936f; border-color: #4d341d; }
html[data-theme=dark] .status-badge[data-status=waiting_approval] { background: #211d0d; color: #e4aa6e; border-color: #423601; }
html[data-theme=dark] .status-badge[data-status=repaired] { background: #19241d; color: #81d093; border-color: #264131; }
html[data-theme=dark] .status-badge[data-status=handed_over] { background: #25212d; color: #c7a3ff; border-color: #403653; }
html[data-theme=dark] .status-badge[data-status=not_repaired] { background: #2d1d1d; color: #ffaaa3; border-color: #533232; }
html[data-theme=dark] .kpi-icon[data-kpi-icon=profit] { background: #1a2624; color: #85cdc5; }
html[data-theme=dark] .kpi-icon[data-kpi-icon=retail] { background: #1f242e; color: #84bcff; }
html[data-theme=dark] .kpi-icon[data-kpi-icon=repairs] { background: #281f18; color: #ff936f; }
html[data-theme=dark] #workspace .sheet tbody tr.order-row:is(:hover, html[data-theme=dark] :focus-within) { background: #1c1a1f; }

/* Customer identity: phone match and name confirmation in the order form (customers.lookup). */
.customer-match { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--control-border); border-radius: var(--radius); background: var(--subtle); }
.customer-match[hidden] { display: none; }
.customer-match p { margin: 0; }
#customer-match-text { font-weight: 600; }
.customer-match-note { color: var(--muted); font-size: var(--text-sm); }
.customer-conflict { display: grid; gap: 8px; padding-block-start: 8px; border-block-start: 1px solid var(--border); }
.customer-conflict[hidden] { display: none; }
.customer-conflict-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.customer-conflict-actions button { white-space: normal; text-align: start; }

/* Client profile: edit form, history timeline, duplicate review. */
.client-duplicate-notice { margin: 0; padding: 10px 14px; border-inline-start: 3px solid var(--accent); }
.client-edit { padding: 12px 16px; }
.client-edit > summary { cursor: pointer; font-weight: 600; }
.client-edit-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-block-start: 12px; }
.client-edit-form :is(.dashboard-note, .module-actions) { grid-column: 1/-1; margin: 0; }
.client-history { padding: 16px; }
.client-history h2 { margin: 0 0 8px; font-size: var(--text-lg); }
.client-timeline { list-style: none; margin: 0; padding: 0; border-inline-start: 2px solid var(--border); }
.client-event { position: relative; padding: 4px 0 12px; padding-inline-start: 16px; }
.client-event::before {
  content: ""; position: absolute; inset-inline-start: -6px; inset-block-start: 9px; inline-size: 10px; block-size: 10px;
  border-radius: 50%; background: var(--accent);
}
.client-event[data-event=merged]::before { background: var(--muted); }
.client-event p { margin: 2px 0; }
.client-change bdi { font-weight: 600; }
[dir=rtl] .change-arrow { display: inline-block; transform: scaleX(-1); }
.client-imported { color: var(--muted); font-size: var(--text-sm); }
.client-imported-badge {
  display: inline-block; margin-inline-end: 6px; padding: 1px 8px; border-radius: var(--radius-pill);
  background: var(--subtle); border: 1px solid var(--border); color: var(--ink); font-size: var(--text-xs); font-weight: 600;
}
.duplicate-group { display: grid; gap: 12px; padding: 16px; }
.duplicate-group h2 { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; font-size: var(--text-lg); }
.duplicate-group fieldset { margin: 0; padding: 0; border: 0; min-inline-size: 0; }
.duplicate-group legend { margin-block-end: 6px; font-weight: 600; }
.duplicate-flag { padding: 2px 8px; border-radius: var(--radius-pill); background: var(--danger-surface); color: var(--danger); font-size: var(--text-xs); }
.duplicate-names { display: grid; gap: 4px; max-block-size: 14rem; overflow: auto; }
.radio-row { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.phone-settings { display: grid; gap: 12px; max-inline-size: 36rem; padding: 16px; }
/* Business time zone settings (D39). */
.timezone-settings { display: grid; gap: 12px; max-inline-size: 44rem; padding: 16px; }
.timezone-settings label { display: grid; gap: 6px; }
.timezone-settings select[size] { min-block-size: 16rem; padding: 4px; font-variant-numeric: tabular-nums; }
.timezone-settings select[size] option { padding: 6px 8px; border-radius: 6px; }
.timezone-current { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 8px 16px; margin: 0; }
.timezone-current dt { color: var(--muted); font-size: var(--text-xs); }
.timezone-current dd { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; margin: 2px 0 0; font-weight: 600; }
.timezone-offset, .timezone-name { color: var(--muted); font-weight: 400; }
.timezone-preview { margin: 0; padding: 8px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--ink); }
.timezone-preview:empty { display: none; }
.timezone-history { margin-block-start: 16px; padding: 16px; max-inline-size: 44rem; }
@media (max-width: 760px) {
  .client-edit-form { grid-template-columns: minmax(0, 1fr); }
}

/* Not repaired outcome: confirmation and refund dialogs, workspace panel, list flag (repair_outcome.py). */
.outcome-dialog { inline-size: min(36rem, calc(100vw - 32px)); }
.outcome-body { display: grid; gap: 12px; }
.outcome-body textarea { inline-size: 100%; resize: vertical; }
.outcome-body fieldset { margin: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); min-inline-size: 0; }
.outcome-body fieldset fieldset { border: 0; padding: 0; }
.outcome-warning { display: grid; gap: 8px; padding: 10px 12px; border-radius: var(--radius); background: var(--danger-surface); color: var(--danger); }
.outcome-warning p { margin: 0; font-weight: 600; }
.outcome-note { margin: 0; color: var(--muted); font-size: var(--text-sm); }
.check-row { display: flex; align-items: flex-start; gap: 8px; font-weight: 500; }
.check-row input { margin-block-start: 3px; flex: none; }
.confirm-row { padding: 10px 12px; border: 1px solid var(--control-border); border-radius: var(--radius); background: var(--subtle); }
.outcome-panel { display: grid; gap: 8px; margin-block: 8px; padding: 12px 14px; border: 1px solid var(--border);
  border-inline-start: 3px solid var(--status-not-repaired); border-radius: var(--radius); background: var(--surface); }
.outcome-panel h3 { margin: 0; }
.outcome-panel dl { margin: 0; }
.outcome-flag { display: inline-block; margin-block-start: 4px; padding: 1px 8px; border-radius: var(--radius-pill);
  background: var(--danger-surface); color: var(--danger); font-size: var(--text-xs); font-weight: 600; white-space: nowrap; }
.payment-refund { margin: 0; padding: 10px 12px; border: 1px solid var(--control-border); border-radius: var(--radius); display: grid; gap: 8px; }
.payment-refund legend { font-weight: 600; }
.history-day .history-event[data-action=not_repaired]::before { background: var(--status-not-repaired); }
.history-day .history-event[data-action=refund]::before { background: var(--status-handed); }

/* Branch lifecycle (D40). */
.branch-table td { vertical-align: middle; }
.branch-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.branch-actions button { min-block-size: 34px; padding-block: 4px; }
.danger-text { color: var(--danger); }
.branch-archived-tag, .branch-active-tag { display: inline-block; padding: 2px 8px; border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: 600; }
.branch-archived-tag { background: var(--subtle, #eef0f6); color: var(--muted); }
.branch-active-tag { background: var(--success-surface); color: var(--success); }
.branch-dialog { width: min(520px, 96vw); }
.branch-dialog form > :not(header, footer) { margin-inline: 20px; }
.branch-dialog footer { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.branch-dependencies { margin-block: 0; padding-inline-start: 20px; }
.branch-feedback:empty { display: none; }
.branch-feedback { color: var(--danger); }
.branch-history-list { margin: 0; padding-inline-start: 18px; display: grid; gap: 4px; font-size: var(--text-sm); }

/* Business branding (D41): custom logo image, monogram when the logo is hidden, coloured name segments. The colours
   come from the per-business stylesheet as --brand-on-light / --brand-on-dark (each ≥ 4.5:1 on its surface). */
.crm-logo.has-image { inline-size: auto; min-inline-size: 36px; max-inline-size: 132px; padding: 0; background: transparent; box-shadow: none; border-radius: 8px; }
.crm-logo.has-image .crm-icon { display: none; }
.brand-logo { display: block; block-size: 36px; inline-size: auto; max-inline-size: 132px; object-fit: contain; }
.brand-monogram { font-size: 17px; font-weight: 800; color: white; }
:is(.sidebar-brand, .topbar-identity, .login-brand).brand-no-logo .brand-monogram { display: none; }
.sidebar-collapsed .sidebar-brand.brand-no-logo .brand-monogram { display: grid; }
.sidebar-collapsed .crm-logo.has-image, .sidebar-collapsed .brand-logo { max-inline-size: 52px; }
.brand-name { overflow-wrap: anywhere; }
.brand-seg { color: var(--brand-on-light, inherit); }
.app-sidebar .brand-seg, html[data-theme=dark] .brand-seg { color: var(--brand-on-dark, inherit); }
.login-brand-text { display: grid; line-height: 1.25; }
.login-tenant { color: var(--muted); font-size: var(--text-xs); font-weight: 400; }

/* Branding editor (Super Admin). */
.branding-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.branding-form { display: grid; gap: 14px; padding: 16px; }
.branding-group { display: grid; gap: 10px; margin: 0; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.branding-group legend { padding-inline: 4px; font-weight: 700; }
.branding-group label { display: grid; gap: 4px; }
.branding-group label.radio-row { display: flex; }
.branding-inline { display: flex; gap: 8px; align-items: center; }
.branding-inline input:not([type=color]) { flex: 1 1 auto; min-inline-size: 0; }
.branding-logo-current { display: flex; align-items: center; gap: 12px; }
.branding-logo-box { display: grid; place-items: center; min-inline-size: 56px; block-size: 56px; padding: 6px; border-radius: 12px;
  background: linear-gradient(180deg, var(--nav-bg) 0%, var(--nav-bg-end) 100%); color: white; }
.branding-logo-box img { block-size: 44px; inline-size: auto; max-inline-size: 180px; object-fit: contain; }
.branding-segments { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.branding-segment { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 8px; align-items: end;
  padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.branding-segment-default { grid-column: 1 / -1; }
.branding-segment-actions { display: flex; gap: 4px; }
.branding-segment-actions button { inline-size: 34px; block-size: 34px; padding: 0; }
.branding-color input[type=color] { inline-size: 42px; block-size: 34px; padding: 2px; }
.branding-contrast { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: var(--text-xs); }
.branding-feedback:empty { display: none; }
.branding-feedback { margin: 0; color: var(--danger); }
#branding-logo-feedback { color: var(--muted); }
.branding-preview { display: grid; gap: 8px; padding: 16px; position: sticky; inset-block-start: calc(var(--topbar-h) + 12px); }
.branding-preview h2 { margin: 0; font-size: var(--text-lg); }
.branding-preview .dashboard-note { margin: 4px 0 0; }
.branding-preview-sidebar { padding: 14px 12px; border-radius: var(--radius); color: var(--nav-ink, white);
  background: linear-gradient(180deg, var(--nav-bg) 0%, var(--nav-bg-end) 100%); }
.branding-preview-sidebar strong { color: white; }
.branding-preview-collapsed { inline-size: 76px; display: grid; place-items: center; overflow: hidden; }
.branding-preview-collapsed :is(.crm-logo.has-image, .brand-logo) { max-inline-size: 52px; min-inline-size: 0; }
.branding-preview-header { padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; color: #1b1f33; }
.branding-preview-dark { background: #161922; border-color: #2a2f3c; color: #e6e8f0; }
.branding-preview-brand { display: flex; align-items: center; gap: 10px; min-inline-size: 0; flex-wrap: wrap; }
.branding-preview-brand .sidebar-brand-text { display: grid; }
.branding-preview-header .crm-tenant { color: #6d7488; font-size: var(--text-xs); }
.branding-preview .crm-logo[hidden] { display: none; }
.branding-summary { display: grid; gap: 8px; justify-items: start; }
@media (max-width: 900px) {
  .branding-layout { grid-template-columns: minmax(0, 1fr); }
  .branding-preview { position: static; }
  .branding-segment { grid-template-columns: minmax(0, 1fr); }
}

/* Sales commission methods, financial access and owner-profit protection (D42) */
.access-pill[data-access=granted] { background: var(--warning-surface); color: var(--warning); }
.finance-access { display: grid; gap: 8px; padding: 12px 14px; }
.finance-access legend { font-weight: 650; padding-inline: 4px; }
.finance-access-intro { margin: 0; color: var(--muted); }
.finance-warning { margin: 4px 0 0; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--subtle); color: var(--muted); }
.finance-warning.finance-warning-active { background: var(--warning-surface); color: var(--ink); border-inline-start: 3px solid var(--warning); }
.profit-conflict-panel, [data-profit-conflicts] { display: grid; gap: 8px; }
.profit-conflict-panel[hidden], [data-profit-conflicts][hidden] { display: none; }
.profit-conflicts { margin: 0; padding-inline-start: 18px; display: grid; gap: 4px; }
.profit-conflicts li { overflow-wrap: anywhere; }
.profit-conflict-panel .profit-conflicts, [data-profit-conflicts] .profit-conflicts {
  padding: 10px 12px 10px 28px; border-radius: var(--radius-sm); background: var(--danger-surface); color: var(--ink);
}
[dir=rtl] .profit-conflict-panel .profit-conflicts, [dir=rtl] [data-profit-conflicts] .profit-conflicts { padding: 10px 28px 10px 12px; }
.product-gross-profit { margin: 6px 0 0; color: var(--muted); font-weight: 600; }
.sales-line-figures { margin-block: 12px; }
.sales-line-figures h3 { margin: 0 0 6px; font-size: var(--text-sm, 14px); }
.sales-line-figures table { inline-size: 100%; border-collapse: collapse; }
.sales-line-figures :is(th, td) { padding: 6px 8px; border-block-end: 1px solid var(--border); text-align: start; }
.profit-table td, .profit-table th { vertical-align: top; }

/* ==========================================================================
   Shared data-table layout (Orders, Stock on Hand / Sales catalog, Sales history)
   One column definition per table: <col data-col> sets the width, the header cell declares data-col and data-align,
   and body cells carry the same attributes (server templates, or alignTableRow() for rows built in the browser).
   table-layout: fixed means widths come from that definition, not from the longest text loaded so far, so columns
   no longer move when the language, the loaded rows or a long name/model/fault changes. Below the table's minimum
   width the sheet scrolls horizontally (header and rows are one table, so they always scroll together).
   ========================================================================== */
.data-table { inline-size: 100%; }
.data-table td { overflow-wrap: anywhere; }
.data-table th { white-space: normal; overflow-wrap: break-word; }  /* between words; inside a word only if it can never fit */
:is(th, td)[data-align=end] { text-align: end; }
td[data-align=end] { font-variant-numeric: tabular-nums; }
.data-table .column-filter-group { min-inline-size: 0; }
.data-table .column-filter { max-inline-size: 100%; white-space: normal; flex-wrap: wrap; row-gap: 2px; }
@media (min-width: 761px) {
  .data-table { table-layout: fixed; min-inline-size: var(--table-min-size, 0); }
  .orders-table { --table-min-size: 70rem; }
  .orders-table col[data-col=number] { width: 8%; }
  .orders-table col[data-col=status] { width: 11%; }
  .orders-table col[data-col=deadline] { width: 9%; }
  .orders-table col[data-col=intake] { width: 10%; }
  .orders-table col[data-col=kind] { width: 8%; }
  .orders-table col[data-col=type] { width: 10%; }
  .orders-table col[data-col=model] { width: 12%; }
  .orders-table col[data-col=fault] { width: 10%; }
  .orders-table col[data-col=customer] { width: 12%; }
  .orders-table col[data-col=amount] { width: 10%; }
  .catalog-table[data-mode=stock] { --table-min-size: 44rem; }
  .catalog-table[data-mode=stock] col[data-col=name] { width: 27%; }
  .catalog-table[data-mode=stock] col[data-col=code] { width: 13%; }
  .catalog-table[data-mode=stock] col[data-col=group] { width: 15%; }
  .catalog-table[data-mode=stock] :is(col[data-col=quantity], col[data-col=minimum], col[data-col=price]) { width: 15%; }
  .catalog-table[data-mode=sales] { --table-min-size: 26rem; }
  .catalog-table[data-mode=sales] col[data-col=name] { width: 44%; }
  .catalog-table[data-mode=sales] col[data-col=code] { width: 20%; }
  .catalog-table[data-mode=sales] :is(col[data-col=quantity], col[data-col=price]) { width: 18%; }
  .sales-history-table { --table-min-size: 44rem; }
  .sales-history-table col[data-col=ref] { width: 9%; }
  .sales-history-table col[data-col=date] { width: 17%; }
  .sales-history-table col[data-col=seller] { width: 15%; }
  .sales-history-table col[data-col=products] { width: 31%; }
  .sales-history-table col[data-col=total] { width: 15%; }
  .sales-history-table col[data-col=method] { width: 13%; }
}

/* Salary: the commission breakdown of each sale opens on demand (collapsed by default) with its own chevron. */
.salary-breakdown-toggle > summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; }
.salary-breakdown-toggle > summary::-webkit-details-marker { display: none; }
.salary-breakdown-toggle > summary::before {
  content: ""; inline-size: 7px; block-size: 7px; border-inline-end: 2px solid currentColor; border-block-end: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform var(--motion-fast) ease;
}
[dir=rtl] .salary-breakdown-toggle > summary::before { transform: rotate(135deg); }
.salary-breakdown-toggle[open] > summary::before { transform: rotate(45deg); }
.salary-list-scroll { max-block-size: min(50dvh, 26rem); }
/* Card layouts on small screens have no columns. */
@media (max-width: 760px) { .orders-table colgroup { display: none; } }
@media (max-width: 640px) { .sales-history-table colgroup { display: none; } }

/* Finance → My Repairs (D45): owner's personal repair breakdown; reuses the Salary list and Dashboard KPI styles. */
.my-repairs .kpi-grid { margin-block: var(--space-4); }
.my-repairs .kpi-note { margin: 0; color: var(--muted); font-size: .85rem; }
.my-repairs-scroll { max-block-size: min(60dvh, 34rem); }
.my-repairs-scroll td { vertical-align: top; }
.my-repairs-work { min-inline-size: 12rem; }
.my-repairs-state small, .my-repairs-deduction { display: block; margin-block-start: 2px; font-size: .8rem; }
.my-repairs-state .outcome-flag { display: inline-block; margin-inline-start: 4px; }

/* Work lines with their own price and technician; settled figures after handover (D46). */
.repair-work-heading [data-work-price] input { inline-size: 9rem; max-inline-size: 100%; }
.repair-work-heading .work-tech { inline-size: 14rem; max-inline-size: 100%; }
.work-settlement { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 6px 0 0; font-size: .85rem; }
.work-settlement div { display: flex; gap: 6px; align-items: baseline; }
.work-settlement dt { margin: 0; }
.work-settlement dd { margin: 0; font-weight: 600; }
#work-final-notice { margin-block: 8px; }

/* Work and materials — compact table (D47): work rows with nested, collapsible material rows and a summary below. */
.work-toolbar { display: grid; grid-template-columns: minmax(11rem, 15rem) minmax(0, 1fr); align-items: end; gap: 12px 18px; margin-block-end: 12px; }
.work-toolbar #work-correct-order { grid-column: 1 / -1; justify-self: start; }
.work-tech-select { display: grid; gap: 4px; margin: 0; }
.work-tech-select select { margin: 0; }
.work-add { display: grid; gap: 4px; min-inline-size: 0; }
.work-add-row { display: flex; align-items: center; gap: 8px; }
@media (max-width: 700px) { .work-toolbar { grid-template-columns: 1fr; } .work-add-row { flex-wrap: wrap; } }
.work-add-field { flex: 1 1 14rem; display: flex; align-items: center; gap: 6px; padding-inline: 10px;
  border: 1px solid var(--control-border); border-radius: 8px; background: var(--surface); }
.work-add-field input { flex: 1; min-inline-size: 0; margin: 0; border: 0; background: transparent; box-shadow: none; }
.work-add-field .crm-icon { color: var(--muted); flex: none; }
.work-add-button { background: var(--accent); color: #fff; border-color: var(--accent); display: inline-grid; place-items: center; }
.work-add-or { color: var(--muted); font-size: .9rem; }
.work-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.work-lines { inline-size: 100%; min-inline-size: 820px; border-collapse: collapse; table-layout: fixed; font-size: .9rem; }
.work-col-toggle { inline-size: 36px; } .work-col-qty { inline-size: 64px; } .work-col-warranty { inline-size: 106px; }
.work-col-price { inline-size: 104px; } .work-col-total { inline-size: 100px; } .work-col-cost { inline-size: 108px; }
.work-col-actions { inline-size: 72px; }
.work-lines th { white-space: normal; line-height: 1.2; vertical-align: bottom; overflow-wrap: anywhere; padding: 8px 6px; background: var(--subtle); color: var(--muted); font-size: .78rem; font-weight: 600; text-align: start; }
.work-lines td { padding: 6px; border-block-start: 1px solid var(--border); vertical-align: middle; }
.work-lines .num { text-align: end; }
.work-lines input, .work-lines select { inline-size: 100%; min-block-size: 32px; margin: 0; padding: 4px 6px; }
.work-lines input[type=number] { text-align: end; }
.work-lines[data-costs="false"] .work-cost-col { display: none; }
.work-row .work-name { font-weight: 600; }
.work-tech-line { display: block; margin-block-start: 3px; color: var(--muted); font-size: .78rem; }
.work-tech-line select { margin-block-start: 4px; }
.work-lines button.work-toggle { inline-size: 26px; block-size: 26px; min-block-size: 26px; padding: 0; display: inline-grid; place-items: center;
  border-radius: 6px; background: var(--accent-soft); color: var(--accent); border: 1px solid transparent; }
.work-lines button.work-toggle[aria-expanded="true"] { background: var(--accent); color: #fff; }
.work-toggle .crm-icon { inline-size: 15px; block-size: 15px; }
.work-group[data-expanded="true"] .work-row td { background: var(--accent-soft); }
.work-materials-head td, .material-row td { background: var(--subtle); border-block-start: 1px dashed var(--border); }
.work-materials-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: .82rem; }
.material-name-cell { padding-inline-start: 14px !important; white-space: nowrap; }
.material-name-cell > * { vertical-align: middle; }
.material-name-cell input, .material-name-cell bdi { display: inline-block; inline-size: calc(100% - 40px); white-space: normal; }
.material-branch { display: inline-block; inline-size: 10px; block-size: 12px; margin-block-start: -10px;
  border-inline-start: 1px solid var(--muted); border-block-end: 1px solid var(--muted); }
.material-name-cell .crm-icon { inline-size: 15px; block-size: 15px; color: var(--muted); }
.material-cost-tag { display: block; color: var(--muted); font-size: .68rem; text-align: end; }
.work-lines .muted { color: var(--muted); }
.work-actions { text-align: end; white-space: nowrap; }
.work-lines button.icon-button { inline-size: 30px; block-size: 30px; min-block-size: 30px; padding: 0; display: inline-grid;
  place-items: center; background: transparent; border: 1px solid transparent; color: var(--muted); }
.work-lines button.icon-button:hover { border-color: var(--border); color: var(--ink); }
.work-lines button.danger-icon, .work-lines button.danger-icon:hover { color: var(--danger); }
.work-lines [data-move-material] { font-size: .78rem; }
.material-move-cell { color: var(--muted); }
.work-tech-line [data-correct-tech] { margin-block-start: 4px; }
.work-lines .work-settlement { margin-block-start: 4px; }
.work-empty { padding: 12px; color: var(--muted); text-align: center; }
.work-summary dl.work-totals { grid-template-columns: 1fr; }
.work-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 12px 32px;
  margin-block: 14px 6px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.work-totals { display: grid; gap: 6px; margin: 0; align-content: start; }
.work-totals > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.work-totals dt { margin: 0; color: var(--muted); }
.work-totals dd { margin: 0; text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.work-settlement dd { white-space: nowrap; }
.work-grand { padding-block-start: 6px; border-block-start: 1px solid var(--border); }
.work-grand dt, .work-grand dd { color: var(--ink); font-weight: 700; }
.work-profit { color: var(--success); font-weight: 700; }
.work-note { margin: 0 0 8px; color: var(--muted); font-size: .78rem; }

/* D48: server-side autocomplete (static/autocomplete.js) and the single material field (inventory or manual). */
.suggest-list { position: fixed; z-index: 1000; margin: 0; padding: 4px; list-style: none; overflow-y: auto;
  background: var(--surface); color: var(--ink); border: 1px solid var(--control-border); border-radius: 10px;
  box-shadow: var(--shadow-md); font-size: .9rem; }
.suggest-list[hidden] { display: none; }
.suggest-option { display: grid; gap: 2px; padding: 7px 10px; border-radius: 7px; cursor: pointer; text-align: start; }
.suggest-option[aria-selected="true"], .suggest-option:hover { background: var(--accent-soft); }
.suggest-option[aria-disabled="true"] { cursor: not-allowed; opacity: .65; }
.suggest-name { overflow-wrap: anywhere; font-weight: 600; }
.suggest-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--muted); font-size: .78rem; }
.suggest-warning { color: var(--danger); }
.suggest-custom { color: var(--accent); font-weight: 600; overflow-wrap: anywhere; }
.suggest-state { padding: 7px 10px; color: var(--muted); font-size: .82rem; }
.suggest-error { color: var(--danger); }
.material-name-cell .material-name-field { display: inline-block; inline-size: calc(100% - 40px); white-space: normal; }
.material-name-cell .material-name-field input { display: block; inline-size: 100%; }
.material-source { display: flex; flex-wrap: wrap; gap: 2px 8px; margin-block-start: 2px; font-size: .7rem; color: var(--muted); }
.material-source bdi { display: inline; inline-size: auto; }
.material-row.is-inventory .material-source [data-material-source] { color: var(--success); font-weight: 600; }
.work-references .work-reference-edit { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
.work-references .work-reference-edit label { flex: 1 1 200px; }
.work-reference-builtin details { padding-block: 4px; border-block-end: 1px solid var(--border); }
.work-reference-builtin summary { cursor: pointer; font-weight: 600; }
.work-reference-builtin ul { columns: 2 260px; margin-block: 6px; }

/* D49: document logo in Settings → Documents. */
.document-logo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.document-logo-preview { display: grid; place-items: center; inline-size: 220px; min-block-size: 80px; padding: 10px;
  border: 1px dashed var(--control-border); border-radius: 10px; background: #fff; }
.document-logo-preview img { max-inline-size: 200px; max-block-size: 72px; object-fit: contain; }
.document-logo-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.document-logo-pick { position: relative; cursor: pointer; }
.document-logo-pick:focus-within { outline: 2px solid var(--ring); outline-offset: 2px; }
.document-settings > form { min-inline-size: 0; }  /* the A4 sample preview scrolls inside its frame on phones */
