/* Zemavo ERP — © 2026 Zemavo Technology — zemavo.com — جميع الحقوق محفوظة */


.sidebar .brand { text-decoration: none; }
.sidebar .brand:hover { text-decoration: none; }
.sidebar .brand-text { display: flex; flex-direction: column; line-height: 1.2; color: var(--ink-tx); }
.sidebar .brand-text b { letter-spacing: .18em; font-size: 1.05rem; }
.sidebar .brand-text small { color: var(--ink-muted); font-size: var(--fs-xs); font-weight: 600; margin-top: 2px; }
.sidebar-foot { margin-top: auto; padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--ink-bd); display: flex; flex-direction: column; font-size: var(--fs-xs); color: var(--ink-tx); }
.sidebar-foot .muted { color: var(--ink-muted); }
.nav-link .ic { flex-shrink: 0; opacity: .9; }
.ic { flex-shrink: 0; vertical-align: middle; }
.btn .ic { margin: 0; }
.btn.icon-only { padding: 7px; }

form.inline { display: inline; }
.right { text-align: end; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.w-100 { width: 100%; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: var(--sp-2); } .mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--sp-2); } .mb-4 { margin-bottom: var(--sp-4); }
.gap-2 { gap: var(--sp-2); }
.pos { color: var(--ok-tx); }
.neg { color: var(--no-tx); }
.num, td.num, th.num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.code-chip { font-family: ui-monospace, Menlo, monospace; direction: ltr; unicode-bidi: embed; background: var(--surface-2); border: 1px solid var(--border); padding: 0 8px; border-radius: 6px; font-size: var(--fs-sm); white-space: nowrap; }
.flash { margin-bottom: var(--sp-4); }
.divider-v { width: 1px; align-self: stretch; background: var(--border); }
.section-title { font-size: var(--fs-md); font-weight: 800; margin: 0 0 var(--sp-3); font-family: var(--font-display); }
hr.sep { border: none; border-top: 1px solid var(--border); margin: var(--sp-4) 0; }
.table td.actions { white-space: nowrap; text-align: end; }
.table td.actions .btn, .table td.actions form { margin-inline-start: 4px; }
.table tfoot td { font-weight: 800; background: var(--surface-2); border-top: 2px solid var(--border-strong); }
.table.compact th, .table.compact td { padding: 6px 10px; }
.table tr.muted-row td { opacity: .55; }
.table tr.group-row td { font-weight: 800; background: var(--surface-2); }

.filters { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: flex-end; padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); }
.filters .field { min-width: 150px; flex: 1 1 150px; max-width: 260px; }
.filters .field.wide { max-width: 360px; flex-basis: 260px; }
.filters .actions { display: flex; gap: var(--sp-2); }

.stat .icon-wrap { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-tint); color: var(--brand-text); }
.stat-row { display: flex; align-items: flex-start; gap: var(--sp-3); }
.stat-row > div:first-child { flex: 1; min-width: 0; }
.stat .value small { font-size: var(--fs-sm); color: var(--text-muted); font-weight: 600; }
.stat.ok .icon-wrap { background: var(--ok-bg); color: var(--ok-tx); }
.stat.no .icon-wrap { background: var(--no-bg); color: var(--no-tx); }
.stat.info .icon-wrap { background: var(--info-bg); color: var(--info-tx); }
.stat.warn .icon-wrap { background: var(--warn-bg); color: var(--warn-tx); }

