/* ============ tokens ============ */
:root {
  --brand: #d9651f;
  --brand-ink: #ffffff;
  --brand-soft: color-mix(in srgb, var(--brand) 12%, var(--surface));
  --brand-line: color-mix(in srgb, var(--brand) 35%, var(--border));

  --bg: #f5f4f1;
  --surface: #ffffff;
  --surface-2: #f8f7f5;
  --surface-3: #efede9;
  --border: #e6e2dc;
  --text: #1f1b17;
  --text-2: #4d463f;
  --muted: #857c72;
  --shadow-sm: 0 1px 2px rgba(31, 27, 23, .05);
  --shadow: 0 1px 3px rgba(31, 27, 23, .06), 0 4px 14px rgba(31, 27, 23, .05);
  --shadow-lg: 0 10px 40px rgba(31, 27, 23, .18);

  --good: #1f8a4c;   --good-soft: #e3f4ea;
  --warn: #a8670b;   --warn-soft: #fcf0dc;
  --bad: #c2392f;    --bad-soft: #fbe6e3;
  --info: #2a62b8;   --info-soft: #e5eefb;
  --violet: #6b4bc4; --violet-soft: #eee9fb;
  --gray: #5e6672;   --gray-soft: #eceef1;

  --sidebar: #1d1915;
  --sidebar-2: #2a241f;
  --sidebar-text: #d9d2ca;
  --sidebar-muted: #8f857a;

  --radius: 14px;
  --radius-sm: 10px;
  --font: 'IBM Plex Sans Arabic', 'Cairo', system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12100e;
    --surface: #1b1815;
    --surface-2: #221e1a;
    --surface-3: #2b2621;
    --border: #332d27;
    --text: #f1ece6;
    --text-2: #cfc6bc;
    --muted: #978c80;
    --shadow-sm: none;
    --shadow: 0 1px 0 rgba(255,255,255,.02);
    --shadow-lg: 0 10px 40px rgba(0,0,0,.5);
    --good: #4cc27c;   --good-soft: #17301f;
    --warn: #e2a54a;   --warn-soft: #342812;
    --bad: #f07a6f;    --bad-soft: #3a1c19;
    --info: #74a6f0;   --info-soft: #172840;
    --violet: #a68cf0; --violet-soft: #271f40;
    --gray: #a3abb6;   --gray-soft: #262a30;
    --sidebar: #0d0b09;
    --sidebar-2: #1a1612;
  }
}

