/* =====================================================================
   WA Platform — design system (developed by Yaknit)
   ===================================================================== */
:root {
  --brand: #0e7a43;
  --brand-hover: #0b6537;
  --brand-soft: #e7f4ec;
  --brand-ink: #0b5c33;
  --accent: #34c27a;

  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --surface-3: #eef2f0;
  --border: #e2e8e4;
  --border-strong: #cdd6d0;
  --text: #111a15;
  --text-2: #3d4a43;
  --muted: #6b7a71;

  --ok: #0d8a3f; --ok-soft: #e4f5ea;
  --warn: #9a6200; --warn-soft: #fff3d9;
  --bad: #c0392b; --bad-soft: #fcebea;
  --info: #1f63b5; --info-soft: #e7f0fb;

  --sidebar: #0f1d16;
  --sidebar-2: #16291f;
  --sidebar-text: #c9dbd0;
  --sidebar-muted: #7f978a;

  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --chat-bg: #efeae2;

  /* charts (validated reference palette) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #e1e0d9;
  --axis: #898781;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .05), 0 1px 1px rgba(16, 24, 20, .03);
  --shadow-lg: 0 10px 30px rgba(16, 24, 20, .12);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
/* dark: chosen in the app (data-theme="dark"), or the system setting when "auto" */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #22a862; --brand-hover: #2cbd71; --brand-soft: #143224; --brand-ink: #7fdcab; --accent: #34c27a;
    --bg: #0c110e; --surface: #141b17; --surface-2: #18211c; --surface-3: #1e2923;
    --border: #26322b; --border-strong: #34433a; --text: #e8eeea; --text-2: #c2cec7; --muted: #8b9a91;
    --ok: #3cc46e; --ok-soft: #15301f; --warn: #e6ac3c; --warn-soft: #33290f; --bad: #ef6b5e; --bad-soft: #3a1c19; --info: #5b9be6; --info-soft: #172a40;
    --sidebar: #0a120e; --sidebar-2: #12201a;
    --bubble-in: #1e2a24; --bubble-out: #144d33; --chat-bg: #0b100d;
    --series-1: #3987e5; --series-2: #d95926; --grid: #2c2c2a; --axis: #898781;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --brand: #22a862; --brand-hover: #2cbd71; --brand-soft: #143224; --brand-ink: #7fdcab; --accent: #34c27a;
    --bg: #0c110e; --surface: #141b17; --surface-2: #18211c; --surface-3: #1e2923;
    --border: #26322b; --border-strong: #34433a; --text: #e8eeea; --text-2: #c2cec7; --muted: #8b9a91;
    --ok: #3cc46e; --ok-soft: #15301f; --warn: #e6ac3c; --warn-soft: #33290f; --bad: #ef6b5e; --bad-soft: #3a1c19; --info: #5b9be6; --info-soft: #172a40;
    --sidebar: #0a120e; --sidebar-2: #12201a;
    --bubble-in: #1e2a24; --bubble-out: #144d33; --chat-bg: #0b100d;
    --series-1: #3987e5; --series-2: #d95926; --grid: #2c2c2a; --axis: #898781;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; }
h1 { font-size: 22px; letter-spacing: -.01em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 10px; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--surface-3); border-radius: 4px; padding: 1px 5px; font-size: 12px; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 12px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.error-box { color: var(--bad); background: var(--bad-soft); padding: 10px 12px; border-radius: var(--radius-sm); }
.warn-box { color: var(--warn); background: var(--warn-soft); padding: 10px 12px; border-radius: var(--radius-sm); }
.info-box { color: var(--info); background: var(--info-soft); padding: 10px 12px; border-radius: var(--radius-sm); }
[hidden] { display: none !important; }
svg.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- controls */
label, .field { display: block; margin: 0 0 14px; font-weight: 600; font-size: 13px; color: var(--text-2); }
label small, .field small { font-weight: 400; color: var(--muted); }
input, select, textarea {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px; font: inherit; font-weight: 400; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 40px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input[readonly] { background: var(--surface-2); color: var(--text-2); }
input[type=checkbox], input[type=radio] { width: auto; display: inline-block; margin: 0; accent-color: var(--brand); }
label.check { display: flex; align-items: center; gap: 9px; font-weight: 500; color: var(--text); }

.switch { display: flex; align-items: center; gap: 12px; font-weight: 600; color: var(--text); cursor: pointer; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .15s; margin: 0; border: none; padding: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(16px); }
.switch input:focus { box-shadow: 0 0 0 3px var(--brand-soft); }

.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; min-height: 36px;
  font: inherit; font-weight: 600; font-size: 13.5px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover, button:hover { background: var(--surface-2); text-decoration: none; }
button:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; }
.btn.primary, button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover, button.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.ghost, button.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover, button.ghost:hover { background: var(--surface-3); }
.btn.danger, button.danger { color: var(--bad); }
.btn.danger:hover, button.danger:hover { background: var(--bad-soft); border-color: var(--bad-soft); }
.btn.sm, button.sm { min-height: 30px; padding: 4px 10px; font-size: 12.5px; }
.btn.block, button.block { width: 100%; min-height: 42px; }
.btn.icon-only, button.icon-only { padding: 6px; min-width: 32px; min-height: 32px; }

.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > label, .row > .field { margin-bottom: 14px; }
.row.center { align-items: center; }
.row.between { justify-content: space-between; align-items: center; }
.row.tight { gap: 6px; }
.grow { flex: 1 1 180px; min-width: 0; }
.grow2 { flex: 2 1 280px; min-width: 0; }
.stack { display: grid; gap: 16px; }
.copy { display: flex; gap: 6px; margin-top: 5px; }
.copy input { margin: 0; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding-top: 6px; }

/* ---------------------------------------------------------------- pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; line-height: 18px; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.plain::before { display: none; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.brand { background: var(--brand-soft); color: var(--brand-ink); }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 19px; height: 19px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #062614; font-size: 11px; font-weight: 700; }

/* ---------------------------------------------------------------- app shell */
body.app { display: grid; grid-template-columns: 248px 1fr; height: 100vh; overflow: hidden; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; min-height: 0; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 700; font-size: 15.5px; }
.sidebar-brand img { width: 32px; height: 32px; border-radius: 9px; }
.sidebar-brand small { display: block; font-weight: 500; font-size: 11px; color: var(--sidebar-muted); }
.sidebar nav { flex: 1; overflow-y: auto; padding: 6px 10px; }
.nav-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-muted); padding: 14px 10px 6px; font-weight: 700; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 10px; margin: 1px 0; border-radius: 8px; color: var(--sidebar-text); font-weight: 550; font-size: 13.5px; background: none; border: none; min-height: 0; justify-content: flex-start; }
.nav-item:hover { background: var(--sidebar-2); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--sidebar-2); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav-item .badge { margin-inline-start: auto; }
.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.07); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; text-transform: uppercase; }
.user-card .who { flex: 1; min-width: 0; line-height: 1.3; }
.user-card .who strong { display: block; color: #fff; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.user-card .who span { font-size: 11.5px; color: var(--sidebar-muted); }
.user-card button { background: none; border: none; color: var(--sidebar-text); min-height: 0; padding: 6px; }
.user-card button:hover { background: var(--sidebar-2); color: #fff; }
.credit { display: block; text-align: center; font-size: 11px; color: var(--sidebar-muted); padding: 8px 0 2px; letter-spacing: .02em; }
.credit b { color: var(--sidebar-text); font-weight: 700; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.mobilebar { display: none; }
#page { flex: 1; overflow-y: auto; min-height: 0; }
.page { max-width: 1320px; margin: 0 auto; padding: 26px 30px 40px; }
.page.full { max-width: none; padding: 0; height: 100%; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-header .crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.page-header .crumbs a { color: var(--muted); }
.page-header p { margin: 4px 0 0; color: var(--muted); }
.page-header .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.page-header .actions select, .page-header .actions input { width: auto; margin: 0; min-height: 36px; padding-top: 7px; padding-bottom: 7px; }

/* ---------------------------------------------------------------- cards & grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-body { padding: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-header p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 10px; }
.section-title:first-child { margin-top: 0; }
.divider { height: 1px; background: var(--border); margin: 18px 0; border: 0; }

/* KPI tiles */
.page-body > * + * { margin-top: 18px; }
.card-body > .row.tight:first-child { margin-bottom: 4px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .label { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi .label .icon { width: 16px; height: 16px; }
.kpi .value { font-size: 27px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; color: var(--text); }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; overflow-y: hidden; }
.tab { padding: 10px 14px; border: none; background: none; border-radius: 0; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; min-height: 0; }
.tab:hover { color: var(--text); background: none; text-decoration: none; }
.tab.active { color: var(--brand-ink); border-bottom-color: var(--brand); }

/* settings layout */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; align-items: start; }
.subnav { display: grid; gap: 2px; position: sticky; top: 0; }
.subnav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--text-2); font-weight: 550; }
.subnav a:hover { background: var(--surface-3); text-decoration: none; }
.subnav a.active { background: var(--brand-soft); color: var(--brand-ink); }

/* tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: start; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tr.clickable { cursor: pointer; }
.table .actions { text-align: end; white-space: nowrap; }
.table td.num, .table th.num { text-align: end; font-variant-numeric: tabular-nums; }
.cell-title { font-weight: 600; color: var(--text); }
.cell-sub { font-size: 12px; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }

/* empty state */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .icon { width: 40px; height: 40px; stroke-width: 1.4; color: var(--border-strong); margin-bottom: 10px; }
.empty h3 { color: var(--text); margin-bottom: 6px; }

/* progress */
.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; min-width: 80px; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .4s; }

/* ---------------------------------------------------------------- charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar-1 { fill: var(--series-1); }
.chart .bar-2 { fill: var(--series-2); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hover-band.on { fill: var(--surface-3); }
.swatch-bar-1 { background: var(--series-1); }
.swatch-bar-2 { background: var(--series-2); }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-2); margin-bottom: 10px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tooltip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; z-index: 5; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); }
.tooltip b { display: block; margin-bottom: 3px; }
.tooltip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-inline-end: 6px; }
.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 160px) 1fr 54px; gap: 10px; align-items: center; font-size: 13px; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.hbar .track, .hbar .fill { display: block; }
.hbar .track { height: 12px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .val { text-align: end; font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.chart-table summary { cursor: pointer; font-size: 12px; color: var(--muted); margin-top: 10px; }

/* ---------------------------------------------------------------- inbox */
.inbox { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: 100%; background: var(--surface); }
.conv-list { border-inline-end: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.conv-list .head { padding: 18px 16px 12px; border-bottom: 1px solid var(--border); display: grid; gap: 10px; }
.conv-list .head input, .conv-list .head select { margin: 0; }
.conv-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 4px 11px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--text-2); min-height: 0; }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.conv-items { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.conv-item { display: grid; grid-template-columns: 40px 1fr auto; gap: 2px 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; align-items: center; }
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: var(--brand-soft); }
.conv-item .avatar { grid-row: span 2; width: 40px; height: 40px; background: var(--surface-3); color: var(--text-2); }
.conv-item .n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .t { font-size: 11.5px; color: var(--muted); text-align: end; }
.conv-item .l { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .c { grid-column: 2 / -1; font-size: 11px; color: var(--brand-ink); font-weight: 600; }
.conv-item.unread .n, .conv-item.unread .l { color: var(--text); font-weight: 700; }
.conv { display: flex; flex-direction: column; min-height: 0; background: var(--chat-bg); }
.conv-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.conv-head .id { flex: 1; min-width: 160px; }
.conv-head .id strong { display: block; font-size: 15px; }
.conv-head .id span { font-size: 12.5px; color: var(--muted); }
.conv-info { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 18px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.messages { flex: 1; overflow-y: auto; padding: 18px 7%; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 68%; padding: 7px 11px 5px; border-radius: 10px; background: var(--bubble-in); box-shadow: 0 1px 1px rgba(0,0,0,.08); white-space: pre-wrap; word-wrap: break-word; font-size: 14px; }
.msg.out { align-self: flex-end; background: var(--bubble-out); }
.msg .meta { display: flex; justify-content: flex-end; gap: 6px; font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.msg .tag { font-size: 11px; color: var(--brand-ink); font-weight: 700; margin-bottom: 3px; }
.msg.failed { outline: 1px solid var(--bad); }
.msg .err { color: var(--bad); font-size: 11.5px; }
.msg img, .msg video { max-width: 100%; max-height: 300px; border-radius: 8px; display: block; margin-bottom: 4px; }
.msg audio { max-width: 260px; display: block; }
.day { align-self: center; background: var(--surface); color: var(--muted); font-size: 11.5px; padding: 3px 12px; border-radius: 8px; margin: 8px 0; box-shadow: var(--shadow); }
.composer { display: flex; gap: 10px; padding: 12px 16px; background: var(--surface); border-top: 1px solid var(--border); align-items: flex-end; }
.composer textarea { margin: 0; max-height: 160px; }
.composer-closed { margin: 0; padding: 14px; text-align: center; background: var(--warn-soft); color: var(--warn); font-weight: 600; display: flex; gap: 12px; justify-content: center; align-items: center; flex-wrap: wrap; }
.inbox-empty { display: grid; place-items: center; height: 100%; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------- template preview / wizard */
.preview { background: var(--chat-bg); border-radius: var(--radius-sm); padding: 18px; min-height: 120px; }
.preview .msg { max-width: 100%; }
.preview .btns { display: grid; gap: 4px; margin-top: 4px; }
.preview .btns span { text-align: center; color: #0a7cff; background: var(--bubble-in); border-radius: 8px; padding: 7px; font-weight: 600; font-size: 13px; }
.preview .media { background: var(--surface-3); border-radius: 8px; padding: 34px; text-align: center; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; font-size: 12px; font-weight: 700; }
.fields:empty { display: none; }
.fields { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 14px 2px; margin-bottom: 12px; }

.wizard-step { display: grid; grid-template-columns: 34px 1fr; gap: 16px; padding: 22px 20px; border-bottom: 1px solid var(--border); }
.wizard-step:last-child { border-bottom: none; }
.wizard-step .n { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; }
.wizard-step h3 { font-size: 15px; margin: 4px 0 4px; }
.wizard-step > div > p.muted { margin-bottom: 14px; }
.choice-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-bottom: 14px; }
.choice-card { display: block; border: 1px solid var(--border-strong); border-radius: 10px; padding: 12px 14px; cursor: pointer; margin: 0; font-weight: 600; color: var(--text); background: var(--surface); }
.choice-card input { margin-inline-end: 8px; }
.choice-card small { display: block; font-weight: 400; color: var(--muted); margin-top: 3px; }
.choice-card:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 1px var(--brand); }
.audience-count { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--brand-soft); color: var(--brand-ink); border-radius: 10px; font-weight: 600; }
.audience-count .big { font-size: 24px; font-weight: 800; }
.filter-group { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px 2px; margin-bottom: 12px; }
.filter-group .opts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 8px 0 12px; }
.filter-group .opts label { margin: 0; font-weight: 500; }

/* ---------------------------------------------------------------- assistant editor */
.flow-step { border: 1px solid var(--border); border-radius: 10px; padding: 14px 14px 2px; margin-bottom: 12px; background: var(--surface-2); }
.flow-step .step-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.flow-step .step-head strong { display: flex; align-items: center; gap: 8px; }
.flow-step .step-head .n { width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 12px; }
.flow-options { border-top: 1px dashed var(--border-strong); padding-top: 10px; margin-bottom: 12px; }
.flow-opt .k { align-self: center; font-weight: 700; color: var(--brand-ink); width: 18px; margin-bottom: 14px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sim { background: var(--chat-bg); border-radius: 10px; min-height: 160px; max-height: 380px; padding: 14px; margin-bottom: 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.sim .msg { max-width: 80%; }
.sim .msg.in { align-self: flex-start; }

/* ---------------------------------------------------------------- misc */
.status-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0; }
.status-list li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); align-items: center; }
.status-list li:last-child { border-bottom: none; }
.status-list li > span:first-child { flex: none; }
.status-list .pill { white-space: normal; text-align: end; line-height: 1.35; padding-top: 3px; padding-bottom: 3px; }
.steps { padding-inline-start: 20px; color: var(--text-2); margin: 0 0 14px; }
.steps li { margin-bottom: 6px; }
.logs { font-family: ui-monospace, Consolas, monospace; font-size: 12px; max-height: 560px; overflow: auto; }
.logs div { padding: 6px 20px; border-bottom: 1px solid var(--border); word-break: break-word; }
.logs .warn { color: var(--warn); } .logs .error { color: var(--bad); }
.test-result { margin-top: 14px; display: grid; gap: 8px; }
.discovered { display: flex; flex-wrap: wrap; gap: 6px; margin: -6px 0 14px; }
.funnel { display: grid; gap: 12px; }
.card.sticky { position: sticky; top: 12px; align-self: start; }
.card-header input, .card-header select { margin: 0; width: auto; min-width: 170px; }
.inbox-empty .icon { width: 44px; height: 44px; stroke-width: 1.4; color: var(--border-strong); }
.inbox-empty h3 { color: var(--text); margin: 10px 0 4px; }
.conv-items .empty { padding: 30px 20px; font-size: 13px; }
.conv-items li.more { padding: 10px; text-align: center; list-style: none; }
.conv-head .avatar { background: var(--surface-3); color: var(--text-2); }
.table .row { flex-wrap: nowrap; }
.table .avatar { width: 32px; height: 32px; font-size: 12px; background: var(--surface-3); color: var(--text-2); }
.progress-wrap { margin: 12px 0 4px; }