.bars { display: flex; align-items: flex-end; gap: 10px; height: 220px; padding: var(--sp-4) var(--sp-2) 0; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.bars .b .col { width: 100%; max-width: 46px; display: flex; gap: 3px; align-items: flex-end; height: 100%; }
.bars .b .bar-s, .bars .b .bar-p { flex: 1; border-radius: 6px 6px 2px 2px; min-height: 2px; transition: height .5s; }
.bars .b .bar-s { background: linear-gradient(180deg, var(--brand), var(--brand-dark)); }
.bars .b .bar-p { background: var(--border-strong); opacity: .6; }
.bars .b span { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.legend { display: flex; gap: var(--sp-4); font-size: var(--fs-sm); color: var(--text-muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: middle; }

.doc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--sp-4); }
.lines-table { width: 100%; border-collapse: collapse; }
.lines-table th { font-size: var(--fs-sm); color: var(--text-muted); font-weight: 700; padding: 8px; background: var(--surface-2); border-bottom: 1px solid var(--border); text-align: start; white-space: nowrap; }
.lines-table td { padding: 6px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.lines-table .input { padding: 6px 8px; }
.lines-table td.idx { color: var(--text-muted); width: 36px; text-align: center; }
.lines-table .c-qty { width: 100px; } .lines-table .c-price { width: 120px; } .lines-table .c-disc { width: 100px; } .lines-table .c-total { width: 130px; }
.lines-table .c-act { width: 44px; text-align: center; }
.lines-table .line-total { font-weight: 800; text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lines-table .item-meta { font-size: var(--fs-xs); color: var(--text-muted); }
.lines-table .stock-warn { color: var(--no-tx); font-weight: 700; }
.scan-bar { display: flex; gap: var(--sp-2); align-items: center; padding: var(--sp-3) var(--sp-5); border-bottom: 1px solid var(--border); background: var(--brand-tint); }
.scan-bar .input { max-width: 520px; }
.totals-box { display: grid; grid-template-columns: 1fr auto; gap: 6px 18px; align-items: center; min-width: 300px; }
.totals-box .lbl { color: var(--text-muted); font-weight: 600; }
.totals-box .val { font-weight: 800; text-align: end; font-variant-numeric: tabular-nums; }
.totals-box .val .input { width: 140px; text-align: end; }
.totals-box .grand { font-size: var(--fs-xl); color: var(--brand-text); }
.totals-box .sep { grid-column: 1 / -1; border-top: 1px dashed var(--border-strong); }
.doc-foot { display: flex; flex-wrap: wrap; gap: var(--sp-5); justify-content: space-between; align-items: flex-start; padding: var(--sp-5); }
.doc-foot .notes { flex: 1 1 320px; }
.sticky-actions { position: sticky; bottom: 0; z-index: 10; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--border); padding: var(--sp-3) var(--sp-5); display: flex; gap: var(--sp-2); justify-content: flex-end; border-radius: 0 0 var(--r) var(--r); }
kbd { font-family: inherit; font-size: 11px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; color: var(--text-muted); background: var(--surface); }

.ac-wrap { position: relative; }
.ac-list { position: absolute; z-index: 60; top: calc(100% + 4px); inset-inline: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); box-shadow: var(--shadow-lg); max-height: 320px; overflow-y: auto; min-width: 320px; }
.ac-item { display: flex; gap: var(--sp-3); align-items: center; padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.active { background: var(--row-hover); }
.ac-item .grow { flex: 1; min-width: 0; }
.ac-item .t { font-weight: 700; }
.ac-item .s { font-size: var(--fs-xs); color: var(--text-muted); }
.ac-empty { padding: 12px; color: var(--text-muted); text-align: center; }

.palette-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; background: rgba(5, 6, 11, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); padding-inline: var(--sp-4); }
.palette-backdrop[hidden], .menu-panel[hidden], .modal-backdrop[hidden], [hidden] { display: none !important; }
.palette-row { display: flex; gap: 10px; align-items: center; }
.palette-row .tag { margin-inline-start: auto; }
.palette-row:hover { background: var(--surface-2); text-decoration: none; }

.tree td.name { padding-inline-start: calc(14px + var(--lvl, 0) * 22px); }
.tree tr.is-group td.name { font-weight: 800; }
.tree tr.lvl-0 td { background: var(--surface-2); }

.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--sp-2) var(--sp-4); }

