:root {
  color-scheme: light;
  --bg: #f3f5fa;
  --panel: #ffffff;
  --panel-2: #f6f8fc;
  --hover: #eef2fa;
  --line: #e2e7f0;
  --text: #0f1729;
  --text-2: #4b5670;
  --muted: #7b869c;
  --accent: #2a78d6;
  --accent-soft: rgba(42, 120, 214, .12);
  --accent-ink: #ffffff;
  --grad: linear-gradient(135deg, #2a78d6 0%, #6250d6 100%);
  --ok: #138a4b;
  --ok-soft: rgba(19, 138, 75, .12);
  --warn: #b26b00;
  --warn-soft: rgba(237, 161, 0, .16);
  --danger: #d23a3a;
  --danger-soft: rgba(227, 73, 72, .12);
  --bubble-in: #ffffff;
  --bubble-out: #2a78d6;
  --bubble-out-ink: #ffffff;
  --chat-bg: #eaf0f8;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --shadow: 0 1px 2px rgba(15, 23, 41, .05), 0 6px 24px rgba(15, 23, 41, .06);
  --radius: 14px;
  --font: "Noto Sans Georgian", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0f1a;
    --panel: #121827;
    --panel-2: #172033;
    --hover: #1c2740;
    --line: #243049;
    --text: #e8edf7;
    --text-2: #b4bfd4;
    --muted: #7f8ba3;
    --accent: #3987e5;
    --accent-soft: rgba(57, 135, 229, .18);
    --ok: #3ccf7f;
    --ok-soft: rgba(60, 207, 127, .14);
    --warn: #f0b23a;
    --warn-soft: rgba(240, 178, 58, .14);
    --danger: #ff6b6b;
    --danger-soft: rgba(255, 107, 107, .14);
    --bubble-in: #1c2740;
    --bubble-out: #2f6fd0;
    --chat-bg: #0e1422;
    --series-1: #3987e5;
    --series-2: #d95926;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 30px rgba(0, 0, 0, .25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f1a;
  --panel: #121827;
  --panel-2: #172033;
  --hover: #1c2740;
  --line: #243049;
  --text: #e8edf7;
  --text-2: #b4bfd4;
  --muted: #7f8ba3;
  --accent: #3987e5;
  --accent-soft: rgba(57, 135, 229, .18);
  --ok: #3ccf7f;
  --ok-soft: rgba(60, 207, 127, .14);
  --warn: #f0b23a;
  --warn-soft: rgba(240, 178, 58, .14);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, .14);
  --bubble-in: #1c2740;
  --bubble-out: #2f6fd0;
  --chat-bg: #0e1422;
  --series-1: #3987e5;
  --series-2: #d95926;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 30px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }

/* ── layout ─────────────────────────────── */
.app { display: grid; grid-template-columns: 248px 1fr; height: 100vh; }
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 18px 14px;
  gap: 4px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 20px; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 12px; background: var(--grad);
  display: grid; place-items: center; color: #fff; flex: none;
  box-shadow: 0 6px 18px rgba(42, 120, 214, .35);
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .2px; }
.brand-sub { color: var(--muted); font-size: 12px; }
/* delete user dialog */
.del-modal { width: min(480px, calc(100% - 32px)); }
.del-opt { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; cursor: pointer; }
.del-opt:hover { background: var(--hover); }
.del-opt input { margin-top: 4px; accent-color: var(--danger); }
.del-opt:has(input:checked) { border-color: var(--danger); background: var(--danger-soft); }
.del-warn { font-size: 12.5px; color: var(--danger); background: var(--danger-soft); border-radius: 10px; padding: 9px 12px; }
.btn-danger-solid { background: var(--danger); color: #fff; border: 0; }
.btn-danger-solid:hover { background: var(--danger); filter: brightness(1.08); }
.btn-del { color: var(--muted); }
.btn-del:hover { color: var(--danger); background: var(--danger-soft); }

/* admin notes */
.side-h { margin: 18px 0 8px; font-size: 13.5px; }
.notes .textarea { min-height: 76px; font-size: 13.5px; }
.notes.compact .textarea { min-height: 64px; }
.note-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.note { padding: 10px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.note.editing { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.note-h { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.note-text { white-space: pre-wrap; word-wrap: break-word; font-size: 13.5px; line-height: 1.5; }
.stars { color: #f0b23a; letter-spacing: 1px; font-size: 13px; }
.stars i { color: var(--line); font-style: normal; }
.star-pick { display: flex; gap: 2px; }
.star-pick button { border: 0; background: none; cursor: pointer; font-size: 20px; line-height: 1; color: var(--line); padding: 2px; transition: transform .1s, color .1s; }
.star-pick button.on { color: #f0b23a; }
.star-pick button:hover { transform: scale(1.15); }
.note-badge { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; vertical-align: 1px; cursor: help; }
.note-badge b { font-weight: 700; }
.note-badge em { font-style: normal; color: #c98500; }

/* payments ($) */
.av-pay {
  position: absolute; right: -4px; top: -4px; width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff; border: 2px solid var(--panel);
  background: var(--muted);
}
.avatar.lg .av-pay { width: 24px; height: 24px; font-size: 14px; }
.av-pay.pay-pending, .pay-mini.pay-pending { background: #e2a400; animation: pay-pulse 1.6s ease-in-out infinite; }
.av-pay.pay-confirmed, .pay-mini.pay-confirmed { background: #1a9e5a; }
.av-pay.pay-rejected, .pay-mini.pay-rejected { background: var(--danger); }
.av-pay.pay-requested, .pay-mini.pay-requested { background: #8a96ad; }
@keyframes pay-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(226, 164, 0, .55); } 50% { box-shadow: 0 0 0 5px rgba(226, 164, 0, 0); } }
.pay-mini { width: 16px; height: 16px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 10px; font-weight: 800; color: #fff; flex: none; }
.tag.pay b { font-weight: 800; }
.tag.pay.pay-pending { background: rgba(226, 164, 0, .16); color: #a87700; border-color: transparent; }
.tag.pay.pay-confirmed { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag.pay.pay-rejected { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tbl tr.row-pay.pay-pending { background: rgba(226, 164, 0, .09); box-shadow: inset 3px 0 0 #e2a400; }
.tbl tr.row-pay.pay-confirmed { background: rgba(26, 158, 90, .07); box-shadow: inset 3px 0 0 #1a9e5a; }
.tbl tr.row-pay.pay-rejected { background: rgba(227, 73, 72, .06); box-shadow: inset 3px 0 0 var(--danger); }
.tbl tr.row-pay:hover { filter: brightness(.98); }
.pay-panel { margin-top: 16px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); }
.pay-panel.pay-pending { border-color: rgba(226, 164, 0, .5); background: rgba(226, 164, 0, .08); }
.pay-panel.pay-confirmed { border-color: rgba(26, 158, 90, .45); background: rgba(26, 158, 90, .07); }
.pay-panel.pay-rejected { border-color: rgba(227, 73, 72, .4); background: rgba(227, 73, 72, .06); }
.pay-coin { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; background: linear-gradient(135deg, #26a17b, #1a7a5c); flex: none; }
.pay-panel.pay-pending .pay-coin { background: linear-gradient(135deg, #f0b23a, #d39100); }
.pay-panel.pay-rejected .pay-coin { background: linear-gradient(135deg, #ff6b6b, #d23a3a); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tag.pay.pay-pending { color: #f0b23a; } }
:root[data-theme="dark"] .tag.pay.pay-pending { color: #f0b23a; }

/* payment card preview */
.pay-box { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.pay-qr { width: 150px; border-radius: 14px; box-shadow: var(--shadow); display: block; }

/* date range picker */
.range-picker { position: relative; }
.range-btn { height: 42px; padding: 0 12px 0 12px; gap: 10px; }
.range-btn > svg:first-child { width: 18px; height: 18px; color: var(--accent); }
.range-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.range-text b { font-size: 13.5px; }
.range-text small { font-size: 11px; color: var(--muted); font-weight: 500; }
.range-btn.wide { border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); }
.range-btn .chev { width: 16px; height: 16px; color: var(--muted); transition: transform .15s; }
.range-picker.open .range-btn { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.range-picker.open .chev { transform: rotate(180deg); }
.rp-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; display: flex;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 50px rgba(15, 23, 41, .18);
  animation: rp-in .14s ease-out; overflow: hidden;
}
@keyframes rp-in { from { opacity: 0; transform: translateY(-4px); } }
.rp-presets { width: 190px; padding: 12px 8px; border-right: 1px solid var(--line); background: var(--panel-2); display: flex; flex-direction: column; gap: 2px; }
.rp-h { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .5px; padding: 4px 10px 8px; }
.rp-preset { text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 9px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.rp-preset:hover { background: var(--hover); color: var(--text); }
.rp-preset.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.rp-body { padding: 14px 16px 12px; }
.rp-months { display: flex; gap: 22px; }
.rp-month { width: 252px; }
.rp-mh { display: grid; grid-template-columns: 30px 1fr 30px; align-items: center; text-align: center; margin-bottom: 8px; font-size: 14px; }
.rp-nav { width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 18px; line-height: 1; color: var(--text-2); }
.rp-nav:hover:not(:disabled) { background: var(--hover); color: var(--accent); }
.rp-nav:disabled { opacity: .35; cursor: default; }
.rp-grid { display: grid; grid-template-columns: repeat(7, 36px); row-gap: 3px; }
.rp-wd { font-size: 11px; color: var(--muted); text-align: center; padding: 4px 0 6px; font-weight: 600; }
.rp-day {
  height: 34px; border: 0; background: none; cursor: pointer; font-size: 13px; color: var(--text); position: relative;
  font-variant-numeric: tabular-nums; border-radius: 0;
}
.rp-day:hover:not(:disabled) { background: var(--hover); border-radius: 9px; }
.rp-day.in { background: var(--accent-soft); }
.rp-day.start { border-top-left-radius: 9px; border-bottom-left-radius: 9px; }
.rp-day.end { border-top-right-radius: 9px; border-bottom-right-radius: 9px; }
.rp-day.start, .rp-day.end { background: var(--accent); color: #fff; font-weight: 700; }
.rp-day.today:not(.start):not(.end)::after { content: ""; position: absolute; left: 50%; bottom: 4px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent); }
.rp-day.off { color: var(--muted); opacity: .4; cursor: default; }
.rp-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.rp-sel { font-size: 13px; }
.rp-warn { display: flex; align-items: center; gap: 5px; margin-top: 4px; font-size: 11.5px; color: var(--warn); }
.load-older { align-self: center; border: 1px solid var(--line); background: var(--panel); color: var(--text-2); border-radius: 999px; padding: 6px 14px; font-size: 12.5px; cursor: pointer; margin-bottom: 6px; }
.load-older:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
@media (max-width: 900px) { .rp-pop { flex-direction: column; } .rp-presets { width: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); } .rp-months > :last-child { display: none; } }

/* balance page */
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.amt-in { color: var(--ok); }
.amt-out { color: var(--danger); }
.wallet-card .tokens td, .wallet-card .tokens th { padding: 7px 8px; }
.wallet-card .tokens tbody tr { cursor: default; }
.wallet-card tr.extra { display: none; }
.wallet-card.show-all tr.extra { display: table-row; }
.icon-btn { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 4px; font-size: 13px; }
.icon-btn:hover { color: var(--accent); }
.spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; display: inline-block; animation: rot .8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

/* bot switcher */
.bot-switch { position: relative; margin: 0 0 14px; }
.bot-current {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px; border-radius: 12px; text-align: left;
  border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; transition: background .15s, border-color .15s;
}
.bot-current:hover:not(:disabled) { background: var(--hover); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.bot-current:disabled { cursor: default; }
.bot-switch.open .bot-current { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.bot-logo { border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 800; flex: none; font-size: 16px; box-shadow: 0 4px 12px rgba(42, 120, 214, .25); }
.bot-meta { min-width: 0; flex: 1; }
.bot-meta .brand-name, .bot-item-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot-current .chev { width: 18px; height: 18px; color: var(--muted); flex: none; transition: transform .15s; }
.bot-switch.open .chev { transform: rotate(180deg); }
.bot-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); animation: fade .12s;
}
.bot-menu-h { font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .5px; padding: 6px 8px; }
.bot-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border-radius: 10px; border: 0; background: none; cursor: pointer; text-align: left; }
.bot-item:hover { background: var(--hover); }
.bot-item.active { background: var(--accent-soft); }
.bot-item.active .bot-item-name { color: var(--accent); font-weight: 700; }
.bot-item-name { font-weight: 600; }
.bot-item svg { color: var(--accent); flex: none; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--text-2); cursor: pointer; border: 0; background: none; width: 100%; text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item svg { width: 19px; height: 19px; flex: none; }
.nav-item .badge { margin-left: auto; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; padding-top: 12px; border-top: 1px solid var(--line); }

.main { overflow: auto; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 28px; position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
}
.topbar h1 { font-size: 20px; margin: 0; font-weight: 700; }
.topbar .sub { color: var(--muted); font-size: 13px; }
.view { padding: 4px 28px 28px; flex: 1; min-height: 0; }
.view.full { padding: 0 28px 20px; display: flex; flex-direction: column; }

/* ── primitives ─────────────────────────── */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; }
.card-h h3 { margin: 0; font-size: 15px; font-weight: 650; }
.card-b { padding: 16px 18px 18px; }
.grid { display: grid; gap: 16px; }
.g-stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.g-2 { grid-template-columns: 2fr 1fr; }
@media (max-width: 1100px) { .g-2 { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); cursor: pointer; font-weight: 600; font-size: 13.5px;
  transition: transform .06s, background .15s, border-color .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--grad); color: #fff; border: 0; box-shadow: 0 4px 14px rgba(42, 120, 214, .3); }
.btn-primary:hover { background: var(--grad); filter: brightness(1.07); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.btn-ok:hover { background: var(--ok-soft); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.btn-icon { width: 38px; padding: 0; }
.btn-ghost { border-color: transparent; background: none; }

.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line); background: var(--panel-2);
  border-radius: 10px; padding: 9px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { resize: vertical; min-height: 120px; line-height: 1.55; }
.label { display: block; font-size: 12.5px; color: var(--text-2); font-weight: 600; margin: 0 0 6px; }
.field { margin-bottom: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

.badge {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 20px; height: 20px; padding: 0 7px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; background: var(--accent); color: #fff;
}
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-2); color: var(--text-2); border: 1px solid var(--line); }
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tag.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 13px; color: var(--text-2); }
.chip:hover { background: var(--hover); }
.chip.active { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }

.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px;
}
.avatar.lg { width: 64px; height: 64px; font-size: 24px; }
.avatar { position: relative; }
.av-status {
  position: absolute; right: -3px; bottom: -3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--danger); color: #fff; display: grid; place-items: center; border: 2px solid var(--panel);
}
.av-status svg { width: 11px; height: 11px; stroke-width: 3; }
.avatar.lg .av-status { width: 24px; height: 24px; right: -2px; bottom: -2px; }
.avatar.lg .av-status svg { width: 14px; height: 14px; }
.tag svg { flex: none; }
.tag.blocked { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.blocked-bar {
  display: flex; gap: 10px; align-items: center; margin-bottom: 10px; padding: 10px 12px; border-radius: 10px;
  background: var(--danger-soft); color: var(--danger); font-size: 13px;
}
.blocked-bar svg { width: 20px; height: 20px; flex: none; }

/* ── stats ──────────────────────────────── */
.stat { padding: 16px 18px; display: flex; gap: 14px; align-items: center; }
.stat-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.stat-ic svg { width: 22px; height: 22px; }
.stat-v { font-size: 24px; font-weight: 750; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-l { color: var(--muted); font-size: 12.5px; }

/* chart */
.chart { position: relative; }
.chart svg { width: 100%; height: 240px; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-t { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: var(--series-1); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .bar, .chart .bar.on { filter: brightness(1.15); }
.tooltip {
  position: absolute; pointer-events: none; background: var(--text); color: var(--panel);
  padding: 6px 10px; border-radius: 8px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -100%);
  box-shadow: var(--shadow); z-index: 3;
}
.hbar { display: grid; grid-template-columns: 110px 1fr 44px; align-items: center; gap: 10px; margin-bottom: 10px; }
.hbar-track { height: 10px; border-radius: 6px; background: var(--panel-2); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 6px; background: var(--series-1); }
.hbar-v { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 600; }

/* activity feed */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); align-items: flex-start; }
.feed li:last-child { border-bottom: 0; }
.ev { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; font-size: 15px; background: var(--panel-2); }

/* ── tables ─────────────────────────────── */
.table-wrap { overflow: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); white-space: nowrap; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { cursor: pointer; transition: background .1s; }
.tbl tbody tr:hover { background: var(--hover); }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell .avatar { width: 34px; height: 34px; font-size: 13px; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-top: 1px solid var(--line); }

/* ── inbox ──────────────────────────────── */
.inbox {
  display: grid; grid-template-columns: 330px 1fr 300px; flex: 1; min-height: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
@media (max-width: 1280px) { .inbox { grid-template-columns: 300px 1fr; } .inbox .profile { display: none; } }
.conv-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.conv-tools { padding: 14px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line); }
.conv-items { overflow: auto; flex: 1; }
.conv {
  display: flex; gap: 12px; padding: 12px 14px; cursor: pointer; border-bottom: 1px solid var(--line);
  transition: background .1s; position: relative;
}
.conv:hover { background: var(--hover); }
.conv.active { background: var(--accent-soft); }
.conv.active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.conv-body { min-width: 0; flex: 1; }
.conv-top { display: flex; justify-content: space-between; gap: 8px; }
.conv-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { color: var(--muted); font-size: 11.5px; flex: none; }
.conv-last { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.conv-last .grow { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.conv.unread .conv-name { color: var(--text); }
.conv.unread .conv-last { color: var(--text-2); font-weight: 600; }

.thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--chat-bg); }
.thread-h { display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.thread-h .name { font-weight: 700; }
.messages { flex: 1; overflow: auto; padding: 20px 6%; display: flex; flex-direction: column; gap: 6px; }
.day-sep { align-self: center; font-size: 12px; color: var(--text-2); background: var(--panel); border: 1px solid var(--line); padding: 3px 12px; border-radius: 999px; margin: 10px 0; }
.msg { max-width: min(560px, 78%); padding: 8px 12px 6px; border-radius: 16px; box-shadow: 0 1px 1px rgba(0, 0, 0, .06); word-wrap: break-word; white-space: pre-wrap; position: relative; }
.msg.in { align-self: flex-start; background: var(--bubble-in); border-bottom-left-radius: 5px; }
.msg.out { align-self: flex-end; background: var(--bubble-out); color: var(--bubble-out-ink); border-bottom-right-radius: 5px; }
.msg.out a { color: #fff; text-decoration: underline; }
.msg .quote { border-left: 3px solid currentColor; padding: 3px 8px; margin: 2px 0 6px; border-radius: 4px; background: rgba(127, 127, 127, .12); font-size: 12.5px; opacity: .9; max-height: 64px; overflow: hidden; white-space: normal; }
.msg .quote b { display: block; font-size: 11.5px; }
.msg.in .quote { border-left-color: var(--accent); }
.msg-reply { position: absolute; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--text-2); cursor: pointer; opacity: 0; transition: opacity .15s; font-size: 14px; line-height: 1; }
.msg.in .msg-reply { right: -36px; }
.msg.out .msg-reply { left: -36px; }
.msg:hover .msg-reply { opacity: 1; }
.msg-reply:hover { color: var(--accent); border-color: var(--accent); }
.tick { font-weight: 700; letter-spacing: -2px; margin-left: 2px; }
.tick.seen { color: #7fe3a8; }
.msg.in .tick.seen, .conv .tick.seen { color: var(--ok); }
.tick.fail { color: #ffd2d2; letter-spacing: 0; }
.conv .tick { margin-right: 4px; color: var(--muted); }
.conv .tick.fail { color: var(--danger); }
.msg.out.failed { background: #b4413f; }
.legend-ticks { font-size: 12px; color: var(--muted); display: flex; gap: 12px; }
.msg .meta { font-size: 11px; opacity: .65; text-align: right; margin-top: 2px; display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.msg img.media, .msg video.media { display: block; max-width: 100%; max-height: 340px; border-radius: 10px; margin: 2px 0 6px; cursor: zoom-in; }
.msg audio { display: block; max-width: 280px; margin: 4px 0; }
.msg .file { display: inline-flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: rgba(127, 127, 127, .12); color: inherit; margin-bottom: 4px; }
.msg code { background: rgba(127, 127, 127, .15); padding: 1px 4px; border-radius: 4px; }
.msg blockquote { margin: 4px 0; padding-left: 10px; border-left: 3px solid currentColor; opacity: .9; }
.composer { padding: 12px 16px; background: var(--panel); border-top: 1px solid var(--line); }
.composer-box { display: flex; align-items: flex-end; gap: 8px; }
.composer textarea {
  flex: 1; resize: none; min-height: 42px; max-height: 200px; border: 1px solid var(--line); background: var(--panel-2);
  border-radius: 12px; padding: 10px 14px; outline: none;
}
.composer textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.attach-pill { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 5px 10px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 12.5px; }
.empty { display: grid; place-items: center; text-align: center; color: var(--muted); padding: 40px; height: 100%; }
.empty svg { width: 56px; height: 56px; opacity: .45; margin-bottom: 10px; }

.profile { border-left: 1px solid var(--line); overflow: auto; padding: 22px 18px; }
.profile .center { text-align: center; margin-bottom: 18px; }
.profile .center .avatar { margin: 0 auto 10px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; overflow: hidden; text-overflow: ellipsis; }

/* ── broadcast / texts ──────────────────── */
.toolbar { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.toolbar .btn { height: 32px; min-width: 34px; padding: 0 10px; font-size: 13px; }
.tg-preview { background: var(--chat-bg); border-radius: 12px; padding: 18px; min-height: 160px; }
.tg-preview .msg { max-width: 100%; }
.progress { height: 10px; border-radius: 6px; background: var(--panel-2); overflow: hidden; }
.progress > div { height: 100%; background: var(--grad); transition: width .4s; }
.text-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; }
.lang-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 1200px) { .lang-cols { grid-template-columns: 1fr; } }
.lang-col { display: flex; flex-direction: column; gap: 8px; }
.lang-col .textarea { min-height: 170px; font-size: 13px; }

/* ── drawer / modal / toast ─────────────── */
.overlay { position: fixed; inset: 0; background: rgba(5, 10, 20, .45); z-index: 40; display: flex; justify-content: flex-end; animation: fade .15s; }
.drawer { width: min(520px, 100%); height: 100%; background: var(--panel); overflow: auto; padding: 22px; box-shadow: var(--shadow); animation: slide .2s; }
.modal-wrap { align-items: center; justify-content: center; }
.modal { width: min(440px, calc(100% - 32px)); background: var(--panel); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 8px; }
.lightbox { align-items: center; justify-content: center; cursor: zoom-out; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 10px; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--panel); padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow); max-width: 380px; animation: fade .2s; font-weight: 500; }
.toast.err { background: var(--danger); color: #fff; }

/* ── login ──────────────────────────────── */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(42, 120, 214, .22), transparent 60%),
    radial-gradient(800px 500px at 90% 90%, rgba(98, 80, 214, .22), transparent 60%),
    var(--bg);
}
.login-card { width: min(400px, 100%); padding: 32px 28px; }
.login-card .brand { justify-content: center; flex-direction: column; text-align: center; padding-bottom: 24px; }
.login-card .brand-logo { width: 64px; height: 64px; border-radius: 18px; }
.login-card .brand-logo svg { width: 32px; height: 32px; }
.err-text { color: var(--danger); font-size: 13px; min-height: 20px; margin-top: 8px; }

.skeleton { background: linear-gradient(90deg, var(--panel-2), var(--hover), var(--panel-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 35%, transparent); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }

/* ═════════ phones ═════════ */
.tabbar, .m-bot, .m-back, .sidebar-backdrop { display: none; }
.topbar-title { min-width: 0; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .main { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }

  /* the sidebar becomes a slide-in menu */
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 80; width: min(300px, 86vw);
    padding-top: calc(16px + env(safe-area-inset-top)); padding-bottom: calc(16px + env(safe-area-inset-bottom));
    transform: translateX(-104%); transition: transform .22s ease; overflow-y: auto; box-shadow: none;
  }
  body.sb-open .sidebar { transform: none; box-shadow: 0 0 60px rgba(0, 0, 0, .35); }
  body.sb-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 75; background: rgba(5, 10, 20, .45); animation: fade .15s; }

  /* bottom tab bar */
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    height: calc(62px + env(safe-area-inset-bottom)); padding: 0 4px env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }
  .tab {
    flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border: 0; background: none; color: var(--muted); font-size: 10.5px; font-weight: 600; position: relative;
    text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .tab svg { width: 23px; height: 23px; flex: none; }
  .tab > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab:hover { text-decoration: none; }
  .tab.active { color: var(--accent); }
  .tab.active::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
  .tab .badge { position: absolute; top: 6px; left: calc(50% + 4px); height: 17px; min-width: 17px; padding: 0 5px; font-size: 10px; }

  /* compact top bar with the bot badge */
  .topbar { padding: calc(10px + env(safe-area-inset-top)) 14px 10px; gap: 10px; flex-wrap: wrap; }
  .topbar h1 { font-size: 18px; }
  .topbar .sub { display: none; }
  .topbar-title { flex: 1; }
  .m-bot { display: grid; place-items: center; position: relative; border: 0; background: none; padding: 0; cursor: pointer; }
  .m-bot .bot-logo { border-radius: 11px; font-size: 15px; }
  .m-bot .badge { position: absolute; top: -6px; right: -8px; height: 17px; min-width: 17px; font-size: 10px; padding: 0 5px; }
  #page-actions { width: 100%; flex-wrap: wrap; gap: 8px; }
  #page-actions > .btn { flex: 1 1 0; min-width: 0; height: 36px; padding: 0 10px; font-size: 13px; }
  .range-picker { flex: 1 1 100%; min-width: 0; }
  .range-btn { width: 100%; justify-content: flex-start; }
  .range-btn .chev { margin-left: auto; }

  .view, .view.full { padding-left: 12px; padding-right: 12px; }
  .view.full { padding-bottom: 8px; }
  .g-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px; gap: 10px; }
  .stat-ic { width: 36px; height: 36px; }
  .stat-v { font-size: 20px; }
  .card-h { flex-wrap: wrap; }
  .hide-sm { display: none; }
  .tbl th, .tbl td { padding: 10px; }
  .toasts { left: 12px; right: 12px; bottom: calc(74px + env(safe-area-inset-bottom)); }
  .toast { max-width: none; }
  .drawer { padding: 16px; }

  /* inbox: list and conversation are two screens */
  .inbox { grid-template-columns: 1fr; border-radius: 12px; }
  .inbox .thread { display: none; }
  .inbox.has-thread .conv-list { display: none; }
  .inbox.has-thread .thread { display: flex; }
  .m-back { display: inline-flex; margin-left: -6px; }
  .m-back svg { width: 22px; height: 22px; }
  .thread-h { padding: 8px 10px; gap: 8px; flex-wrap: wrap; }
  .thread-h .legend-ticks { display: none; }
  .thread-h { flex-wrap: nowrap; }
  .thread-h > div:not(.avatar) { flex: 1; min-width: 0; }
  .thread-h .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .thread-h .name .tag { display: none; }   /* status stays visible as the $ / 🚫 badge on the avatar */
  .thread-h .muted.small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .thread-h .btn-sm { font-size: 0; gap: 0; width: 34px; padding: 0; flex: none; }
  .thread-h .btn-sm svg { width: 17px; height: 17px; }
  .thread-h .btn-sm[data-pay] { font-size: 12px; width: auto; padding: 0 8px; }
  .thread-h .btn-sm { padding: 0 9px; }
  .messages { padding: 14px 10px; }
  .msg { max-width: 88%; }
  .composer { padding: 8px 10px; }
  .composer .btn-primary { padding: 0; width: 42px; height: 42px; font-size: 0; gap: 0; border-radius: 12px; }

  /* calendar opens as a bottom sheet */
  .rp-pop { position: fixed; left: 8px; right: 8px; top: auto; bottom: calc(70px + env(safe-area-inset-bottom)); max-height: 76vh; overflow-y: auto; }
  .rp-month { width: 100%; }
  .rp-grid { grid-template-columns: repeat(7, 1fr); }
  .rp-foot { flex-wrap: wrap; }

  .lang-cols { grid-template-columns: 1fr; }
  .pay-qr { width: 120px; }
}

/* touch screens have no hover: keep the "reply to message" button visible */
@media (hover: none) {
  .msg-reply { opacity: .8; position: static; transform: none; float: right; width: 26px; height: 26px; margin: -2px -4px 2px 8px; font-size: 13px; }
  .msg.in .msg-reply, .msg.out .msg-reply { left: auto; right: auto; }
}
