/* madionia.css — screens of the debts & collections system (on top of the shared design system). */
.md-branch { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: 13px; }
.md-branch select { border: 0; background: transparent; font: inherit; color: var(--text); font-weight: 600; cursor: pointer; outline: none; max-width: 240px; }

/* ── entry screen (like the journal screen) ── */
.md-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 10px 16px; }
.md-bar-t { display: flex; align-items: center; gap: 10px; font-size: 17px; color: var(--heading); }
.md-bar-t .sep { color: var(--text-3); }
.md-bar-t > span:not(.sep) { color: var(--text-2); font-size: 15px; }
.md-tools { display: flex; align-items: center; gap: 4px; }
.md-sep { width: 1px; height: 22px; background: var(--border); margin-inline: 4px; }
.md-cust { margin-top: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--text); font-size: 13.5px; }
.md-link { margin-inline-start: auto; color: var(--accent); font-weight: 600; text-decoration: none; }
.md-sec { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.md-sec-h { display: flex; align-items: center; gap: 10px; padding: 12px 16px; color: var(--heading); }
.md-sec-h b { font-size: 15px; }
.md-pill { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.md-grid-wrap { overflow-x: auto; }
.md-grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; min-width: 980px; }
.md-grid thead th { background: var(--accent-soft); color: var(--heading); font-weight: 600; font-size: 12.5px; text-align: start; padding: 9px 8px; white-space: nowrap; }
.md-grid td { padding: 6px 6px; border-top: 1px solid var(--border); vertical-align: middle; }
.md-grid td .inp { height: 34px; }
.md-grid .n { width: 44px; text-align: center; }
.md-grid .end { text-align: end; }
.md-no { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 600; }
.md-empty { text-align: center; color: var(--text-3); padding: 18px !important; }
.md-ok { color: var(--ok, #15803d); }
.md-sum { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 16px; }
.md-sum > div { display: grid; gap: 2px; padding: 6px 14px; border-radius: 10px; background: var(--surface-sunken); min-width: 150px; }
.md-sum > div span { font-size: 12px; color: var(--text-3); }
.md-sum > div b { font-size: 17px; color: var(--heading); }
.md-sum > div.due { background: #fff4e5; } .md-sum > div.due b { color: #b45309; }
.md-sum > div.ok { background: #ecfdf3; } .md-sum > div.ok b { color: #15803d; }
.md-hint { margin: 0; font-size: 12.5px; color: var(--text-3); }
.md-drop { display: flex; align-items: center; justify-content: center; gap: 8px; height: 90px; border: 2px dashed var(--border); border-radius: 12px; color: var(--text-2); cursor: pointer; position: relative; }
.md-drop:hover { border-color: var(--accent); color: var(--accent); }
.md-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.md-up { display: grid; gap: 10px; }
.md-ffilter { display: flex; align-items: center; gap: 6px; margin-top: 14px; padding: 8px 10px; border-radius: 10px; background: var(--accent-soft); color: var(--text); font-size: 13px; }
.md-link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }
.md-files { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.md-files li { display: flex; align-items: flex-start; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.md-files li.muted { align-items: center; }
.md-thumb { flex: none; width: 56px; height: 56px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-sunken); display: grid; place-items: center; overflow: hidden; cursor: zoom-in; padding: 0; color: var(--text-3); }
.md-thumb img { width: 100%; height: 100%; object-fit: cover; }
.md-fbody { flex: 1; min-width: 0; display: grid; gap: 6px; }
.md-fname { background: none; border: 0; padding: 0; text-align: start; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-fname:hover { text-decoration: underline; }
.md-fmeta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--text-2); }
.md-fmeta span { display: inline-flex; align-items: center; gap: 4px; }
.md-ftag { padding: 1px 8px; border-radius: 999px; background: var(--surface-sunken); color: var(--text-2); }
.md-ftag.line { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.md-relink { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); white-space: nowrap; }
.md-relink .inp { height: 30px; padding-block: 0; font-size: 12px; max-width: 280px; }
.md-factions { display: flex; align-items: center; gap: 2px; }
.md-ilink { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; color: var(--text-2); }
.md-ilink:hover { background: var(--surface-sunken); color: var(--accent); }
.md-clip { display: inline-flex; align-items: center; gap: 3px; height: 28px; min-width: 30px; justify-content: center; padding: 0 6px; border: 1px dashed var(--border); border-radius: 8px; background: none; color: var(--text-3); cursor: pointer; font: inherit; font-size: 12px; }
.md-clip:hover { border-color: var(--accent); color: var(--accent); }
.md-clip.has { border-style: solid; border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.md-grid td.c, .md-grid th.c { text-align: center; }

/* ── in-page file viewer ── */
.md-viewer { position: fixed; inset: 0; z-index: 3000; background: rgba(15, 23, 42, .55); display: grid; place-items: center; padding: 24px; }
.md-viewer-box { width: min(1100px, 100%); height: min(92vh, 100%); background: var(--surface); border-radius: 14px; display: grid; grid-template-rows: auto 1fr; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.md-viewer-h { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.md-viewer-t { display: grid; min-width: 0; }
.md-viewer-t b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-viewer-t small { color: var(--text-3); font-size: 12px; }
.md-viewer-b { background: var(--surface-sunken); display: grid; place-items: center; overflow: auto; min-height: 0; }
.md-viewer-b img { max-width: 100%; max-height: 100%; object-fit: contain; }
.md-viewer-b iframe { width: 100%; height: 100%; border: 0; background: #fff; }
@media (max-width: 640px) { .md-viewer { padding: 0; } .md-viewer-box { height: 100%; border-radius: 0; } }

/* ── account picker ── */
.md-pick { position: relative; }
.md-pick-in { display: flex; align-items: center; gap: 6px; position: relative; }
.md-pick-in > .ag-i { position: absolute; inset-inline-start: 10px; color: var(--text-3); pointer-events: none; }
.md-pick-in .inp { padding-inline-start: 32px; }
.md-pick-x { position: absolute; inset-inline-end: 8px; border: 0; background: transparent; color: var(--text-3); font-size: 18px; cursor: pointer; }
.md-pick-list { position: absolute; z-index: 30; inset-inline: 0; top: calc(100% + 4px); max-height: 300px; overflow-y: auto; margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 28px rgba(16,24,40,.14); }
.md-pick-list li { display: flex; gap: 10px; align-items: center; padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: 13.5px; }
.md-pick-list li.hi, .md-pick-list li:hover { background: var(--accent-soft); }
.md-pick-list li .code { min-width: 82px; color: var(--text-2); }

/* ── customers tree ── */
.md-tree-layout { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .md-tree-layout { grid-template-columns: 1fr; } }
.md-tree-card { position: sticky; top: 72px; }
.md-tree-search { padding: 12px; border-bottom: 1px solid var(--border); }
.md-tree { max-height: calc(100vh - 260px); overflow-y: auto; padding: 6px; }
.md-node { display: flex; align-items: center; gap: 2px; border-radius: 8px; }
.md-node.sel { background: var(--accent-soft); }
.md-node.stopped .md-node-n { color: var(--text-3); text-decoration: line-through; }
.md-caret { width: 22px; height: 26px; flex: none; border: 0; background: transparent; color: var(--text-3); cursor: pointer; font-size: 12px; }
.md-node-b { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 6px 6px; text-align: start; font: inherit; font-size: 13.5px; color: var(--text); cursor: pointer; border-radius: 7px; }
.md-node-b:hover { background: var(--surface-sunken); }
.md-node-b .ag-i { color: var(--accent); flex: none; }
.md-node-b .code { color: var(--text-2); font-size: 12px; }
.md-node-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.md-kpis > div { display: grid; gap: 2px; padding: 10px 12px; border-radius: 10px; background: var(--surface-sunken); border: 1px solid var(--border); }
.md-kpis span { font-size: 12px; color: var(--text-3); }
.md-kpis b { font-size: 17px; color: var(--heading); }
.md-kpis .due b { color: #b45309; }
.md-kpis .late { background: #fef3f2; } .md-kpis .late b { color: #b42318; }
.md-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.md-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; background: var(--surface-sunken); border: 1px solid var(--border); font-size: 12.5px; }
.md-kpis.big b { font-size: 20px; }
.md-late { color: #b42318; font-weight: 600; font-variant-numeric: tabular-nums; }
.md-simple { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.md-simple td { padding: 10px 16px; border-top: 1px solid var(--border); cursor: pointer; }
.md-simple tr:hover td { background: var(--surface-sunken); }
.md-simple .end { text-align: end; }
.d-block { display: block; }
/* grid cells never shrink below a usable width — the grid scrolls sideways instead */
.md-grid td .inp { min-width: 110px; }
.md-grid td input[type=date].inp { min-width: 140px; }
.md-grid td input[type=number].inp { min-width: 120px; }
.md-grid td select.inp { min-width: 130px; }

/* ── change tracking ── */
.md-stamp { display: inline-flex; align-items: center; gap: 4px; margin-inline-start: 8px; padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); font: inherit; font-size: 12px; cursor: pointer; }
.md-stamp:hover { border-color: var(--accent); color: var(--accent); }
.md-stamp b { color: var(--text); font-weight: 600; }
.md-stamp-sep { margin: 0 4px; color: var(--text-3); }
.md-who { display: grid; gap: 1px; text-align: start; background: none; border: 0; padding: 2px 4px; border-radius: 6px; font: inherit; cursor: pointer; color: var(--text); max-width: 150px; }
.md-who:hover { background: var(--surface-sunken); }
.md-who-n { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-who small { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.md-who.new { font-size: 12px; color: var(--accent); cursor: default; }
.md-hist-filter { display: grid; gap: 8px; margin-bottom: 12px; }
.md-hist { list-style: none; margin: 0; padding: 0; position: relative; }
.md-hist::before { content: ""; position: absolute; inset-block: 6px; inset-inline-start: 11px; width: 2px; background: var(--border); }
.md-hist-i { position: relative; display: flex; gap: 10px; padding: 0 0 14px; }
.md-hist-dot { position: relative; z-index: 1; flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-sunken); color: var(--text-2); border: 2px solid var(--surface); }
.md-hist-i.add .md-hist-dot { background: var(--accent-soft); color: var(--accent); }
.md-hist-i.del .md-hist-dot { background: #fdecec; color: #b42318; }
.md-hist-i.chg .md-hist-dot { background: #fff4e5; color: #b54708; }
.md-hist-b { flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--surface); }
.md-hist-h { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; }
.md-hist-h small { color: var(--text-3); font-size: 12px; }
.md-hist-act { color: var(--text-2); }
.md-hist-where { padding: 0 8px; border-radius: 999px; background: var(--surface-sunken); color: var(--text-2); font-size: 12px; }
.md-hist-title { margin-top: 4px; font-weight: 600; font-size: 13px; }
.md-hist-ch { width: 100%; margin-top: 6px; border-collapse: collapse; font-size: 12px; }
.md-hist-ch th { width: 1%; white-space: nowrap; text-align: start; padding: 3px 0; padding-inline-end: 12px; color: var(--text-3); font-weight: 500; vertical-align: top; }
.md-hist-ch td { padding: 3px 0; }
.md-hist-ch .old { color: #b42318; opacity: .8; }
.md-hist-ch .arr { margin: 0 6px; color: var(--text-3); }
.md-hist-ch .new { color: var(--text); font-weight: 600; }
.md-ehist { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; display: grid; gap: 10px; }
.md-ehist-h { display: flex; align-items: center; gap: 6px; background: none; border: 0; padding: 0; font: inherit; font-size: 12px; color: var(--text-2); cursor: pointer; text-align: start; }
.md-ehist-h b { color: var(--text); }

/* ── statement ── */
.md-kpis.md-kpis-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 900px) { .md-kpis.md-kpis-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.md-stmt-who { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.md-stmt-rep { display: inline-flex; align-items: center; gap: 6px; margin-inline-start: auto; padding: 4px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 13px; }
.md-stmt-rep b { color: var(--text); }
.md-stmt-rep.muted { background: var(--surface-sunken); color: var(--text-2); }
.md-ref { display: inline-block; min-width: 34px; text-align: center; padding: 1px 7px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); font-weight: 700; font-size: 12px; font-variant-numeric: tabular-nums; direction: ltr; }
.md-settles { display: grid; gap: 3px; }
.md-settle { display: flex; align-items: center; gap: 6px; font-size: 12.5px; white-space: nowrap; }
.md-settle b { margin-inline-start: auto; padding-inline-start: 10px; font-weight: 600; }
.md-settle.credit { color: var(--text-2); font-style: italic; }

/* ── project reps (more than one) ── */
.md-reps { display: flex; flex-wrap: wrap; gap: 4px; }
.md-rep { display: inline-flex; align-items: center; gap: 4px; vertical-align: middle; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--surface-sunken); border: 1px solid var(--border); white-space: nowrap; }
.md-rep.main { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.md-rep-pick { display: grid; gap: 6px; }
.md-rep-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.md-rep-no { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-sunken); font-size: 11.5px; font-weight: 600; flex: none; }
.md-rep-who { flex: 1; display: grid; line-height: 1.3; min-width: 0; }
.md-rep-who small { color: var(--text-muted); font-size: 11.5px; }
.md-chips.tight { margin-top: 0; min-height: 34px; align-items: center; }
.md-rep-opt { font-size: 11px; }

/* ── debt types: view toggle + the short view (departments beside their types) ── */
.md-view-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 13px; }
.md-view-toggle { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.md-view-toggle button { width: 32px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 6px; background: none; color: var(--text-muted); cursor: pointer; }
.md-view-toggle button:hover { background: var(--surface-sunken); color: var(--text); }
.md-view-toggle button.on { background: var(--accent); color: #fff; }
.md-split { display: grid; grid-template-columns: 260px 1fr; gap: 14px; align-items: start; }
.md-split-deps { display: grid; gap: 4px; padding: 6px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); position: sticky; top: 12px; max-height: calc(100vh - 200px); overflow: auto; }
.md-split-deps button { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; border-radius: 8px; background: none; text-align: start; cursor: pointer; color: var(--text); font: inherit; }
.md-split-deps button:hover { background: var(--surface-sunken); }
.md-split-deps button.on { background: var(--accent-tint); color: var(--accent-text); }
.md-split-deps .nm { flex: 1; display: grid; line-height: 1.35; min-width: 0; }
.md-split-deps .nm small { color: var(--text-muted); font-size: 11.5px; }
.md-count { min-width: 26px; padding: 1px 7px; border-radius: 999px; background: var(--surface-sunken); border: 1px solid var(--border); font-size: 12px; text-align: center; font-variant-numeric: tabular-nums; color: var(--text); }
.md-split-types { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; }
.md-split-h { display: flex; align-items: center; gap: 8px; padding: 12px 14px; flex-wrap: wrap; }
.md-split-title { display: grid; line-height: 1.35; }
.md-split-title small { color: var(--text-muted); font-size: 12px; }
.md-split-search { position: relative; width: 230px; }
.md-split-search > svg { position: absolute; inset-inline-start: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.md-split-search .inp { padding-inline-start: 32px; height: 34px; }
.md-split-body { max-height: calc(100vh - 260px); overflow: auto; }
@media (max-width: 860px) { .md-split { grid-template-columns: 1fr; } .md-split-deps { position: static; max-height: none; } .md-split-search { width: 100%; } }

/* ── settings: where the reps come from ── */
.md-src { display: grid; gap: 8px; }
.md-src button { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); text-align: start; cursor: pointer; color: var(--text); font: inherit; }
.md-src button:hover { background: var(--surface-sunken); }
.md-src button.on { border-color: var(--accent); background: var(--accent-tint); }
.md-src .nm { flex: 1; display: grid; gap: 2px; line-height: 1.4; min-width: 0; }
.md-src .nm small { color: var(--text-muted); font-size: 12px; }
.md-src-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); flex: none; }
.md-src button.on .md-src-dot { border-color: var(--accent); box-shadow: inset 0 0 0 3px var(--surface), inset 0 0 0 8px var(--accent); }

/* ── the department debts sheet (Excel-like) ── */
.md-sheet-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.md-sheet-filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.md-sheet-search { position: relative; width: 280px; }
.md-sheet-search > .ag-i { position: absolute; inset-inline-start: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.md-sheet-search .inp { padding-inline-start: 32px; }
.md-sheet-kpis { margin-bottom: 12px; }
.md-kpis small { font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.md-kpis.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.md-sheet-wrap { overflow: auto; max-height: calc(100vh - 330px); min-height: 260px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.md-sheet { border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 100%; }
.md-sheet th, .md-sheet td { padding: 6px 9px; border-bottom: 1px solid var(--border); border-inline-start: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.md-sheet thead { position: sticky; top: 0; z-index: 3; }
.md-sheet thead th { background: var(--surface-sunken); font-weight: 600; text-align: start; color: var(--heading); }
.md-sheet thead tr.grp th { font-size: 12px; text-align: center; color: var(--accent-text); background: var(--accent-tint); }
.md-sheet thead tr.grp th:empty { background: var(--surface-sunken); }
.md-sheet th.item, .md-sheet th.tot { text-align: end; }
.md-sheet th.add, .md-sheet td.add { background: color-mix(in srgb, var(--accent-tint) 45%, transparent); }
.md-vat-tag { display: block; font-size: 10.5px; font-weight: 500; color: var(--text-muted); }
.md-sheet .n { width: 34px; text-align: center; color: var(--text-muted); font-size: 12px; }
.md-sheet .num { text-align: end; font-variant-numeric: tabular-nums; }
.md-sheet td small { display: block; font-size: 11px; color: var(--text-muted); font-weight: 400; }
.md-sheet .cust { position: sticky; inset-inline-start: 0; z-index: 1; background: var(--surface); max-width: 230px; overflow: hidden; text-overflow: ellipsis; box-shadow: inset -1px 0 0 var(--border); }
.md-sheet thead .cust { z-index: 4; background: var(--surface-sunken); }
.md-sheet .desc { max-width: 260px; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.md-sheet .notes { max-width: 220px; overflow: hidden; text-overflow: ellipsis; color: var(--text-muted); font-size: 12px; }
.md-sheet .reps { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.md-sheet tbody tr:hover td { background: var(--surface-sunken); }
.md-sheet tbody tr:hover td.cust { background: var(--surface-sunken); }
.md-sheet tr.stopped td { color: var(--text-muted); }
.md-sheet td.cell { padding: 2px; min-width: 104px; }
.md-sheet td.tot { background: var(--surface-sunken); }
.md-sheet td.rem b { color: #b45309; }
.md-sheet td.paid { color: var(--ok); }
.md-sheet tfoot { position: sticky; bottom: 0; z-index: 2; }
.md-sheet tfoot td { background: var(--surface-sunken); font-weight: 700; border-top: 2px solid var(--border); }
.md-sheet tfoot td.rem { color: #b45309; }
.md-sheet-link { all: unset; cursor: pointer; font-weight: 600; color: var(--heading); }
.md-sheet-link:hover { color: var(--accent-text); text-decoration: underline; }
.md-cell { all: unset; box-sizing: border-box; display: block; width: 100%; padding: 4px 7px; border-radius: 6px; text-align: end; cursor: pointer; font-variant-numeric: tabular-nums; }
.md-cell:hover, .md-cell:focus-visible { background: var(--accent-tint); outline: 1px solid var(--accent-line); }
.md-cell b { font-weight: 600; }
.md-cell small { display: block; font-size: 10.5px; color: var(--text-muted); }
.md-cell.part b { color: #b45309; }
.md-cell.done b { color: var(--ok); }
.md-cell.done b::before { content: "✓ "; }
.md-cell.empty { text-align: center; }
.md-na { display: block; height: 100%; min-height: 26px; background: repeating-linear-gradient(-45deg, transparent 0 5px, var(--border) 5px 6px); opacity: .5; border-radius: 4px; }
.md-stop { margin-inline-start: 6px; padding: 1px 7px; border-radius: 999px; font-size: 11px; background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-line); }
.md-shared { margin-inline-start: 6px; padding: 1px 7px; border-radius: 999px; font-size: 11px; background: var(--accent-soft); color: var(--accent-text); border: 1px solid var(--accent-line); }
.md-inline-new { display: grid; gap: 8px; padding: 10px 12px; border: 1px dashed var(--accent-line); border-radius: 10px; background: var(--accent-soft); }
.md-row-amounts { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-sunken); }
.md-vat-pill { margin-inline-start: 6px; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--accent-soft); color: var(--accent-text); }
.md-chip-x { all: unset; cursor: pointer; margin-inline-start: 2px; color: var(--text-muted); font-size: 14px; line-height: 1; }
.md-chip-x:hover { color: var(--danger); }
.md-sub { margin: 18px 0 8px; font-size: 14px; color: var(--heading); }
.md-moves { width: 100%; border-collapse: collapse; font-size: 13px; }
.md-moves td { padding: 7px 6px; border-top: 1px solid var(--border); }
.md-moves tr.x td { text-decoration: line-through; color: var(--text-muted); }
.md-moves tr.x td:last-child { text-decoration: none; }
.md-move-k { padding: 1px 8px; border-radius: 999px; font-size: 11.5px; border: 1px solid var(--border); }
.md-move-k.pay { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.md-move-k.amt { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-line); }
@media (max-width: 860px) { .md-sheet-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .md-sheet-search { width: 100%; } .md-sheet .cust { position: static; } }

/* ── contracts ── */
.sh-body:has(.md-sheet-page) { max-width: none; }
.md-extra { color: var(--accent-text) !important; }
.md-tpls { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.md-tpl { all: unset; box-sizing: border-box; display: grid; gap: 10px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); cursor: pointer; }
.md-tpl:hover { border-color: var(--accent-line); box-shadow: var(--shadow-sm); }
.md-tpl.off { opacity: .6; }
.md-tpl-h { display: flex; align-items: center; gap: 8px; color: var(--heading); }
.md-tpl-items { display: grid; gap: 6px; }
.md-tpl-i { display: grid; grid-template-columns: 110px 1fr 52px; align-items: center; gap: 8px; font-size: 13px; }
.md-tpl-bar { height: 7px; border-radius: 999px; background: var(--surface-sunken); overflow: hidden; }
.md-tpl-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.md-tpl-i b { text-align: end; }
.md-tpl-edit, .md-split-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.md-tpl-edit td, .md-split-tbl td, .md-split-tbl th { padding: 5px 4px; border-top: 1px solid var(--border); }
.md-split-tbl th { text-align: start; font-weight: 600; color: var(--text-muted); font-size: 12px; border-top: 0; }
.md-split-tbl tr.sum td { font-weight: 600; border-top: 2px solid var(--border); }
.md-tpl-edit .n { width: 26px; color: var(--text-muted); text-align: center; }
.md-pct { position: relative; }
.md-pct .inp { padding-inline-start: 26px; }
.md-pct > span { position: absolute; inset-inline-start: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 12px; }
.md-pct-sum { padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid; }
.md-pct-sum.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.md-pct-sum.bad { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-line); }

/* items outside / inside the row's contract */
.md-sheet td.cell.out { background: repeating-linear-gradient(-45deg, var(--surface-sunken) 0 6px, transparent 6px 12px); }
.md-out { display: block; text-align: center; font-size: 10.5px; color: var(--text-muted); opacity: .8; }
.md-sheet td.cell.in { box-shadow: inset 0 -2px 0 var(--accent-line); }

/* due dates */
.md-kpis.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.md-due { display: inline-block; margin-top: 2px; padding: 0 6px; border-radius: 999px; font-size: 10.5px !important; font-weight: 600; line-height: 1.6; border: 1px solid transparent; }
.md-due.late { background: var(--danger-bg); color: var(--danger) !important; border-color: var(--danger-line); }
.md-due.soon { background: var(--warn-bg); color: var(--warn) !important; border-color: var(--warn-line); }
.md-due.upcoming { background: var(--surface-sunken); color: var(--text-muted) !important; border-color: var(--border); }
.md-due.on-time { background: var(--ok-bg); color: var(--ok) !important; border-color: var(--ok-line); }
.md-due.early { background: var(--accent-soft); color: var(--accent-text) !important; border-color: var(--accent-line); }
.md-due.paid-late { background: var(--warn-bg); color: var(--warn) !important; border-color: var(--warn-line); }
.md-cell.late { background: color-mix(in srgb, var(--danger-bg) 70%, transparent); }
.md-cell.late b { color: var(--danger); }
.md-due-bar { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-sunken); font-size: 13px; }
.md-due-bar.late { border-color: var(--danger-line); }
.md-move-t { display: block; font-size: 11px; color: var(--text-muted); }
@media (max-width: 1100px) { .md-kpis.five { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.md-split-tbl.fixed { table-layout: fixed; }
.md-split-tbl.fixed .inp { width: 100%; min-width: 0; box-sizing: border-box; }
.md-split-tbl.fixed input[type="date"].inp { padding-inline: 6px; font-size: 12.5px; }

/* the sheet row's files: «العقد» column, the project no under the customer, a smaller drop zone in the row drawer */
.md-sheet th.files, .md-sheet td.files { width: 64px; text-align: center; }
.md-clip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px; font-size: 11.5px; cursor: pointer;
           border: 1px dashed var(--border); background: transparent; color: var(--text-muted); white-space: nowrap; }
.md-clip:hover { border-color: var(--accent); color: var(--accent); }
.md-clip.has { border-style: solid; border-color: var(--accent-line, var(--accent)); background: var(--accent-tint); color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.md-sheet td small.md-proj { color: var(--text-2); }
.md-drop.small { height: 64px; font-size: 13px; }

/* carried out or not: only the unpaid part of a carried-out item is a debt */
.md-kpis.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1250px) { .md-kpis.six { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.md-due.notdone { background: var(--surface-sunken); color: var(--text-muted) !important; border: 1px dashed var(--border); }
.md-cell.notdone b { color: var(--text-muted); font-weight: 500; }
.md-sheet th.debt, .md-sheet td.debt { background: color-mix(in srgb, var(--warn-bg) 55%, transparent); }
.md-sheet td.debt b { color: var(--warn); }
.md-done-bar { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 8px 12px; border: 1px dashed var(--border); border-radius: 10px; background: var(--surface-sunken); font-size: 13px; color: var(--text-2); }
.md-done-bar.on { border-style: solid; border-color: var(--ok-line); background: var(--ok-bg); color: var(--ok); }
.md-done-bar small { color: inherit; opacity: .85; }

/* carried out and not collected = a debt: amber cell with a solid edge, so it shows at a glance */
.md-cell.debt { background: color-mix(in srgb, var(--warn-bg) 85%, transparent); border-inline-start: 3px solid var(--warn); }
.md-cell.debt b { color: var(--warn); font-weight: 700; }
.md-due.debt { background: var(--warn-bg); color: var(--warn) !important; border-color: var(--warn-line); }
.md-cell.debt.late { background: color-mix(in srgb, var(--danger-bg) 85%, transparent); border-inline-start-color: var(--danger); }
.md-cell.debt.late b { color: var(--danger); }
.md-cell.notdone { opacity: .75; }
.md-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text-muted); }
.md-legend span { display: inline-flex; align-items: center; gap: 5px; }
.md-legend i { display: inline-block; width: 14px; height: 12px; border-radius: 3px; border: 1px solid var(--border); }
.md-legend i.debt { background: var(--warn-bg); border-color: var(--warn-line); border-inline-start: 3px solid var(--warn); }
.md-legend i.late { background: var(--danger-bg); border-color: var(--danger-line); border-inline-start: 3px solid var(--danger); }
.md-legend i.paid { background: var(--ok-bg); border-color: var(--ok-line); }
.md-legend i.notdone { background: var(--surface-sunken); border-style: dashed; }
.md-cell.done { background: color-mix(in srgb, var(--ok-bg) 55%, transparent); }

/* ═══ شيت المديونيات 2 — a row per project, items as status pills, one number per thing ═══ */
.sh-body:has(.s2) { max-width: none; }
.s2 { display: grid; gap: 14px; }
.s2-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.s2-title h1 { margin: 0; font-size: 20px; font-weight: 700; color: var(--heading); display: flex; align-items: center; gap: 8px; }
.s2-title p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-muted); }
.s2-beta { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); }

.s2-sum { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); overflow: hidden; box-shadow: var(--shadow-sm); }
.s2-tile { all: unset; box-sizing: border-box; display: grid; gap: 2px; padding: 14px 18px; border-inline-start: 1px solid var(--border); }
.s2-tile:first-child { border-inline-start: 0; }
.s2-tile span { font-size: 12.5px; color: var(--text-muted); }
.s2-tile b { font-size: 22px; font-weight: 700; color: var(--heading); font-variant-numeric: tabular-nums; }
.s2-tile small { font-size: 11.5px; color: var(--text-muted); }
.s2-tile.ok b { color: var(--ok); }
.s2-tile.debt { background: color-mix(in srgb, var(--warn-bg) 60%, transparent); cursor: pointer; }
.s2-tile.debt b { color: var(--warn); font-size: 24px; }
.s2-tile.late { cursor: pointer; }
.s2-tile.late b { color: var(--danger); }
.s2-tile.muted b { color: var(--text-2); }
.s2-tile.debt.on { box-shadow: inset 0 -3px 0 var(--warn); }
.s2-tile.late.on { box-shadow: inset 0 -3px 0 var(--danger); }
.s2-bar { grid-column: 1 / -1; display: flex; height: 8px; background: var(--surface-sunken); border-top: 1px solid var(--border); }
.s2-bar i, .s2-mini i { display: block; height: 100%; }
.s2-bar .ok, .s2-mini .ok { background: var(--ok); }
.s2-bar .debt, .s2-mini .debt { background: #f59e0b; }
.s2-bar .late, .s2-mini .late { background: var(--danger); }
.s2-bar .rest { background: var(--border-strong); opacity: .5; }

.s2-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
/* «فلاتر أخرى»: a button opening a small panel (project number, dates) */
.s2-more { position: relative; }
.s2-more-btn { all: unset; cursor: pointer; box-sizing: border-box; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border: 1px solid var(--field-border); border-radius: var(--r-field); background: var(--surface); color: var(--text-2); font-size: 13px; white-space: nowrap; }
.s2-more-btn:hover { border-color: var(--field-hover); color: var(--text); }
.s2-more-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.s2-more-btn.on { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-text); }
.s2-more-btn b { min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 11px; display: inline-grid; place-items: center; }
.s2-more-back { position: fixed; inset: 0; z-index: 40; }
.s2-more-pop { position: absolute; top: calc(100% + 6px); inset-inline-start: 0; z-index: 41; width: 340px; padding: 14px; display: grid; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-pop); }
.s2-more-f { display: grid; gap: 6px; }
.s2-more-f > span { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.s2-more-f .inp { width: 100%; box-sizing: border-box; }
.s2-range { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px; }
.s2-range i { font-style: normal; color: var(--text-muted); font-size: 12px; }
.s2-presets { display: flex; flex-wrap: wrap; gap: 4px; }
.s2-presets button { all: unset; cursor: pointer; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--border); font-size: 11.5px; color: var(--text-2); }
.s2-presets button:hover { border-color: var(--border-strong); color: var(--text); }
.s2-presets button.on { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-text); }
.s2-more-foot { display: flex; align-items: center; justify-content: space-between; padding-top: 10px; border-top: 1px solid var(--border); }
/* the extra filters that are on, as removable chips */
.s2-active { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.s2-active-chip { display: inline-flex; align-items: center; gap: 4px; padding-block: 3px; padding-inline: 10px 4px; border-radius: 999px; background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--accent-text); font-size: 12px; }
.s2-active-chip button { all: unset; cursor: pointer; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; }
.s2-active-chip button:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.s2-active-clear { all: unset; cursor: pointer; font-size: 12px; color: var(--text-muted); text-decoration: underline; text-underline-offset: 3px; padding: 2px 4px; }
.s2-active-clear:hover { color: var(--text); }
.s2-active-clear:disabled { opacity: .4; cursor: default; text-decoration: none; }
.s2-search { position: relative; flex: 1 1 280px; max-width: 420px; }
.s2-search svg { position: absolute; inset-inline-start: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.s2-search .inp { width: 100%; padding-inline-start: 32px; box-sizing: border-box; }
.s2-states { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.s2-chip { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: 12.5px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); }
.s2-chip b { font-weight: 600; color: var(--text-muted); }
.s2-chip:hover { border-color: var(--border-strong); }
.s2-chip.on { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.s2-chip.on b { color: inherit; opacity: .8; }
.s2-chip.debt:not(.on) b { color: var(--warn); }
.s2-chip.late:not(.on) b { color: var(--danger); }
.s2-chip.ok:not(.on) b { color: var(--ok); }

.s2-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); overflow: auto; max-height: calc(100vh - 230px); box-shadow: var(--shadow-sm); }
.s2-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.s2-table thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-sunken); text-align: start; font-weight: 600; font-size: 12px; color: var(--text-muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.s2-table thead th.end { text-align: end; }
.s2-table th small { font-weight: 400; margin-inline-start: 6px; opacity: .8; }
.s2-sort { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; font: inherit; color: inherit; border-radius: 6px; padding: 2px 6px; margin: -2px -6px; }
.s2-proj .s2-sort { margin-inline-start: 6px; font-weight: 400; border: 1px solid var(--border); padding: 1px 6px; margin-block: -2px; }
.s2-sort:hover { color: var(--text); background: color-mix(in srgb, var(--text) 6%, transparent); }
.s2-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.s2-sort.on { color: var(--accent); font-weight: 700; }
.s2-sort-ic { font-size: 10px; opacity: .55; }
.s2-sort.on .s2-sort-ic { opacity: 1; }
.s2-table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.s2-table tbody tr:hover td { background: color-mix(in srgb, var(--surface-sunken) 60%, transparent); }
.s2-table tbody tr.has-debt td:first-child { box-shadow: inset -3px 0 0 #f59e0b; }
.s2-table tbody tr.has-late td:first-child { box-shadow: inset -3px 0 0 var(--danger); }
.s2-table tr.stopped td { opacity: .6; }
.s2-table .end { text-align: end; }
.s2-table .num, .s2-table td.end { font-variant-numeric: tabular-nums; white-space: nowrap; }
.s2-n { width: 28px; color: var(--text-muted); font-size: 12px; text-align: center; }
.s2-proj { min-width: 220px; max-width: 300px; }
.s2-cust { all: unset; cursor: pointer; font-weight: 700; color: var(--heading); font-size: 14px; }
.s2-cust:hover { color: var(--accent-text); text-decoration: underline; }
.s2-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 4px; font-size: 12px; color: var(--text-2); align-items: center; }
.s2-meta > span:first-child:not(.s2-tag) { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s2-tag { all: unset; display: inline-flex; align-items: center; gap: 3px; padding: 0 6px; border-radius: 4px; font-size: 11px; background: var(--surface-sunken); color: var(--text-2); border: 1px solid var(--border); }
.s2-tag.clip { cursor: pointer; background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-line); }
.s2-tag.nofile { cursor: pointer; border-style: dashed; color: var(--text-muted); }
.s2-tag.kind { background: var(--info-bg); color: var(--info); border-color: var(--info-line); font-weight: 600; }
.s2-dates { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.s2-rep { font-size: 12.5px; white-space: nowrap; }
.s2-items { min-width: 300px; }
.s2-pills { display: flex; flex-wrap: wrap; gap: 5px; }
.s2-pill { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 8px; font-size: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); }
.s2-pill b { font-weight: 600; font-variant-numeric: tabular-nums; }
.s2-pill:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.s2-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); flex: none; }
.s2-pill.paid { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.s2-pill.paid .s2-dot { background: var(--ok); }
.s2-pill.debt { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.s2-pill.debt .s2-dot { background: #f59e0b; }
.s2-pill.late { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger); }
.s2-pill.late .s2-dot { background: var(--danger); }
.s2-pill.notdone { border-style: dashed; color: var(--text-2); }
.s2-pill.empty { border-style: dashed; color: var(--text-muted); opacity: .75; }
.s2-pill.add { padding: 4px 10px; border-style: dashed; color: var(--accent-text); }
.s2-add-sel { width: 160px; height: 28px; font-size: 12px; }
.s2-prog { width: 150px; }
.s2-mini { display: flex; height: 6px; border-radius: 99px; overflow: hidden; background: var(--surface-sunken); margin: 5px 0 4px; }
.s2-prog small { font-size: 11.5px; color: var(--text-muted); }
.s2-table td.s2-debt, .s2-table th.s2-debt-h { background: color-mix(in srgb, var(--warn-bg) 45%, var(--surface)); }
.s2-debt b { color: var(--warn); font-size: 14px; }
.s2-late { display: block; font-size: 11px; color: var(--danger); font-weight: 600; }
.s2-zero { color: var(--text-muted); }
.s2-sub { display: block; font-size: 11px; color: var(--text-muted); }
.s2-act { width: 36px; }
.s2-table tfoot td { position: sticky; bottom: 0; background: var(--surface-sunken); font-weight: 700; border-top: 2px solid var(--border); border-bottom: 0; }
.s2-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-muted); }
.s2-legend span { display: inline-flex; align-items: center; gap: 5px; }
.s2-legend i { width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--border); }
.s2-legend i.paid { background: var(--ok-bg); border-color: var(--ok-line); }
.s2-legend i.debt { background: var(--warn-bg); border-color: var(--warn-line); }
.s2-legend i.late { background: var(--danger-bg); border-color: var(--danger-line); }
.s2-legend i.notdone, .s2-legend i.empty { border-style: dashed; }
@media (max-width: 1200px) { .s2-sum { grid-template-columns: repeat(3, minmax(0, 1fr)); } .s2-tile:nth-child(4) { border-inline-start: 0; } }
@media (max-width: 640px) { .s2-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); } .s2-search { max-width: none; } }

/* sheet 2: item names black and bold; owed items say «مديونية» in words, not by colour only */
.s2-pill .s2-pn { color: var(--heading); font-weight: 700; }
.s2-pill.empty .s2-pn { color: var(--text-2); font-weight: 600; }
.s2-word { font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; line-height: 1.5; }
.s2-pill.debt .s2-word { background: #f59e0b; color: #fff; }
.s2-pill.late .s2-word { background: var(--danger); color: #fff; }
.s2-pill.debt b { color: var(--warn); }
.s2-pill.late b { color: var(--danger); }

/* a payment bigger than the item: where the extra goes; the customer's credit */
.md-spread { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--warn-line); border-radius: 10px; background: color-mix(in srgb, var(--warn-bg) 55%, var(--surface)); display: grid; gap: 8px; font-size: 13px; }
.md-spread p { margin: 0; color: var(--text-2); }
.md-spread-h { display: flex; align-items: center; gap: 8px; color: var(--warn); }
.md-spread-tbl { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.md-spread-tbl th { text-align: start; font-size: 11.5px; font-weight: 600; color: var(--text-muted); padding: 6px 8px; border-bottom: 1px solid var(--border); }
.md-spread-tbl th.end, .md-spread-tbl td.end { text-align: end; }
.md-spread-tbl td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.md-spread-tbl td b { color: var(--heading); }
.md-spread-tbl td small { display: block; font-size: 11px; color: var(--text-muted); }
.md-spread-tbl .md-due { margin-inline-start: 6px; }
.md-spread-tbl .inp { width: 100%; box-sizing: border-box; }
.md-due.debt { background: var(--warn-bg); color: var(--warn) !important; border-color: var(--warn-line); }
.md-spread-credit { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; background: var(--info-bg); color: var(--info); border: 1px solid var(--info-line); }
.md-credit-box { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--info-bg); color: var(--info); border: 1px solid var(--info-line); font-size: 13px; }
.md-credit-box b { color: var(--heading); }
.md-credit-tag { display: inline-block; margin-inline-start: 6px; padding: 0 7px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--info-bg); color: var(--info); border: 1px solid var(--info-line); white-space: nowrap; }

/* the row drawer: a bit wider; nothing in a drawer may push it sideways (long file names, long values wrap) */
.ag-drawer.md-row-drawer { --dw: 620px; }
.ag-drawer-b > * { min-width: 0; }
.md-hist-b, .md-hist-title, .md-hist-ch td, .md-hist-b .muted { overflow-wrap: anywhere; }
.md-files .md-fname, .md-fbody { min-width: 0; overflow-wrap: anywhere; }

/* لوحة المديونيات والتحصيلات — the sheet's numbers, in cards */
.md-dash-sum { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.md-dash-sum.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.md-dash-sum.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
a.s2-tile { text-decoration: none; color: inherit; cursor: pointer; }
.md-dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.md-dash-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.md-dash-tbl th { text-align: start; font-weight: 600; font-size: 12px; color: var(--text-muted); padding: 9px 14px; background: var(--surface-sunken); border-bottom: 1px solid var(--border); white-space: nowrap; }
.md-dash-tbl td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.md-dash-tbl tr:last-child td { border-bottom: 0; }
.md-dash-tbl .end { text-align: end; }
.md-dash-tbl .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.md-dash-tbl td b { color: var(--heading); }
.md-dash-tbl td small { display: block; font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.md-dash-tbl td.debt { color: var(--warn); font-weight: 700; }
.md-dash-tbl td.ok { color: var(--ok); font-weight: 600; }
.md-dash-tbl tr.click { cursor: pointer; }
.md-dash-tbl tr.click:hover td { background: color-mix(in srgb, var(--surface-sunken) 60%, transparent); }
@media (max-width: 1100px) { .md-dash-grid { grid-template-columns: 1fr; } .md-dash-sum, .md-dash-sum.five, .md-dash-sum.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* dashboard: the split view — the tables listed on the side, one table at full width */
.md-dash .md-view-bar { display: flex; align-items: center; gap: 10px; }
.md-dash-split { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 14px; align-items: start; }
.md-dash-nav { display: grid; gap: 6px; position: sticky; top: 76px; }
.md-dash-nav button { all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }
.md-dash-nav button:hover { border-color: var(--border-strong); }
.md-dash-nav button.on { border-color: var(--accent-line); background: var(--accent-soft); box-shadow: inset -3px 0 0 var(--accent); }
.md-dash-nav .ic { flex: none; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-sunken); color: var(--text-2); }
.md-dash-nav button.on .ic { background: var(--accent); color: var(--on-accent); }
.md-dash-nav .tx { display: grid; gap: 1px; min-width: 0; }
.md-dash-nav .tx b { font-size: 13.5px; color: var(--heading); }
.md-dash-nav .tx small { font-size: 11.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-dash .ag-dt-foot { border-top: 1px solid var(--border); }
@media (max-width: 900px) { .md-dash-split { grid-template-columns: 1fr; } .md-dash-nav { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* the «إضافات» screen: the additions the customer asked for, on their own (the moves list mixes them with payments) */
.md-extras { margin-top: 16px; border: 1px solid var(--accent-line); border-radius: 10px; background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); padding: 10px 12px; display: grid; gap: 8px; font-size: 13px; }
.md-extras-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--accent-text); }
.md-extras-h b { color: var(--heading); }
.md-extras-h .muted b { color: var(--text); }
.md-extras-n { min-width: 22px; padding: 0 7px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 11.5px; font-weight: 700; text-align: center; }
.md-extras-tbl { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.md-extras-tbl th { text-align: start; font-size: 11.5px; font-weight: 600; color: var(--text-muted); padding: 6px 8px; border-bottom: 1px solid var(--border); }
.md-extras-tbl th.end, .md-extras-tbl td.end { text-align: end; }
.md-extras-tbl td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
.md-extras-tbl td b { color: var(--heading); }
.md-extras-tbl td small { display: block; font-size: 11px; color: var(--text-muted); }
.md-extras-tbl tr.sum td { border-bottom: 0; font-weight: 600; background: var(--surface-sunken); }

/* an addition: carried out or not */
.md-xdone { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; cursor: pointer; white-space: nowrap;
            border: 1px dashed var(--border-strong); color: var(--text-2); background: var(--surface); }
.md-xdone.on { border-style: solid; border-color: var(--warn-line); background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.md-xdone input { margin: 0; }

/* a sure debt: the projects that started (a signing item alone can still be cancelled) */
.s2-tile.confirmed { background: color-mix(in srgb, var(--warn-bg) 30%, transparent); }
.s2-tile.confirmed b { color: #b45309; }
.s2-unsure { display: block; font-size: 10.5px; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.s2-tile.confirmed { cursor: pointer; }
.s2-tile.confirmed.on { box-shadow: inset 0 -3px 0 #b45309; }

/* ── reconcile page ── */
.rc-tbl { width: 100%; }
.rc-tbl .n { text-align: left; white-space: nowrap; }
.rc-cust { cursor: pointer; }
.rc-cust.on, .rc-cust:hover { background: var(--ag-surface-2, rgba(0,0,0,.03)); }
.rc-ok { color: var(--ag-muted, #6b7280); }
.rc-more { color: #b42318; font-weight: 700; }
.rc-less { color: #b54708; font-weight: 700; }
.rc-detail > td { padding: 10px 14px 16px; background: var(--ag-surface-2, rgba(0,0,0,.02)); }
.rc-refs { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 10px; font-size: 13px; }
.rc-proj { width: 100%; font-size: 13px; border-collapse: collapse; }
.rc-proj th, .rc-proj td { padding: 6px 8px; border-bottom: 1px solid var(--ag-border, #e5e7eb); text-align: right; }
.rc-proj .n { text-align: left; }
.rc-in { width: 130px; }
.rc-note { width: 180px; }
.rc-pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 12px 0; }
.rc-warn { color: #b54708; font-size: 13px; }

/* the row drawer: the project's money at a glance */
.md-row-sum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--r-card, 10px); overflow: hidden; }
.md-row-sum > div { display: grid; gap: 2px; padding: 10px 12px; border-inline-start: 1px solid var(--border); }
.md-row-sum > div:first-child { border-inline-start: 0; }
.md-row-sum span { font-size: 12px; color: var(--text-muted); }
.md-row-sum b { font-size: 16px; color: var(--heading); }
.md-row-sum .ok b { color: var(--success, #15803d); }
.md-row-sum .debt b { color: #b54708; }
.md-row-sum small { font-size: 11px; color: var(--text-muted); }

/* editing an existing project's items */
.md-items-tbl td { vertical-align: middle; }
.md-items-tbl tr.chg td { background: color-mix(in srgb, #f59e0b 10%, transparent); }
.md-items-tbl .md-debt, .md-debt { color: #b54708; font-weight: 600; }
.md-mini-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); border-radius: 6px; font-size: 11px; padding: 2px 6px; cursor: pointer; white-space: nowrap; }
.md-mini-btn:hover { color: var(--heading); border-color: var(--text-muted); }

/* user role picker */
.md-role-pick { display: grid; gap: 6px; }
.md-role { display: flex; gap: 10px; align-items: flex-start; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; cursor: pointer; background: var(--surface); }
.md-role.on { border-color: var(--accent-line); background: var(--accent-soft); }
.md-role input { margin-top: 3px; }
.md-role span { display: grid; gap: 2px; }
.md-role small { color: var(--text-muted); font-size: 12px; }

/* warranty (تركيب المصاعد) */
.s2-tag.warr-in { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); font-weight: 600; }
.s2-tag.warr-soon { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); font-weight: 600; }
.s2-tag.warr-out { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-line); font-weight: 600; }
.s2-tag.warr-missing { border-style: dashed; color: var(--text-muted); }
.md-warranty { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--info-line); border-radius: 10px; background: color-mix(in srgb, var(--info-bg) 55%, var(--surface)); display: grid; gap: 8px; font-size: 13px; }
.md-warranty .md-spread-h { color: var(--info); }

/* ── مركز التقارير and the reports ─────────────────────────────────────────────────────────── */
.rp { max-width: none; }
.rp .dim, .rp-chart.dim { opacity: .55; transition: opacity .15s; }
.rp-head { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.rp-title h1 { margin: 0; font-size: 21px; font-weight: 700; color: var(--heading); display: flex; align-items: center; gap: 10px; }
.rp-title p { margin: 4px 0 0; font-size: 12.5px; color: var(--text-muted); }
.rp-ic { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-text); }
.rp-crumb { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--accent-text); text-decoration: none; margin-bottom: 6px; font-weight: 600; }
.rp-crumb:hover { text-decoration: underline; }
.rp-note { margin: 0; font-size: 12px; color: var(--text-muted); }

/* the report center: headline strip + one panel per group, laid out so the columns end level */
.rp-hub { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: stretch;
  grid-template-areas: "cust reps" "cust sec" "follow follow"; }
.rp-panel { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-sm); overflow: hidden; }
.rp-panel[data-area="cust"] { grid-area: cust; }
.rp-panel[data-area="reps"] { grid-area: reps; }
.rp-panel[data-area="sec"] { grid-area: sec; }
.rp-panel[data-area="follow"] { grid-area: follow; }
.rp-panel-h { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.rp-panel-h h2 { margin: 0; font-size: 14.5px; font-weight: 700; color: var(--heading); }
.rp-panel-h small { font-size: 12px; color: var(--text-muted); }
.rp-panel-ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--hb, var(--accent-soft)); color: var(--h, var(--accent-text)); flex: none; }
.rp-links { display: grid; flex: 1; align-content: stretch; }
.rp-panel[data-area="follow"] .rp-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rp-panel[data-area="follow"] .rp-link + .rp-link { border-top: 0; border-inline-start: 1px solid var(--border); }
.rp-link { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 14px; padding: 14px 18px; text-decoration: none; color: inherit;
  transition: background .12s; min-height: 64px; }
.rp-link + .rp-link { border-top: 1px solid var(--border); }
.rp-link:hover { background: color-mix(in srgb, var(--hb, var(--accent-soft)) 45%, var(--surface)); }
.rp-link:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.rp-link-ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--text-muted); background: var(--surface-sunken); transition: color .12s, background .12s; }
.rp-link:hover .rp-link-ic { color: var(--h, var(--accent-text)); background: var(--surface); }
.rp-link-tx { display: grid; gap: 2px; min-width: 0; }
.rp-link-tx b { font-size: 13.5px; font-weight: 600; color: var(--heading); }
.rp-link-tx span { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-link-stat { display: grid; justify-items: end; text-align: end; }
.rp-link-stat b { font-size: 15px; font-weight: 700; color: var(--heading); white-space: nowrap; font-variant-numeric: tabular-nums; }
.rp-link-stat small { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.rp-link-go { color: var(--text-3); transition: color .12s, transform .12s; }
.rp-link:hover .rp-link-go { color: var(--h, var(--accent-text)); transform: translateX(-2px); }
@media (max-width: 1100px) {
  .rp-hub { grid-template-columns: minmax(0, 1fr); grid-template-areas: "cust" "reps" "sec" "follow"; }
  .rp-panel[data-area="follow"] .rp-links { grid-template-columns: minmax(0, 1fr); }
  .rp-panel[data-area="follow"] .rp-link + .rp-link { border-inline-start: 0; border-top: 1px solid var(--border); }
}
.rp-skel { display: block; width: 70px; height: 18px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-sunken), var(--border), var(--surface-sunken)); background-size: 200% 100%; animation: rp-sk 1.2s linear infinite; }
@keyframes rp-sk { to { background-position: -200% 0; } }

/* filters row */
.rp-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rp-sel { width: auto; min-width: 150px; max-width: 220px; }
.rp-search { flex: 1 1 220px; max-width: 340px; }
.rp-dates { position: relative; }
.rp-dates-btn { all: unset; cursor: pointer; box-sizing: border-box; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border: 1px solid var(--field-border);
  border-radius: var(--r-field); background: var(--surface); color: var(--text-2); font-size: 13px; white-space: nowrap; }
.rp-dates-btn:hover { border-color: var(--field-hover); }
.rp-dates-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.rp-dates-btn b { color: var(--heading); font-weight: 600; }
.rp-dates-btn.on { border-color: var(--accent-line); background: var(--accent-soft); }
.rp-dates-pop { position: absolute; top: calc(100% + 6px); inset-inline-start: 0; z-index: 41; width: 300px; padding: 6px; display: grid; gap: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-pop); }
.rp-presets { display: grid; }
.rp-presets button { all: unset; cursor: pointer; display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: 8px; font-size: 13px; color: var(--text); }
.rp-presets button:hover { background: var(--surface-sunken); }
.rp-presets button.on { font-weight: 700; color: var(--accent-text); }
.rp-custom { display: grid; gap: 6px; padding: 10px 8px 6px; border-top: 1px solid var(--border); }
.rp-custom > span { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.rp-custom .inp { width: 100%; box-sizing: border-box; }

/* KPI strips */
.rp-kpis.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.rp-kpis.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.rp-kpis.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.rp-kpis .s2-tile.debt { cursor: default; }
.rp-kpis .s2-tile b { font-size: 20px; }
.rp-kpis .s2-tile small .ag-delta { font-size: 11.5px; }
@media (max-width: 1200px) { .rp-kpis.five, .rp-kpis.six { grid-template-columns: repeat(3, minmax(0, 1fr)); } .rp-kpis.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* tables */
.rp-tbl-wrap { overflow-x: auto; }
.rp-tbl thead th { position: sticky; top: 0; z-index: 1; }
.rp-tbl .rp-n { width: 34px; color: var(--text-muted); }
.rp-tbl th.rp-debt-h, .rp-tbl td.rp-debt { background: color-mix(in srgb, var(--warn-bg) 45%, transparent); }
.rp-tbl tfoot td { background: var(--surface-sunken); border-top: 1px solid var(--border-strong); font-weight: 700; padding: 11px 14px; }
.rp-tbl .rp-bar-col { width: 150px; }
.rp-rate { display: grid; gap: 2px; min-width: 110px; }
.rp-rate .s2-mini { margin: 4px 0 0; }
.rp-rate small { font-size: 11.5px; color: var(--text-muted); }
.rp-tbl .s2-sort { margin-inline: -6px; }
.rp-tools { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }

/* detailed customers: a customer row, its projects under it */
.rp-detail .rp-cust td { background: var(--surface); }
.rp-detail .rp-group-b.open .rp-cust td { background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); }
.rp-caret { display: inline-grid; place-items: center; width: 18px; color: var(--text-muted); vertical-align: -2px; }
.rp-proj td { background: var(--surface); font-size: 12.5px; padding-block: 8px; }
.rp-proj td:nth-child(2) { padding-inline-start: 34px; }
.rp-proj-name { color: var(--heading); font-weight: 600; text-decoration: none; }
.rp-proj-name:hover { text-decoration: underline; color: var(--accent-text); }
.rp-items { display: flex; flex-wrap: wrap; gap: 4px; max-width: 420px; }
.rp-item { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); white-space: nowrap; }
.rp-item b { font-weight: 600; color: var(--heading); }
.rp-item.ok { border-color: var(--ok-line); background: var(--ok-bg); }
.rp-item.debt { border-color: var(--warn-line); background: var(--warn-bg); }
.rp-item.rest { border-style: dashed; }
.rp-indent { color: var(--text-3); margin-inline-end: 6px; }

/* charts */
.rp-chart { display: grid; gap: 10px; }
.rp-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.rp-legend button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text); padding: 2px 4px; border-radius: 6px; }
.rp-legend button:hover { background: var(--surface-sunken); }
.rp-legend button:focus-visible { outline: 2px solid var(--focus); }
.rp-legend button i { width: 12px; height: 12px; border-radius: 3px; }
.rp-legend button b { font-weight: 600; color: var(--text-muted); font-size: 11.5px; }
.rp-legend button.off { opacity: .45; }
.rp-legend button.off i { background: var(--border-strong) !important; }
.rp-plot { position: relative; }
.rp-plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.rp-plot line.grid { stroke: var(--border); stroke-width: 1; }
.rp-plot line.base { stroke: var(--border-strong); stroke-width: 1; }
.rp-plot .hit { fill: transparent; cursor: pointer; outline: none; }
.rp-plot .hit:focus-visible { stroke: var(--focus); stroke-width: 2; }
.rp-plot path.hot, .rp-plot rect.hot { filter: brightness(1.08) saturate(1.1); }
.rp-plot .tot { font-size: 11px; fill: var(--text-2); font-weight: 600; font-family: inherit; }
.rp-yl, .rp-xl { position: absolute; inset: 0; pointer-events: none; }
.rp-yl span { position: absolute; right: 0; width: 58px; text-align: left; transform: translateY(-50%); font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.rp-xl span { position: absolute; bottom: 4px; transform: translateX(-50%); font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.rp-tip { position: absolute; top: 4px; transform: translateX(-50%); z-index: 5; min-width: 180px; padding: 10px 12px; display: grid; gap: 4px; pointer-events: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-pop); font-size: 12px; }
.rp-tip.to-r { transform: translateX(-12%); }
.rp-tip.to-l { transform: translateX(-88%); }
.rp-tip-h { font-weight: 700; color: var(--heading); }
.rp-tip-total { display: flex; align-items: baseline; gap: 6px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.rp-tip-total b { font-size: 15px; color: var(--heading); }
.rp-tip-total span, .rp-tip-row span { color: var(--text-muted); }
.rp-tip-row { display: flex; align-items: center; gap: 6px; }
.rp-tip-row i { width: 12px; height: 2px; border-radius: 2px; }
.rp-tip-row b { color: var(--heading); font-weight: 600; }
.rp-key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }

/* heat table (reps × months) */
.rp-heat td, .rp-heat th { padding-inline: 10px; }
.rp-heat .rp-sticky { position: sticky; inset-inline-start: 0; background: var(--surface); z-index: 1; min-width: 130px; }
.rp-heat thead .rp-sticky { background: var(--surface-sunken); z-index: 2; }
.rp-heat tfoot .rp-sticky { background: var(--surface-sunken); }

/* sections */
.rp-dep-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 14px; }
.rp-dep-sum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.rp-dep-sum div { display: grid; gap: 2px; }
.rp-dep-sum span { font-size: 12px; color: var(--text-muted); }
.rp-dep-sum b { font-size: 15.5px; color: var(--heading); }
.rp-dep-sum b.ok { color: var(--ok); } .rp-dep-sum b.debt { color: var(--warn); } .rp-dep-sum b.muted { color: var(--text-2); }
.rp-mix { display: grid; gap: 14px; padding-top: 12px; }
.rp-mix-row { display: grid; gap: 6px; }
.rp-mix-h { display: flex; align-items: baseline; gap: 8px; }
.rp-mix-h b { color: var(--heading); }
.rp-mix-h span { margin-inline-start: auto; font-weight: 600; color: var(--heading); }
.rp-mix-h small { color: var(--text-muted); font-size: 11.5px; }
.rp-mix-bar { display: flex; gap: 2px; height: 12px; border-radius: 4px; overflow: hidden; background: var(--surface-sunken); }
.rp-mix-bar i { display: block; height: 100%; }
.rp-mix-bar .ok, .rp-mix-legend .ok { background: var(--ok); }
.rp-mix-bar .debt, .rp-mix-legend .debt { background: #f59e0b; }
.rp-mix-bar .rest, .rp-mix-legend .rest { background: #cbd2da; }
.rp-mix-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11.5px; color: var(--text-muted); }
.rp-mix-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-inline-end: 5px; vertical-align: -1px; }

/* aging */
.rp-aging { display: grid; grid-template-columns: 220px 1fr; gap: 12px; align-items: stretch; }
.rp-aging .rp-note { grid-column: 1 / -1; }
.rp-aging-total { display: grid; align-content: center; gap: 4px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-sm); }
.rp-aging-total span { font-size: 12.5px; color: var(--text-muted); }
.rp-aging-total b { font-size: 24px; color: var(--warn); }
.rp-aging-total small { font-size: 12px; color: var(--text-muted); }
.rp-aging-buckets { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.rp-aging-b { all: unset; cursor: pointer; box-sizing: border-box; position: relative; display: grid; gap: 3px; padding: 14px 14px 18px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); box-shadow: var(--shadow-sm); overflow: hidden; }
.rp-aging-b::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 4px; background: var(--sev); }
.rp-aging-b:hover { border-color: var(--border-strong); }
.rp-aging-b:focus-visible { outline: 2px solid var(--focus); }
.rp-aging-b.on { border-color: var(--sev); box-shadow: 0 0 0 2px color-mix(in srgb, var(--sev) 35%, transparent); }
.rp-aging-b span { font-size: 12.5px; color: var(--text-muted); font-weight: 600; }
.rp-aging-b b { font-size: 17px; color: var(--heading); }
.rp-aging-b small { font-size: 11.5px; color: var(--text-muted); }
.rp-aging-b i { position: absolute; bottom: 0; inset-inline-start: 0; height: 4px; background: var(--sev); }
@media (max-width: 1200px) { .rp-aging { grid-template-columns: 1fr; } .rp-aging-buckets { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.rp-days { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; background: var(--surface-sunken); color: var(--text-2); white-space: nowrap; }
.rp-days.soon { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.rp-days.out { background: var(--danger-bg); color: var(--danger); font-weight: 600; }

@media print {
    .sh-side, .sh-top, .rp-bar, .rp-noprint, .rp-head .ag-btn, .rp-crumb, .rp-legend button.off { display: none !important; }
    .sh, .sh-main, .sh-body { display: block !important; padding: 0 !important; margin: 0 !important; }
    .rp .ag-card, .rp .s2-sum { box-shadow: none !important; break-inside: avoid; }
    .rp-tbl-wrap { overflow: visible; }
    .rp-tbl thead th { position: static; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.rp-detail th:nth-child(2), .rp-detail td:nth-child(2) { min-width: 280px; }
.rp-detail td:nth-child(3) { min-width: 220px; }

/* ── reports: page frame, toolbar and tables (the polished layout) ───────────────────────────── */
.rp { gap: 14px; }
.rp-head { align-items: center; gap: 16px; }
.rp-title h1 { font-size: 22px; }
.rp-title p { margin-top: 6px; display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--surface-sunken); color: var(--text-2); font-size: 12px; }
.rp-actions { display: flex; align-items: center; gap: 8px; }

.rp-toolbar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-sm); }
.rp-toolbar .rp-bar { padding: 10px 12px; gap: 8px; }
.rp-toolbar .rp-search { flex: 1 1 240px; max-width: none; }
.rp-toolbar .rp-sel { min-width: 160px; }
.rp-views { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-sunken) 55%, var(--surface)); border-radius: 0 0 var(--r-card) var(--r-card); }

.rp-tbl { font-size: 13px; }
.rp-tbl th { font-size: 12px; padding-block: 10px; }
.rp-tbl td { vertical-align: middle; padding: 9px 14px; }
.rp-tbl td b { font-weight: 600; }
.rp-tbl tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-sunken) 35%, var(--surface)); }
.rp-tbl tbody tr.click:hover td { background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface)); }
.rp-tbl th.rp-debt-h, .rp-tbl td.rp-debt { background: color-mix(in srgb, var(--warn-bg) 30%, var(--surface)) !important; }
.rp-tbl tbody tr.click:hover td.rp-debt { background: color-mix(in srgb, var(--warn-bg) 60%, var(--surface)) !important; }
.rp-tbl tfoot td { font-size: 13px; }
.rp-tbl .rp-n { text-align: center; font-size: 12px; }
.rp-tbl .rp-bar-col { width: 170px; }
.rp-rate { display: flex; align-items: center; gap: 8px; min-width: 140px; }
.rp-rate .s2-mini { flex: 1; margin: 0; height: 6px; }
.rp-rate small { min-width: 42px; text-align: end; font-size: 12px; font-weight: 600; color: var(--text-2); }
.rp .ag-card-h .sub { font-size: 12px; }

