/* آوین ۳ — design system v3 (owner, 30 Nov 2026). One source of tokens: the design system artifact «آوین ۳»
   (claude.ai/artifact/Eb2xgNHp2Cyc82coXZRMZ9, tokens.json). Loaded LAST: it maps the older layers' variables
   (app.css, design.css, v2.css) onto the v3 tokens, then adds the v3 components. When the old layers are retired,
   only the «legacy aliases» block goes.

   Owner's rules this file serves: nobody gets lost between tasks; what each person needs is in front of them;
   the action shows itself; different information in different frames; no explanatory text, only a small «!». */

/* ---------- tokens ---------- */
:root, :root[data-theme="light"] {
    --ground: #f3f2ef; --surface: #ffffff; --surface-2: #f7f6f3; --line: #e2e0db; --control-border: #8f8c85;
    --ink: #1c1d1f; --muted: #5d6168; --brand: #ffcc00; --brand-strong: #e0b000; --brand-soft: #fff6cc; --on-brand: #1c1d1f;
    --danger: #b42318; --danger-soft: #fcebe9; --warning: #8a5300; --warning-soft: #fbf1df; --info: #2f5f9e; --info-soft: #e8eff9;
    --success: #13734f; --success-soft: #e6f4ee; --focus: #315da1; --rail: #1c1d1f; --rail-ink: #ecebe7; --rail-muted: #a7a59f;
    --rail-active: #33353a; --scrim: #1c1d1f80; --shadow-overlay: 0 10px 30px -18px rgba(0,0,0,.35);
    --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-6: 24px; --space-8: 32px;
    --radius-sm: 6px; --radius-md: 10px; --radius-lg: 14px; --radius-full: 999px;
    --control-h: 40px; --control-h-touch: 48px; --bar-h: 64px;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --ground: #141517; --surface: #1c1d20; --surface-2: #232428; --line: #2e3035; --control-border: #6e727a;
        --ink: #f2f2f0; --muted: #a9adb4; --brand-strong: #ffd633; --brand-soft: #3a3415;
        --danger: #f07167; --danger-soft: #3a1c1a; --warning: #e3a33b; --warning-soft: #352a14; --info: #8fb4ea; --info-soft: #1c2a3d;
        --success: #4cc08f; --success-soft: #16302a; --focus: #ffdf59; --rail: #0e0f10; --rail-ink: #e4e3df; --rail-muted: #9a9893;
        --rail-active: #26282c; --scrim: #00000099; --shadow-overlay: 0 10px 30px -12px rgba(0,0,0,.7);
    }
}
:root[data-theme="dark"] {
    --ground: #141517; --surface: #1c1d20; --surface-2: #232428; --line: #2e3035; --control-border: #6e727a;
    --ink: #f2f2f0; --muted: #a9adb4; --brand-strong: #ffd633; --brand-soft: #3a3415;
    --danger: #f07167; --danger-soft: #3a1c1a; --warning: #e3a33b; --warning-soft: #352a14; --info: #8fb4ea; --info-soft: #1c2a3d;
    --success: #4cc08f; --success-soft: #16302a; --focus: #ffdf59; --rail: #0e0f10; --rail-ink: #e4e3df; --rail-muted: #9a9893;
    --rail-active: #26282c; --scrim: #00000099; --shadow-overlay: 0 10px 30px -12px rgba(0,0,0,.7);
}

/* ---------- legacy aliases: the older layers read these names ---------- */
:root, :root[data-theme] {
    --bg: var(--ground); --sf: var(--surface); --sf2: var(--surface-2); --tx: var(--ink); --mu: var(--muted); --fa: var(--muted);
    --ln: var(--line); --ln2: var(--control-border); --brandD: var(--brand-strong); --brandS: var(--brand-soft);
    --red: var(--danger); --redS: var(--danger-soft); --amb: var(--warning); --ambS: var(--warning-soft);
    --focus-ring: var(--focus);
    --nav: var(--rail); --nav-text: var(--rail-ink); --nav-muted: var(--rail-muted); --nav-line: #2e3035; --nav-active: var(--rail-active);
}
body { background: var(--ground) !important; color: var(--ink); }
:focus-visible { outline: 2px solid var(--focus) !important; outline-offset: 2px; }
.stock-zero, .tred { color: var(--danger); }