.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-4); }
.report-tile { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-4); border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); color: var(--text); transition: border-color var(--dur), transform var(--dur), box-shadow var(--dur); }
.report-tile:hover { border-color: var(--brand-bd); transform: translateY(-2px); box-shadow: var(--shadow-lg); text-decoration: none; }
.report-tile .icon-wrap { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-tint); color: var(--brand-text); flex-shrink: 0; }
.report-tile b { display: block; }
.report-tile span { font-size: var(--fs-sm); color: var(--text-muted); }

.labels { display: grid; grid-template-columns: repeat(var(--cols, 3), 1fr); gap: 8px; }
.labels .label { border: 1px dashed var(--border-strong); border-radius: 6px; padding: 6px 8px; text-align: center; background: #fff; color: #000; break-inside: avoid; page-break-inside: avoid; }
.labels .label .ln { font-size: 11px; font-weight: 700; line-height: 1.3; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.labels .label .lp { font-size: 13px; font-weight: 800; }
.labels .label svg { width: 100%; height: 46px; display: block; }
.labels .label .lc { font-family: ui-monospace, Menlo, monospace; font-size: 10px; letter-spacing: 1px; direction: ltr; }

.doc-page { background: var(--surface); }
.print-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-4); padding-bottom: var(--sp-3); border-bottom: 3px solid var(--brand); margin-bottom: var(--sp-4); }
.print-co { display: flex; gap: var(--sp-3); align-items: center; }
.print-co h2 { font-size: var(--fs-xl); }
.print-logo { max-height: 70px; max-width: 160px; object-fit: contain; }
.print-doc { text-align: end; }
.print-doc .doc-title { font-size: var(--fs-xl); font-weight: 900; font-family: var(--font-display); color: var(--brand-text); }
.doc-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-4); }
.doc-meta .box { border: 1px solid var(--border); border-radius: var(--r-sm); padding: var(--sp-3); }
.doc-meta .box h4 { margin: 0 0 4px; font-size: var(--fs-xs); color: var(--text-muted); }
.words { padding: var(--sp-2) var(--sp-3); background: var(--surface-2); border-radius: var(--r-sm); font-weight: 700; margin-top: var(--sp-3); }
.signs { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-6); margin-top: 48px; text-align: center; }
.signs div { border-top: 1px solid var(--border-strong); padding-top: 6px; color: var(--text-muted); font-size: var(--fs-sm); }
.powered { text-align: center; font-size: 10px; color: var(--text-muted); margin-top: var(--sp-5); }
.stamp { display: inline-block; border: 2px solid var(--no-tx); color: var(--no-tx); padding: 2px 14px; border-radius: 8px; font-weight: 900; transform: rotate(-6deg); }