/* every rep, each in his own small chart on one scale */
.rp-reps { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.rp-rep { all: unset; box-sizing: border-box; cursor: pointer; display: grid; gap: 6px; padding: 12px 14px 10px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); transition: border-color .12s, box-shadow .12s; }
.rp-rep:hover { border-color: var(--accent-line); box-shadow: var(--shadow-sm); }
.rp-rep:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.rp-rep-h { display: flex; align-items: baseline; gap: 8px; }
.rp-rep-h b { color: var(--heading); font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-rep-h .rk { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.rp-rep-h span.tot { margin-inline-start: auto; font-weight: 700; color: var(--heading); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-rep-sub { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--text-muted); }
.rp-rep svg { display: block; width: 100%; height: 56px; }
.rp-rep svg rect { fill: var(--accent); }
.rp-rep svg rect.zero { fill: var(--border); }
.rp-rep svg rect.best { fill: color-mix(in srgb, var(--accent) 78%, #000); }
.rp-rep svg line { stroke: var(--border-strong); stroke-width: 1; }
.rp-rep-x { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--text-3); }
.rp-rep.idle { background: color-mix(in srgb, var(--surface-sunken) 45%, var(--surface)); }
.rp-rep.idle .rp-rep-h span.tot { color: var(--text-3); }

/* customer statement */
.rp-cust-pick { position: relative; flex: 1 1 320px; min-width: 260px; }
.rp-cust-pick .s2-search { max-width: none; }
.rp-cust-chip { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px 0 12px; padding-inline: 12px 6px; border: 1px solid var(--accent-line); border-radius: var(--r-field);
  background: var(--accent-soft); color: var(--accent-text); font-size: 13px; }
.rp-cust-chip b { color: var(--heading); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-cust-chip small { color: var(--text-muted); }
.rp-cust-chip button { all: unset; cursor: pointer; margin-inline-start: auto; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; color: var(--text-muted); }
.rp-cust-chip button:hover { background: var(--surface); color: var(--danger); }
.rp-cust-chip button:focus-visible { outline: 2px solid var(--focus); }
.rp-cust-pop { position: absolute; top: calc(100% + 6px); inset-inline: 0; z-index: 41; max-height: 420px; overflow: auto; padding: 6px; display: grid; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-pop); }
.rp-cust-pop button { all: unset; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; }
.rp-cust-pop button:hover, .rp-cust-pop button:focus-visible { background: var(--surface-sunken); }
.rp-cust-pop button span { display: grid; min-width: 0; }
.rp-cust-pop button b { font-size: 13px; color: var(--heading); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-cust-pop button small { font-size: 11.5px; color: var(--text-muted); }
.rp-cust-pop button em { margin-inline-start: auto; font-style: normal; font-weight: 700; font-size: 12.5px; color: var(--warn); white-space: nowrap; }
.rp-cust-pop button em.muted { color: var(--text-3); font-weight: 500; }
.rp-open { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 600; color: var(--accent-text); white-space: nowrap; }

.rp-cust-card { display: flex; align-items: center; gap: 16px; padding: 16px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card);
  box-shadow: var(--shadow-sm); border-inline-start: 4px solid var(--accent); }
.rp-cust-id { display: flex; align-items: center; gap: 14px; min-width: 0; }
.rp-cust-av { flex: none; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); font-size: 20px; font-weight: 700; }
.rp-cust-id h2 { margin: 0; font-size: 18px; color: var(--heading); }
.rp-cust-id p { margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--text-muted); }
.rp-cust-id p b { color: var(--text); }
.rp-cust-bal { margin-inline-start: auto; display: grid; justify-items: end; text-align: end; gap: 1px; padding-inline-start: 20px; border-inline-start: 1px solid var(--border); }
.rp-cust-bal span { font-size: 12px; color: var(--text-muted); }
.rp-cust-bal b { font-size: 24px; color: var(--warn); font-variant-numeric: tabular-nums; }
.rp-cust-bal small { font-size: 11.5px; color: var(--text-muted); }

.rp-kind { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.rp-kind.due { background: var(--warn-bg); color: var(--warn); }
.rp-kind.pay { background: var(--ok-bg); color: var(--ok); }
.rp-kind.settle { background: var(--surface-sunken); color: var(--text-2); }
.rp-ledger td { white-space: nowrap; }
.rp-ledger td:nth-child(3), .rp-ledger td:nth-child(5) { white-space: normal; }
.rp-ledger .rp-open-row td { background: color-mix(in srgb, var(--accent-soft) 50%, var(--surface)) !important; }

/* ── report header: a clear way back, the title and what it answers, the scope as chips ── */
.rp-hero { display: grid; gap: 14px; padding: 14px 20px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-sm); }
.rp-hero-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.rp-back { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px 0 12px; padding-inline: 10px 14px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface-sunken); color: var(--text); font-size: 13px; font-weight: 600; text-decoration: none; transition: background .12s, border-color .12s, color .12s; }
.rp-back svg { color: var(--accent-text); transition: transform .12s; }
.rp-back:hover { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); }
.rp-back:hover svg { transform: translateX(2px); }
.rp-back:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.rp-hero .rp-actions { display: flex; align-items: center; gap: 8px; }
.rp-hero-main { display: flex; align-items: center; gap: 14px; }
.rp-hero-ic { flex: none; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); }
.rp-hero-tx { min-width: 0; }
.rp-hero-tx h1 { margin: 0; font-size: 22px; font-weight: 700; color: var(--heading); line-height: 1.3; }
.rp-hero-tx p { margin: 3px 0 0; font-size: 13px; color: var(--text-muted); }
.rp-scope { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.rp-scope-l { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-muted); margin-inline-end: 2px; }
.rp-scope-chip { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; background: var(--surface-sunken); border: 1px solid var(--border);
  font-size: 12px; color: var(--text-2); white-space: nowrap; }