/* ---------- rail: five places ---------- */
.side { background: var(--rail) !important; }
.side .ngl:empty { display: none; }
.side .ng { border: 0 !important; padding-top: 4px; }
.side .ni { min-height: 42px; font-weight: 600; border-radius: var(--radius-sm); }
.side .ni.on { background: var(--rail-active) !important; box-shadow: inset -3px 0 0 var(--brand) !important; color: #fff !important; }
.side .ni.on .i { color: var(--brand) !important; }
.side .badge { background: var(--brand) !important; color: var(--on-brand) !important; font-weight: 800; }

/* place tabs: the old pages of a place, one row under the top bar */
.ptabs { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 0 0 var(--space-4); }
.ptabs a { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: var(--radius-full); border: 1px solid var(--line);
    background: var(--surface); color: var(--ink); font-size: 13.5px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.ptabs a:hover { border-color: var(--control-border); }
.ptabs a.on { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.ptabs a b { min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-full); background: var(--brand); color: var(--on-brand); font-size: 11.5px; font-weight: 800;
    display: inline-grid; place-items: center; }
@media (max-width: 760px) { .ptabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: 100%; } .ptabs a { height: 38px; flex: none; } }

/* top bar: search, «+ تازه», call, me */
.top .newbtn { background: var(--brand) !important; border-color: var(--brand-strong) !important; color: var(--on-brand) !important; font-weight: 800; }
.top .newbtn .i { color: var(--on-brand); }

/* ---------- controls: 3:1 borders, one height ---------- */
input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea { border-color: var(--control-border); }
.btn { border-color: var(--control-border); }
.btn.ghost { border-color: transparent; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn, .card, .ptabs a, .av-tip > button { transition: background-color .12s ease, border-color .12s ease, transform .12s ease, box-shadow .12s ease; }

/* ---------- InfoTip «!» ---------- */
.av-tip { position: relative; display: inline-flex; vertical-align: middle; margin-inline: 4px; }
.av-tip > button { width: 18px; height: 18px; min-height: 0; padding: 0; border-radius: var(--radius-full); border: 1px solid var(--control-border); background: var(--surface);
    color: var(--muted); font-family: inherit; font-size: 11px; font-weight: 800; line-height: 1; display: inline-grid; place-items: center; cursor: pointer; }
.av-tip > button:hover, .av-tip.open > button { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.av-tip .pop { position: absolute; top: 24px; inset-inline-start: -8px; z-index: 60; width: min(280px, 80vw); padding: var(--space-3); border-radius: var(--radius-md);
    background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-overlay); font-size: 13px; line-height: 21px; font-weight: 500; color: var(--ink); text-align: start; white-space: normal; }
.av-tip .pop b { display: block; font-weight: 800; margin-bottom: 2px; }
.touch .av-tip > button { width: 24px; height: 24px; }

/* ---------- Avino: one line, one mood, at most one action ---------- */
.av-avino { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-4) var(--space-2) var(--space-3); margin: 0 0 var(--space-4);
    background: var(--brand-soft); border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px; font-size: 14.5px; line-height: 23px; font-weight: 600; color: var(--ink); }
.av-avino .avino { width: 38px; height: 34px; flex: none; transition: transform .2s ease; }
.av-avino:hover .avino { transform: rotate(-8deg); }
.av-avino .say { flex: 1; min-width: 0; }
.av-avino .btn { flex: none; }
.av-avino.quiet { background: var(--surface-2); --avino-eyes: 0; --avino-closed-eyes: 1; }
.av-avino.cheer { background: var(--success-soft); --avino-eyes: 0; --avino-closed-eyes: 1; }
.av-avino.worry { background: var(--danger-soft); }
@media (max-width: 700px) { .av-avino { flex-wrap: wrap; } .av-avino .btn { flex: 1 1 100%; min-height: var(--control-h-touch); } }

/* ---------- on someone else's behalf ---------- */
.av-behalf { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; min-height: 44px; padding: var(--space-2) var(--space-4); margin: 0 0 var(--space-4);
    background: var(--ink); color: var(--surface); border-radius: var(--radius-md); font-size: 14px; font-weight: 600; }
.av-behalf b { font-weight: 800; }
.av-behalf .who { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--radius-full); background: var(--brand); color: var(--on-brand); font-weight: 800; }
.av-behalf .sp { flex: 1; }
.av-behalf .btn { height: 32px; min-height: 0; font-size: 13px; }
.btn.pri.behalf { box-shadow: inset 0 0 0 2px var(--ink) !important; }

/* ---------- ChangeNote + «به‌روز شد» ---------- */
.pill-updated { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 9px; border-radius: var(--radius-full); background: var(--ink); color: var(--surface);
    font-size: 11.5px; font-weight: 800; white-space: nowrap; vertical-align: middle; }