/* ============ base ============ */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14.5px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; font-weight: 700; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
a { color: var(--brand); text-decoration: none; }
button { font: inherit; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.tiny { font-size: .76rem; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.error { color: var(--bad); min-height: 1.2em; font-size: .9rem; }
code { background: var(--surface-3); padding: 0 .35em; border-radius: 6px; font-size: .88em; direction: ltr; unicode-bidi: isolate; }

/* ============ shell ============ */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .7rem; padding: 1.2rem 1.1rem 1rem; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 12px; background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 1.1rem; overflow: hidden; flex-shrink: 0;
}
.brand-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand-name { color: #fff; font-weight: 700; font-size: 1.02rem; line-height: 1.25; }
.brand-tag { color: var(--sidebar-muted); font-size: .76rem; }
.nav { padding: .25rem .65rem; display: flex; flex-direction: column; gap: 1px; }
.nav-label { color: var(--sidebar-muted); font-size: .72rem; font-weight: 600; padding: .9rem .6rem .35rem; letter-spacing: .02em; }
.nav button {
  all: unset; cursor: pointer; display: flex; align-items: center; gap: .65rem; padding: .55rem .7rem;
  border-radius: 9px; color: var(--sidebar-text); font-weight: 500; font-size: .92rem;
}
.nav button svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; }
.nav button:hover { background: var(--sidebar-2); }
.nav button.active { background: color-mix(in srgb, var(--brand) 22%, transparent); color: #fff; }
.nav button.active svg { opacity: 1; color: var(--brand); }
.nav button:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.nav .count { margin-inline-start: auto; background: var(--brand); color: var(--brand-ink); font-size: .7rem; font-weight: 700; border-radius: 99px; padding: 0 .45rem; min-width: 1.4rem; text-align: center; }
.sidebar-foot { margin-top: auto; padding: .8rem; border-top: 1px solid var(--sidebar-2); }
.me { display: flex; align-items: center; gap: .6rem; padding: .4rem; border-radius: 10px; }
.me .who { flex: 1; min-width: 0; }
.me .who b { color: #fff; display: block; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .who span { color: var(--sidebar-muted); font-size: .76rem; }
.icon-btn { all: unset; cursor: pointer; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; color: var(--sidebar-text); }
.icon-btn:hover { background: var(--sidebar-2); }
.icon-btn svg { width: 17px; height: 17px; }
.conn-mini { display: flex; align-items: center; gap: .45rem; color: var(--sidebar-muted); font-size: .78rem; padding: .3rem .5rem .55rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex-shrink: 0; }
.dot.ok { background: #3ccf73; }
.dot.bad { background: var(--bad); }

.main { flex: 1; min-width: 0; padding: 1.5rem 1.75rem 3rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.page-head p { margin: .15rem 0 0; color: var(--muted); }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ============ cards ============ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow-sm); }
.card + .card, .grid + .card, .card + .grid, .grid + .grid { margin-top: 1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .9rem; flex-wrap: wrap; }
.card-head p { margin: .1rem 0 0; color: var(--muted); font-size: .85rem; }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .75rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; cursor: pointer; text-align: start; transition: border-color .15s; }
.kpi:hover { border-color: var(--brand-line); }
.kpi .v { font-size: 1.65rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: .82rem; display: flex; align-items: center; gap: .35rem; }
.kpi .s { color: var(--muted); font-size: .76rem; }

/* ============ forms ============ */
label.lbl { display: block; font-weight: 600; font-size: .86rem; margin-bottom: .3rem; color: var(--text-2); }
.field { margin-bottom: .85rem; }
.hint { color: var(--muted); font-size: .8rem; margin-top: .3rem; }
.input, select.input, textarea.input {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .5rem .7rem; outline: none; min-height: 38px;
}
textarea.input { min-height: 100px; resize: vertical; line-height: 1.6; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input.sm { min-height: 32px; padding: .3rem .55rem; font-size: .88rem; }
.row { display: flex; gap: .55rem; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 140px; }
.check { display: flex; align-items: center; gap: .55rem; cursor: pointer; font-weight: 500; margin: .2rem 0 .6rem; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); flex-shrink: 0; }

.switch { position: relative; display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; font-weight: 600; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 42px; height: 24px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--border); position: relative; transition: .2s; flex-shrink: 0; }
.switch .track::after { content: ''; position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + .track { background: var(--brand); border-color: var(--brand); }
.switch input:checked + .track::after { right: 20px; }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ============ buttons ============ */
.btn {
  font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; border-radius: var(--radius-sm); padding: .48rem .95rem;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; white-space: nowrap; min-height: 38px; text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { padding: .25rem .6rem; font-size: .82rem; min-height: 30px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.wa { background: #1fa855; border-color: #1fa855; color: #fff; }

/* ============ pills / badges ============ */
.pill { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 600; padding: .12rem .6rem; border-radius: 99px; white-space: nowrap; background: var(--gray-soft); color: var(--gray); }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.plain::before { display: none; }
.pill svg { width: 13px; height: 13px; }
.st-new { background: var(--gray-soft); color: var(--gray); }
.st-no_answer { background: var(--warn-soft); color: var(--warn); }
.st-callback { background: var(--violet-soft); color: var(--violet); }
.st-contacted { background: var(--info-soft); color: var(--info); }
.st-qualified { background: var(--good-soft); color: var(--good); }
.st-unqualified { background: var(--bad-soft); color: var(--bad); }
.st-won { background: var(--brand-soft); color: var(--brand); }
.ok { background: var(--good-soft); color: var(--good); }
.bad { background: var(--bad-soft); color: var(--bad); }
.warn { background: var(--warn-soft); color: var(--warn); }
.info { background: var(--info-soft); color: var(--info); }

.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; font-size: .74rem; font-weight: 700; background: var(--brand-soft); color: var(--brand); flex-shrink: 0; }
.avatar.lg { width: 36px; height: 36px; font-size: .85rem; }
.avatar.none { background: var(--surface-3); color: var(--muted); }

/* ============ filters ============ */
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .75rem; }
.toolbar .search { flex: 1; min-width: 200px; position: relative; }
.toolbar .search svg { position: absolute; top: 50%; right: .7rem; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.toolbar .search .input { padding-right: 2.1rem; }
.toolbar select.input { width: auto; min-width: 130px; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .85rem; }
.chip {
  font: inherit; font-size: .84rem; font-weight: 600; cursor: pointer; padding: .3rem .75rem; border-radius: 99px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); display: inline-flex; gap: .4rem; align-items: center;
}
.chip .n { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.chip.active { background: var(--text); color: var(--surface); border-color: var(--text); }
.chip.active .n { color: inherit; opacity: .7; }
.chip svg { width: 14px; height: 14px; }
.chip.add { border-style: dashed; color: var(--brand); border-color: var(--brand-line); background: var(--brand-soft); }

/* ============ tables ============ */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .6rem .75rem; text-align: start; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--surface-2); font-weight: 600; color: var(--muted); font-size: .8rem; white-space: nowrap; position: sticky; top: 0; z-index: 1; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--surface-2); }
tbody tr.selected td { background: var(--brand-soft); }
td .title { font-weight: 600; }
td .sub { color: var(--muted); font-size: .8rem; }
td.cell-clip { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td input[type=checkbox], th input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--brand); }
.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
.status-select {
  font: inherit; font-size: .8rem; font-weight: 600; border: 0; border-radius: 99px; padding: .2rem .55rem; cursor: pointer;
  appearance: none; -webkit-appearance: none; text-align: center;
}
.status-select:focus-visible { outline: 2px solid var(--brand); }
.assign-select { font: inherit; font-size: .84rem; border: 1px solid transparent; background: transparent; color: var(--text); border-radius: 8px; padding: .15rem .3rem; cursor: pointer; max-width: 140px; }
.assign-select:hover { border-color: var(--border); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .7rem .2rem 0; color: var(--muted); font-size: .85rem; flex-wrap: wrap; }
.bulkbar { position: sticky; bottom: 1rem; margin-top: .75rem; background: var(--text); color: var(--surface); border-radius: var(--radius); padding: .6rem .8rem; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; box-shadow: var(--shadow-lg); z-index: 5; }
.bulkbar select { background: var(--surface); color: var(--text); }
.wa-link { display: inline-flex; align-items: center; gap: .3rem; color: var(--text); font-variant-numeric: tabular-nums; }
.wa-link svg { width: 15px; height: 15px; color: #1fa855; }
.wa-link:hover { color: var(--brand); }

/* ============ charts ============ */
.bars { display: flex; flex-direction: column; gap: .55rem; }
.bar-row { display: grid; grid-template-columns: 96px 1fr 44px; gap: .6rem; align-items: center; cursor: pointer; border-radius: 8px; padding: .15rem .25rem; }
.bar-row:hover { background: var(--surface-2); }
.bar-row .track { height: 12px; background: var(--surface-3); border-radius: 0 4px 4px 0; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--brand); border-radius: 4px 0 0 4px; min-width: 2px; }
.bar-row .v { text-align: end; font-weight: 600; font-variant-numeric: tabular-nums; }
.cols { position: relative; height: 170px; display: flex; align-items: flex-end; gap: 2px; padding-top: 8px; border-bottom: 1px solid var(--border); }
.cols .c { flex: 1; height: 100%; display: flex; align-items: flex-end; position: relative; cursor: default; }
.cols .c i { display: block; width: 100%; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; opacity: .9; }
.cols .c:hover i { opacity: 1; filter: brightness(1.1); }
.cols .c.zero i { background: var(--surface-3); }
.cols-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: .74rem; padding-top: .3rem; }
.tip { position: fixed; z-index: 100; pointer-events: none; background: var(--text); color: var(--surface); font-size: .8rem; padding: .35rem .6rem; border-radius: 8px; box-shadow: var(--shadow-lg); white-space: nowrap; }
.legend-note { color: var(--muted); font-size: .8rem; }

