/* برنا — سیستم طراحی. فقط ویژگی‌های منطقی (inline/block)؛ هیچ left/right. */
@font-face {
  font-family: Vazirmatn;
  src: url('/static/fonts/Vazirmatn.woff2') format('woff2-variations'), url('/static/fonts/Vazirmatn.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f7f6f4;
  --surface: #ffffff;
  --surface-2: #f2f0ed;
  --border: #e7e4df;
  --border-strong: #d3cec7;
  --text: #1d1b19;
  --text-2: #4a4641;
  --muted: #857f77;

  --accent: #8b2f2b;
  --accent-hover: #772623;
  --accent-text: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 10%, transparent);

  --h-red: #c53b34; --h-orange: #d4691f; --h-amber: #b8860b; --h-green: #2f8a4c; --h-teal: #1d8a84;
  --h-blue: #2f6bd1; --h-indigo: #5146c7; --h-violet: #8146c4; --h-pink: #c23f7f; --h-slate: #6b7280;

  --pill-bg: 11%; --pill-text: 78%; --pill-border: 22%;

  --radius-sm: 7px; --radius: 10px; --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(30, 20, 10, .05);
  --shadow: 0 10px 30px rgba(30, 20, 10, .12);
  --font: Vazirmatn, 'Segoe UI', Tahoma, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111012; --surface: #1a191c; --surface-2: #222125; --border: #2c2a2f; --border-strong: #3d3a41;
    --text: #ebe8e4; --text-2: #c4bfb9; --muted: #8f8982;
    --accent: #e07a6f; --accent-hover: #ea8b80; --accent-text: #1a0d0b;
    --h-red: #ef7a72; --h-orange: #f0a061; --h-amber: #e3bd55; --h-green: #6cc58a; --h-teal: #5cc7c0;
    --h-blue: #7aa6f0; --h-indigo: #9b93f0; --h-violet: #b98ff0; --h-pink: #ee8ab9; --h-slate: #9aa1ad;
    --pill-bg: 15%; --pill-text: 82%; --pill-border: 28%;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 12px 34px rgba(0, 0, 0, .55);
  }
}
:root[data-theme="dark"] {
  --bg: #111012; --surface: #1a191c; --surface-2: #222125; --border: #2c2a2f; --border-strong: #3d3a41;
  --text: #ebe8e4; --text-2: #c4bfb9; --muted: #8f8982;
  --accent: #e07a6f; --accent-hover: #ea8b80; --accent-text: #1a0d0b;
  --h-red: #ef7a72; --h-orange: #f0a061; --h-amber: #e3bd55; --h-green: #6cc58a; --h-teal: #5cc7c0;
  --h-blue: #7aa6f0; --h-indigo: #9b93f0; --h-violet: #b98ff0; --h-pink: #ee8ab9; --h-slate: #9aa1ad;
  --pill-bg: 15%; --pill-text: 82%; --pill-border: 28%;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 12px 34px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 13.5px; line-height: 1.75; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.4; margin: 0; }