#toasts { position: fixed; inset-inline-end: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 100; max-width: min(420px, calc(100vw - 36px)); }
.toast { background: var(--text); color: var(--bg); padding: 11px 15px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 500; }
.toast.error { background: var(--bad); color: #fff; }
.toast.ok { background: var(--brand); color: #fff; }

/* ---------------------------------------------------------------- auth pages */
body.auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, 520px); min-height: 100vh; }
.auth-side { background: radial-gradient(circle at 20% 20%, #1e8f55 0, transparent 45%), linear-gradient(150deg, #0f3d26, #0a1f15 70%); color: #e6f2eb; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side .brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 18px; color: #fff; }
.auth-side .brand img { width: 40px; height: 40px; border-radius: 11px; }
.auth-side h2 { font-size: 34px; line-height: 1.15; color: #fff; max-width: 520px; letter-spacing: -.02em; }
.auth-side ul { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 10px; color: #c4dccd; }
.auth-side li::before { content: "✓"; color: var(--accent); font-weight: 800; margin-inline-end: 10px; }
.auth-side .credit { color: #8fb3a0; text-align: start; font-size: 12.5px; }
.auth-side .credit b { color: #fff; }
.auth-main { display: grid; place-items: center; padding: 32px; background: var(--surface); }
.auth-card { width: 100%; max-width: 360px; }
.auth-card h1 { margin-bottom: 6px; }
.auth-card form { margin-top: 26px; }
.auth-card .credit { color: var(--muted); margin-top: 28px; }
.auth-card .credit b { color: var(--text); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-main { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  body.app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .mobilebar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border); font-weight: 700; }
  .page { padding: 18px 16px 32px; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .settings { grid-template-columns: 1fr; }
  .subnav { position: static; grid-auto-flow: column; overflow-x: auto; }
  .pair { grid-template-columns: 1fr; }
  .inbox { grid-template-columns: 1fr; }
  .inbox.has-conv .conv-list { display: none; }
  .inbox:not(.has-conv) .conv { display: none; }
  .msg { max-width: 88%; }
  .messages { padding: 14px; }
  body.auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
}
@media (min-width: 901px) { .mobile-only { display: none !important; } }

/* ---------------------------------------------------------------- display preferences (theme, language, collapsed menu) */
.prefs { display: flex; align-items: center; gap: 4px; padding: 0 4px 8px; position: relative; }
.prefs button { background: none; border: none; color: var(--sidebar-text); min-height: 0; padding: 6px 8px; border-radius: 8px; font-size: 12px; font-weight: 700; gap: 6px; }
.prefs button:hover, .prefs button[aria-expanded="true"] { background: var(--sidebar-2); color: #fff; }
.prefs .collapse-btn { margin-inline-start: auto; }
.lang-menu { position: absolute; bottom: calc(100% + 4px); inset-inline-start: 4px; z-index: 60; min-width: 170px; padding: 6px; display: grid; gap: 2px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }
.lang-menu button { justify-content: flex-start; width: 100%; color: var(--text); font-size: 13.5px; font-weight: 550; padding: 8px 10px; }
.lang-menu button:hover { background: var(--surface-2); color: var(--text); }
.lang-menu button .icon { margin-inline-start: auto; color: var(--brand); }
.lang-menu .code { display: inline-grid; place-items: center; min-width: 26px; height: 18px; border-radius: 4px; background: var(--surface-3); font-size: 10.5px; font-weight: 800; }
[dir="rtl"] .nav-item.active { box-shadow: inset -3px 0 0 var(--accent); }
[dir="rtl"] .switch input { direction: ltr; }
[dir="rtl"] svg.icon.flip-rtl { transform: scaleX(-1); }
@media (min-width: 901px) {
  body.app { transition: grid-template-columns .18s; }
  .nav-collapsed body.app { grid-template-columns: 68px 1fr; }
  .nav-collapsed .sidebar-brand { justify-content: center; padding-inline: 0; }
  .nav-collapsed .sidebar-brand > div, .nav-collapsed .nav-title, .nav-collapsed .nav-label, .nav-collapsed .user-card .who, .nav-collapsed .credit, .nav-collapsed .prefs .lang-code { display: none; }
  .nav-collapsed .sidebar nav { padding-inline: 8px; }
  .nav-collapsed .nav-item { justify-content: center; padding: 10px 0; position: relative; }
  .nav-collapsed .nav-item .badge { position: absolute; top: 2px; inset-inline-end: 4px; min-width: 16px; height: 16px; padding: 0 4px; font-size: 10px; }
  .nav-collapsed .nav-item + .nav-item { margin-top: 2px; }
  .nav-collapsed .sidebar nav > .nav-title + .nav-item, .nav-collapsed .sidebar nav > .nav-item:first-child { margin-top: 10px; }
  .nav-collapsed .sidebar-foot { padding: 10px 6px; }
  .nav-collapsed .user-card { flex-direction: column; padding: 4px 0; gap: 6px; }
  .nav-collapsed .prefs { flex-direction: column; padding: 0 0 6px; }
  .nav-collapsed .prefs .collapse-btn { margin: 0; }
  .nav-collapsed .lang-menu { inset-inline-start: calc(100% + 8px); bottom: 0; }
}
@media (max-width: 900px) {
  .prefs .collapse-btn { display: none; }
  [dir="rtl"] .sidebar { inset: 0 0 0 auto; transform: translateX(100%); }
  [dir="rtl"] body.nav-open .sidebar { transform: none; }
}

/* ---------------------------------------------------------------- leads */
.row.wrap { flex-wrap: wrap; }
.pad { padding: 0 14px; }
.spacer { height: 14px; }
.status-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.status-chip { display: inline-flex; align-items: center; gap: 7px; min-height: 0; padding: 5px 12px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; color: var(--text-2); }
.status-chip b { color: var(--text); font-variant-numeric: tabular-nums; }
.status-chip.info { color: var(--info); } .status-chip.warn { color: var(--warn); } .status-chip.ok { color: var(--ok); }
.status-chip.bad { color: var(--bad); } .status-chip.brand { color: var(--brand-ink); }
.status-chip.active { border-color: currentColor; box-shadow: inset 0 0 0 1px currentColor; background: var(--surface-2); }
.status-chip:not(.info):not(.warn):not(.ok):not(.bad):not(.brand).active { color: var(--text); }
.bulk-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; background: var(--brand-soft); border-bottom: 1px solid var(--border); }
.bulk-bar select { width: auto; margin: 0; min-width: 160px; }
.leads-table select { margin: 0; width: auto; min-width: 130px; padding-top: 4px; padding-bottom: 4px; font-size: 12.5px; }
.status-select { font-weight: 700; text-transform: uppercase; font-size: 11.5px !important; }
.status-select.info { color: var(--info); } .status-select.warn { color: var(--warn); } .status-select.ok { color: var(--ok); }
.status-select.bad { color: var(--bad); } .status-select.brand { color: var(--brand-ink); }

.lead-head { display: flex; gap: 14px; align-items: center; }
.lead-head h2 { margin: 0 0 4px; font-size: 20px; }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }
.facts-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin: 18px 0; padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.facts-row small { display: block; color: var(--muted); font-size: 12px; }
.facts-row strong { font-size: 15px; }
.facts-row + .info-box { margin-bottom: 14px; display: flex; gap: 6px; align-items: flex-start; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 13.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; text-align: end; word-break: break-word; }

.outcomes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 14px; }
.outcome { min-height: 44px; font-weight: 700; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); position: relative; }
.outcome.info { color: var(--info); background: var(--info-soft); border-color: transparent; }
.outcome.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.outcome.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.outcome.bad { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.outcome.brand { color: var(--brand-ink); background: var(--brand-soft); border-color: transparent; }
.outcome.current::after { content: "actuel"; position: absolute; top: 2px; inset-inline-end: 6px; font-size: 9.5px; font-weight: 600; opacity: .7; text-transform: uppercase; }
.outcome.selected { border-color: currentColor; box-shadow: 0 0 0 2px currentColor; }
.work textarea { min-height: 70px; }

.queue-layout { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr) minmax(260px, 340px); gap: 18px; align-items: start; margin-top: 18px; }
.queue-card .card-header input { min-width: 0; width: 100%; }
.queue-list { max-height: calc(100vh - 290px); overflow-y: auto; padding-bottom: 8px; }
.queue-item { display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: start; border: none; border-bottom: 1px solid var(--border); border-radius: 0; background: none; padding: 12px 14px; min-height: 0; font-weight: 400; }
.queue-item:hover { background: var(--surface-2); }
.queue-item.active { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.queue-item strong { color: var(--text); }
.queue-item .tags { margin-top: 5px; }
.qnum { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-size: 11.5px; font-weight: 700; color: var(--text-2); }
.qnum .icon { width: 14px; height: 14px; }
.queue-item.active .qnum { background: var(--brand); color: #fff; }

.mini-msgs { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow-y: auto; background: var(--chat-bg); padding: 10px; border-radius: var(--radius-sm); }
.mini-msg { max-width: 85%; padding: 6px 9px; border-radius: 8px; background: var(--bubble-in); font-size: 13px; white-space: pre-wrap; word-wrap: break-word; }
.mini-msg.out { align-self: flex-end; background: var(--bubble-out); }
.mini-msg small { display: block; font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: 13px; }
.timeline li { padding-inline-start: 12px; border-inline-start: 2px solid var(--border-strong); }
.timeline li.note { border-inline-start-color: var(--brand); }
.timeline small { color: var(--muted); font-size: 11.5px; }

@media (max-width: 1250px) { .queue-layout { grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); } .queue-layout > :last-child { grid-column: 1 / -1; } }
@media (max-width: 900px) { .queue-layout { grid-template-columns: 1fr; } .queue-list { max-height: 340px; } }
.lead-page { align-items: start; }
.lead-page > .stack, .queue-layout > .stack { align-content: start; }

/* ---------------------------------------------------------------- leads tools */
.gap-top { margin-top: 18px; }
.center { text-align: center; }
.filters-bar { margin: 18px 0 14px; flex-wrap: wrap; }
.filters-bar input[type=search] { max-width: 340px; margin: 0; }
.filters-bar select { width: auto; margin: 0; }
.filters-bar label.check { margin: 0; }
.agent-bar { display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: center; padding: 10px 16px; margin-bottom: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; color: var(--text-2); }
.agent-bar > span { display: inline-flex; align-items: center; gap: 6px; }
.agent-bar .icon { width: 15px; height: 15px; color: var(--muted); }
.agent-bar .online { color: var(--ok); font-weight: 700; }
.agent-bar .online::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.edit-details { margin-top: 14px; padding: 12px; background: var(--surface-2); border-radius: var(--radius-sm); align-items: flex-end; }
.edit-details label { margin-bottom: 0; }
.review-card { border-color: var(--warn); }
.resolve p { margin: 0 0 12px; }
.review-reason { margin-top: 12px; font-size: 13px; }
.review-reason small { color: var(--muted); }

.cb-list > .cb-item:last-child { border-bottom: none; }
.cb-item { display: flex; gap: 16px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.cb-item.late { box-shadow: inset 3px 0 0 var(--bad); }
.cb-when { display: grid; justify-items: start; gap: 2px; min-width: 110px; }
.cb-when strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.cb-when small { color: var(--muted); font-size: 12px; }
.cb-note { font-size: 12.5px; color: var(--text-2); font-style: italic; margin-top: 4px; }
.cb-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.sm-select { width: auto !important; margin: 0 !important; min-height: 30px; padding: 4px 8px; font-size: 12.5px; }

.prio { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13.5px; }
.prio.bad { background: var(--bad-soft); color: var(--bad); } .prio.warn { background: var(--warn-soft); color: var(--warn); }
.prio.info { background: var(--info-soft); color: var(--info); } .prio.ok { background: var(--ok-soft); color: var(--ok); }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; }
.day-col { display: grid; justify-items: center; gap: 4px; font-size: 12px; }
.day-col small { color: var(--muted); text-transform: capitalize; }
.day-bars { height: 120px; width: 100%; display: flex; gap: 3px; align-items: flex-end; justify-content: center; }
.day-bar { width: 14px; min-height: 2px; border-radius: 4px 4px 0 0; background: var(--series-1); }
.day-bar.won { background: var(--ok); }
.bar-row { display: grid; grid-template-columns: minmax(110px, 38%) 1fr auto; gap: 10px; align-items: center; margin-bottom: 9px; font-size: 13px; }
.bar-label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--muted); }
.bar-fill.info { background: var(--info); } .bar-fill.warn { background: var(--warn); } .bar-fill.ok { background: var(--ok); }
.bar-fill.bad { background: var(--bad); } .bar-fill.brand { background: var(--brand); }
.bar-value { min-width: 32px; text-align: end; font-weight: 700; }
.note-meta { display: grid; justify-items: end; color: var(--muted); }

.import-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px; }
.import-step { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-weight: 600; font-size: 13px; }
.import-step b { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-size: 12px; flex: none; }
.import-step.active { border-color: var(--brand); color: var(--brand-ink); }
.import-step.active b { background: var(--brand); color: #fff; }
.import-step.done b { background: var(--ok-soft); color: var(--ok); }
.dropzone { display: grid; justify-items: center; gap: 6px; padding: 36px 20px; border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); cursor: pointer; text-align: center; color: var(--text-2); font-weight: 500; }
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone .icon { width: 34px; height: 34px; color: var(--brand); }
.dropzone small { color: var(--muted); }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
@media (max-width: 700px) { .import-steps { grid-template-columns: repeat(2, 1fr); } .cb-when { min-width: 0; } }

/* ---------------------------------------------------------------- app mobile / calls */
.phone-head { display: flex; gap: 14px; align-items: center; }
.phone-head h2 { margin: 0 0 4px; font-size: 18px; }
.phone-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex: none; }
.phone-icon.sm { width: 34px; height: 34px; }
.pair { display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: start; }
.pair-qr { display: grid; gap: 8px; justify-items: center; width: 226px; }
.qr-box { padding: 7px; border: 2px solid var(--brand); border-radius: 14px; background: #fff; line-height: 0; }
.qr-box .qr { display: block; width: 210px; height: 210px; }
.pair-qr .bar-track { width: 100%; }
.steps-list { margin: 0 0 14px; padding-inline-start: 20px; display: grid; gap: 8px; font-size: 13.5px; }
.pair-manual { display: grid; gap: 2px; margin-bottom: 14px; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
.pair-code { font-size: 24px; font-weight: 800; letter-spacing: .12em; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.pair-server { font-size: 12.5px; word-break: break-all; }
.or-sep { display: flex; align-items: center; gap: 10px; margin: 20px 0 14px; color: var(--muted); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.or-sep::before, .or-sep::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.apk-card { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.apk-qr { display: flex; gap: 12px; align-items: center; }
.apk-qr .qr { flex: none; border-radius: 6px; }
.device { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); display: grid; gap: 10px; }
.device label { margin-bottom: 0; }
.device-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.device-facts > div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px; display: grid; gap: 2px; }
.device-facts small { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.call-ctl { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sim-select { width: auto !important; margin: 0 !important; min-height: 34px; padding: 4px 8px; font-size: 12.5px; }
.call-status { font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface-3); }
.call-status.ok { background: var(--ok-soft); color: var(--ok); } .call-status.info { background: var(--info-soft); color: var(--info); }
.call-status.warn { background: var(--warn-soft); color: var(--warn); } .call-status.bad { background: var(--bad-soft); color: var(--bad); }
.call-hint { font-size: 12px; color: var(--muted); }
.agent-bar .phone-state { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; margin-inline-start: auto; padding: 3px 10px; border-radius: 999px; text-decoration: none; }
.agent-bar .phone-state.on { background: var(--ok-soft); color: var(--ok); }
.agent-bar .phone-state.off { background: var(--warn-soft); color: var(--warn); }
.agent-bar .phone-state .icon { color: currentColor; }
.phone-grid { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
@media (max-width: 1300px) { .phone-grid { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .pair { grid-template-columns: 1fr; justify-items: center; } }

/* ---------------------------------------------------------------- centres & predefined messages */
.edit-table td { padding: 6px 8px; }
.edit-table input { margin: 0; min-width: 110px; }
.qm-row, .qm-item { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.qm-row:last-child, .qm-item:last-child { border-bottom: none; }
.qm-img { max-width: 100%; max-height: 220px; border-radius: var(--radius-sm); display: block; margin-bottom: 6px; }
.fixed-loc { padding-inline-start: 26px; }
.qm-panel { margin-top: 14px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.qm-list { margin-top: 8px; }
.qm-text { font-size: 12.5px; color: var(--text-2); white-space: pre-wrap; margin-top: 4px; max-height: 66px; overflow: hidden; }
.segs { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border-strong); border-radius: 999px; padding: 2px; background: var(--surface); }
.seg { border: none; background: none; border-radius: 999px; min-height: 0; padding: 5px 12px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.seg.active { background: var(--brand); color: #fff; }
.seg:disabled { opacity: .45; }
.centre-field { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--ok-soft); color: var(--ok); }
.centre-field select { margin-top: 6px; }

/* supervision */
.goal { font-weight: 600; }
.goal.ok { color: var(--brand-ink); }
.goal-input { width: 76px; text-align: end; }
tr.group td { background: var(--bg, #f4f6f5); }
.small { font-size: 12px; }

/* work session, confirmés, clôturées, distribution */
.session-state { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.session-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.session-state.active { color: var(--ok); }
.session-state.active::before { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.session-state.paused { color: var(--warn); }
.session-state.paused::before { background: var(--warn); }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; margin: 0 0 8px; cursor: pointer; font-weight: 400; }
.choice input { margin-top: 3px; width: auto; }
.choice small { display: block; color: var(--muted); margin-top: 2px; }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.field-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.field-row:last-child { border-bottom: none; }
.field-row small { display: block; }
.rdv-when { font-weight: 600; color: var(--brand-ink); display: inline-flex; align-items: center; gap: 4px; }
.rdv-when.late, .bad-text { color: var(--bad); }
.rdv-when .icon { width: 15px; height: 15px; }

/* pay */
.month-nav { margin-bottom: 14px; }
.month-nav strong { min-width: 150px; text-align: center; }
.table.statement tfoot td { border-top: 2px solid var(--border-strong); }
.table.statement tr.neg td { color: var(--bad); }
.pay-row { padding: 6px 0; border-bottom: 1px dashed var(--border); }
.pay-row select, .pay-row input:not(.goal-input) { width: auto; min-width: 150px; }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: 4px 0; }
.statement-items summary { cursor: pointer; font-weight: 600; margin: 8px 0; }
label.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
@media print {
  #nav, .sidebar, .topbar, .page-header .actions, .month-nav button, .toasts, #nav-toggle { display: none !important; }
  body, .page, .card { background: #fff !important; box-shadow: none !important; }
  .main, main { margin: 0 !important; padding: 0 !important; }
  .statement-items { display: block; }
}

/* profile, users, teams */
.avatar { overflow: hidden; }
.avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.avatar-big { width: 96px; height: 96px; border-radius: 50%; border: 2px dashed var(--border-strong); background: var(--brand-soft); color: var(--brand-ink); font-size: 30px; font-weight: 700; padding: 0; overflow: hidden; cursor: pointer; flex: none; display: inline-flex; align-items: center; justify-content: center; }
.avatar-big-img { width: 100%; height: 100%; object-fit: cover; }
.profile-head { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.profile-head h2 { margin: 0 0 6px; }
tr.row-disabled td { opacity: .6; }
tr.edit-row td { background: var(--bg); }
.table td select { min-width: 130px; width: auto; }
.tabs.sub { margin-top: -10px; }
.tabs.sub .tab { font-size: 13px; padding: 6px 12px; }
pre.code { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; font-size: 12px; }

/* ---------------------------------------------------------------- shared bits (detection, confirmation) */
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }
.row.end { justify-content: flex-end; }
.stack.tight { gap: 8px; }
.grow { flex: 1 1 auto; min-width: 0; }
.segbar { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border-strong); border-radius: 999px; padding: 2px; background: var(--surface); }
.segbar > a { border-radius: 999px; padding: 4px 12px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.segbar > a.active { background: var(--text); color: var(--surface); }
.segbar > a.active .muted { color: inherit; opacity: .7; }
.status-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; border: 1px solid var(--border); }
.status-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-chip.on { color: var(--ok); background: var(--ok-soft); }
.status-chip.off { color: var(--muted); background: var(--surface-3); }
.count-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; text-align: center; margin-inline-start: 4px; }
.kpi.kpi-warn { background: var(--warn-soft); }
.kpi .value small { font-size: 14px; font-weight: 600; color: var(--text-2); letter-spacing: 0; }
.btn.danger-solid, button.danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger-solid:hover, button.danger-solid:hover { filter: brightness(.93); }
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; inset-inline-end: 0; top: calc(100% + 4px); z-index: 20; display: grid; gap: 2px; min-width: 230px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(0, 0, 0, .14); }
.menu-list .btn { justify-content: flex-start; }

/* ---------------------------------------------------------------- Centre de détection */
.fr-grid { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 16px; align-items: start; margin-top: 16px; }
.fr-list { padding: 8px; display: grid; gap: 4px; max-height: calc(100vh - 260px); overflow: auto; position: sticky; top: 12px; }
.fr-list > .segbar { margin: 2px 2px 8px; justify-self: start; }
.fr-item { display: grid; gap: 4px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text); border-inline-start: 3px solid transparent; }
.fr-item:hover { background: var(--surface-2); }
.fr-item.active { background: var(--surface-2); border-inline-start-color: var(--text); }
.fr-item-foot { margin-top: 2px; }
.fr-detail { padding: 18px 20px 0; min-width: 0; }
.fr-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.fr-head h2 { font-size: 18px; }
.fr-detail .warn-box { margin-bottom: 6px; gap: 10px; }
.fr-detail .warn-box .icon { width: 15px; height: 15px; vertical-align: -2px; }
.evs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.ev { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 12.5px; color: var(--text-2); background: var(--surface); }
.ev .icon { width: 14px; height: 14px; }
.ev.ok .icon { color: var(--ok); }
.ev.bad { color: var(--bad); background: var(--bad-soft); }
.ev.dashed { border-style: dashed; color: var(--muted); }
.tl { margin-top: 8px; }
.tl-line { position: relative; height: 54px; margin: 6px 14px 0; border-bottom: 2px solid var(--border); }
.tl-dot { position: absolute; bottom: -12px; transform: translateX(-50%); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 10.5px; font-weight: 700; background: var(--surface); border: 2px solid var(--muted); color: var(--text-2); }
.tl-dot.held { border-color: var(--warn); color: var(--warn); }
.tl-dot.fake { border-color: var(--bad); color: var(--bad); }
.tl-dot.sm { position: static; display: inline-block; width: 11px; height: 11px; transform: none; vertical-align: -1px; }
.tl-gap { position: absolute; top: 6px; transform: translateX(-50%); font: 11px ui-monospace, Consolas, monospace; color: var(--muted); white-space: nowrap; }
.tl-ends { margin: 16px 0 4px; }
.tl-legend { gap: 14px; font-size: 12px; color: var(--text-2); }
.fr-table td { vertical-align: top; }
.fr-table tr.row-held td { background: var(--warn-soft); }
.rep { background: var(--bad-soft); color: var(--bad); padding: 0 4px; border-radius: 4px; }
.ip-letter { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--warn); color: var(--warn); font-size: 10px; font-weight: 700; }
.fr-bar { position: sticky; bottom: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 12px -20px 0; padding: 12px 20px; background: var(--surface); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); }
.rules-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; margin: 14px 0; }
.inline-field { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.inline-field .num-input { width: 84px; }
@media (max-width: 980px) { .fr-grid { grid-template-columns: 1fr; } .fr-list { position: static; max-height: 320px; } }

/* ---------------------------------------------------------------- Gestion de la confirmation */
.perf-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.perf-toolbar .chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; }
.perf-toolbar .chip .icon { width: 14px; height: 14px; }
.perf-toolbar .chip.active { background: var(--text); border-color: var(--text); color: var(--surface); }
.perf-team .kpi { box-shadow: none; }
.perf-team .tint-1, .perf-team .tint-3 { background: var(--info-soft); }
.perf-team .tint-2 { background: var(--brand-soft); }
.perf-team .tint-4 { background: var(--ok-soft); }
.perf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; margin-top: 12px; }
.perf-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); display: grid; overflow: hidden; }
.perf-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text); }
.perf-head:hover { background: var(--surface-2); }
.perf-head > .icon { color: var(--muted); }
.perf-av { position: relative; flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--sidebar); color: #fff; font-weight: 700; font-size: 13px; }
.perf-av img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.perf-av::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--surface); background: var(--border-strong); }
.perf-av.online::after { background: var(--ok); }
.perf-av.paused::after { background: var(--warn); }
.perf-table .perf-av { width: 28px; height: 28px; font-size: 11px; }
.perf-rates { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px 16px 6px; }
.perf-rate { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; }
.perf-rate small { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; color: var(--muted); }
.perf-rate strong { font-size: 22px; letter-spacing: -.02em; }
.ring { width: 48px; height: 48px; flex: none; }
.ring-bg { fill: none; stroke: var(--surface-3); stroke-width: 5; }
.ring-fg { fill: none; stroke: var(--muted); stroke-width: 5; stroke-linecap: round; }
.ring.ring-conv .ring-fg { stroke: var(--info); }
.perf-toolbar select { width: auto; min-width: 0; }
.ring.ring-visit .ring-fg { stroke: var(--ok); }
.ring-text { font-size: 11px; font-weight: 700; fill: var(--text); }
.perf-line { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.perf-line > div { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; }
.perf-line .icon { grid-row: span 2; width: 26px; height: 26px; padding: 5px; border-radius: 8px; background: var(--info-soft); color: var(--info); }
.perf-line small { font-size: 11.5px; color: var(--muted); }
.perf-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 12px 16px 0; }
.perf-tiles.small { grid-template-columns: repeat(5, 1fr); padding-bottom: 12px; }
.perf-tile { display: grid; gap: 1px; padding: 9px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.perf-tile .icon { width: 16px; height: 16px; color: var(--muted); }
.perf-tile strong { font-size: 18px; letter-spacing: -.01em; }
.perf-tiles.small .perf-tile strong { font-size: 15px; }
.perf-tile small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.perf-tile.info { background: var(--info-soft); }
.perf-tile.info .icon, .perf-tile.info strong { color: var(--info); }
.perf-tile.ok { background: var(--ok-soft); }
.perf-tile.ok .icon, .perf-tile.ok strong { color: var(--ok); }
.perf-tile.brand { background: var(--brand-soft); }
.perf-tile.brand .icon, .perf-tile.brand strong { color: var(--brand-ink); }
.perf-tile.warn { background: var(--warn-soft); }
.perf-tile.warn strong { color: var(--warn); }
.perf-tile.bad { background: var(--bad-soft); }
.perf-tile.bad strong { color: var(--bad); }
.perf-foot { display: flex; justify-content: space-between; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12.5px; font-weight: 600; color: var(--text); }
.perf-foot:hover { background: var(--surface-2); }
@media (max-width: 560px) {
  .perf-grid { grid-template-columns: 1fr; }
  .perf-tiles { grid-template-columns: repeat(2, 1fr); }
  .perf-tiles.small { grid-template-columns: repeat(3, 1fr); }
  .perf-rates { grid-template-columns: 1fr; }
}

/* fields linked to statuses */
.fields-editor { display: grid; gap: 10px; padding: 6px 2px; }
.statuses-table tr:not(.edit-row) > td:first-child input { min-width: 170px; }
.statuses-table td select { min-width: 120px; }
.field-def { display: grid; grid-template-columns: minmax(170px, 1.4fr) 150px minmax(150px, 1.6fr) 130px 36px; gap: 8px; align-items: center; max-width: 900px; }
.field-def input:not([type=checkbox]), .field-def select { margin: 0; width: 100%; }
.field-def > label.switch { margin: 0; white-space: nowrap; }
@media (max-width: 760px) { .field-def { grid-template-columns: 1fr 1fr; } }
.linked-fields { margin-top: 4px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.linked-fields .section-title { margin-top: 0; }
.fields-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 14px; }
/* lead dispatch: shares and routing rules (Paramètres → Numéros → Leads & validateurs) */
.weight-row .num-input { width: 76px; margin-top: 0; }
.weight-row .num-input:disabled { opacity: .45; }
.card-inset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface-2); display: grid; gap: 8px; }
.rule-row input:not([type=checkbox]), .rule-row select { width: auto; margin-top: 0; }
/* supervision: leads by city */
.mini-bar { height: 4px; border-radius: 2px; background: var(--surface-3); margin-top: 4px; max-width: 160px; }
.mini-bar span { display: block; height: 100%; border-radius: 2px; background: var(--brand); }
.ok-text { color: var(--ok); font-weight: 600; }
.rule-users { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 2px 10px; max-height: 150px; overflow-y: auto; padding: 4px 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.rule-users label.check { font-size: 13px; }
/* Paramètres → Agent IA: simulation */
.sim-chat { display: grid; gap: 6px; max-height: 320px; overflow-y: auto; padding: 10px; border-radius: var(--radius-sm); background: var(--chat-bg); margin-bottom: 8px; }
.sim-chat:empty { display: none; }
.sim-chat .msg { max-width: 80%; padding: 6px 10px; border-radius: 8px; font-size: 13.5px; white-space: pre-wrap; }
.sim-chat .msg.in { background: var(--bubble-in); justify-self: start; }
.sim-chat .msg.out { background: var(--bubble-out); justify-self: end; }

/* Yaknit logo in the "Développé par" credits (white letters on the dark sidebar / login side, dark letters on light cards) */
.credit .yk { height: 13px; width: auto; vertical-align: -2px; margin-inline-start: 3px; }
.auth-side .credit .yk { height: 16px; vertical-align: -3px; }
.yk-on-dark { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .yk-on-light { display: none; } :root:not([data-theme="light"]) .yk-on-dark { display: inline; } }
:root[data-theme="dark"] .yk-on-light { display: none; }
:root[data-theme="dark"] .yk-on-dark { display: inline; }

/* ---------------------------------------------------------------- phones: compact pages (less scrolling before the work)
   figures 2 per row, result buttons in 2 columns, tighter cards and headers */
@media (max-width: 600px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 10px 12px; }
  .kpi .label { font-size: 11.5px; gap: 5px; }
  .kpi .label .icon { width: 14px; height: 14px; }
  .kpi .value { font-size: 21px; margin-top: 3px; }
  .kpi .sub { font-size: 11px; line-height: 1.3; }
  .outcomes { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .outcomes .outcome { padding: 6px; font-size: 12.5px; min-height: 40px; }
  .card-body { padding: 14px; }
  .facts-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0; padding: 10px 0; }
  .page-header { margin-bottom: 12px; gap: 10px; }
  .page-header h1 { font-size: 21px; }
  .page-header p { font-size: 12.5px; }
  .stack { gap: 12px; }
  .agent-bar { gap: 6px 12px; padding: 10px 12px; font-size: 12.5px; }
}
/* Paramètres → Sauvegardes */
code.path { word-break: break-all; }
details.guide { margin: 4px 0 6px; }
details.guide summary { cursor: pointer; font-weight: 600; color: var(--brand-ink); }
details.guide ol { margin: 8px 0 0; padding-inline-start: 20px; display: grid; gap: 6px; font-size: 13px; color: var(--text-2); }
