:root {
  --bg: #f6f7f9; --panel: #ffffff; --panel-2: #f1f3f6; --text: #1b2430; --muted: #657083; --line: #e2e6ec;
  --accent: #0f766e; --accent-2: #14b8a6; --accent-ink: #ffffff; --danger: #c2410c; --warn: #b45309; --ok: #15803d;
  --chip: #e6f4f2; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --radius: 10px; --font: Vazirmatn, "Vazir", "IRANSans", "Segoe UI", Tahoma, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --panel: #151b23; --panel-2: #1c232d; --text: #e6edf3; --muted: #8b96a5; --line: #2a333f;
    --accent: #2dd4bf; --accent-2: #14b8a6; --accent-ink: #062320; --chip: #12312e; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --panel: #151b23; --panel-2: #1c232d; --text: #e6edf3; --muted: #8b96a5; --line: #2a333f;
  --accent: #2dd4bf; --accent-2: #14b8a6; --accent-ink: #062320; --chip: #12312e; --shadow: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); font-weight: 600; }
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-left: 1px solid var(--line); padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; padding: 4px 8px 16px; }
.brand .dot { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); font-size: 13px; }
.side select { width: 100%; margin-bottom: 12px; }
.nav a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); margin-bottom: 2px; }
.nav a:hover { background: var(--panel-2); }
.nav a.active { background: var(--chip); color: var(--accent); font-weight: 600; }
.nav .sep { font-size: 11px; color: var(--muted); padding: 12px 10px 4px; }
.main { padding: 24px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.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)); }
.kpi .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 12px; }
.btn { background: var(--accent); color: var(--accent-ink); border: 0; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0; }
textarea { width: 100%; min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-2); outline-offset: -1px; }
label.f { display: block; margin-bottom: 10px; }
label.f > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
label.f.check { display: flex; gap: 8px; align-items: center; cursor: pointer; align-self: end; padding-bottom: 8px; }
label.f.check input { width: auto; flex: none; }
label.f.check > span { margin: 0; font-size: 13px; color: var(--text); }
.grid { margin-bottom: 16px; }
.grid > .card, .grid > div > .card:last-child { margin-bottom: 0; }
label.f input, label.f select { width: 100%; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: right; padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }
.tablewrap { overflow-x: auto; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--chip); color: var(--accent); font-size: 12px; margin: 1px; white-space: nowrap; }
.chip.warn { background: #fef3c7; color: #92400e; }
.chip.bad { background: #ffedd5; color: #9a3412; }
.chip.ok { background: #dcfce7; color: #166534; }
.chip.muted { background: var(--panel-2); color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; direction: ltr; text-align: left; white-space: pre-wrap; font-size: 12px; overflow-wrap: anywhere; }
pre.mono { background: var(--panel-2); padding: 10px; border-radius: 8px; overflow: auto; max-height: 420px; margin: 0; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 8px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.bars .bar { display: grid; grid-template-columns: 110px 1fr 48px; gap: 8px; align-items: center; margin-bottom: 6px; font-size: 12px; }
.bars .track { background: var(--panel-2); border-radius: 4px; height: 10px; overflow: hidden; }
.bars .fill { background: var(--accent); height: 100%; border-radius: 4px; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 70px; }
.spark div { flex: 1; background: var(--accent-2); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.kanban { display: grid; grid-template-columns: repeat(6, minmax(150px, 1fr)); gap: 10px; overflow-x: auto; }
.kanban .col { background: var(--panel-2); border-radius: 8px; padding: 8px; min-height: 120px; }
.kanban .item { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 6px; font-size: 12px; }
.transcript { display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 80%; padding: 8px 12px; border-radius: 12px; line-height: 1.7; }
.msg.user { align-self: flex-start; background: var(--panel-2); border-top-right-radius: 3px; }
.msg.assistant { align-self: flex-end; background: var(--chip); border-top-left-radius: 3px; }
.msg.tool { align-self: center; font-size: 12px; color: var(--muted); background: transparent; border: 1px dashed var(--line); }
.msg .meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.phone { display: grid; grid-template-columns: 340px 1fr; gap: 16px; }
.dial { text-align: center; }
.dial .status { font-size: 13px; color: var(--muted); margin: 8px 0 14px; min-height: 20px; }
.callbtn { display: inline-grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; border: 0; cursor: pointer; font-size: 26px; color: #fff; background: var(--ok); }
.callbtn.end { background: var(--danger); }
.meter { height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; margin: 10px 0; }
.meter div { height: 100%; width: 0; background: var(--accent-2); transition: width .06s; }
.ringing { animation: ring 1s infinite; }
@keyframes ring { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }
.emotion { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 12px; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border-radius: 12px; padding: 20px; width: min(640px, 100%); max-height: 90vh; overflow: auto; }
#toasts { position: fixed; bottom: 16px; left: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 360px; }
.toast.err { background: var(--danger); color: #fff; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(380px, 100%); }
.score { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; font-weight: 700; font-size: 12px; }
.s1, .s2 { background: #ffedd5; color: #9a3412; } .s3 { background: #fef3c7; color: #92400e; } .s4, .s5 { background: #dcfce7; color: #166534; }
details summary { cursor: pointer; color: var(--muted); }
.hamb { display: none; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 0 0 auto; width: 240px; z-index: 40; transform: translateX(100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .hamb { display: inline-block; }
  .g2, .g3, .g4, .phone { grid-template-columns: 1fr; }
  .main { padding: 16px; }
  .msg { max-width: 92%; }
}