h1 { font-size: 20px; font-weight: 700; }
h2 { font-size: 15px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; }
img { max-width: 100%; }
.mono, .num { font-variant-numeric: tabular-nums; unicode-bidi: isolate; }
.ltr { direction: ltr; unicode-bidi: isolate; text-align: start; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.bold { font-weight: 600; }
.neg { color: var(--h-red); }
.pos { color: var(--h-green); }
.hide-sm { }
hr { border: 0; border-block-start: 1px solid var(--border); margin: 16px 0; }

/* ---------- چیدمان پنل ---------- */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-inline-end: 1px solid var(--border); padding: 16px 12px;
  position: sticky; inset-block-start: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; font-weight: 800; font-size: 17px;
}
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.3; }
.brand-sub { font-size: 11px; color: var(--muted); }
.nav-label { font-size: 11px; font-weight: 600; color: var(--muted); padding: 12px 10px 4px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; position: relative; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .12s, color .12s;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a.active::before {
  content: ""; position: absolute; inset-inline-start: 0; inset-block: 7px; width: 2.5px; border-radius: 2px; background: var(--accent);
}
.nav .ico { width: 18px; text-align: center; flex: none; }
.nav .badge { margin-inline-start: auto; }
.sidebar-foot { margin-block-start: auto; padding: 12px 10px 0; border-block-start: 1px solid var(--border); font-size: 12px; }

.main { min-width: 0; padding: 24px 32px 56px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-block-end: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 12.5px; margin-block-start: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.topbar-sm { display: none; }

/* ---------- کارت و شبکه ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-block-end: 1px solid var(--border); }
.card-body { padding: 16px 20px; }
.grid { display: grid; gap: 16px; }
.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)); }
.span2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.mt { margin-block-start: 16px; }
.mt-sm { margin-block-start: 8px; }
.mb { margin-block-end: 16px; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-block-end: 16px; }
.kpi { padding: 16px 18px; }
.kpi-label { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 22px; font-weight: 700; margin-block-start: 4px; font-variant-numeric: tabular-nums; line-height: 1.3; }
.kpi-value .unit { font-size: 12px; font-weight: 500; color: var(--muted); margin-inline-start: 4px; }
.kpi-foot { font-size: 12px; color: var(--muted); margin-block-start: 4px; }
.target { font-size: 11px; color: var(--muted); }
.meter { height: 5px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-block-start: 8px; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* ---------- جدول ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.t th {
  font-size: 11px; font-weight: 600; color: var(--muted); background: var(--surface-2); text-align: start;
  padding: 8px 14px; white-space: nowrap; position: sticky; inset-block-start: 0;
}
.t td { padding: 10px 14px; border-block-start: 1px solid var(--border); color: var(--text-2); vertical-align: middle; height: 44px; }
.t tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.t td.title { color: var(--text); font-weight: 500; }
.t .end, .t th.end { text-align: end; }
.t tfoot td { font-weight: 700; color: var(--text); background: var(--surface-2); }
.empty-cell { color: var(--border-strong); }
.t a.rowlink { color: var(--text); font-weight: 500; }

/* ---------- قرص ---------- */
.pill {
  --hue: var(--h-slate);
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  white-space: nowrap; line-height: 1.8;
  background: color-mix(in srgb, var(--hue) var(--pill-bg), transparent);
  color: color-mix(in srgb, var(--hue) var(--pill-text), var(--text));
  border: 1px solid color-mix(in srgb, var(--hue) var(--pill-border), transparent);
}
.hue-red { --hue: var(--h-red); } .hue-orange { --hue: var(--h-orange); } .hue-amber { --hue: var(--h-amber); }
.hue-green { --hue: var(--h-green); } .hue-teal { --hue: var(--h-teal); } .hue-blue { --hue: var(--h-blue); }
.hue-indigo { --hue: var(--h-indigo); } .hue-violet { --hue: var(--h-violet); } .hue-pink { --hue: var(--h-pink); }
.hue-slate { --hue: var(--h-slate); }
.badge { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: 10.5px; font-weight: 700; text-align: center; line-height: 18px; }

/* ---------- دکمه ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 500;
  cursor: pointer; user-select: none; white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn:focus-visible, .input:focus-visible, .chip:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--h-red); }
.btn-sm { padding: 3px 10px; font-size: 12.5px; }
.btn-lg { padding: 11px 22px; font-size: 15px; border-radius: var(--radius); }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-loading { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* ---------- فرم ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field .req { color: var(--h-red); }
.hint { font-size: 11.5px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; transition: border-color .12s, box-shadow .12s;
}
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
textarea.input { min-height: 84px; resize: vertical; line-height: 1.8; }
.input-sm { padding: 4px 8px; font-size: 12.5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input {
  appearance: none; width: 17px; height: 17px; border: 1.5px solid var(--border-strong); border-radius: 5px; margin: 0;
  display: grid; place-items: center; cursor: pointer; transition: background .14s, border-color .14s; background: var(--surface);
}
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after { content: ""; width: 5px; height: 9px; border: solid var(--accent-text); border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.check input:active { transform: scale(.9); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border-strong); background: transparent; color: var(--text-2);
  font: inherit; font-weight: 500; cursor: pointer; user-select: none; transition: all .12s;
}
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); font-weight: 600; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.stepper button { width: 34px; height: 34px; border: 0; background: var(--surface-2); color: var(--text); font: inherit; font-size: 17px; cursor: pointer; }
.stepper button:hover { background: var(--border); }
.stepper output { min-width: 40px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- پیام فلش ---------- */
.flash { padding: 10px 14px; border-radius: var(--radius-sm); margin-block-end: 16px; border: 1px solid; font-weight: 500; }
.flash-success { --hue: var(--h-green); }
.flash-error { --hue: var(--h-red); }
.flash { background: color-mix(in srgb, var(--hue) 10%, var(--surface)); border-color: color-mix(in srgb, var(--hue) 30%, transparent); color: color-mix(in srgb, var(--hue) 80%, var(--text)); }

/* ---------- خالی ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 34px; opacity: .55; }

/* ---------- نمودار ---------- */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 170px; padding-block-start: 8px; }
.bar { flex: 1; display: flex; flex-direction: column-reverse; min-width: 0; height: 100%; justify-content: flex-start; position: relative; }
.bar span { display: block; width: 100%; }
.bar .a { background: var(--accent); border-radius: 0 0 2px 2px; }
.bar .b { background: color-mix(in srgb, var(--h-slate) 45%, transparent); border-radius: 3px 3px 0 0; }
.bar:hover::after {
  content: attr(data-tip); position: absolute; inset-block-end: calc(100% + 4px); inset-inline-start: 50%; translate: 50% 0;
  background: var(--text); color: var(--surface); font-size: 11px; padding: 3px 8px; border-radius: 6px; white-space: nowrap; z-index: 2;
}
.bars-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-block-start: 6px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 5px; vertical-align: -1px; }
.hbar { display: grid; grid-template-columns: 120px 1fr auto; gap: 10px; align-items: center; padding: 5px 0; }
.hbar .track { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.hbar .track span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.funnel-step { display: flex; justify-content: space-between; padding: 8px 0; border-block-end: 1px dashed var(--border); }

/* ---------- گفتگو ---------- */
.chat { display: flex; flex-direction: column; height: calc(100vh - 170px); min-height: 480px; }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); }
.msg { max-width: 78%; padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; line-height: 1.8; box-shadow: var(--shadow-sm); }
.msg.in { align-self: flex-start; background: var(--accent); color: var(--accent-text); border-start-start-radius: 4px; }
.msg.out { align-self: flex-end; background: var(--surface); border: 1px solid var(--border); border-start-end-radius: 4px; }
.msg.operator { border-color: color-mix(in srgb, var(--h-teal) 40%, transparent); }
.msg .meta { display: block; font-size: 10.5px; opacity: .7; margin-block-start: 2px; }
.msg .linkbtn { display: inline-block; margin-block-start: 6px; padding: 4px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chat-kb { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-block-start: 1px solid var(--border); background: var(--surface); }
.chat-kb .kb-row { display: flex; gap: 6px; }
.chat-kb .kb-row button { flex: 1; }
.chat-input { display: flex; gap: 8px; padding: 12px; border-block-start: 1px solid var(--border); background: var(--surface); }
.rec { color: var(--h-red); }

/* ---------- عمومی (وب‌اپ مشتری) ---------- */
.pub-nav { display: flex; align-items: center; justify-content: space-between; max-width: 1080px; margin: 0 auto; padding: 16px 20px; }
.pub-wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px 64px; }
.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 40px; align-items: center; padding: 32px 0 40px; }
.hero h1 { font-size: 32px; line-height: 1.5; font-weight: 800; }
.hero .lead { font-size: 15.5px; color: var(--text-2); margin-block-start: 12px; line-height: 2; }
.trust { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 8px 0 32px; }
.trust .card { padding: 18px; }
.trust .ico { font-size: 22px; }
.section-title { font-size: 20px; font-weight: 800; margin-block-end: 6px; }
.calc-result { display: none; }
.calc-result.show { display: block; animation: rise .18s ease; }
.cut-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.cut-card { padding: 14px 16px; }
.price { font-weight: 700; font-variant-numeric: tabular-nums; }
.invite { border: 1px dashed color-mix(in srgb, var(--accent) 50%, transparent); background: var(--accent-soft); border-radius: var(--radius); padding: 12px 16px; margin-block-end: 16px; }
.timeline { display: flex; gap: 0; margin: 16px 0; }
.timeline .st { flex: 1; text-align: center; font-size: 12px; color: var(--muted); position: relative; padding-block-start: 22px; }
.timeline .st::before { content: ""; position: absolute; inset-block-start: 6px; inset-inline: 0; height: 3px; background: var(--border); }
.timeline .st::after { content: ""; position: absolute; inset-block-start: 1px; inset-inline-start: 50%; translate: 50% 0; width: 13px; height: 13px; border-radius: 50%; background: var(--border-strong); }
.timeline .st.done { color: var(--text); font-weight: 600; }
.timeline .st.done::before, .timeline .st.done::after { background: var(--accent); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; }
.kv dt { color: var(--muted); font-size: 12.5px; }
.kv dd { margin: 0; font-weight: 500; }
.center-box { max-width: 460px; margin: 8vh auto; padding: 0 16px; }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---------- واکنش‌گرا ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: 260px; z-index: 30; translate: 100% 0; transition: translate .18s; box-shadow: var(--shadow); }
  .sidebar.open { translate: 0 0; }
  .topbar-sm { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--surface); border-block-end: 1px solid var(--border); position: sticky; inset-block-start: 0; z-index: 20; }
  .main { padding: 16px 16px 48px; }
  .g2, .g3, .form-grid, .hero, .trust { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .hero h1 { font-size: 25px; }
  .hide-sm { display: none; }
  .kv { grid-template-columns: 110px 1fr; }
  .msg { max-width: 90%; }
}
@media (max-width: 520px) {
  .kpis, .g4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px; }
  .kpi-value { font-size: 18px; }
}