/* ============ kanban ============ */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: .75rem; overflow-x: auto; padding-bottom: .75rem; align-items: start; }
.col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 210px); }
.col-head { display: flex; align-items: center; gap: .5rem; padding: .7rem .8rem; border-bottom: 1px solid var(--border); }
.col-head .n { margin-inline-start: auto; color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.col-body { padding: .5rem; display: flex; flex-direction: column; gap: .45rem; overflow-y: auto; min-height: 80px; }
.col.drop { border-color: var(--brand); background: var(--brand-soft); }
.lead-card { background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: .6rem .7rem; cursor: grab; box-shadow: var(--shadow-sm); }
.lead-card:hover { border-color: var(--brand-line); }
.lead-card.dragging { opacity: .45; }
.lead-card .t { font-weight: 600; font-size: .9rem; }
.lead-card .c { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-card .m { display: flex; align-items: center; gap: .4rem; margin-top: .45rem; color: var(--muted); font-size: .76rem; }
.lead-card .m .avatar { width: 22px; height: 22px; font-size: .65rem; margin-inline-start: auto; }
.more { all: unset; cursor: pointer; text-align: center; color: var(--brand); font-size: .84rem; padding: .3rem; border-radius: 8px; }
.more:hover { background: var(--surface); }

/* ============ drawer ============ */
.overlay { position: fixed; inset: 0; background: rgba(15, 12, 9, .42); z-index: 40; animation: fade .15s; }
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; width: min(560px, 100vw); background: var(--surface); z-index: 41;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .2s ease;
}
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(-30px); opacity: 0; } }
.drawer-head { padding: 1.1rem 1.25rem .9rem; border-bottom: 1px solid var(--border); }
.drawer-head .top { display: flex; align-items: flex-start; gap: .75rem; }
.drawer-head h2 { font-size: 1.2rem; }
.drawer-body { flex: 1; overflow-y: auto; padding: 1.1rem 1.25rem 2rem; }
.drawer section + section { margin-top: 1.4rem; }
.drawer h3 { font-size: .82rem; color: var(--muted); font-weight: 600; margin-bottom: .55rem; }
.status-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .4rem; }
.status-btn { font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; padding: .45rem .3rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); }
.status-btn:hover { border-color: var(--brand-line); }
.status-btn.on { border-color: currentColor; box-shadow: inset 0 0 0 1px currentColor; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: .45rem .75rem; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.note { background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: .6rem .75rem; }
.note + .note { margin-top: .5rem; }
.note .meta { display: flex; align-items: center; gap: .45rem; color: var(--muted); font-size: .78rem; margin-bottom: .2rem; }
.note .meta button { margin-inline-start: auto; }
.note .txt { white-space: pre-wrap; word-break: break-word; }
.timeline { border-inline-start: 2px solid var(--border); padding-inline-start: .9rem; display: flex; flex-direction: column; gap: .5rem; font-size: .84rem; }
.timeline .ev { position: relative; color: var(--text-2); }
.timeline .ev::before { content: ''; position: absolute; right: calc(-.9rem - 6px); top: .5em; width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.timeline .ev time { color: var(--muted); font-size: .76rem; margin-inline-start: .35rem; }

/* ============ smart score ============ */
.prio { display: inline-flex; align-items: center; gap: .25rem; font-size: .8rem; padding: .1rem .5rem; border-radius: 99px; white-space: nowrap; background: var(--gray-soft); color: var(--gray); cursor: help; }
.prio b { font-weight: 700; }
.prio-hot { background: var(--bad-soft); color: var(--bad); }
.prio-good { background: var(--warn-soft); color: var(--warn); }
.prio-normal { background: var(--info-soft); color: var(--info); }
.prio-low { background: var(--gray-soft); color: var(--gray); }
.prio-closed { background: var(--surface-3); color: var(--muted); }
.prio-out { background: var(--surface-3); color: var(--muted); border: 1px dashed var(--border); }
.ai-tag { display: inline-block; font-size: .64rem; font-weight: 700; letter-spacing: .03em; padding: 0 .35rem; border-radius: 5px; background: var(--violet-soft); color: var(--violet); vertical-align: middle; direction: ltr; }
.ai-box { margin-top: .65rem; padding: .6rem .7rem; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); font-size: .88rem; }
.score-card { border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem .95rem; background: var(--surface-2); color: var(--text); }
.score-card.prio-hot { border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); background: color-mix(in srgb, var(--bad-soft) 55%, var(--surface)); }
.score-card.prio-good { border-color: color-mix(in srgb, var(--warn) 35%, var(--border)); background: color-mix(in srgb, var(--warn-soft) 55%, var(--surface)); }
.score-big { display: flex; align-items: baseline; gap: .2rem; flex-shrink: 0; }
.score-big span { font-size: 1.3rem; }
.score-big b { font-size: 1.9rem; line-height: 1; }
.score-big small { color: var(--muted); }
.meter { height: 6px; border-radius: 99px; background: var(--surface-3); margin: .7rem 0 .55rem; overflow: hidden; }
.meter i { display: block; height: 100%; background: currentColor; border-radius: 99px; }
.score-card.prio-hot .meter i { background: var(--bad); }
.score-card.prio-good .meter i { background: var(--warn); }
.score-card.prio-normal .meter i { background: var(--info); }
.score-card.prio-low .meter i, .score-card.prio-closed .meter i { background: var(--gray); }
.reasons { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .3rem .45rem; font-size: .82rem; }
.reasons li { display: inline-flex; align-items: center; gap: .3rem; background: var(--surface); border: 1px solid var(--border); border-radius: 99px; padding: .1rem .55rem .1rem .3rem; }
.reasons .pts { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 2.1em; text-align: center; color: var(--muted); }
.reasons .pts.plus { color: var(--good); }
.reasons .pts.minus { color: var(--bad); }