.rp-scope-chip:last-child { background: transparent; border-style: dashed; color: var(--text-muted); }
@media print { .rp-hero-top, .rp-scope-l { display: none !important; } .rp-hero { box-shadow: none; } }

/* ── detailed customers: an obvious «عرض المشاريع» button per customer ── */
.rp-hint { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; padding: 10px 14px; border: 1px solid var(--accent-line); border-radius: var(--r-card, 12px);
  background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); color: var(--text); font-size: 13.5px; }
.rp-hint b { color: var(--accent); }
.rp-hint-ic { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--surface); color: var(--accent); flex: none; }
.rp-hint .sp { flex: 1; }
.rp-exp-col { width: 1%; white-space: nowrap; text-align: end; }
.rp-exp { all: unset; box-sizing: border-box; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--accent-line); background: var(--surface); color: var(--accent); font-size: 12.5px; font-weight: 600; white-space: nowrap; transition: background .15s, color .15s; }
.rp-exp:hover, tr.rp-cust:hover .rp-exp { background: var(--accent); color: #fff; border-color: var(--accent); }
.rp-exp.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.rp-exp:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
tr.rp-cust.click:hover td { background: color-mix(in srgb, var(--accent-soft) 35%, var(--surface)); }
tr.rp-cust:has(.rp-exp.on) td { background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface)); }
tr.rp-cust:has(.rp-exp.on) td:first-child { box-shadow: inset -4px 0 0 var(--accent); }
tr.rp-proj-h td { background: var(--surface-sunken); color: var(--text-muted); font-size: 12px; padding-block: 6px; }
tr.rp-proj-h b { color: var(--heading); }
@media print { .rp-exp-col, tr.rp-proj-h { display: none; } }

