:root {
  --bg: #f0f2f5; --card: #fff; --line: #e4e8ec;
  --ink: #111b21; --mut: #667781;
  --brand: #00a884; --brand-d: #008f72; --brand-l: #d9f4ec;
  --side: #111b21; --side2: #202c33; --sidetxt: #aebac1;
  --red: #e5484d; --amber: #f5a524; --blue: #3b82f6; --gray: #94a3b8;
  --r: 12px;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body { font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif; background: var(--bg); color: var(--ink); }

/* ---------- Sidebar (fixed, never scrolls with page) ---------- */
.side { position: fixed; top: 0; left: 0; bottom: 0; width: 232px; background: var(--side); color: var(--sidetxt); display: flex; flex-direction: column; z-index: 40; overflow-y: auto; }
.side-brand { padding: 20px 18px 16px; font-size: 17px; color: #fff; letter-spacing: .3px; border-bottom: 1px solid #2a3942; }
.side-brand b { color: var(--brand); }
.side nav { flex: 1; padding: 10px 10px; overflow-y: auto; }
.side nav a { display: flex; align-items: center; gap: 11px; color: var(--sidetxt); text-decoration: none; font-size: 14px; font-weight: 500; padding: 10px 12px; border-radius: 9px; margin-bottom: 2px; }
.side nav a svg { width: 19px; height: 19px; flex-shrink: 0; opacity: .85; }
.side nav a:hover { background: var(--side2); color: #fff; }
.side nav a.on { background: var(--brand); color: #fff; }
.side nav a.on svg { opacity: 1; }
.side nav .nav-group { position: relative; }
.side nav .nav-fold { display: flex; align-items: center; gap: 11px; width: 100%; color: var(--sidetxt); background: none; border: 0; font: inherit; font-size: 14px; font-weight: 500; padding: 10px 12px; border-radius: 9px; margin-bottom: 2px; cursor: pointer; text-align: left; }
.side nav .nav-fold svg:first-child { width: 19px; height: 19px; flex-shrink: 0; opacity: .85; }
.side nav .nav-fold .caret { width: 14px; height: 14px; margin-left: auto; opacity: .6; transition: transform .15s; }
.side nav .nav-group.open .nav-fold .caret { transform: rotate(90deg); }
.side nav .nav-fold:hover { background: var(--side2); color: #fff; }
.side nav .nav-fold.on { color: #fff; }
.side nav .nav-sub { display: none; padding: 4px 0 8px; }
.side nav .nav-group.open .nav-sub { display: block; }
.side nav .nav-sub a { display: flex; align-items: center; gap: 9px; padding: 9px 12px 9px 20px; border-radius: 8px; font-size: 13.2px; margin-bottom: 1px; }
.side nav .nav-sub a::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .35; flex-shrink: 0; }
.side nav .nav-sub a:hover { background: var(--side2); color: #fff; }
.side nav .nav-sub a.on { background: var(--brand); color: #fff; }
.side nav .nav-sub a.on::before { opacity: 1; }
.side-sep { border-top: 1px solid #2a3942; margin: 10px 6px; }
.side-user { padding: 14px; border-top: 1px solid #2a3942; font-size: 12.5px; }
.side-user b { display: block; color: #fff; font-size: 13.5px; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user span { color: var(--sidetxt); }
.side-user a { color: var(--brand); text-decoration: none; font-weight: 600; }

/* ---------- Main ---------- */
.main { margin-left: 232px; min-height: 100vh; display: flex; flex-direction: column; }
.ptop { background: var(--card); border-bottom: 1px solid var(--line); padding: 14px 26px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 5; }
.ptop h1 { font-size: 18px; }
.content { padding: 22px 26px 70px; max-width: 1200px; width: 100%; margin: 0 auto; }
.sub { color: var(--mut); font-size: 13px; margin: 4px 0 16px; }
.mt { margin-top: 14px; } .mb0 { margin-bottom: 0 !important; }

h1 { font-size: 20px; } h2 { font-size: 15.5px; margin-bottom: 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; margin-bottom: 18px; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 15px 17px; }
.stat b { display: block; font-size: 25px; margin-top: 3px; }
.stat span { color: var(--mut); font-size: 11px; text-transform: uppercase; letter-spacing: .7px; font-weight: 700; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; color: var(--mut); font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:hover td { background: #fafbfc; }
.tbl tr:last-child td { border-bottom: 0; }
.dev-cell b { display: block; } .dev-cell small { color: var(--mut); }

.btn { display: inline-block; background: var(--brand); color: #fff !important; border: 0; border-radius: 8px; padding: 9px 16px; font-size: 13.5px; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--brand-d); }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 7px; }
.btn-ghost { background: transparent; color: var(--ink) !important; border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--red); } .btn-gray { background: var(--gray); }
.btn-blue { background: var(--blue); }
button:disabled { opacity: .55; cursor: not-allowed; }

input, select, textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; background: #fff; color: var(--ink); font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-l); border-color: var(--brand); }
label { display: block; font-size: 12px; font-weight: 700; margin: 0 0 5px; color: #37475a; }
.frow { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.frow > div { flex: 1; min-width: 150px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.check input { width: auto; }

.alert { padding: 10px 14px; border-radius: 9px; font-size: 13px; margin-bottom: 14px; }
.alert-ok { background: #e7f7f1; color: #067a5b; border: 1px solid #bfe8da; }
.alert-error { background: #fdecec; color: #b3251e; border: 1px solid #f5c6c4; }

.chip { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 800; letter-spacing: .4px; }
.chip-green { background: #e7f7f1; color: #067a5b; }
.chip-amber { background: #fdf3df; color: #a36a00; }
.chip-blue { background: #e8f0fe; color: #1d62d6; }
.chip-red { background: #fdecec; color: #b3251e; }
.chip-gray { background: #eef1f4; color: #5b6b7c; }

.tok { font-family: Consolas, Menlo, monospace; font-size: 12px; background: var(--bg); padding: 2px 7px; border-radius: 6px; word-break: break-all; }
code.tok { user-select: all; }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(11,20,26,.55); display: none; align-items: center; justify-content: center; z-index: 50; padding: 18px; }
.modal-back.open { display: flex; }
.modal { background: var(--card); border-radius: 16px; width: 100%; max-width: 430px; max-height: 92vh; overflow-y: auto; padding: 20px 22px; box-shadow: 0 18px 60px rgba(0,0,0,.28); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h3 { font-size: 15.5px; }
.mx { background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--mut); }

#qrbox { width: 270px; height: 270px; background: #f0fdf9; border: 2px dashed var(--brand); border-radius: 12px; display: flex; align-items: center; justify-content: center; margin: 8px auto 12px; color: var(--mut); font-size: 12.5px; text-align: center; padding: 12px; }
#qrbox img { width: 100%; height: 100%; border-radius: 10px; }
.qr-ok { color: #067a5b; font-size: 42px; flex-direction: column; gap: 6px; }

.pager a, .pager b { display: inline-block; padding: 5px 10px; margin-right: 3px; border-radius: 7px; font-size: 13px; text-decoration: none; color: var(--ink); border: 1px solid var(--line); background: #fff; }
.pager b { background: var(--brand); color: #fff; border-color: var(--brand); }
.empty { text-align: center; color: var(--mut); padding: 30px 10px; font-size: 13.5px; }

/* ---------- Connect popup ---------- */
.mc-tabs { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 8px; }
.mc-tabs button { position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; background: transparent; padding: 10px; border-radius: 9px; font-size: 13.5px; font-weight: 700; color: var(--mut); cursor: pointer; transition: color .18s ease; }
.mc-tabs button .ic { font-size: 15px; line-height: 1; }
.mc-tabs button:hover { color: var(--ink); }
.mc-tabs button.active { color: var(--brand); }
.mc-tabs .mc-thumb { position: absolute; top: 4px; left: 4px; width: calc(50% - 6px); height: calc(100% - 8px); background: #fff; border-radius: 9px; box-shadow: 0 2px 8px rgba(17,27,33,.12); transition: left .22s cubic-bezier(.4,0,.2,1); }
.mc-tabs:has(button[data-mode="phone"].active) .mc-thumb { left: calc(50% + 2px); }

.mc-modehint { font-size: 12.5px; color: var(--mut); line-height: 1.5; min-height: 20px; margin-bottom: 4px; }

.mc-field { margin-top: 14px; }
.mc-field label { font-size: 12px; font-weight: 700; margin-bottom: 6px; color: #37475a; }
.mc-phone { display: flex; align-items: stretch; }
.mc-phone .pfx { display: flex; align-items: center; justify-content: center; width: 40px; font-size: 15px; font-weight: 700; color: var(--mut); background: var(--bg); border: 1px solid var(--line); border-right: 0; border-radius: 8px 0 0 8px; flex-shrink: 0; }
.mc-phone input { border-radius: 0 8px 8px 0; }
.mc-divider { display: flex; align-items: center; gap: 10px; margin: 12px 0 8px; color: var(--mut); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .7px; }
.mc-divider::before, .mc-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.mc-steps { margin: 0; padding-left: 20px; color: var(--mut); font-size: 13px; line-height: 1.9; }
.mc-steps b { color: var(--ink); }

/* ---------- Phone code ---------- */
.phone-code { text-align: center; margin: 18px auto 4px; }
.code-lbl { font-size: 11px; font-weight: 700; color: var(--mut); text-transform: uppercase; letter-spacing: .9px; margin-bottom: 12px; }
.phone-code .digits { display: flex; gap: 6px; justify-content: center; }
.phone-code .d { width: 42px; height: 54px; display: flex; align-items: center; justify-content: center; font-family: Consolas, "Segoe UI", monospace; font-size: 26px; font-weight: 800; color: var(--ink); background: var(--card); border: 1.5px solid var(--line); border-radius: 11px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.code-sub { margin-top: 12px; font-size: 12px; color: var(--mut); line-height: 1.5; }

/* ---------- Segmented tabs ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button { border: 1px solid var(--line); background: #fff; color: var(--mut); padding: 8px 15px; border-radius: 9px; font-size: 13px; font-weight: 700; cursor: pointer; }
.tabs button:hover { color: var(--ink); }
.tabs button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.tabpanel { display: none; }
.tabpanel.on { display: block; }

/* ---------- Checkbox picker list ---------- */
.pick { list-style: none; padding: 0; margin: 0; max-height: 250px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.pick li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.pick li:last-child { border-bottom: 0; }
.pick li:hover { background: #fafbfc; }
.pick input { width: auto; flex-shrink: 0; }
.pick .nm { flex: 1; font-weight: 600; font-size: 13.5px; }
.pick .ph { color: var(--mut); font-size: 12px; }
.pick .ct { color: var(--mut); font-size: 11px; white-space: nowrap; }
.pick .empty { padding: 14px; }

/* ---------- Small helpers ---------- */
.pill { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; background: var(--bg); color: var(--mut); border: 1px solid var(--line); }
.kbd { font-family: Consolas, Menlo, monospace; font-size: 12px; }
.dim { color: var(--mut); }
.review { display: flex; flex-wrap: wrap; gap: 6px; min-height: 30px; }
.review .chip { cursor: default; }

.fail-chip { display: inline-block; padding: 3px 9px; border-radius: 6px; font-size: 11px; font-weight: 700; letter-spacing: .3px; }
.fail-rate_limited { background: #fff4d6; color: #9a6700; }
.fail-quota_reached, .fail-device_disconnected, .fail-send_failed { background: #fdecec; color: #b3251e; }

/* ---------- Webhook page ---------- */
.hook-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hook-row .tok { flex: 1; min-width: 240px; padding: 10px 12px; background: var(--side); color: #d8e3ea; font-size: 12.5px; }
.json-pre { background: #0d1b20; color: #a8d8f0; padding: 14px 16px; border-radius: 10px; font-family: Consolas, Menlo, monospace; font-size: 12px; line-height: 1.6; overflow: auto; max-height: 60vh; white-space: pre-wrap; word-break: break-word; }


@media (max-width: 860px) {
  .side { width: 64px; }
  .main { margin-left: 64px; }
  .side-brand { font-size: 0; text-align: center; padding: 18px 6px; }
  .side-brand b::before { content: "⚡"; font-size: 18px; }
  .side nav a { justify-content: center; }
  .side nav a span { display: none; }
  .side nav .nav-fold { justify-content: center; }
  .side nav .nav-fold .caret, .side nav .nav-fold span { display: none; }
  .side nav .nav-group.open .nav-sub { position: absolute; left: 56px; top: 0; display: flex; flex-direction: column; background: var(--side2); border-radius: 10px; padding: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.35); min-width: 150px; z-index: 60; }
  .side nav .nav-sub a { padding: 9px 12px; white-space: nowrap; }
  .side-user { font-size: 0; } .side-user * { display: none; }
  .content { padding: 16px 12px 60px; }
}