@media print {
  @page { size: A4; margin: 12mm; }
  html, body { background: #fff !important; color: #000 !important; }
  :root { --surface: #fff; --surface-2: #f3f4f7; --text: #000; --border: #cfd4dd; }
  .sidebar, .topbar, .no-print, .toasts, .scrim, .flash, .page-head .row, .filters .actions, .pager { display: none !important; }
  .shell, .main { display: block !important; }
  .content { padding: 0 !important; max-width: none !important; }
  .card { box-shadow: none !important; border: none !important; }
  .card-body { padding: 0 !important; }
  .table th { background: #f3f4f7 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-head, .bar-s, .labels .label { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-only { display: block !important; }
  a { color: #000 !important; text-decoration: none !important; }
  .labels .label { border-color: #bbb; }
  .filters { border: none; padding: 0 0 8px; }
  .filters .input { border: none; padding: 0; background: none; }
}

.receipt { width: 80mm; margin: 0 auto; font-size: 12px; color: #000; background: #fff; padding: 4mm; }
.receipt h2 { font-size: 16px; text-align: center; margin: 0; }
.receipt .c { text-align: center; }
.receipt table { width: 100%; border-collapse: collapse; }
.receipt td, .receipt th { padding: 2px 0; font-size: 11px; }
.receipt .line { border-top: 1px dashed #000; margin: 4px 0; }

.install-card { width: min(640px, 100%); }

@media (max-width: 700px) {
  .lines-table thead { display: none; }
  .lines-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .lines-table td { border: none; padding: 2px; }
  .lines-table td.c-item { grid-column: 1 / -1; }
  .lines-table td.idx { display: none; }
  .totals-box { min-width: 0; width: 100%; }
  .kv { grid-template-columns: 120px 1fr; }
}

.pager { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; padding: var(--sp-4); border-top: 1px solid var(--border); }
.pager a { min-width: 34px; height: 34px; display: inline-grid; place-items: center; padding: 0 10px; border: 1px solid var(--border); border-radius: 10px; color: var(--text-2); font-weight: 700; font-variant-numeric: tabular-nums; transition: all var(--dur); }
.pager a:hover { border-color: var(--brand-bd); background: var(--brand-tint); text-decoration: none; }
.pager a.active { background: linear-gradient(135deg, var(--brand), var(--brand-light)); border-color: transparent; color: var(--on-brand); box-shadow: var(--shadow-brand); }
.pager .dots { padding: 0 6px; color: var(--text-muted); align-self: center; }
.progress { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.progress.sm { height: 6px; margin: 0 0 2px; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-light)); border-radius: inherit; transition: width .6s; }

* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--text-muted) 40%, transparent) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--text-muted) 35%, transparent); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: color-mix(in srgb, var(--brand) 60%, transparent); }
.sidebar { scrollbar-color: rgba(255,255,255,.12) transparent; }
.sidebar::-webkit-scrollbar-thumb { background-color: rgba(255,255,255,.12); }
::selection { background: color-mix(in srgb, var(--brand) 30%, transparent); }

.sidebar { background:
    radial-gradient(420px 260px at 100% 0%, color-mix(in srgb, var(--brand) 13%, transparent), transparent 70%),
    linear-gradient(180deg, var(--ink) 0%, color-mix(in srgb, var(--ink) 92%, #1a1f27) 100%); }
.sidebar .brand { position: sticky; top: 0; z-index: 2; padding: var(--sp-5) var(--sp-5) var(--sp-4);
    background: linear-gradient(180deg, var(--ink) 75%, transparent); }
.sidebar .brand img { width: 40px; height: 40px; padding: 6px; border-radius: 12px; background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.08); box-shadow: 0 6px 22px color-mix(in srgb, var(--brand) 25%, transparent); }
.nav-group { padding: 2px var(--sp-3); }
.nav-group h4 { font-size: 11px; letter-spacing: .02em; color: color-mix(in srgb, var(--ink-muted) 85%, transparent); margin-top: var(--sp-4); display: flex; align-items: center; gap: 8px; }
.nav-group h4::after { content: ''; flex: 1; height: 1px; background: var(--ink-bd); }
.nav-link { font-weight: 600; color: color-mix(in srgb, var(--ink-tx) 88%, transparent); padding: 7px 12px; margin: 1px 0; transition: background var(--dur), color var(--dur), transform var(--dur); }
.nav-link:hover { color: #fff; transform: translateX(-2px); }
[dir="ltr"] .nav-link:hover { transform: translateX(2px); }
.nav-link .ic { color: var(--ink-muted); transition: color var(--dur); }
.nav-link:hover .ic { color: color-mix(in srgb, var(--brand) 70%, white); }
.nav-link.active { background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--brand) 20%, transparent)); color: #fff; }
.nav-link.active .ic { color: var(--brand); filter: drop-shadow(0 0 6px color-mix(in srgb, var(--brand) 60%, transparent)); }
.sidebar-foot { background: rgba(255,255,255,.02); }

.topbar { background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); }
.search-btn { min-width: 280px; justify-content: flex-start; border-radius: 12px; }
.search-btn kbd { margin-inline-start: auto; }
@media (max-width: 900px) { .search-btn { min-width: 0; } }

.content { max-width: 1520px; margin-inline: auto; }
.main { background:
    radial-gradient(900px 400px at 0% 0%, color-mix(in srgb, var(--brand) 5%, transparent), transparent 60%), var(--bg); }

.card { border-radius: 18px; }
.card-head { background: linear-gradient(180deg, var(--surface-2), transparent); border-radius: 18px 18px 0 0; }
.card-head h2, .card-head h3 { display: flex; align-items: center; gap: 8px; }
.card-head h2 .ic, .card-head h3 .ic { color: var(--brand); }

.stat { transition: transform 220ms var(--ease), box-shadow 240ms var(--ease), border-color 240ms; }
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--brand-bd); }
.stat .label { font-size: var(--fs-sm); }
.stat .value { font-family: var(--font-display); font-weight: 900; letter-spacing: -.01em; margin-top: 2px; }
.stat .icon-wrap { width: 46px; height: 46px; border-radius: 14px; position: relative; z-index: 1;
    background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 22%, transparent), color-mix(in srgb, var(--brand) 6%, transparent));
    box-shadow: inset 0 0 0 1px var(--brand-bd); }