/* ============ modal ============ */
.modal { position: fixed; inset: 0; background: rgba(15, 12, 9, .45); display: grid; place-items: center; padding: 1rem; z-index: 60; animation: fade .15s; }
.modal .card { width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal h2 { margin-bottom: 1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

/* ============ misc ============ */
.list { display: flex; flex-direction: column; gap: .4rem; }
.list-item { display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { border-color: var(--brand-line); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item.selected { border-color: var(--brand); background: var(--brand-soft); }
.scroll-list { max-height: 420px; overflow-y: auto; }
.cond { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: .45rem; align-items: center; margin-bottom: .45rem; }
.qr-box { width: 230px; height: 230px; border-radius: 14px; background: #fff; border: 1px solid var(--border); display: grid; place-items: center; overflow: hidden; flex-shrink: 0; }
.qr-box img { width: 100%; height: 100%; }
.spinner { width: 34px; height: 34px; border: 3px solid #e9e4dd; border-top-color: var(--brand); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bubble-bg { background: #efe7dd; border-radius: 12px; padding: 1rem; }
.bubble { background: #dcf8c6; color: #111b21; border-radius: 10px 0 10px 10px; padding: .6rem .8rem; white-space: pre-wrap; word-break: break-word; max-width: 420px; box-shadow: 0 1px 1px rgba(0,0,0,.08); font-size: .9rem; }
@media (prefers-color-scheme: dark) { .bubble-bg { background: #0b141a; } .bubble { background: #005c4b; color: #e9edef; } }
.log { display: flex; gap: .7rem; padding: .5rem .2rem; border-bottom: 1px solid var(--border); font-size: .88rem; align-items: baseline; }
.log:last-child { border-bottom: 0; }
.log time { color: var(--muted); font-size: .76rem; white-space: nowrap; direction: ltr; font-variant-numeric: tabular-nums; }
.log .msg { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-word; }
.swatch { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); padding: 0; cursor: pointer; background: none; }
.preview-brand { display: flex; align-items: center; gap: .75rem; padding: 1rem; border-radius: var(--radius); background: var(--sidebar); }
.callout { border-radius: var(--radius-sm); padding: .7rem .9rem; font-size: .88rem; }
.callout.warn { background: var(--warn-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.callout.info { background: var(--info-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--info) 30%, transparent); }

#toasts { position: fixed; bottom: 1rem; left: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 100; }
.toast { background: var(--text); color: var(--surface); padding: .6rem 1rem; border-radius: 11px; box-shadow: var(--shadow-lg); max-width: 360px; animation: up .2s ease; font-size: .9rem; }
.toast.bad { background: var(--bad); color: #fff; }
@keyframes up { from { transform: translateY(8px); opacity: 0; } }

/* ============ login ============ */
.login-body { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-side { background: var(--sidebar); color: #fff; display: flex; flex-direction: column; justify-content: center; padding: 3rem; position: relative; overflow: hidden; }
.login-side::after { content: ''; position: absolute; width: 520px; height: 520px; border-radius: 50%; background: var(--brand); opacity: .14; bottom: -220px; left: -160px; }
.login-side h1 { font-size: 2rem; margin: 1.2rem 0 .5rem; }
.login-side p { color: var(--sidebar-text); max-width: 360px; }
.login-main { display: grid; place-items: center; padding: 2rem 16px; }
.login-card { width: 100%; max-width: 360px; }
.login-card h2 { font-size: 1.35rem; margin-bottom: .3rem; }

/* ============ responsive ============ */
@media (max-width: 1200px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1150px) { .g-main { grid-template-columns: 1fr; } }
@media (max-width: 980px) {
  .g2, .g3, .g-main { grid-template-columns: 1fr; }
  .login-body { grid-template-columns: 1fr; }
  .login-side { display: none; }
}
@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar { position: static; width: 100%; height: auto; }
  .brand { padding: .8rem 16px .4rem; }
  .nav { flex-direction: row; overflow-x: auto; padding: 0 12px .5rem; }
  .nav-label { display: none; }
  .nav button { white-space: nowrap; padding: .45rem .65rem; }
  .sidebar-foot { display: flex; align-items: center; justify-content: space-between; padding: .4rem 16px; }
  .conn-mini { padding: 0; }
  .main { padding: 1rem 16px 3rem; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cond { grid-template-columns: 1fr 1fr; }
  .bar-row { grid-template-columns: 90px 1fr 40px; }
}