/* ── reps summary: ranking + amount ranges ── */
.rp-rank { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rp-rank-l, .rp-amt-l { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.rp-rank-l svg { color: var(--accent); }
.rp-amt { display: inline-flex; align-items: center; gap: 6px; padding: 4px 4px 4px 10px; padding-inline: 10px 4px; border: 1px solid var(--border); border-radius: var(--r-field); background: var(--surface); }
.rp-amt .inp { width: 110px; height: 30px; padding-inline: 8px; }
.rp-amt i { font-style: normal; color: var(--text-muted); font-size: 12px; }
.rp-filter-note { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; padding: 8px 12px; border-radius: var(--r-field); background: var(--surface-sunken); color: var(--text-muted); font-size: 12.5px; }
.rp-filter-note b { color: var(--heading); }
.rp-medal { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-weight: 700; font-size: 12px; color: #fff; }
.rp-medal.m1 { background: #d4a017; }
.rp-medal.m2 { background: #8f9aa5; }
.rp-medal.m3 { background: #b8743d; }

/* ── monthly reps: the ranking chart (one horizontal bar per rep) ── */
.rp-hbars { display: grid; gap: 2px; --bar: var(--accent); }
.rp-hbars.ok { --bar: #1a7f45; }
.rp-hbars.debt { --bar: #d9822b; }
.rp-hbars.rate { --bar: var(--accent); }
.rp-hbars.weak { --bar: #8f9aa5; }
.rp-hbar { all: unset; box-sizing: border-box; cursor: pointer; display: grid; grid-template-columns: 34px minmax(130px, 200px) minmax(120px, 1fr) 130px; grid-template-rows: auto auto;
  column-gap: 12px; row-gap: 2px; align-items: center; padding: 8px 10px; border-radius: 10px; }
.rp-hbar:hover:not(:disabled) { background: color-mix(in srgb, var(--accent-soft) 40%, var(--surface)); }
.rp-hbar:focus-visible { outline: 2px solid var(--focus); }
.rp-hbar:disabled { cursor: default; opacity: .75; }
.rp-hbar .rk { grid-row: 1 / 3; text-align: center; color: var(--text-muted); font-weight: 700; font-size: 13px; }
.rp-hbar .nm { grid-row: 1 / 3; display: grid; min-width: 0; }
.rp-hbar .nm b { color: var(--heading); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-hbar .nm small { color: var(--text-muted); font-size: 11.5px; }
.rp-hbar .tr { height: 14px; border-radius: 0 7px 7px 0; background: var(--surface-sunken); overflow: hidden; display: flex; }
.rp-hbar .tr i { display: block; height: 100%; min-width: 2px; background: var(--bar); border-radius: 0 7px 7px 0; transition: width .3s; }
.rp-hbar:nth-child(-n+3) .tr i { filter: saturate(1.15); }
.rp-hbar .vl { text-align: end; font-weight: 700; color: var(--heading); font-size: 14px; }
.rp-hbar .ot { grid-column: 3 / 5; display: flex; gap: 14px; flex-wrap: wrap; color: var(--text-muted); font-size: 11.5px; }
.rp-hbar .ot b { color: var(--text); font-weight: 600; }
@media (max-width: 900px) { .rp-hbar { grid-template-columns: 28px 1fr 100px; } .rp-hbar .tr { grid-column: 2 / 4; } .rp-hbar .nm { grid-row: auto; } }

/* ── reps reports: «إخفاء» toggles (zero debt, zero collection, no projects) ── */
.rp-hide { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rp-toggle { all: unset; box-sizing: border-box; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 11px; border-radius: 999px;
  border: 1px dashed var(--border-strong, var(--border)); color: var(--text-muted); font-size: 12.5px; font-weight: 600; white-space: nowrap; background: var(--surface); }
.rp-toggle svg { opacity: 0; width: 0; transition: width .15s, opacity .15s; }
.rp-toggle:hover { border-color: var(--accent); color: var(--accent); }
.rp-toggle.on { border-style: solid; border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text, var(--accent)); }
.rp-toggle.on svg { opacity: 1; width: 13px; }
.rp-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ── «الشرح بالفيديو» ── */
.hp-aud { margin-bottom: 14px; }
.hp-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 18px; align-items: start; }
.hp-list { display: grid; gap: 8px; position: sticky; top: 12px; }
.hp-item { all: unset; box-sizing: border-box; cursor: pointer; display: grid; grid-template-columns: 22px 38px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.hp-item:hover { border-color: var(--accent-line); }
.hp-item.on { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); background: color-mix(in srgb, var(--accent-soft) 35%, var(--surface)); }
.hp-item:focus-visible { outline: 2px solid var(--focus); }
.hp-num { color: var(--text-muted); font-weight: 700; text-align: center; }
.hp-ic, .hp-head-ic { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.hp-tx { display: grid; min-width: 0; }
.hp-tx b { color: var(--heading); font-size: 14px; }
.hp-tx small { color: var(--text-muted); font-size: 12px; }
.hp-tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.hp-tag.vid { background: var(--accent); color: #fff; }
.hp-tag.aud { background: var(--ok-bg); color: var(--ok); }
.hp-main { display: grid; gap: 14px; min-width: 0; padding: 20px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.hp-head { display: flex; gap: 14px; align-items: center; }
.hp-head-ic { width: 46px; height: 46px; border-radius: 12px; }
.hp-head h2 { margin: 0; font-size: 20px; color: var(--heading); }
.hp-head p { margin: 2px 0 0; color: var(--text-muted); }
.hp-video { width: 100%; border-radius: 12px; background: #000; aspect-ratio: 16 / 9; }
.hp-stage { display: grid; gap: 10px; padding: 22px 24px; border-radius: 14px; min-height: 260px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 92%, #000) 0%, var(--accent) 100%); color: #fff; }
.hp-stage-top { display: flex; align-items: center; gap: 10px; }
.hp-stage-n { padding: 3px 10px; border-radius: 999px; background: rgba(255,255,255,.16); font-size: 12px; font-weight: 600; }
.hp-stage h3 { margin: 4px 0 0; font-size: 24px; color: #fff; }
.hp-say { margin: 0; font-size: 16px; line-height: 1.9; color: rgba(255,255,255,.92); max-width: 70ch; }
.hp-stage .hp-open { color: #fff; border-color: rgba(255,255,255,.4); background: rgba(255,255,255,.1); }
.hp-dots { display: flex; gap: 6px; margin-top: auto; }
.hp-dots i { flex: 1; height: 4px; border-radius: 2px; background: rgba(255,255,255,.22); }
.hp-dots i.done { background: rgba(255,255,255,.6); }
.hp-dots i.on { background: #fff; }
.hp-ctrl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 6px; }
.hp-ctrl audio { height: 36px; max-width: 360px; width: 100%; }
.hp-ctrl small { color: rgba(255,255,255,.8) !important; }
.hp-open { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--accent-line);
  color: var(--accent); font-size: 12.5px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.hp-open:hover { background: var(--accent-soft); }
.hp-open.sm { height: 26px; padding: 0 10px; font-size: 12px; }
.hp-sub { margin: 4px 0 0; color: var(--heading); }
.hp-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.hp-steps li { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid transparent; }
.hp-steps li.on { border-color: var(--accent-line); background: color-mix(in srgb, var(--accent-soft) 40%, var(--surface)); }
.hp-step { all: unset; cursor: pointer; flex: 1; display: flex; gap: 12px; min-width: 0; }
.hp-step:disabled { cursor: default; }
.hp-step-n { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--surface-sunken); color: var(--heading); font-weight: 700; font-size: 12.5px; }
.hp-steps li.on .hp-step-n { background: var(--accent); color: #fff; }
.hp-step-tx { display: grid; gap: 2px; }
.hp-step-tx b { color: var(--heading); }
.hp-step-tx span { color: var(--text-muted); font-size: 13px; line-height: 1.8; }
@media (max-width: 1000px) { .hp-grid { grid-template-columns: 1fr; } .hp-list { position: static; } }