.stat.ok .icon-wrap { background: linear-gradient(135deg, var(--ok-bg), transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ok-tx) 30%, transparent); }
.stat.no .icon-wrap { background: linear-gradient(135deg, var(--no-bg), transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--no-tx) 30%, transparent); }
.stat.info .icon-wrap { background: linear-gradient(135deg, var(--info-bg), transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--info-tx) 30%, transparent); }
.stat.warn .icon-wrap { background: linear-gradient(135deg, var(--warn-bg), transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn-tx) 30%, transparent); }
.stat .hint { margin-top: 2px; }

.table-wrap { border-radius: 0 0 18px 18px; }
.card > .table-wrap:first-child { border-radius: 18px; }
.table th { position: sticky; top: 0; z-index: 1; font-size: 12px; letter-spacing: .01em; text-transform: none; }
.table td { font-size: var(--fs-base); }
.table tbody tr { position: relative; }
.table tbody tr.clickable:hover td:first-child, .table tbody tr[data-href]:hover td:first-child { box-shadow: inset -3px 0 0 var(--brand); }
[dir="ltr"] .table tbody tr.clickable:hover td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
.table tbody tr[data-href] { cursor: pointer; }
.table tfoot td { font-family: var(--font-display); }
.code-chip { background: var(--brand-tint); border-color: var(--brand-bd); color: var(--brand-text); font-weight: 700; }

.badge { padding: 2px 10px; letter-spacing: .01em; }
.badge.ok::before, .badge.warn::before, .badge.no::before, .badge.info::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }

