@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --ink: #102030;
  --ink-2: #3b4a5a;
  --muted: #6b7a89;
  --line: #e3e8ee;
  --line-2: #d3dae2;
  --brand: #0e7c74;
  --brand-2: #0b625c;
  --brand-soft: #e3f3f1;
  --side: #0e2740;
  --side-2: #16385a;
  --side-ink: #b9c8d4;
  --ok: #15803d;
  --ok-soft: #e5f5ea;
  --warn: #b45309;
  --warn-soft: #fdf1e1;
  --bad: #c62828;
  --bad-soft: #fdeaea;
  --info: #2563eb;
  --info-soft: #e8effd;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 32, 48, .06), 0 4px 14px rgba(16, 32, 48, .05);
  --shadow-lg: 0 12px 40px rgba(16, 32, 48, .18);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Vazirmatn", Tahoma, sans-serif;
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.4; font-weight: 700; }
h1 { font-size: 21px; }
h2 { font-size: 16.5px; }
h3 { font-size: 15px; }
p { margin: 0 0 .6em; }
.ltr { direction: ltr; unicode-bidi: embed; display: inline-block; }
td.ltr { display: table-cell; text-align: right; }
dd.ltr { display: block; text-align: right; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: left; }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; overflow-x: clip; }
.side {
  background: var(--side);
  color: var(--side-ink);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 9px; background: linear-gradient(135deg, #18a497, #0e7c74);
  display: grid; place-items: center; font-weight: 800; font-size: 15px; color: #fff; letter-spacing: -.5px;
}
.brand-logo { width: 36px; height: 36px; display: block; flex: none; border-radius: 9px; }
.powered { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 22px; font-size: 12px; font-weight: 600; color: var(--muted); }
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.3; }
.brand-sub { font-size: 11.5px; color: var(--side-ink); opacity: .8; }
.brand-ver { font-size: 10.5px; color: #7f9db0; letter-spacing: .3px; margin-top: 1px; }
.nav { padding: 6px 10px 20px; flex: 1; }
.nav-group { font-size: 11.5px; color: #7f95a6; padding: 14px 10px 4px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--side-ink); font-size: 14px; text-decoration: none;
}
.nav a:hover { background: var(--side-2); color: #fff; }
.nav a.active { background: var(--brand); color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav .badge { margin-inline-start: auto; }
.side-foot { padding: 12px 18px; font-size: 12px; border-top: 1px solid var(--side-2); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 0 22px; position: sticky; top: 0; z-index: 20;
}
.topbar .search { flex: 1; max-width: 420px; position: relative; }
.topbar .search input { padding-inline-start: 34px; background: var(--surface-2); }
.topbar .search svg { position: absolute; inset-inline-start: 10px; top: 50%; transform: translateY(-50%); width: 16px; color: var(--muted); }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; }
.content { padding: 22px; max-width: 1360px; width: 100%; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { flex: 1; min-width: 0; }
.page-head .sub { color: var(--muted); font-size: 13px; font-weight: 400; display: block; margin-top: 2px; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.crumbs a { color: var(--muted); }

/* ---------- pills / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
  white-space: nowrap;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.pill.brand { background: var(--brand-soft); color: var(--brand-2); border-color: transparent; }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: #e0473e; color: #fff;
  font-size: 11.5px; display: inline-grid; place-items: center; font-weight: 600;
}
.st-draft { background: #eef1f4; color: #55657a; border-color: transparent; }
.st-issued, .st-open, .st-customer_reply { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.st-paid, .st-answered, .st-completed { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.st-cancelled, .st-missed { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.st-closed, .st-on_hold { background: #eef1f4; color: #55657a; border-color: transparent; }
.pr-urgent { color: var(--bad); font-weight: 700; }
.pr-high { color: var(--warn); font-weight: 600; }
.pr-low { color: var(--muted); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { flex: 1; }
.card-body { padding: 18px; }
.card + .card { margin-top: 18px; }
.grid > .card + .card, .grid > a.card + .card, .grid > .card + a.card { margin-top: 0; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }

.stat { padding: 16px 18px; display: flex; gap: 14px; align-items: center; }
.stat-ico { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.stat-ico svg { width: 21px; height: 21px; }
.stat-val { font-size: 21px; font-weight: 700; line-height: 1.3; }
.stat-lbl { font-size: 12.5px; color: var(--muted); }
.ico-brand { background: var(--brand-soft); color: var(--brand); }
.ico-warn { background: var(--warn-soft); color: var(--warn); }
.ico-ok { background: var(--ok-soft); color: var(--ok); }
.ico-info { background: var(--info-soft); color: var(--info); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th {
  text-align: start; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 10px 14px;
  background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.t td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr:hover { background: #fafcfd; }
.t .actions { white-space: nowrap; text-align: left; }
.t a.rowlink { color: var(--ink); font-weight: 600; }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.empty svg { width: 34px; height: 34px; opacity: .5; display: block; margin: 0 auto 8px; }

/* ---------- forms ---------- */
label { display: block; font-size: 13px; font-weight: 500; color: var(--ink-2); margin-bottom: 5px; }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=number], input[type=url], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 14px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 11px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.8; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(14, 124, 116, .14); }
input.ltr, input[dir=ltr] { direction: ltr; text-align: left; }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.row { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.row3 { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; cursor: pointer; margin: 0; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg label { margin: 0; padding: 7px 14px; cursor: pointer; font-weight: 500; border-inline-start: 1px solid var(--line-2); }
.seg label:first-child { border-inline-start: 0; }
.seg input { display: none; }
.seg input:checked + span { color: var(--brand-2); }
.seg label:has(input:checked) { background: var(--brand-soft); color: var(--brand-2); }
.form-actions { display: flex; gap: 10px; align-items: center; padding-top: 6px; flex-wrap: wrap; }
fieldset { border: 0; padding: 0; margin: 0; }
.sec-title { font-size: 13px; font-weight: 700; color: var(--brand-2); margin: 6px 0 12px; display: flex; align-items: center; gap: 8px; }
.sec-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: inherit; font-size: 14px; font-weight: 500;
  padding: 7px 15px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  cursor: pointer; text-decoration: none !important; white-space: nowrap; line-height: 1.6; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); border-color: #c3ccd6; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: #f3c3c3; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 3px 10px; font-size: 13px; }
.btn.icon { padding: 6px; width: 34px; height: 34px; }
.btn.sm.icon { width: 28px; height: 28px; padding: 4px; }
.btn.call { color: var(--ok); }
.btn.call:hover { background: var(--ok-soft); border-color: #bfe3c9; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- filters ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.filters input[type=search] { max-width: 280px; }
.filters select { width: auto; min-width: 140px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; }
.tabs a, .tabs button {
  padding: 11px 14px; font: inherit; font-size: 14px; color: var(--muted); border: 0; background: none; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none;
}
.tabs a.on, .tabs button.on { color: var(--brand-2); border-bottom-color: var(--brand); font-weight: 600; }
.tab-pane { display: none; }
.tab-pane.on { display: block; }

/* ---------- flash / alerts ---------- */
.flash svg { width: 18px; height: 18px; flex: none; }
.flash { padding: 11px 14px; border-radius: 9px; margin-bottom: 16px; font-size: 14px; display: flex; gap: 10px; align-items: center; }
.flash.ok { background: var(--ok-soft); color: #14532d; }
.flash.err { background: var(--bad-soft); color: #7f1d1d; }
.flash.info { background: var(--info-soft); color: #1e3a8a; }

/* ---------- misc components ---------- */
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--brand-soft); color: var(--brand-2); font-weight: 700;
}
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }
.who { display: flex; gap: 12px; align-items: center; }
.contact-line { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.contact-line:last-child { border-bottom: 0; }
.contact-line .k { width: 58px; color: var(--muted); font-size: 12.5px; }
.contact-line .v { flex: 1; min-width: 0; }

.thread { display: flex; flex-direction: column; gap: 14px; }
.msg { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--surface); max-width: 88%; }
.msg.me { align-self: flex-start; background: var(--brand-soft); border-color: #c7e6e2; }
.msg.them { align-self: flex-end; }
.msg.internal { background: #fff8e6; border-color: #f3dfa8; border-style: dashed; }
.msg-head { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.msg-head b { color: var(--ink); font-weight: 600; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }

.notes .note { padding: 10px 0; border-bottom: 1px solid var(--line); }
.notes .note:last-child { border-bottom: 0; }

.bars { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar i { display: block; width: 100%; max-width: 46px; border-radius: 6px 6px 2px 2px; background: var(--brand); min-height: 3px; }
.bar span { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

.totals { width: 100%; max-width: 360px; margin-inline-start: auto; }
.totals div { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }
.totals div:last-child { border-bottom: 0; font-weight: 700; font-size: 16px; }

.items-table input, .items-table select { padding: 6px 8px; font-size: 13.5px; }
.items-table td { padding: 6px 6px; }
.items-table .w-qty { width: 82px; }
.items-table .w-price { width: 140px; }
.items-table .w-unit { width: 80px; }

.picker { position: relative; }
.picker-list {
  position: absolute; inset-inline: 0; top: 100%; z-index: 30; background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 8px; box-shadow: var(--shadow-lg); max-height: 260px; overflow-y: auto; margin-top: 4px;
}
.picker-list div { padding: 8px 12px; cursor: pointer; }
.picker-list div:hover, .picker-list div.on { background: var(--brand-soft); }

.ext-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; padding: 16px; }
.ext {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; background: var(--surface);
}
.ext-top { display: flex; align-items: center; gap: 10px; }
.ext-num { font-size: 18px; font-weight: 700; direction: ltr; }
.ext-state { font-size: 12px; }
.ext[data-state=NOT_INUSE] .ext-dot { background: #22c55e; }
.ext[data-state=INUSE], .ext[data-state=BUSY] .ext-dot { background: #ef4444; }
.ext[data-state=INUSE] .ext-dot { background: #ef4444; }
.ext[data-state=RINGING] .ext-dot, .ext[data-state=RINGINUSE] .ext-dot { background: #f59e0b; animation: blink 1s infinite; }
.ext[data-state=ONHOLD] .ext-dot { background: #a855f7; }
.ext-dot { width: 10px; height: 10px; border-radius: 50%; background: #94a3b8; flex: none; }
@keyframes blink { 50% { opacity: .3; } }

/* ---------- call bar / popup ---------- */
.ami-pill { cursor: default; }
.dialer { position: relative; }
.dialer-panel {
  position: absolute; inset-inline-end: 0; top: calc(100% + 8px); width: 300px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 14px; z-index: 40;
}
.dialer-panel input { font-size: 18px; direction: ltr; text-align: center; letter-spacing: 1px; margin-bottom: 10px; }
.dialer-panel .btn { width: 100%; }
.dialer-panel .grid { gap: 8px; }

.toasts { position: fixed; inset-inline-start: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 10px; width: 360px; max-width: calc(100vw - 36px); }
.toast {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 12px 14px;
  animation: slidein .25s ease-out; font-size: 14px;
}
.toast.ok { border-inline-start: 4px solid var(--ok); }
.toast.err { border-inline-start: 4px solid var(--bad); }
.toast.info { border-inline-start: 4px solid var(--info); }
@keyframes slidein { from { transform: translateY(14px); opacity: 0; } }

.popup { border: 0; overflow: hidden; padding: 0; }
.popup-head { background: linear-gradient(135deg, #0e7c74, #0b5d73); color: #fff; padding: 12px 14px; display: flex; gap: 10px; align-items: center; }
.popup-head .ring { width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.18); display: grid; place-items: center; animation: ring 1.2s infinite; }
.popup-head .ring svg { width: 18px; height: 18px; }
@keyframes ring { 0%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(-14deg); } 20%, 40% { transform: rotate(14deg); } 50% { transform: rotate(0); } }
.popup.answered .ring { animation: none; background: rgba(34,197,94,.35); }
.popup-head .t1 { font-size: 12px; opacity: .85; }
.popup-head .t2 { font-size: 16px; font-weight: 700; direction: ltr; text-align: right; }
.popup-head .x { margin-inline-start: auto; color: #fff; background: rgba(255,255,255,.16); border: 0; cursor: pointer; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; padding: 0; }
.popup-head .x:hover { background: rgba(255,255,255,.3); }
.popup-body { padding: 12px 14px; }
.popup-body .name { font-size: 16px; font-weight: 700; }
.popup-body .meta { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 10px; }
.popup-body .btn-row .btn { flex: 1; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-art {
  background: radial-gradient(circle at 20% 20%, #17a092 0, transparent 45%), radial-gradient(circle at 80% 80%, #0b4f6b 0, transparent 50%), var(--side);
  color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-art h2 { font-size: 28px; font-weight: 800; line-height: 1.5; max-width: 420px; }
.auth-art p { color: #c7d6e0; max-width: 420px; }
.auth-art ul { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 10px; color: #dbe7ee; }
.auth-art li::before { content: "✓"; color: #5eead4; margin-inline-end: 8px; }
.auth-form { display: grid; place-items: center; padding: 32px 18px; background: var(--surface); }
.auth-box { width: 100%; max-width: 360px; }
.auth-box h1 { margin-bottom: 4px; }
.auth-box .btn { width: 100%; padding: 10px; }

/* ---------- portal ---------- */
.portal-top { background: var(--surface); border-bottom: 1px solid var(--line); }
.portal-top .inner { max-width: 1100px; margin: 0 auto; padding: 0 18px; display: flex; align-items: center; gap: 18px; height: 64px; }
.portal-top .brand { padding: 0; color: var(--ink); }
.portal-top .brand-sub { color: var(--muted); }
.portal-nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.portal-nav a { padding: 8px 12px; border-radius: 8px; color: var(--ink-2); white-space: nowrap; text-decoration: none; }
.portal-nav a.active { background: var(--brand-soft); color: var(--brand-2); font-weight: 600; }
.portal-main { max-width: 1100px; margin: 0 auto; padding: 24px 18px 80px; }
.hero { background: linear-gradient(135deg, #0e7c74, #0b5d73); color: #fff; border-radius: 14px; padding: 22px 24px; display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.hero h1 { font-size: 20px; }
.hero p { margin: 4px 0 0; color: #d4ecea; }
.hero .spacer { flex: 1; }

/* click to talk */
.c2t { background: #fff; color: var(--brand-2); border: 0; font-weight: 600; }
.c2t:hover { background: #effaf8; }
.c2t-panel {
  position: fixed; inset-inline-start: 18px; bottom: 18px; width: 260px; z-index: 100; text-align: center; color: #fff;
  background: linear-gradient(160deg, #0b5d73, #0e2a3a); border-radius: 20px; padding: 20px 18px 18px; box-shadow: var(--shadow-lg);
}
.c2t-panel.hidden { display: none; }
.c2t-ava { width: 58px; height: 58px; margin: 0 auto 8px; border-radius: 50%; background: rgba(255,255,255,.14); display: grid; place-items: center; animation: ring 1.4s infinite; }
.c2t-ava svg { width: 28px; height: 28px; }
.c2t-panel.live .c2t-ava { animation: none; background: rgba(34,197,94,.3); }
.c2t-who { font-weight: 700; font-size: 15px; }
.c2t-status { font-size: 13px; color: #a5c2d2; margin-top: 2px; min-height: 20px; }
.c2t-timer { font-size: 30px; font-weight: 700; direction: ltr; margin: 6px 0 14px; font-variant-numeric: tabular-nums; }
.c2t-btns { display: flex; justify-content: center; gap: 28px; }
.c2t-b { background: none; border: 0; color: #fff; font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0; }
.c2t-b .ic { width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,.16); display: grid; place-items: center; transition: background .15s; }
.c2t-b .ic svg { width: 24px; height: 24px; }
.c2t-b .lb { font-size: 12px; color: #d6e4ec; }
.c2t-b[aria-pressed="true"] .ic { background: #fff; color: #0b5d73; }
.c2t-b.hang .ic { background: #dc2626; }
.c2t-b.hang:hover .ic { background: #b91c1c; }
@media (max-width: 560px) {
  .c2t-panel { inset: auto 0 0 0; width: auto; border-radius: 22px 22px 0 0; padding: 26px 18px calc(22px + env(safe-area-inset-bottom)); }
  .c2t-timer { font-size: 38px; }
  .c2t-b .ic { width: 66px; height: 66px; }
  .c2t-btns { gap: 48px; }
}
.btn.hang { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.hang:hover { background: #a61f1f; }

/* ---------- print / invoice ---------- */
.paper { background: #fff; max-width: 900px; margin: 24px auto; padding: 36px 40px; border-radius: 12px; box-shadow: var(--shadow); }
.inv-head { display: flex; gap: 20px; align-items: flex-start; border-bottom: 2px solid var(--ink); padding-bottom: 16px; margin-bottom: 18px; }
.inv-head .co { flex: 1; }
.inv-head .co h2 { font-size: 19px; }
.inv-head .meta { text-align: left; font-size: 13.5px; }
.inv-head .meta .big { font-size: 22px; font-weight: 800; color: var(--brand-2); }
.inv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.inv-parties .box { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 13.5px; }
.inv-parties .box h4 { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.inv-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.inv-table th { background: var(--surface-2); font-weight: 600; padding: 8px; border: 1px solid var(--line); }
.inv-table td { padding: 8px; border: 1px solid var(--line); }
.inv-words { margin-top: 10px; font-size: 13px; color: var(--ink-2); }
.inv-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 30px; text-align: center; font-size: 13px; color: var(--muted); }
.inv-foot div { border-top: 1px dashed var(--line-2); padding-top: 8px; min-height: 70px; }
.print-bar { max-width: 900px; margin: 18px auto 0; display: flex; gap: 10px; justify-content: space-between; align-items: center; padding: 0 4px; flex-wrap: wrap; }

@media print {
  body { background: #fff; }
  .print-bar, .no-print { display: none !important; }
  .paper { box-shadow: none; margin: 0; padding: 0; max-width: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; width: 260px; z-index: 60; transform: translateX(100%); transition: transform .2s, visibility .2s; visibility: hidden; }
  .side.open { transform: none; visibility: visible; box-shadow: var(--shadow-lg); }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 12px; }
  .topbar .search { display: none; }
  .content { padding: 16px; }
  .g2, .g3, .row, .row3, .inv-parties { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .paper { padding: 20px 16px; margin: 0; border-radius: 0; }
  .inv-head { flex-direction: column; }
  .inv-head .meta { text-align: right; }
  .hide-sm { display: none; }
}
@media (max-width: 520px) {
  .g4 { grid-template-columns: 1fr; }
  .topbar .user-name { display: none; }
}

/* web phone launcher in the top bar */
.phone-btn .dot { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; }
.phone-btn.ok { border-color: #bfe3c9; color: var(--ok); }
.phone-btn.ok .dot { background: #22c55e; }
.btn.answer { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn.answer:hover { background: #15803d; border-color: #15803d; }
.btn.answer svg { width: 16px; height: 16px; }

/* ---------- InvoEcho ERP phase 0 ---------- */
.flash.warn { background: var(--warn-soft); color: #7c2d12; flex-wrap: wrap; }
.flash.pinned { font-weight: 600; }
.text-bad { color: var(--bad) !important; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .5px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }
select.sm, input.sm { padding: 4px 8px; font-size: 13px; min-height: 0; }
.na { color: var(--line-2); }

/* permission matrix */
.perm-matrix th, .perm-matrix td { padding: 6px 8px; vertical-align: middle; }
.perm-matrix th[scope=row] { font-weight: 600; white-space: nowrap; text-align: right; background: var(--surface-2); }
.perm-matrix th[scope=row] .pill { margin-inline-start: 6px; }
.perm-matrix .c { text-align: center; width: 56px; }
.perm-matrix thead th.c { font-size: 12px; white-space: nowrap; }
.perm-matrix .specials { min-width: 240px; }
.perm-matrix .specials .check { display: inline-flex; margin: 2px 0 2px 12px; font-size: 13px; }
.perm-matrix input[type=checkbox] { width: 16px; height: 16px; }
.ov-sel { padding: 2px 4px; font-size: 13px; min-width: 46px; }
.ov-sel.set { border-color: var(--brand); background: var(--brand-soft); font-weight: 700; }
.ov-line { display: inline-flex; gap: 6px; align-items: center; margin: 2px 0 2px 12px; font-size: 13px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; z-index: 5; }

/* two-step login */
.qr-box { display: flex; justify-content: center; margin: 12px 0; }
.qr-box svg { border: 8px solid #fff; border-radius: 8px; box-shadow: var(--shadow); }
.otp { font-size: 22px; letter-spacing: 6px; text-align: center; font-family: ui-monospace, Menlo, Consolas, monospace; }
.steps { padding-inline-start: 20px; margin: 8px 0; line-height: 2; }
.backup-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 12px; }
.backup-codes code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; text-align: center; font-size: 16px; letter-spacing: 1px; }

/* credit */
.credit-stats { margin-bottom: 16px; }
.credit-stats .stat-val { font-size: 19px; }
.stat .bar { display: block; height: 6px; background: var(--line); border-radius: 4px; margin-top: 8px; overflow: hidden; width: 100%; }
.stat .bar span { display: block; height: 100%; background: var(--ok); border-radius: 4px; }
.stat .bar span.warn { background: var(--warn); }
.stat .bar span.bad { background: var(--bad); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-inline-start: 2px solid var(--line); padding: 4px 12px 12px; position: relative; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: -6px; top: 9px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.credit-edit > summary { list-style: none; }

/* barcode & QR */
.doc-barcode { margin-bottom: 12px; }
.doc-barcode svg, .inv-codes svg.barcode { max-width: 100%; height: auto; }
.inv-codes { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.inv-qr { text-align: center; }
.inv-qr svg { display: block; margin: 0 auto; }
.inv-logo { height: 64px; max-width: 160px; object-fit: contain; }
.inv-terms { margin-top: 12px; font-size: 13px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.inv-footer { margin-top: 18px; text-align: center; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; }
.inv-foot { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.inv-foot .sig { position: relative; }
.stamp { display: flex; justify-content: center; gap: 8px; margin-top: 6px; }
.stamp img { max-height: 80px; max-width: 120px; opacity: .92; }
.paper { position: relative; overflow: hidden; }
.watermark { position: absolute; inset: 0; display: grid; place-items: center; font-size: 110px; font-weight: 800; color: rgba(198, 40, 40, .08); transform: rotate(-24deg); pointer-events: none; z-index: 0; }
.paper.a5 { max-width: 620px; font-size: 12.5px; }
.print-only { display: none; }
@media print {
  .print-only { display: initial; }
  .screen-only { display: none !important; }
  .paper.a5 { max-width: none; }
  @page { size: A4; margin: 12mm; }
}

/* settings files */
.file-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.file-prev { height: 90px; display: grid; place-items: center; background: var(--surface-2); border-radius: 8px; }
.file-prev img { max-height: 80px; max-width: 100%; }
tr.hl td { background: var(--brand-soft); }

/* calendar */
.cal-split { grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border-radius: 10px; overflow: hidden; }
.cal-wd { background: var(--surface-2); text-align: center; padding: 8px 0; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.cal-day { background: #fff; min-height: 92px; padding: 6px; font-size: 12px; overflow: hidden; }
.cal-day.blank { background: var(--surface-2); }
.cal-day.off .cal-n { color: var(--bad); }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--brand); }
.cal-n { font-weight: 800; font-size: 15px; }
.cal-t { margin-top: 3px; padding: 1px 5px; border-radius: 5px; background: var(--surface-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-t.h { background: var(--bad-soft); color: #7f1d1d; }
.cal-t.unconf { border: 1px dashed var(--warn); }
.cal-t.intl { background: #eef4ff; color: #1e3a8a; }
.cal-g { float: left; font-size: 10.5px; font-weight: 500; color: var(--ink-3, #8a97a6); margin-top: 3px; }
.cal-more { margin-top: 3px; font-size: 11px; color: var(--ink-2); }
.cal-list li.occ { font-size: 12.5px; color: var(--ink-2); }
.cal-list { list-style: none; padding: 0; margin: 0; }
.cal-list li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.cal-actions { margin-top: 6px; gap: 6px; }
.cal-actions form { display: inline-flex; gap: 4px; align-items: center; }

/* call popup additions */
.popup-pin { margin-top: 8px; padding: 6px 8px; background: var(--warn-soft); border-radius: 6px; font-size: 13px; }
.popup-inv { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.popup-inv a { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--ink); text-decoration: none; }
.popup-inv a.late { background: var(--bad-soft); color: #7f1d1d; }
.popup-note { margin-top: 6px; }
.ap-form input { width: 170px; }
@media (max-width: 900px) { .cal-split { grid-template-columns: 1fr; } .cal-day { min-height: 64px; } }
.inv-foot .stamp { border-top: 0; min-height: 0; padding: 0; }
.perm-matrix select { min-width: 132px; }

/* ---- offline copy served by the edge server ---- */
.offline-banner { background: #fff7e6; border: 1px solid #f5c26b; border-inline-start: 4px solid #d98a00; color: #5c3b00; border-radius: 10px; padding: 12px 16px; margin: 0 0 16px; line-height: 1.9; font-size: 13.5px; }
.offline-banner .ob-title { font-weight: 800; font-size: 15px; margin-bottom: 2px; }
.offline-banner .ob-note { margin-top: 6px; font-weight: 700; }
.offline-banner .ob-err { margin-top: 8px; color: #991b1b; font-weight: 700; }
.print-offline { max-width: 900px; margin: 16px auto 0; padding: 0 12px; }
.auth-offline { padding: 12px 12px 0; max-width: 900px; margin: 0 auto; }
body.offline .auth { min-height: auto; }
body.offline form[action^="/pay/"], body.offline [data-c2t] { display: none !important; }
@media print { .offline-banner, .print-offline { display: none; } }

.cal-list li.occ .pill { font-size: 11px; padding: 0 7px; }
.cal-del { display: inline; }
.cal-del .linklike { background: none; border: 0; color: var(--ink-3, #8a97a6); cursor: pointer; font-size: 15px; padding: 0 4px; }
.cal-del .linklike:hover { color: var(--bad); }
.cal-list { max-height: 70vh; overflow-y: auto; }

.ext.ext-pbx { background: var(--surface-2); }

/* ---------- dashboard desk ---------- */
.desk { display: grid; grid-template-columns: auto 1fr 1.3fr; gap: 22px; align-items: center; padding: 18px 22px; margin-bottom: 18px;
  background: linear-gradient(135deg, #0e2a3a, #0b5d73); color: #fff; border: 0; }
.desk-time { font-size: 44px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.desk-wd { margin-top: 6px; color: #a5c2d2; font-size: 14px; }
.desk-j { font-size: 20px; font-weight: 700; }
.desk-o { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; color: #a5c2d2; font-size: 13px; }
.desk-o .ltr { text-align: right; }
.desk-ev { background: rgba(255,255,255,.08); border-radius: 12px; padding: 10px 14px; font-size: 13.5px; }
.desk-ev-h { font-size: 12px; color: #a5c2d2; margin-bottom: 4px; }
.desk-ev ul { margin: 0 0 6px; padding: 0; list-style: none; display: grid; gap: 3px; }
.desk-ev li::before { content: "•"; color: #7dd3fc; margin-inline-end: 6px; }
.desk-ev li.hol { color: #fecaca; font-weight: 600; }
.desk-ev li.hol::before { color: #f87171; }
.desk-next li { font-size: 12.5px; color: #d6e4ec; }
.desk-next .d { color: #a5c2d2; }
.desk-ev a { color: #7dd3fc; }
.desk .muted { color: #a5c2d2 !important; }
@media (max-width: 900px) { .desk { grid-template-columns: 1fr 1fr; } .desk-ev { grid-column: 1 / -1; } }
@media (max-width: 560px) { .desk { grid-template-columns: 1fr; } .desk-time { font-size: 38px; } }

/* ---------- phase 1: warehouse, slips, documents ---------- */
.text-warn { color: var(--warn); }
.row-bad td { background: var(--bad-soft); }
details.inline-edit { display: inline-block; }
details.inline-edit > summary { list-style: none; display: inline-flex; }
details.inline-edit > summary::-webkit-details-marker { display: none; }
details.inline-edit[open] { display: block; }
.scan-row.done td { background: #e8f7ee; }
.scan-row.short td { background: #fff6e0; }
.scan-row.over td { background: var(--bad-soft); }
.scan-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.scan-bar input { max-width: 260px; }
.scan-msg { font-size: 13px; padding: 6px 10px; border-radius: 8px; }
.scan-msg.ok { background: #e8f7ee; color: #166534; }
.scan-msg.warn { background: var(--warn-soft); color: #7c3d06; }
.scan-msg.err { background: var(--bad-soft); color: var(--bad); }
.serial-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.serial-list span { font-size: 11px; direction: ltr; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; }
.panel-pop { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); padding: 12px 14px; margin: 10px 16px; font-size: 13px; }
.panel-pop h4 { margin: 0 0 8px; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.panel-pop .pp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 8px; }
.panel-pop .pp-box { background: var(--surface-2); border-radius: 8px; padding: 6px 10px; }
.panel-pop .pp-box b { display: block; font-size: 15px; }
.panel-pop .pp-max b { color: var(--bad); }
.panel-pop .pp-min b { color: var(--info); }
.panel-pop .pp-sug b { color: var(--brand-2); }
.panel-pop table { width: 100%; font-size: 12.5px; border-collapse: collapse; }
.panel-pop td, .panel-pop th { padding: 3px 6px; border-bottom: 1px dashed var(--line); text-align: right; }
.items-table tr.below-floor td { background: var(--bad-soft); }
.items-table .pp-btn { padding: 3px 6px; }
.flow { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 13px; }
.flow .step { padding: 4px 10px; border-radius: 20px; background: var(--surface-2); border: 1px solid var(--line); }
.flow .step.done { background: #e8f7ee; border-color: #bfe5cc; color: #166534; }
.flow .arrow { color: var(--muted); }
.product-form:has(input[name=kind][value=service]:checked) .goods-only { display: none; }
.t.compact td, .t.compact th { padding: 4px 6px; }
.ico-bad { background: var(--bad-soft); color: var(--bad); }
