:root {
  --bg: #f5f6f8; --panel: #fff; --ink: #1c2330; --muted: #6b7686; --line: #e3e7ee;
  --brand: #00a884; --brand-ink: #fff; --brand-soft: #e3f6f1; --accent: #3b6cf6;
  --warn: #b7791f; --warn-soft: #fdf3dc; --bad: #c53030; --bad-soft: #fde8e8; --ok: #2f855a; --ok-soft: #e4f5ea;
  --bubble-in: #fff; --bubble-out: #d9fdd3; --bubble-bot: #e8eefc; --shadow: 0 1px 2px rgba(20,30,50,.06), 0 4px 14px rgba(20,30,50,.05);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f141b; --panel: #171e28; --ink: #e8edf4; --muted: #93a0b2; --line: #263040; --brand-soft: #0d3a31; --warn-soft: #3a2f12; --bad-soft: #3d1b1b; --ok-soft: #12351f; --bubble-in: #202a37; --bubble-out: #0f4a3d; --bubble-bot: #22304d; --shadow: none; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
h1 { font-size: 20px; margin: 0 0 4px; } h2 { font-size: 15px; margin: 0 0 10px; } h3 { font-size: 13px; margin: 0 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); padding: 6px 12px; border-radius: 8px; }
button:hover { border-color: var(--muted); } button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
button.danger { color: var(--bad); } button.sm { padding: 3px 8px; font-size: 12px; } button.link { border: 0; background: none; color: var(--accent); padding: 0; }
input, select, textarea { width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
textarea { resize: vertical; min-height: 70px; } textarea.code { font: 12px/1.4 ui-monospace, Menlo, monospace; min-height: 280px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 3px; }
table { width: 100%; border-collapse: collapse; } th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr.click:hover { background: var(--bg); cursor: pointer; }
.shell { display: grid; grid-template-columns: 220px 1fr; height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.brand { font-weight: 700; font-size: 17px; padding: 4px 10px 12px; display: flex; gap: 8px; align-items: center; }
.brand i { width: 24px; height: 24px; border-radius: 7px; background: var(--brand); display: inline-block; }
.side a { color: var(--ink); padding: 7px 10px; border-radius: 8px; display: flex; justify-content: space-between; text-decoration: none; }
.side a:hover { background: var(--bg); } .side a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.side .who { margin-top: auto; padding: 10px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.main { overflow-y: auto; padding: 20px 24px 40px; } .main.flush { padding: 0; overflow: hidden; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.sub { color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.grid { display: grid; gap: 14px; } .g2 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } .row > * { flex: 0 0 auto; } .row > .grow { flex: 1 1 140px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .n { font-size: 26px; font-weight: 700; } .kpi .l { color: var(--muted); font-size: 12px; } .kpi .t { font-size: 12px; margin-top: 4px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; } .pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; } .pill.brand { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.bar { height: 8px; border-radius: 99px; background: var(--bg); overflow: hidden; } .bar > i { display: block; height: 100%; background: var(--brand); }
.bar.warn > i { background: #d69e2e; } .bar.bad > i { background: var(--bad); }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 110px; } .chart i { flex: 1; background: var(--brand); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.modal-bg { position: fixed; inset: 0; background: rgba(10,15,25,.5); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.modal { background: var(--panel); border-radius: 14px; padding: 18px 20px; width: min(640px, 100%); max-height: 90vh; overflow-y: auto; }
.modal.wide { width: min(900px, 100%); }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 30; }
.toast { background: var(--ink); color: var(--bg); padding: 9px 14px; border-radius: 10px; max-width: 360px; box-shadow: var(--shadow); } .toast.err { background: var(--bad); color: #fff; }
.auth { max-width: 400px; margin: 8vh auto; padding: 0 16px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 12px; color: var(--muted); } .tabs button.on { color: var(--brand); border-color: var(--brand); font-weight: 600; }
/* inbox */
.inbox { display: grid; grid-template-columns: 330px 1fr 300px; height: 100vh; }
.inbox > div { min-height: 0; display: flex; flex-direction: column; } .inbox > div + div { border-left: 1px solid var(--line); }
.list { overflow-y: auto; flex: 1; } .list .item { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; } .list .item:hover { background: var(--bg); } .list .item.on { background: var(--brand-soft); }
.item .top { display: flex; justify-content: space-between; gap: 6px; font-weight: 600; } .item .pv { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.unread { background: var(--brand); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 6px; }
.thread { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.msg { max-width: 72%; padding: 8px 11px; border-radius: 12px; box-shadow: var(--shadow); white-space: pre-wrap; word-wrap: break-word; }
.msg.in { align-self: flex-start; background: var(--bubble-in); } .msg.out { align-self: flex-end; background: var(--bubble-out); } .msg.bot { align-self: flex-end; background: var(--bubble-bot); }
.msg.note { align-self: center; background: var(--warn-soft); max-width: 85%; font-size: 13px; } .msg .meta { font-size: 11px; color: var(--muted); margin-top: 3px; display: flex; gap: 6px; }
.opts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; } .opts span { border: 1px solid var(--brand); color: var(--brand); border-radius: 99px; padding: 1px 9px; font-size: 12px; }
.opts button.opt { border-color: var(--brand); color: var(--brand); border-radius: 99px; padding: 2px 10px; font-size: 12px; }
.banner { padding: 7px 14px; font-size: 12.5px; display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.banner.ok { background: var(--ok-soft); color: var(--ok); } .banner.warn { background: var(--warn-soft); color: var(--warn); } .banner.free { background: var(--brand-soft); color: var(--brand); }
.composer { border-top: 1px solid var(--line); padding: 10px 12px; background: var(--panel); }
.composer textarea { min-height: 54px; margin-bottom: 6px; }
.side-panel { overflow-y: auto; padding: 14px; background: var(--panel); } .side-panel section { margin-bottom: 16px; }
.kv { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; font-size: 13px; } .kv span:first-child { color: var(--muted); }
.tag { display: inline-flex; align-items: center; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; margin: 0 4px 4px 0; font-size: 12px; } .tag button { border: 0; padding: 0; background: none; color: var(--muted); }
.sim { display: grid; grid-template-columns: 340px 1fr; gap: 14px; }
.phone { background: #0b141a; border-radius: 22px; padding: 12px; height: 560px; display: flex; flex-direction: column; } .phone .thread { background: #0b141a url(); border-radius: 12px; }
.phone .msg.in { background: #005c4b; color: #fff; align-self: flex-end; } .phone .msg.out, .phone .msg.bot { background: #202c33; color: #e9edef; align-self: flex-start; }
.phone .opts button.opt { border-color: #53bdeb; color: #53bdeb; }
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; } .side { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); padding: 6px; } .side .who, .brand { display: none; }
  .g2, .g3, .g4, .sim { grid-template-columns: 1fr; } .inbox { grid-template-columns: 1fr; height: auto; } .inbox > div + div { border-left: 0; border-top: 1px solid var(--line); } .list { max-height: 40vh; } .thread { min-height: 50vh; }
  .main { padding: 14px 12px 40px; } .shell { height: auto; }
}