.av-change { border: 1px solid var(--ink); border-radius: var(--radius-md); background: var(--surface); overflow: hidden; margin: 0 0 var(--space-4); }
.av-change > header { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); padding: var(--space-2) var(--space-4); background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: 13px; }
.av-change > header b { font-weight: 800; }
.av-change > header .sp { flex: 1; }
.av-change ul { list-style: none; margin: 0; padding: var(--space-2) var(--space-4); display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.av-change li { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: baseline; }
.av-change .was { color: var(--muted); text-decoration: line-through; }
.av-change .now { font-weight: 800; }
.av-change .plus { color: var(--success); font-weight: 800; } .av-change .minus { color: var(--danger); font-weight: 800; }
.av-change footer { display: flex; gap: var(--space-2); justify-content: flex-end; padding: 0 var(--space-4) var(--space-3); }

/* ---------- quiet feed «مشتری‌های من» ---------- */
.av-feed { display: flex; flex-direction: column; }
.av-feed .row-f { display: grid; grid-template-columns: 76px minmax(0,1fr); gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; line-height: 22px; }
.av-feed .row-f:last-child { border-bottom: 0; }
.av-feed small { color: var(--muted); font-size: 12px; }
.av-feed b { font-weight: 800; }
.av-feed .row-f.unseen { background: linear-gradient(to left, var(--brand-soft), transparent 40%); }

/* ---------- motion: quick and small; off when the person asks for less ---------- */
.just-done { animation: av-done .45s ease both; }
@keyframes av-done { 0% { background: var(--success-soft); } 100% { background: transparent; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* the delivery dialog's «به‌جای لجستیک» note uses the on-behalf look */
.proxy-note.av-behalf-note { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; padding: var(--space-2) var(--space-4); border-radius: var(--radius-md);
    background: var(--ink) !important; color: var(--surface) !important; font-weight: 600; border: 0; }
.proxy-note.av-behalf-note b { color: var(--brand); }
.proxy-note.av-behalf-note .i { color: var(--brand); }
.av-change-hist { margin: 0 0 var(--space-4); }
.av-change-hist summary { cursor: pointer; padding: 4px 0; }
.ptabs { margin-top: var(--space-3); }

/* ---------- tablet (761–1200px): the rail keeps its labels (no unlabelled icon anywhere) ---------- */
@media (max-width: 1200px) and (min-width: 761px) {
    .shell { grid-template-columns: 92px minmax(0, 1fr) !important; }
    .side .ni { flex-direction: column; justify-content: center; gap: 3px; min-height: 60px; padding: 8px 4px; text-align: center; }
    .side .ni span { display: block !important; font-size: 11.5px; line-height: 15px; white-space: normal; overflow: visible; }
    .side .ni.on { box-shadow: inset 0 -3px 0 var(--brand) !important; }
    .side .badge { display: grid !important; position: absolute; top: 5px; inset-inline-start: 10px; min-width: 18px; height: 18px; font-size: 11px; }
    .top .search { flex: 1 1 200px; }
    .top .qsale span { display: none; }
    .page.wide, .page { padding-inline: 20px; }
}

/* ---------- phone (≤760px) ---------- */
@media (max-width: 760px) {
    .top .newbtn { width: 44px; height: 44px; padding: 0; justify-content: center; }
    .top .newbtn span { display: none; }
    .top .qsale { display: none; }                       /* in «+ تازه» on a phone */
    .bnav button { min-height: 56px; font-size: 11.5px; }
    .bnav button.on { box-shadow: inset 0 3px 0 var(--brand); color: var(--ink); }
    .av-avino { padding: 10px 12px; font-size: 14px; }
    .av-tip .pop { position: fixed; inset-inline: 16px; top: auto; bottom: 84px; width: auto; }
    .av-change ul { padding-inline: 12px; }
}

/* ---------- every Avino line in the app follows the v3 rule: one line, no how-to sentence ---------- */
.coach:not(.call-coach) { background: var(--brand-soft) !important; border: 0 !important; border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px !important; box-shadow: none !important; }
.coach:not(.call-coach) .say > span { display: none; }
.coach .avino { width: 38px; height: 34px; }
.pop[data-for] { z-index: 200; padding: var(--space-3); border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-overlay);
    font-size: 13px; line-height: 21px; font-weight: 500; color: var(--ink); text-align: start; direction: rtl; }
.pop[data-for] b { display: block; font-weight: 800; margin-bottom: 2px; }
.pcopies { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.pcopies input { width: 64px; height: 40px; text-align: center; }

/* phone top bar: a short label under every icon (owner, 30 Nov 2026: no unlabelled icon in a bar) */
@media (max-width: 760px) {
    .top { height: 60px; }
    .top :is(.search, .okdot, .fbtop, .newbtn, .me) { flex-direction: column; gap: 1px; height: 50px !important; width: 50px !important; min-width: 50px; padding: 4px 0 !important; }
    .top :is(.search, .okdot, .fbtop, .newbtn, .me)::after { font-size: 10px; line-height: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; }
    .top .newbtn::after { color: var(--on-brand); }
    .top .search::after { content: "جست‌وجو"; }
    .top .okdot::after { content: "تلفن"; }
    .top .fbtop::after { content: "ایراد"; }
    .top .newbtn::after { content: "تازه"; }
    .top .me::after { content: "من"; }
    .top .me span { display: none; }
}

/* phone: the order's customer is one compact block so the items start on the first screen (review 30 Nov) */
@media (max-width: 760px) {
    .order-page .cust-id { padding: 10px 12px !important; }
    .order-page .ci-facts { display: flex !important; flex-wrap: wrap; gap: 2px 14px; margin-top: 4px; }
    .order-page .ci-f { margin: 0 !important; display: flex; gap: 6px; align-items: baseline; font-size: 13px; }
    .order-page .ci-f.wide, .order-page .ci-links { display: none !important; }
    .order-page .document-actions { gap: 6px; }
}

/* phone: each warehouse's stock is shown once, under the product name (the old card printed it twice) */
@media (max-width: 760px) { .tbl td.whst { display: none !important; } }

/* ---------- layout stability (owner, 30 Nov 2026: «تب سمت راست جابه‌جا می‌شود») ----------
   The rail jumped 15px between short pages and pages with a scrollbar: the scrollbar took its width only when it
   appeared. The gutter is now always reserved, so nothing moves between pages or while data loads. */
@media (min-width: 761px) {   /* phones use overlay scrollbars: nothing to reserve there */
    html { scrollbar-gutter: stable; }
}

/* ---------- breathing room (measured 30 Nov 2026: buttons sat 0px from their frame) ----------
   Sticky action bars and button rows that have their own surface keep 12px from every edge, 8px between buttons. */
.oacts, .actbar:not(.document-actions), .ccre { padding-inline: 12px !important; gap: 8px; border-radius: var(--radius-md); }
.ccre { padding-block: 10px !important; }
.card.sms-compose { padding-bottom: 16px !important; }
.card.sms-compose .btn.pri { margin-top: 4px; }
.card > .actbar:last-child, .card > .oacts:last-child { margin-bottom: 0; }
/* the same rhythm everywhere: 16px inside a card, 16px between cards, 8px between controls */
.page > .card + .card, .page > section + section { margin-top: var(--space-4); }
.mft { gap: var(--space-2); padding: var(--space-3) var(--space-4) !important; }

/* ---------- mouse and keyboard feedback: only cheap properties (colour, border, a 1px move); no shadows or filters
   that cost paint on long lists ---------- */
.is-link, .row.clk, .mw, .deal, .ocard.clk { cursor: pointer; }
.is-link:hover, .row.clk:hover { background: var(--surface-2); }
.mw:hover { border-color: var(--control-border) !important; }
.mw:active, .is-link:active { transform: translateY(1px); }
.row:focus-visible, .is-link:focus-visible, .mw:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.side .ni:hover:not(.on) { background: #2a2c30 !important; }
.ptabs a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.u-min0 { min-width: 0; }
.u-scroll45 { max-height: 45vh; overflow: auto; }

/* ---------- پرونده‌ها: one board, three views ---------- */
.cb-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-4); }
.cb-head h1 { margin: 0; font-size: 24px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.cb-head .cnt, .cb-col h2 .cnt, .cb-group h2 .cnt { font-size: 13px; font-weight: 700; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 1px 9px; }
.cb-tools { display: flex; gap: var(--space-2); align-items: flex-end; flex-wrap: wrap; }
.cb-lens button { min-height: 38px; padding: 0 14px; }
.cb-sel { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); font-weight: 600; }
.cb-sel select { height: 38px; min-width: 140px; border: 1px solid var(--control-border); border-radius: var(--radius-md); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; font-weight: 700; padding: 0 10px; }
.cb-cols { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: var(--space-3); align-items: start; overflow-x: auto; padding-bottom: 4px; }
.cb-col { background: var(--surface-2); border-radius: var(--radius-lg); padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.cb-col h2, .cb-group h2 { margin: 0 0 var(--space-1); font-size: 15px; font-weight: 800; display: flex; align-items: center; gap: 6px; }
.cb-none { color: var(--muted); margin: 0; text-align: center; }
.cb-group { margin-bottom: var(--space-6); }
.cb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-3); }
.cb-card { display: flex; flex-direction: column; gap: 6px; padding: var(--space-3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); color: var(--ink); text-decoration: none; min-width: 0; }
.cb-card:hover { border-color: var(--control-border); }
.cb-card:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.cb-card.is-mine { border-color: var(--brand-strong); box-shadow: inset -3px 0 0 var(--brand); }
.cb-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cb-name { font-size: 15px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-amt { font-size: 14px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cb-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-track { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; list-style: none; margin: 2px 0; padding: 0; }
.cb-track li { height: 6px; border-radius: 3px; background: var(--line); }
.cb-track li.done { background: var(--success); }
.cb-track li.mine { background: var(--brand-strong); }
.cb-track li.waiting { background: var(--info); }
.cb-track li.late { background: var(--danger); }
.cb-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.pill-s { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink); font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.pill-s.late { background: var(--danger-soft); color: var(--danger); }
.pill-s.mine { background: var(--brand-soft); color: var(--ink); }
.pill-s.waiting { background: var(--info-soft); color: var(--info); }
@media (max-width: 1200px) { .cb-cols { grid-template-columns: repeat(5, minmax(220px, 1fr)); } }
@media (max-width: 760px) {
    .cb-head h1 { font-size: 20px; }
    .cb-tools { width: 100%; }
    .cb-lens { width: 100%; display: grid !important; grid-template-columns: repeat(3, 1fr); }
    .cb-sel { flex: 1 1 140px; } .cb-sel select { width: 100%; height: 44px; }
    .cb-cols { display: flex; flex-direction: column; overflow: visible; }
    .cb-col { padding: var(--space-2); }
    .cb-grid { grid-template-columns: 1fr; }
}
.cb-name { white-space: normal !important; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 22px; }
.cb-items { font-size: 13px; font-weight: 600; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 20px; }
.cb-top { align-items: flex-start; }

.av-behalf .btn { color: var(--ink) !important; background: var(--surface) !important; border-color: var(--surface) !important; }

@media (max-width: 760px) { .cb-cols { align-items: stretch !important; } .cb-col { width: 100%; } }

/* ---------- case page v3: document · path · turn · log ---------- */
.c3 .card { border-radius: var(--radius-lg); }
.c3-head { padding: var(--space-4) var(--space-6) !important; display: grid; gap: var(--space-3); margin-bottom: var(--space-4); }
.c3-title { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.c3-title h1 { margin: 0; font-size: 1.45rem; line-height: 1.3; }
.c3-title .sp { flex: 1; }
.c3-who { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.c3-who .nm { font-size: 1.15rem; font-weight: 800; background: none; border: 0; padding: 0; color: var(--ink); cursor: pointer; font-family: inherit; }
.c3-who .nm:hover { text-decoration: underline; text-underline-offset: 4px; }
.c3-who .c3-tel { color: var(--ink); font-weight: 700; text-decoration: none; border-bottom: 1px dashed var(--control-border); }
.c3-who .mu { display: inline-flex; align-items: center; gap: 4px; }
.c3-who .mu .i { width: 16px; height: 16px; }
.c3-people { display: flex; gap: var(--space-6); flex-wrap: wrap; font-weight: 700; }
.c3-people small, .c3-facts dt { display: block; color: var(--muted); font-size: .78rem; font-weight: 500; }
.c3-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-2) var(--space-4); margin: 0;
    padding-top: var(--space-3); border-top: 1px solid var(--line); }
.c3-facts div { min-width: 0; } .c3-facts dd { margin: 2px 0 0; font-weight: 800; }
.c3-note { display: flex; gap: 8px; align-items: flex-start; margin: 0; padding: 8px 12px; border-radius: var(--radius-md); background: var(--warning-soft); }
.c3-note .i { flex: none; width: 18px; height: 18px; margin-top: 3px; }

.c3-path { margin: 0 0 var(--space-4); }
.c3-path ol { list-style: none; margin: 0; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.c3-path li { position: relative; min-width: 0; }
.c3-path li::before, .c3-path li::after { content: ""; position: absolute; top: 19px; height: 2px; background: var(--line); }
.c3-path li::before { inset-inline-start: 0; inset-inline-end: 50%; }
.c3-path li::after { inset-inline-start: 50%; inset-inline-end: 0; }
.c3-path li:first-child::before, .c3-path li:last-child::after { display: none; }
.c3-path li.st-done::before, .c3-path li.st-done::after, .c3-path li.st-now::before { background: var(--success); }
.c3-path .case-phase { position: relative; z-index: 1; display: grid; justify-items: center; gap: 2px; width: 100%; background: none; border: 0; padding: 0 4px;
    cursor: pointer; color: var(--ink); text-align: center; min-height: 0; border-radius: var(--radius-md); font-family: inherit; }
.c3-path .case-phase:hover b { text-decoration: underline; text-underline-offset: 3px; }
.c3-path .dot { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--line); }
.c3-path .dot .i { width: 18px; height: 18px; }
.c3-path .st-done .dot { background: var(--success); border-color: var(--success); color: #fff; }
.c3-path .st-now .dot { background: var(--brand); border-color: var(--brand-strong); box-shadow: 0 0 0 5px var(--brand-soft); }
.c3-path .st-wait b { color: var(--muted); font-weight: 600; }
.c3-path b { font-size: .95rem; margin-top: 4px; }
.c3-path small { color: var(--muted); font-size: .74rem; line-height: 1.5; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c3-path .st-now small { color: var(--ink); font-weight: 700; white-space: normal; }

.c3-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); gap: var(--space-4); align-items: start; }
.c3-main, .c3-side { display: grid; gap: var(--space-4); min-width: 0; align-content: start; }
.c3-main > .cact, .c3-main > section, .c3-main > details, .c3-main > p { margin: 0 !important; }
.c3-now { padding: var(--space-4) var(--space-6) !important; display: grid; gap: var(--space-3); border-inline-start: 4px solid var(--warning) !important; }
.c3-now.mine { border-inline-start-color: var(--brand) !important; }
.c3-now.grn { border-inline-start-color: var(--success) !important; } .c3-now.red { border-inline-start-color: var(--danger) !important; }
.c3-mine { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.c3-mine small { color: var(--muted); font-weight: 700; } .c3-mine h2 { margin: 0; font-size: 1.3rem; display: flex; align-items: center; gap: 6px; }
.c3-wait { margin: 0; font-size: 1.02rem; }
.c3-more { display: flex; gap: var(--space-2); flex-wrap: wrap; padding-top: var(--space-3); border-top: 1px solid var(--line); }
.c3-sub h3 { margin: 0 0 6px; font-size: 1rem; }
.c3-items { padding: var(--space-4) var(--space-6) !important; }
.c3-items .case-order-items { margin: 0; } .c3-items .case-order-items h2 { margin-top: 0; }
.c3-money { padding: var(--space-4) !important; } .c3-money h2 { margin: 0 0 var(--space-2); font-size: 1rem; }
.c3-money .case-facts { display: grid; gap: var(--space-2); grid-template-columns: 1fr; }

.c3-log { padding: var(--space-4) !important; display: grid; gap: var(--space-3); }
.c3-log header { display: flex; align-items: center; gap: 6px; } .c3-log h2 { margin: 0; font-size: 1rem; }
.c3-compose { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 !important; }
.c3-compose .input { flex: 1 1 160px; min-width: 0; }
.c3-filters { display: flex; gap: 4px; flex-wrap: wrap; }
.c3-filters button { height: 30px; padding: 0 10px; border-radius: var(--radius-full); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: .82rem; cursor: pointer; }
.c3-filters button small { color: var(--muted); }
.c3-filters button.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.c3-filters button.on small { color: inherit; opacity: .75; }
.c3-list { list-style: none; margin: 0; padding: 0; max-height: 70vh; overflow: auto; overscroll-behavior: contain; }
.c3-list .c3-day { position: sticky; top: 0; background: var(--surface); color: var(--muted); font-size: .78rem; font-weight: 800; padding: 8px 0 4px; z-index: 1; }
.c3-ev { display: grid; grid-template-columns: 28px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.c3-ev:last-child { border-bottom: 0; }
.c3-ev > i { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); font-style: normal; }
.c3-ev > i .i { width: 15px; height: 15px; }
.c3-ev.k-decide > i { background: var(--success-soft); color: var(--success); }
.c3-ev.k-change > i { background: var(--warning-soft); color: var(--warning); }
.c3-ev.k-note > i { background: var(--info-soft); color: var(--info); }
.c3-ev.fresh { background: var(--brand-soft); border-radius: var(--radius-sm); }
.c3-ev .c3-t { display: block; font-weight: 600; line-height: 1.6; overflow-wrap: anywhere; }
.c3-ev small { color: var(--muted); font-size: .76rem; }
.c3-diff { list-style: none; margin: 6px 0 0; padding: 6px 8px; border-radius: var(--radius-sm); background: var(--surface-2); display: grid; gap: 2px; font-size: .82rem; }
.c3-diff li { display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; }
.c3-diff span, .c3-diff s { color: var(--muted); } .c3-diff em { font-style: normal; font-weight: 800; }
.c3-empty { color: var(--muted); padding: 8px 0; }
.c3-files summary { cursor: pointer; font-weight: 700; }

@media (max-width: 1100px) { .c3-grid { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
    .c3-head, .c3-now, .c3-items { padding: var(--space-3) var(--space-4) !important; }
    .c3-title h1 { font-size: 1.2rem; }
    .c3-path { overflow-x: auto; scrollbar-width: none; }
    .c3-path ol { grid-auto-columns: minmax(84px, 1fr); }
    .c3-path small { display: none; } .c3-path .st-now small { display: block; }
    .c3-mine .btn.pri { width: 100%; justify-content: center; }
    .c3-facts { grid-template-columns: 1fr 1fr; }
    .c3-list { max-height: none; }
}

/* case v3 fixes: no legacy phase-tab look, one border around items, a compose row that never overflows */
.c3-path .case-phase, .c3-path .case-phase.now { min-height: 0 !important; box-shadow: none !important; border: 0 !important; background: none !important; place-content: initial; }
.c3-path .case-phase b { display: block; font-size: .95rem; }
.c3-path .case-phase small { font-size: .74rem; }
.c3-items .case-order-items, .c3-items .case-order-list { border: 0 !important; box-shadow: none !important; padding: 0 !important; background: none !important; }
.c3-log .c3-compose { display: grid !important; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; flex-direction: initial; }
.c3-log .c3-compose > #cc_text { grid-column: 1 / -1; height: var(--control-h) !important; min-height: 0 !important; }
.c3-log .c3-compose > select { width: 100% !important; max-width: none; height: var(--control-h); min-height: 0 !important; }
.c3-log .c3-compose > .btn { min-width: 72px; }
@media (max-width: 760px) {
    .c3-path ol { grid-auto-columns: minmax(62px, 1fr); }
    .c3-path .dot { width: 32px; height: 32px; }
    .c3-path li::before, .c3-path li::after { top: 15px; }
    .c3-path .case-phase b { font-size: .85rem; }
    .c3-log .c3-compose > #cc_text, .c3-log .c3-compose > select { height: var(--control-h-touch); }
}

/* «برگردان»: 5 seconds to take back an action with no way back */
.av-undo { position: fixed; z-index: 1000; inset-inline: 0; bottom: calc(var(--space-6) + env(safe-area-inset-bottom)); margin: 0 auto; width: min(520px, calc(100% - 32px));
    display: flex; align-items: center; gap: var(--space-3); padding: 12px 16px; border-radius: var(--radius-lg); background: var(--ink); color: var(--surface);
    box-shadow: var(--shadow-overlay); overflow: hidden; }
.av-undo-t { flex: 1; display: grid; gap: 2px; } .av-undo-t small { opacity: .8; }
.av-undo .btn { background: var(--brand) !important; color: var(--on-brand) !important; border-color: var(--brand) !important; font-weight: 800; min-width: 96px; justify-content: center; }
.av-undo-bar { position: absolute; inset-inline-start: 0; bottom: 0; height: 3px; width: 100%; background: var(--brand); transform-origin: right; animation: av-undo-run 5s linear forwards; }
@keyframes av-undo-run { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) { .av-undo-bar { animation: none; } }
@media (max-width: 760px) { .av-undo { bottom: calc(76px + env(safe-area-inset-bottom)); } }

/* ---------- the document page v3: same frames as the case ---------- */
.o3 .document-header.card { padding: var(--space-4) var(--space-6) !important; border-radius: var(--radius-lg); margin-bottom: var(--space-4); align-items: start; }
.o3 .document-header .ci, .o3 .document-header .customer-identity { box-shadow: none !important; border: 0 !important; padding-inline: 0 !important; background: none !important; }
.o3 .document-header .sales-trace { margin: var(--space-2) 0 0; padding-top: var(--space-3); border-top: 1px solid var(--line); }
.o3 .olayout { align-items: start !important; gap: var(--space-4); }
.o3 .oside { display: grid; gap: var(--space-4); align-content: start; position: sticky; top: calc(var(--bar-h) + var(--space-4)); }
.o3 .omain { display: grid; gap: var(--space-4); align-content: start; }
.o3 .omain > *, .o3 .oside > * { margin: 0 !important; }
.o3 .o3-turn h2 { margin: 0; font-size: 1.2rem; }
.o3 .o3-turn .decide { border: 0 !important; padding: 0 !important; box-shadow: none !important; background: none !important; }
.o3 .o3-turn .decide .sh { font-size: .9rem !important; color: var(--muted); }
.o3 .o3-turn .oacts { display: grid; gap: var(--space-2); padding: 0 !important; }
.o3 .o3-turn .oacts .btn.pri { width: 100%; justify-content: center; min-height: var(--control-h-touch); }
.o3 .o3-sum { padding: var(--space-4) !important; }
.o3 .o3-more { display: flex; flex-wrap: wrap; gap: var(--space-2); padding: 0 !important; }
.o3 .o3-more .dan-t { color: var(--danger) !important; margin-inline-start: auto; }
.o3 .c3-log { padding: var(--space-4) var(--space-6) !important; }
@media (max-width: 1100px) { .o3 .oside { position: static; } }
@media (max-width: 760px) {
    .o3 .document-header.card { padding: var(--space-3) var(--space-4) !important; }
    .o3 .c3-log { padding: var(--space-3) var(--space-4) !important; }
}
.o3 .document-header .cust-id { box-shadow: none !important; border: 0 !important; border-top: 1px solid var(--line) !important; border-radius: 0 !important; padding: var(--space-3) 0 0 !important; background: none !important; margin-top: var(--space-2); }
.o3 .oside .o3-more { position: static !important; background: none !important; border: 0 !important; padding: 0 !important; z-index: auto; }
.o3 .o3-turn .oacts { position: static !important; background: none !important; border: 0 !important; }
@media (max-width: 1100px) {
    .o3 .olayout { display: flex !important; flex-direction: column; }
    .o3 .oside { display: contents !important; }
    .o3 .o3-turn { order: 1; } .o3 .omain { order: 2; } .o3 .o3-sum { order: 3; } .o3 .o3-more { order: 4; }
}
@media (max-width: 1100px) { .o3 .olayout { align-items: stretch !important; } .o3 .omain, .o3 .oside > * { width: 100%; } }
.c3-age { display: block; font-size: .72rem; margin-top: 2px; }
@media (pointer: coarse) {
    .av-tip > button, .apbox .av-tip > button { width: 32px !important; height: 32px !important; min-width: 32px !important; min-height: 32px !important; }
    .c3-filters button { height: 36px; padding: 0 12px; }
}
/* keeper hand-over: one-line serial field that grows with each scanned line */
.case-handover textarea[data-hserial] { min-height: var(--control-h) !important; height: auto; field-sizing: content; max-height: 160px; resize: vertical; }
@media (max-width: 760px) { .case-handover .seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); } .case-handover .seg button { white-space: normal; line-height: 1.3; padding: 4px 6px; font-size: .86rem; min-height: var(--control-h-touch); } }
.page > .ptabs { margin: 0; }
.top .call-pending { flex: none; white-space: nowrap; gap: 6px; }
.top .call-pending .cp-n { min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-full); background: var(--warning); color: #fff; font-size: .75rem; display: inline-grid; place-items: center; }
@media (max-width: 1100px) { .top .call-pending span { display: none; } }

/* ---------- rail clock (#176): quiet, readable, light on the CPU (one attribute per second) ---------- */
.side .av-clock { display: grid; justify-items: center; gap: 2px; margin: var(--space-4) var(--space-3); padding: var(--space-3) var(--space-2);
    border: 1px solid #2e3035; border-radius: var(--radius-lg); background: linear-gradient(180deg, #25272b, #1c1d1f); color: var(--rail-ink);
    cursor: pointer; font: inherit; transition: border-color .15s ease, transform .15s ease; }
.side .av-clock:hover { border-color: var(--brand); }
.side .av-clock:active { transform: scale(.98); }
.av-clock svg { width: 104px; height: 104px; filter: drop-shadow(0 6px 10px rgba(0,0,0,.35)); }
.av-clock .rim { fill: #f7f6f3; stroke: #3a3c41; stroke-width: 3; }
.av-clock .ticks line { stroke: #5d6168; stroke-width: 2; stroke-linecap: round; }
.av-clock .hh { stroke: #1c1d1f; stroke-width: 5; stroke-linecap: round; }
.av-clock .mh { stroke: #1c1d1f; stroke-width: 3.2; stroke-linecap: round; }
.av-clock .sh { stroke: var(--brand-strong); stroke-width: 1.4; stroke-linecap: round; }
.av-clock .pin { fill: var(--brand); stroke: #1c1d1f; stroke-width: 1; }
.av-clock-day { font-weight: 800; font-size: .95rem; margin-top: 6px; }
.av-clock-date { color: var(--rail-muted); font-size: .8rem; }
.av-clock-badge { margin-top: 4px; padding: 1px 10px; border-radius: var(--radius-full); background: var(--brand); color: var(--on-brand); font-size: .74rem; font-weight: 800; }
.av-clock-badge[hidden] { display: none; }
@media (max-width: 1200px) and (min-width: 761px) {   /* tablet rail: icons with labels; a small clock */
    .av-clock svg { width: 56px; height: 56px; } .av-clock-date { display: none; } .side .av-clock { margin: var(--space-2); padding: var(--space-2) 4px; }
}
@media (max-height: 640px) { .side .av-clock { display: none; } }

/* the panel */
.rem-panel { display: grid; gap: var(--space-3); }
.rem-new { display: grid; gap: var(--space-2); padding: var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-2); }
.rem-when { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-b { height: 34px; padding: 0 12px; border-radius: var(--radius-full); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: .86rem; cursor: pointer; }
.chip-b.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.rem-opts { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: end; }
.rem-opts .rem-for { flex: 1 1 160px; margin: 0; }
.rem-panel h3 { margin: var(--space-2) 0 0; font-size: .95rem; color: var(--muted); }
.rem-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.rem-row { display: flex; gap: var(--space-3); align-items: center; justify-content: space-between; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.rem-row > div { display: grid; gap: 2px; min-width: 0; } .rem-row b { overflow-wrap: anywhere; }
.rem-row.due b::before { content: "● "; color: var(--danger); }
.rem-given summary { cursor: pointer; color: var(--muted); font-weight: 700; }
@media (pointer: coarse) { .chip-b { height: 40px; } }

/* the alarm card */
.av-alarms { position: fixed; z-index: 1001; inset-inline: 0; top: calc(var(--bar-h) + var(--space-3)); margin: 0 auto; width: min(460px, calc(100% - 32px)); display: grid; gap: var(--space-2); pointer-events: none; }
.av-alarm { pointer-events: auto; display: grid; grid-template-columns: 44px 1fr; gap: var(--space-3); padding: var(--space-4); border-radius: var(--radius-lg);
    background: var(--surface); border: 2px solid var(--brand); box-shadow: var(--shadow-overlay); animation: av-alarm-in .25s ease-out; }
.av-alarm-face .brand-face { width: 44px; height: 44px; }
.av-alarm-t small { color: var(--muted); font-weight: 700; } .av-alarm-t b { display: block; font-size: 1.1rem; } .av-alarm-t p { margin: 4px 0 0; }
.av-alarm-a { grid-column: 1 / -1; display: flex; gap: var(--space-2); } .av-alarm-a .btn { flex: 1; justify-content: center; }
@keyframes av-alarm-in { from { transform: translateY(-12px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .av-alarm { animation: none; } }
.sales-report-records .sales-doc-no { display: block; font-size: .74rem; }

/* ---------- «تأمین» desk ---------- */
.sup-page .sup-tools { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.sup-g, .sup-buys { padding: var(--space-4) var(--space-6) !important; border-radius: var(--radius-lg); display: grid; gap: var(--space-3); }
.sup-g > header { display: flex; gap: var(--space-3); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.sup-g h2, .sup-buys h2 { margin: 0; font-size: 1.1rem; }
.sup-list { list-style: none; margin: 0; padding: 0; display: grid; }
.sup-list li { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid var(--line); }
.sup-list li > div { flex: 1 1 220px; display: grid; gap: 2px; min-width: 0; }
.sup-shares { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-2); }
.sup-share { margin: 0; }
.sup-people { display: grid; gap: 6px; max-height: 55vh; overflow: auto; }
@media (max-width: 760px) { .sup-g, .sup-buys { padding: var(--space-3) var(--space-4) !important; } }
.oday { display: flex; gap: 6px; align-items: end; flex-wrap: wrap; }
.rpage .rtabs-sel { margin: 0; }
