/* Sales panel. Right-to-left throughout; logical properties keep the layout direction-proof.
   The interface font draws Latin digits as Persian ones, so numbers read naturally and still
   copy as plain digits. Technical text (tokens, links, usernames) uses .mono, which does not. */

@font-face { font-family: "Vazirmatn FD"; src: url("fonts/Vazirmatn-FD-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Vazirmatn FD"; src: url("fonts/Vazirmatn-FD-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Vazirmatn FD"; src: url("fonts/Vazirmatn-FD-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --font: "Vazirmatn FD", Vazirmatn, Tahoma, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;

  --bg: #f5f6f8;
  --surface: #fff;
  --surface-2: #f9fafb;
  --hover: #f2f4f6;
  --ink: #17212b;
  --ink-2: #3f4b58;
  --muted: #5f6b78;
  --faint: #98a2ad;
  --line: #e5e8ec;
  --line-2: #cfd6dd;

  --brand: #0b6e4f;
  --brand-strong: #085a41;
  --brand-soft: #e8f4ef;
  --brand-line: #b9dccd;
  --sun: #f2a516;

  --ok: #0a6847;       --ok-bg: #e6f4ee;      --ok-line: #b7dfcd;
  --info: #1a5aa8;     --info-bg: #e9f1fc;    --info-line: #bcd4f3;
  --warn: #7d4c00;     --warn-bg: #fff3d4;    --warn-line: #efd28a;
  --danger: #b42318;   --danger-bg: #fdecea;  --danger-line: #f3bdb7;
  --violet: #5f33b0;   --violet-bg: #f1ebfb;  --violet-line: #d5c5f1;

  --radius: 12px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(23, 33, 43, .04), 0 1px 3px rgba(23, 33, 43, .05);
  --shadow-lg: 0 16px 40px rgba(23, 33, 43, .18);
  --focus: 0 0 0 3px rgba(11, 110, 79, .28);
  --sidebar: 252px;
  --gutter: 32px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.75; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 22px; line-height: 1.5; font-weight: 700; }
h2 { font-size: 15.5px; line-height: 1.6; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
::selection { background: #cfe8dc; }

.muted { color: var(--muted); }
.dash { color: var(--faint); }
.num { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: var(--mono); direction: ltr; unicode-bidi: isolate; font-size: .92em; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }
.stack-sm > * + * { margin-top: 8px; }
.stack > * + * { margin-top: 16px; }

/* ---- shell --------------------------------------------------------------- */

body.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.skip { position: absolute; inset-inline-start: 12px; top: -60px; z-index: 100; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px; }
.skip:focus { top: 12px; }

.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding: 16px 12px 12px; background: var(--surface); border-inline-end: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--brand); color: var(--sun); display: grid; place-items: center; flex: none; }
.brand-mark .ic { width: 21px; height: 21px; stroke-width: 2; }
.brand b { display: block; font-size: 14.5px; line-height: 1.5; }
.brand small { display: block; color: var(--muted); font-size: 12px; line-height: 1.5; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-title { font-size: 11.5px; font-weight: 500; color: var(--muted); padding: 14px 10px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 10px; border-radius: 9px; color: var(--ink-2); font-weight: 500; font-size: 13.5px; }
.nav-item:hover { background: var(--hover); text-decoration: none; color: var(--ink); }
.nav-item .ic { color: var(--muted); }
.nav-item.on { background: var(--brand-soft); color: var(--brand-strong); }
.nav-item.on .ic { color: var(--brand); }
.nav-item .count { margin-inline-start: auto; min-width: 22px; padding: 0 7px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11.5px; line-height: 20px; text-align: center; }
.nav-item .dot { margin-inline-start: auto; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }

.main { min-width: 0; }
.topbar { display: none; }
.content { max-width: 1240px; margin: 0 auto; padding: 28px var(--gutter) 72px; }
.scrim { display: none; }

.icon-btn { width: 38px; height: 38px; display: inline-grid; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--hover); }

/* ---- page head ----------------------------------------------------------- */

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head > :first-child { flex: 1 1 320px; min-width: 0; }
.page-head .title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sub { color: var(--muted); margin-top: 2px; max-width: 92ch; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.back .ic { width: 15px; height: 15px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---- buttons ------------------------------------------------------------- */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font-weight: 500; font-size: 13.5px; line-height: 1.4; white-space: nowrap; cursor: pointer; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--hover); border-color: #b9c2cc; text-decoration: none; }
.btn .ic { width: 16px; height: 16px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn.danger { color: var(--danger); border-color: var(--danger-line); }
.btn.danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger.solid:hover { background: #981b12; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; gap: 6px; }
.btn.sm .ic { width: 14px; height: 14px; }
.btn.block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn.is-busy { opacity: .8; cursor: progress; }
.btn.is-busy .ic { display: none; }
.btn.is-busy::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-inline-end-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- cards --------------------------------------------------------------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card, .card + .cols, .cols + .card, .cols + .cols, .stats + .cols { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.card-head p { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.card-body { padding: 20px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--line); }
.cols { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols.aside { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.cols > .card + .card, .cols > * > .card:first-child, .stats > .card { margin-top: 0; }
.cols > * > .card + .card { margin-top: 16px; }

/* ---- messages ------------------------------------------------------------ */

.flash { display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; margin-bottom: 18px; border: 1px solid var(--ok-line); border-radius: 10px; background: var(--ok-bg); color: #0a4d37; }
.flash.bad { border-color: var(--danger-line); background: var(--danger-bg); color: #8f1c13; }
.flash .ic { margin-top: 3px; }
.flash p { flex: 1; overflow-wrap: anywhere; }
.flash .icon-btn { width: 26px; height: 26px; color: inherit; margin: -1px 0; }
.flash .icon-btn:hover { background: rgba(0, 0, 0, .06); }

.note { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); font-size: 13px; }
.note .ic { margin-top: 3px; color: var(--muted); }
.note.warn { border-color: var(--warn-line); background: var(--warn-bg); color: #5f3a00; }
.note.warn .ic { color: var(--warn); }
.note.info { border-color: var(--info-line); background: var(--info-bg); color: #15467f; }
.note.info .ic { color: var(--info); }
.note.danger { border-color: var(--danger-line); background: var(--danger-bg); color: #8f1c13; }
.note.danger .ic { color: var(--danger); }
.note b { display: block; }

.empty { padding: 52px 20px; text-align: center; color: var(--muted); }
.empty > .ic { width: 38px; height: 38px; stroke-width: 1.4; color: var(--faint); }
.empty b { display: block; margin: 10px 0 2px; font-size: 15px; color: var(--ink); }
.empty .btn { margin-top: 14px; }

/* ---- badges, dots, tones --------------------------------------------------- */

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 1px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; line-height: 1.8; white-space: nowrap; }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.t-neutral { background: #eceff2; color: #404c59; }
.t-faint { background: #f1f3f5; color: #5f6b78; }
.t-info { background: var(--info-bg); color: var(--info); }
.t-ok { background: var(--ok-bg); color: var(--ok); }
.t-warn { background: var(--warn-bg); color: var(--warn); }
.t-danger { background: var(--danger-bg); color: var(--danger); }
.t-violet { background: var(--violet-bg); color: var(--violet); }
.t-solid { background: var(--brand); color: #fff; }

i.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #b3bcc6; flex: none; }
i.dot.ok { background: #12a06c; }
i.dot.warn { background: #dd9a00; }
i.dot.bad, i.dot.danger { background: #d92d20; }
i.dot.violet { background: #7c4ddb; }
i.dot.info { background: #2f7de1; }

/* ---- filters, tabs, search ------------------------------------------------- */

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { display: inline-flex; align-items: center; gap: 7px; min-height: 32px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); color: var(--ink-2); font-size: 13px; font-weight: 500; white-space: nowrap; }
.tab:hover { background: var(--hover); text-decoration: none; }
.tab.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.tab-n { font-size: 12px; opacity: .72; }
.search { position: relative; width: 320px; max-width: 100%; }
.search .ic { position: absolute; inset-inline-start: 12px; top: 50%; margin-top: -8px; width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.search .input { padding-inline-start: 36px; }
.search .input::-webkit-search-cancel-button { cursor: pointer; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; padding: 12px 20px; border-top: 1px solid var(--line); font-size: 13px; }
.pager-nav { display: inline-flex; align-items: center; gap: 10px; }

/* ---- tables -------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { padding: 9px 12px; text-align: start; font-size: 12.5px; font-weight: 500; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-inline-start: 20px; }
.table th:last-child, .table td:last-child { padding-inline-end: 20px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr[data-href] { cursor: pointer; }
.table tbody tr[data-href]:hover { background: var(--hover); }
.table td.num, .table th.num { direction: ltr; text-align: right; }
.table td.shrink { width: 1%; white-space: nowrap; }
.table .row-link { color: inherit; font-weight: 500; }
.table tr.is-off td { color: var(--muted); }
.table.top td { vertical-align: top; }
.clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; white-space: pre-line; overflow-wrap: anywhere; }

.who { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.who b { display: block; font-weight: 500; line-height: 1.6; }
.who small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 14px; }
.avatar .ic { width: 16px; height: 16px; }
.avatar.lg { width: 52px; height: 52px; font-size: 20px; }
.avatar.none { background: #eceff2; color: var(--muted); }

/* ---- forms --------------------------------------------------------------- */

.input { width: 100%; min-height: 38px; padding: 6px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: #fff; color: var(--ink); transition: border-color .12s, box-shadow .12s; }
.input::placeholder { color: #6f7b88; opacity: 1; }
.input:hover { border-color: #b3bcc6; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
.input.is-wrong { border-color: var(--danger); background: #fffafa; }
.input[dir="ltr"] { text-align: left; }
/* a token or username: typed left-to-right in the technical font, while its Persian hint reads normally */
.input.code { font-family: var(--mono); font-size: 13px; direction: ltr; text-align: left; }
.input.code:placeholder-shown { font-family: var(--font); font-size: inherit; direction: rtl; text-align: right; }
textarea.input { min-height: 82px; line-height: 1.85; resize: vertical; }
select.input { appearance: none; padding-inline-end: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235f6b78' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 10px center; background-size: 16px; }
.input.short { max-width: 150px; }
.input.mid { max-width: 280px; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; vertical-align: -4px; }

.field { display: grid; gap: 6px; align-content: start; }
.field > label, .label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.75; }
.req { color: var(--danger); }
.form-grid { display: grid; gap: 16px 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: 1 / -1; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline .input { flex: 1 1 120px; }
.inline select.input { flex: 0 0 116px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }

.switch { display: inline-flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { position: relative; flex: none; width: 38px; height: 22px; margin-top: 2px; border-radius: 999px; background: #8f9aa6; transition: background .15s; }
.switch-ui::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch input:checked + .switch-ui { background: var(--brand); }
.switch input:checked + .switch-ui::after { transform: translateX(-16px); }
.switch input:focus-visible + .switch-ui { box-shadow: var(--focus); }

/* one setting per row: what it is on one side, the control on the other */
.set-row { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 8px 32px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.set-row:first-child { padding-top: 0; }
.set-row:last-child { padding-bottom: 0; border-bottom: 0; }
.set-label b { display: block; font-weight: 500; }
.set-label label { font-weight: 500; }
.set-control { display: grid; gap: 8px; align-content: start; min-width: 0; }

/* a number with a default: the default always shows under the box, and turns into the way back once the value differs */
.num-field { display: inline-grid; gap: 2px; justify-items: start; }
.num-box { display: inline-flex; align-items: center; gap: 8px; }
.num-field .input { width: 110px; }
.num-field .unit { color: var(--muted); font-size: 13px; }
.num-field .revert { display: inline-flex; align-items: center; gap: 5px; min-height: 22px; padding: 0; border: 0; background: none; color: var(--muted); font-size: 12px; cursor: default; }
.num-field .revert .ic { display: none; width: 12px; height: 12px; }
.num-field.is-changed .input { border-color: var(--brand); background: #f6fbf8; }
.num-field.is-changed .revert { color: var(--brand); cursor: pointer; }
.num-field.is-changed .revert:hover { text-decoration: underline; }
.num-field.is-changed .revert .ic { display: inline; }

.copy { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 4px; padding-inline-start: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.copy code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; text-align: left; }

.savebar { position: sticky; bottom: 16px; z-index: 5; display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin-top: 20px; padding: 10px 14px; border: 1px solid var(--line-2); border-radius: var(--radius); background: rgba(255, 255, 255, .94); backdrop-filter: blur(8px); box-shadow: 0 8px 24px rgba(23, 33, 43, .12); }
.savebar .grow { flex: 1; color: var(--muted); font-size: 13px; }
.dirty-note { display: none; align-items: center; gap: 8px; color: var(--warn); font-weight: 500; }
.is-dirty .dirty-note { display: inline-flex; }
.is-dirty .clean-note { display: none; }

/* ---- facts and small lists ------------------------------------------------- */

.facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 18px; margin: 0; }
.facts dt { color: var(--muted); font-size: 13px; white-space: nowrap; }
.facts dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.facts dd pre { margin: 0; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li > a, .list > li > div { display: flex; align-items: center; gap: 12px; padding: 12px 20px; color: inherit; border-bottom: 1px solid var(--line); }
.list > li:last-child > a, .list > li:last-child > div { border-bottom: 0; }
.list > li > a:hover { background: var(--hover); text-decoration: none; }
.list .grow { flex: 1; min-width: 0; }
.list b { display: block; font-weight: 500; }
.list .go { color: var(--faint); width: 16px; height: 16px; }
.media { display: flex; align-items: center; gap: 12px; }
.media b { display: block; }
.bubble { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.svc-name { flex: 0 0 132px; font-weight: 500; }

pre { direction: ltr; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; padding: 12px 14px; border-radius: var(--radius-sm); background: #f4f6f8; font-family: var(--mono); font-size: 12px; line-height: 1.7; }
details.fold > summary { cursor: pointer; padding: 14px 20px; font-weight: 500; list-style: none; display: flex; align-items: center; gap: 8px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: ""; width: 7px; height: 7px; border: solid var(--muted); border-width: 0 0 2px 2px; transform: rotate(45deg); transition: transform .15s; margin-inline: 4px 6px; }
details.fold[open] > summary::before { transform: rotate(-45deg); }
details.fold[open] > summary { border-bottom: 1px solid var(--line); }
details.fold > summary .hint { font-weight: 400; margin-inline-start: auto; }

/* ---- dashboard ----------------------------------------------------------- */

.stats { display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { display: grid; gap: 2px; padding: 16px 20px; color: inherit; }
a.stat:hover { text-decoration: none; border-color: var(--line-2); }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.45; }
.stat-value small { font-size: 13px; font-weight: 500; color: var(--muted); }
.stat-sub { color: var(--muted); font-size: 12.5px; }
.delta { font-weight: 500; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--danger); }

/* calls per day: one series, so one colour and no legend; the heading names it */
.chart { padding: 28px 20px 16px; }
.chart-plot { display: flex; align-items: flex-end; gap: 2px; height: 148px; border-bottom: 1px solid var(--line-2); }
.chart-col { position: relative; flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.chart-col:focus-visible { box-shadow: none; }
.chart-bar { width: min(24px, 72%); border-radius: 4px 4px 0 0; background: var(--brand); }
.chart-col:hover .chart-bar, .chart-col:focus-visible .chart-bar { background: var(--brand-strong); }
.chart-col:hover, .chart-col:focus-visible { background: linear-gradient(var(--hover), var(--hover)) center / 100% 100% no-repeat; }
.chart-val { margin-bottom: 3px; font-size: 11.5px; font-weight: 500; line-height: 1.4; color: var(--ink-2); }
.chart-col::after { content: attr(data-tip); position: absolute; left: 50%; top: -6px; transform: translate(-50%, -100%); padding: 3px 9px; border-radius: 7px; background: var(--ink); color: #fff; font-size: 12px; white-space: nowrap; pointer-events: none; opacity: 0; z-index: 2; }
.chart-col:hover::after, .chart-col:focus-visible::after { opacity: 1; }
.chart-axis { display: flex; gap: 2px; margin-top: 6px; }
.chart-axis span { flex: 1; min-width: 0; text-align: center; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: visible; }

/* ---- call transcript ------------------------------------------------------- */

.chat { display: flex; flex-direction: column; gap: 10px; padding: 20px; }
.msg { max-width: min(80%, 640px); padding: 8px 14px 9px; border-radius: 14px; line-height: 1.9; overflow-wrap: anywhere; }
.msg small { display: block; font-size: 11.5px; font-weight: 500; color: var(--muted); line-height: 1.6; }
.msg.agent { align-self: flex-start; background: var(--brand-soft); border-start-start-radius: 4px; }
.msg.user { align-self: flex-end; background: #eef0f3; border-start-end-radius: 4px; }
.msg.system { align-self: center; max-width: 92%; padding: 3px 10px; border: 1px dashed var(--line-2); border-radius: 8px; color: var(--muted); font-family: var(--mono); font-size: 11.5px; direction: ltr; text-align: left; }
audio { display: block; width: 100%; height: 40px; }

/* the bar a call's recording plays in, over the foot of the call list */
.icon-btn.play { width: 32px; height: 32px; color: var(--brand); }
.icon-btn.play .ic { width: 22px; height: 22px; }
.icon-btn.play.is-playing { background: var(--brand-soft); }
.player { position: fixed; z-index: 30; bottom: 16px; inset-inline: calc(var(--sidebar) + var(--gutter)) var(--gutter); max-width: 900px; margin-inline: auto; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-lg); }
.player-info { flex: 0 1 240px; min-width: 0; }
.player-info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.player-info a { font-size: 12.5px; }
.player audio { flex: 1 1 300px; min-width: 0; }
body.has-player .content { padding-bottom: 140px; }

/* ---- quote: progress and document ------------------------------------------ */

.steps { list-style: none; margin: 0; padding: 0; }
.steps li { position: relative; display: flex; align-items: center; gap: 10px; padding: 6px 0; color: var(--muted); }
.steps li::before { content: ""; position: relative; z-index: 1; width: 18px; height: 18px; flex: none; border: 2px solid var(--line-2); border-radius: 50%; background: #fff; }
.steps li:not(:last-child)::after { content: ""; position: absolute; inset-inline-start: 8px; top: 27px; bottom: -9px; width: 2px; background: var(--line-2); }
.steps li.done { color: var(--ink); }
.steps li.done::before { border-color: var(--brand); background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 11px no-repeat; }
.steps li.done::after { background: var(--brand); }
.steps li.now { color: var(--ink); font-weight: 700; }
.steps li.now::before { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.steps.off li { color: var(--faint); }

.doc { padding: 32px 36px; }
.doc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; padding-bottom: 18px; margin-bottom: 20px; border-bottom: 2px solid var(--ink); }
.doc-head h1 { font-size: 24px; }
.doc-seller { margin-top: 2px; font-size: 15px; font-weight: 500; color: var(--ink-2); }
.doc-no { text-align: end; }
.doc-no b { display: block; font-size: 20px; line-height: 1.5; }
.doc-parties { display: grid; grid-template-columns: 1.2fr 1fr .8fr 1.7fr; gap: 12px 20px; margin-bottom: 22px; }
.doc-parties div span { display: block; color: var(--muted); font-size: 12.5px; }
.doc-parties div b { font-weight: 500; overflow-wrap: anywhere; }
.doc h2 { margin: 22px 0 8px; }
.doc .table { border: 1px solid var(--line); }
.doc .table th:first-child, .doc .table td:first-child { padding-inline-start: 14px; }
.doc .table th:last-child, .doc .table td:last-child { padding-inline-end: 14px; }
.doc-total { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding: 14px 18px; border-radius: 10px; background: var(--brand-soft); }
.doc-total span { font-weight: 500; }
.doc-total b { font-size: 22px; }
.doc-total b small { font-size: 13px; font-weight: 500; }
.doc ul { margin: 0; padding-inline-start: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.chip b { display: block; font-size: 13.5px; font-weight: 500; color: var(--ink); }
.doc-note { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }

/* ---- pages without the menu: sign-in, customer's quote, errors -------------- */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(100%, 384px); padding: 32px 28px 28px; }
.auth-card .brand-mark { width: 48px; height: 48px; border-radius: 14px; margin-bottom: 16px; }
.auth-card .brand-mark .ic { width: 27px; height: 27px; }
.auth-card h1 { font-size: 20px; }
.auth-card form { display: grid; gap: 14px; margin-top: 22px; }
.public { max-width: 880px; margin: 0 auto; padding: 24px 16px 48px; }
.public-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.public-foot { margin-top: 16px; text-align: center; color: var(--muted); font-size: 12.5px; }
.oops { min-height: 60vh; display: grid; place-items: center; text-align: center; padding: 24px; }
.oops .code { font-size: 64px; font-weight: 700; line-height: 1.2; color: var(--line-2); }
.oops h1 { margin: 6px 0 4px; }
.oops .btn { margin-top: 18px; }

/* ---- dialogs ------------------------------------------------------------- */

dialog.dialog { width: min(92vw, 440px); padding: 0; border: 0; border-radius: 14px; background: var(--surface); color: inherit; box-shadow: var(--shadow-lg); }
dialog.dialog.wide { width: min(94vw, 660px); }
dialog.dialog::backdrop { background: rgba(15, 23, 31, .45); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 0; }
.dialog-head .icon-btn { margin: -6px; }
.dialog-body { padding: 10px 22px 6px; color: var(--ink-2); }
.dialog-body > .flash { margin: 6px 0 14px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px 20px; }

/* ---- smaller screens ------------------------------------------------------- */

@media screen and (max-width: 1080px) {
  .cols.aside { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media screen and (max-width: 900px) {
  :root { --gutter: 16px; }
  body.app { display: block; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 60; width: min(84vw, 300px); height: auto; transform: translateX(105%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(15, 23, 31, .45); }
  .topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
  .topbar .brand { padding: 0; }
  .topbar .brand-mark { width: 30px; height: 30px; border-radius: 8px; }
  .topbar .brand-mark .ic { width: 17px; height: 17px; }
  .content { padding-top: 20px; }
  .player { inset-inline: 12px; bottom: 12px; flex-wrap: wrap; }
  .player-info { flex: 1 1 0; order: 1; }
  .player [data-player-close] { order: 2; }
  .player audio { order: 3; flex-basis: 100%; }
  body.has-player .content { padding-bottom: 170px; }
  .cols { grid-template-columns: minmax(0, 1fr); }
  .set-row { grid-template-columns: minmax(0, 1fr); }
  .doc { padding: 22px 18px; }
  .doc-parties { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media screen and (max-width: 720px) {
  h1 { font-size: 20px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .search { width: 100%; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; margin-inline: -20px; padding-inline: 20px; scrollbar-width: none; max-width: calc(100% + 40px); }
  .stat { padding: 14px 16px; }
  .stat-value { font-size: 24px; }
  .msg { max-width: 92%; }
  .svc-name { flex-basis: 108px; }

  /* a list row becomes a small card: its main cell on top, the rest as label and value */
  .table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table.stack, .table.stack tbody { display: block; }
  .table.stack tr { display: block; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .table.stack tbody tr:last-child { border-bottom: 0; }
  .table.stack td, .table.stack td:first-child, .table.stack td:last-child { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: auto; padding: 3px 0; border: 0; text-align: end; }
  .table.stack td[data-label]::before { content: attr(data-label); flex: none; color: var(--muted); font-size: 12.5px; }
  .table.stack td.cell-main { display: block; padding-bottom: 6px; text-align: start; }
  .table.stack td.hide-sm { display: none; }
}

@media screen and (max-width: 480px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
  .page-head .actions { width: 100%; }
  .page-head .actions > * { flex: 1 1 auto; }
  .page-head .actions form .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: .01ms !important; }
}

/* ---- paper --------------------------------------------------------------- */

@media print {
  @page { margin: 14mm; }
  .sidebar, .topbar, .scrim, .flash, .noprint, .skip, dialog { display: none !important; }
  body, body.app { display: block; background: #fff; font-size: 12pt; }
  .content, .public { max-width: none; margin: 0; padding: 0; }
  .cols, .cols.aside { display: block; }
  .card, .doc { border: 0; box-shadow: none; padding: 0; }
  .doc-total { border: 1px solid #000; background: none; }
  a { color: inherit; }
  .table th { background: #f1f1f1; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