.input, select.input { min-height: 40px; }
.lines-table .input, .totals-box .input { min-height: 36px; }
.input:hover:not(:focus) { border-color: var(--border-strong); }
select.input { appearance: none; -webkit-appearance: none; padding-inline-end: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23959DAE' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 12px center; }
[dir="ltr"] select.input { background-position: right 12px center; }
.field label { font-size: 12.5px; }
.filters { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.scan-bar { background: linear-gradient(90deg, var(--brand-tint), transparent); }
.scan-bar .ic { color: var(--brand); }

.totals-box { padding: var(--sp-4) var(--sp-5); border: 1px solid var(--border); border-radius: 16px; background: var(--surface-2); }
.totals-box .grand { font-family: var(--font-display); font-weight: 900; font-size: 1.6rem; }

.bars { position: relative; height: 240px; background: repeating-linear-gradient(0deg, transparent 0 47px, var(--border) 47px 48px); border-bottom: 1px solid var(--border-strong); padding-bottom: 0; }
.bars .b { position: relative; }
.bars .b .bar-s { box-shadow: 0 -4px 14px color-mix(in srgb, var(--brand) 30%, transparent); }
.bars .b:hover .bar-s { filter: brightness(1.1); }
.bars .b span { transform: translateY(20px); position: absolute; bottom: 0; }
.bars-wrap { padding-bottom: 26px; }

.empty-state .ic { color: var(--brand); opacity: .8; padding: 14px; width: 64px; height: 64px; border-radius: 20px; background: var(--brand-tint); }

@keyframes zr-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.content > .card, .content > form.card, .content > .grid, .content > .page-head { animation: zr-rise 380ms var(--ease-out, ease-out) both; }
.content > .card:nth-of-type(2) { animation-delay: 60ms; }
.content > .card:nth-of-type(3) { animation-delay: 120ms; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.toast { border-radius: 14px; padding: 12px 18px; }

:root[data-theme="dark"] .code-chip { color: color-mix(in srgb, var(--brand) 70%, white); }
:root[data-theme="dark"] .totals-box { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
:root[data-theme="dark"] .labels .label { background: #fff; color: #000; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1180px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .grid-4 { grid-template-columns: minmax(0, 1fr); } }
.bars { margin-bottom: 28px; }
.bars .b span { white-space: nowrap; }
.grid-stats { grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); }
@media (max-width: 1180px) { .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .grid-stats { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) { .scrim { display: none; } .sidebar.open + .scrim { display: block; } }
@media (max-width: 520px) {
  .grid-4, .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
  .stat { padding: var(--sp-3); }
  .stat .value { font-size: 1.15rem; }
  .stat .icon-wrap { width: 34px; height: 34px; border-radius: 10px; }
  .stat .icon-wrap .ic { width: 16px; height: 16px; }
  .stat .hint { display: none; }
  .hero { padding: var(--sp-4); }
  .hero h1 { font-size: var(--fs-xl); }
  .hero-tile { padding: 8px 12px; font-size: var(--fs-sm); }
  .page-head .row { width: 100%; }
  .page-head .row .btn { flex: 1; }
}
.row > .grow { flex: 1; min-width: 0; }
.doc-grid { grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); }
.form-grid { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.sticky-actions { flex-wrap: wrap; }
@media (max-width: 600px) {
  .doc-grid, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .doc-grid > *, .form-grid > * { grid-column: auto !important; }
  .sticky-actions { padding: var(--sp-3); }
  .sticky-actions .btn { flex: 1 1 calc(50% - var(--sp-2)); justify-content: center; }
  .sticky-actions .btn.primary { flex-basis: 100%; order: -1; }
}
@media (max-width: 900px) {
  .toasts { top: calc(64px + env(safe-area-inset-top, 0px)); bottom: auto; inset-inline: var(--sp-3); align-items: center; }
  .toast { max-width: 100%; }
}
.nowrap, .table td.num, .code-chip { white-space: nowrap; }
.row.nowrap { flex-wrap: nowrap; }
@media (max-width: 600px) {
  .btn { min-height: 40px; }
  .btn.sm { min-height: 36px; min-width: 36px; padding-inline: 12px; }
  .search-btn { min-height: 40px; min-width: 40px; justify-content: center; }
  .input, select.input, textarea.input, .content input:not([type=checkbox]):not([type=radio]), .content select, .content textarea { font-size: 16px; }
  .page-head .row .btn.primary { flex-basis: 100%; order: -1; }
  .page-head .row .btn { white-space: nowrap; }
}
@media (pointer: coarse) and (max-width: 900px) {
  .btn.sm { min-height: 36px; }
  .nav-link { min-height: 42px; }
}
.doc-meta { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.table-wrap.table-auto { border-radius: 0; max-width: 100%; }
.scan-bar > .ac-wrap, .scan-bar > .input { flex: 1 1 auto; min-width: 0; max-width: 520px; }
.scan-bar > .ac-wrap > .input { width: 100%; max-width: none; }
@media (max-width: 600px) { .scan-bar { padding: var(--sp-3); } }
.mono-input { font-size: 12px; }
@media (max-width: 600px) { .mono-input { font-size: 16px; } }
@media screen and (min-width: 1800px) { .content { max-width: 1680px; } }
@media screen and (min-width: 2300px) { html { font-size: 112.5%; } :root { --sidebar-w: 288px; } .content { max-width: 1960px; } }
@media screen and (min-width: 3200px) { html { font-size: 125%; } .content { max-width: 2300px; } }
@media (max-width: 700px) {
  .lines-table td[data-label] { display: flex; flex-direction: column; gap: 2px; justify-content: flex-end; }
  .lines-table td[data-label]::before { content: attr(data-label); font-size: var(--fs-xs); color: var(--text-muted); font-weight: 700; }
  .lines-table td.line-total { font-weight: 800; }
}
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
.import-steps { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.import-steps span { padding: 6px 14px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); font-size: var(--fs-sm); font-weight: 700; }
.import-steps span.active { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.import-steps span.done { background: var(--ok-bg); border-color: transparent; color: var(--ok-tx); }
.import-file { max-width: 460px; width: 100%; }
.import-notes { margin: 0; padding-inline-start: 18px; display: grid; gap: 4px; }
.import-preview td { white-space: nowrap; }
.import-preview td.imp-status { white-space: normal; min-width: 220px; }
.import-preview tr.imp-bad td { background: var(--no-bg); }
.imp-errs { margin: 0; padding-inline-start: 16px; color: var(--no-tx); font-size: var(--fs-xs); font-weight: 700; display: grid; gap: 2px; }
.alert .ic { vertical-align: -3px; }
@media (max-width: 600px) {
  .mcards-wrap { overflow: visible; padding: var(--sp-3); }
  .table.mcards, .table.mcards tbody, .table.mcards tr, .table.mcards td,
  .import-preview, .import-preview tbody, .import-preview tr, .import-preview td,
  .import-cols, .import-cols tbody, .import-cols tr, .import-cols td { display: block; width: 100%; }
  .table.mcards thead, .import-preview thead, .import-cols thead { display: none; }
  .table.mcards tr, .import-preview tr, .import-cols tr { border: 1px solid var(--border); border-radius: 14px; margin: 0 0 var(--sp-3); padding: var(--sp-2) var(--sp-3); background: var(--surface); }
  .import-preview, .import-cols { padding: var(--sp-3); }
  .table.mcards tbody tr td, .table.mcards tbody tr:nth-child(even) td, .table.mcards tbody tr:hover td,
  .import-preview tbody tr td, .import-preview tbody tr:nth-child(even) td, .import-preview tbody tr:hover td,
  .import-cols tbody tr td, .import-cols tbody tr:nth-child(even) td, .import-cols tbody tr:hover td { background: transparent; }
  .import-preview tr.imp-bad { border-color: var(--no-solid); background: var(--no-bg); }
  .table.mcards td, .import-preview td, .import-cols td { border: 0; padding: 6px 0; min-height: 32px; display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); text-align: start; white-space: normal; min-width: 0; overflow-wrap: anywhere; }
  .table.mcards td::before, .import-preview td::before, .import-cols td::before { content: attr(data-label); flex: 0 0 auto; max-width: 48%; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 700; }
  .table.mcards td.mc-title { display: block; font-size: var(--fs-md); padding-bottom: var(--sp-2); margin-bottom: var(--sp-1); border-bottom: 1px dashed var(--border); }
  .table.mcards td.mc-title::before { display: none; }
  .table.mcards td.mc-title .code-chip { white-space: normal; overflow-wrap: anywhere; }
  .table.mcards td.mc-input { display: block; padding-top: var(--sp-2); }
  .table.mcards td.mc-input::before { display: block; max-width: none; margin-bottom: 6px; color: var(--text); }
  .table.mcards td.mc-input .input { width: 100%; min-height: 44px; font-size: 16px; }
  .import-preview td.imp-status { display: block; min-width: 0; }
  .import-preview td.imp-status::before { display: block; margin-bottom: 4px; }
}
.stat { container-type: inline-size; }
.stat .icon-wrap { flex-shrink: 0; }
.stat .value { font-size: clamp(1.2rem, 13cqi, var(--fs-2xl)); white-space: nowrap; }
@container (max-width: 250px) {
  .stat-row { flex-direction: column-reverse; gap: var(--sp-2); }
  .stat .icon-wrap { width: 36px; height: 36px; border-radius: 11px; }
}
