/* SMS Bridge dashboard. No framework, no build step. */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f8f9fb;
  --line: #e3e6eb;
  --text: #16181d;
  --muted: #646b78;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --accent-soft: #e8efff;
  --ok: #15803d;
  --warn: #b45309;
  --warn-soft: #fff4e0;
  --bad: #c62828;
  --bad-soft: #fdecec;
  --bubble-in: #eceef2;
  --bubble-out: #2563eb;
  --bubble-out-text: #ffffff;
  --radius: 10px;
  --shadow: 0 8px 30px rgba(15, 23, 42, .14);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  color: var(--text);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --panel: #171a20;
    --panel-2: #1d2128;
    --line: #2b313b;
    --text: #e8eaee;
    --muted: #9aa3b2;
    --accent: #5b8cff;
    --accent-text: #0b1020;
    --accent-soft: #1d2a4a;
    --ok: #4ade80;
    --warn: #f5b454;
    --warn-soft: #3a2c13;
    --bad: #ff6b6b;
    --bad-soft: #3b1c1c;
    --bubble-in: #252a33;
    --bubble-out: #3b6ef5;
    --bubble-out-text: #ffffff;
    --shadow: 0 8px 30px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
#root { height: 100%; }
.boot { display: grid; place-items: center; height: 100%; color: var(--muted); }

/* ---- buttons and fields ---- */
.btn {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; line-height: 1.2; white-space: nowrap;
}
.btn:hover { background: var(--panel-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.link { background: none; border: 0; padding: 4px 0; color: var(--accent); cursor: pointer; }
.icon { background: none; border: 0; padding: 6px 9px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 16px; }
.icon:hover { background: var(--panel-2); color: var(--text); }
input, select, textarea {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 9px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field { display: block; margin: 0 0 14px; }
.field .label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--muted); }

/* phone field: country select, flag + code, number */
.pf { display: grid; grid-template-columns: minmax(0, 9.5em) auto minmax(0, 1fr); gap: 6px; align-items: center; }
.pf-prefix { white-space: nowrap; color: var(--muted); padding: 0 2px; }
.pf-hint { min-height: 1.3em; font-size: 13px; margin-top: 4px; color: var(--muted); }
.pf-hint.ok { color: var(--ok); }
.pf-hint.err { color: var(--bad); }
.form-error { color: var(--bad); min-height: 1.3em; margin: 4px 0 10px; font-size: 14px; }
.form-error:empty { min-height: 0; margin: 0; }
.form-info { color: var(--ok); margin: 10px 0; font-size: 14px; }
.form-info:empty { margin: 0; }

/* ---- sign in / join / reset ---- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 22px; margin: 6px 0 20px; }
.auth-card form .btn.primary { width: 100%; padding: 11px; margin-top: 4px; }
.auth-card .link { display: block; margin: 14px auto 0; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--accent); }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-text); font-size: 15px; }

/* ---- admin app layout ---- */
.app { display: grid; grid-template-columns: 360px minmax(0, 1fr); height: 100%; }
.side { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-right: 1px solid var(--line); }
.side-head { display: flex; gap: 8px; padding: 12px 12px 6px; }
.picker { position: relative; flex: 1; min-width: 0; }
.picker input { font-weight: 600; }
.picker input::placeholder { color: var(--text); opacity: .85; }
.picker-results {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0; max-height: 320px; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
}
.picker-results button { display: flex; width: 100%; gap: 8px; align-items: baseline; text-align: left; padding: 9px 12px; background: none; border: 0; cursor: pointer; }
.picker-results button:hover, .picker-results button.active { background: var(--panel-2); }
.picker-results .sub { color: var(--muted); font-size: 13px; margin-left: auto; }
.picker-results .none { padding: 10px 12px; color: var(--muted); }
.countline { padding: 0 14px; font-size: 13px; color: var(--muted); }
.statusline { margin: 8px 12px 4px; padding: 8px 10px; border-radius: 8px; font-size: 13px; background: var(--panel-2); color: var(--muted); }
.statusline.warn { background: var(--warn-soft); color: var(--warn); }
.tabs { display: flex; gap: 4px; padding: 8px 12px 0; align-items: center; }
.tab { background: none; border: 0; padding: 7px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tab.on { background: var(--accent-soft); color: var(--accent); }
.tabs .icon { margin-left: auto; font-size: 20px; line-height: 1; color: var(--accent); }
.side-search { padding: 8px 12px; }
.list { flex: 1; overflow: auto; min-height: 0; border-top: 1px solid var(--line); }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; width: 100%; padding: 11px 14px; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:hover { background: var(--panel-2); }
.row.on { background: var(--accent-soft); }
.row .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .when { color: var(--muted); font-size: 12px; }
.row .snippet { grid-column: 1 / -1; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.unread .title, .row.unread .snippet { font-weight: 700; color: var(--text); }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: var(--accent); color: var(--accent-text); }
.list .more, .list .empty { display: block; width: 100%; padding: 14px; text-align: center; color: var(--muted); background: none; border: 0; }
.list .more { color: var(--accent); cursor: pointer; }
.side-foot { display: flex; gap: 4px; padding: 8px 10px; border-top: 1px solid var(--line); }
.side-foot .link { padding: 6px 8px; }
.side-foot .link:last-child { margin-left: auto; color: var(--muted); }

/* ---- conversation ---- */
.conv { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.conv-empty { margin: auto; color: var(--muted); text-align: center; padding: 20px; }
.conv-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.conv-head .who { min-width: 0; flex: 1; }
.conv-head .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-head .num { color: var(--muted); font-size: 13px; }
.back { display: none; }
.msgs { flex: 1; overflow: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.day { align-self: center; font-size: 12px; color: var(--muted); margin: 12px 0 6px; }
.bubble { max-width: min(560px, 80%); padding: 8px 12px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.in { align-self: flex-start; background: var(--bubble-in); border-bottom-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: var(--bubble-out); color: var(--bubble-out-text); border-bottom-right-radius: 4px; }
.bubble.failed { background: var(--bad-soft); color: var(--bad); }
.bubble.queued { opacity: .75; }
.meta { font-size: 11px; color: var(--muted); display: flex; gap: 8px; margin: 0 4px 6px; }
.meta.in { align-self: flex-start; }
.meta.out { align-self: flex-end; }
.meta .del { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; text-decoration: underline; font-size: 11px; visibility: hidden; }
.meta:hover .del, .meta .del:focus { visibility: visible; }
.older { align-self: center; }
.compose { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 10px 12px; background: var(--panel); border-top: 1px solid var(--line); align-items: end; }
.compose textarea { resize: none; max-height: 160px; min-height: 40px; line-height: 1.35; }
.compose-side { display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
.compose-foot { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); }
.compose-foot select { width: auto; padding: 4px 8px; font-size: 12px; }
.compose-foot .count { margin-left: auto; }
.to-row { position: relative; padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.to-row .picker-results { left: 16px; right: 16px; }

/* ---- dialogs ---- */
dialog.dlg { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
dialog.dlg::backdrop { background: rgba(10, 12, 16, .45); }
.dlg-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 2; }
.dlg-head h2 { font-size: 18px; margin: 0; flex: 1; }
.dlg-body { padding: 16px 18px 20px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input { flex: 1; min-width: 160px; }
.toolbar select { width: auto; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; color: var(--muted); font-size: 13px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; background: var(--panel); }
.card-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-top .name { font-weight: 700; }
.card .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.card .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.card .acts select { width: auto; padding: 5px 8px; font-size: 13px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--ok); }
.tag { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.tag.default { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.tag.alert { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.off { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.section { margin: 18px 0 8px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.step { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-align: center; }
.step h3 { margin: 0 0 8px; font-size: 15px; }
.qr { width: 220px; max-width: 100%; aspect-ratio: 1; background: #fff; border-radius: 8px; padding: 4px; }
.note { color: var(--muted); font-size: 14px; }
.copyrow { display: flex; gap: 6px; margin-top: 8px; }
.copyrow input { font-size: 12px; }
details summary { cursor: pointer; color: var(--accent); margin-top: 8px; }
.countdown { margin-top: 12px; color: var(--muted); font-size: 13px; text-align: center; }
.act-row { display: grid; grid-template-columns: 7.5em minmax(0, 1fr); gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.act-row .t { color: var(--muted); font-size: 12px; padding-top: 2px; }
.act-row.alert { background: var(--warn-soft); margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 6px; }

/* ---- member view ---- */
.member { max-width: 1100px; margin: 0 auto; padding: 16px; }
.member-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.member-head .brand { margin-right: auto; }
.member-head .me { color: var(--muted); font-size: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 10px; }
.tile { background: var(--panel-2); border-radius: 8px; padding: 8px 4px; text-align: center; }
.tile b { display: block; font-size: 18px; }
.tile span { font-size: 11px; color: var(--muted); }
.warnline { color: var(--warn); font-size: 13px; margin-top: 6px; }
.empty-state { text-align: center; color: var(--muted); padding: 60px 16px; }

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #1f2430; color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow);
  max-width: min(560px, calc(100vw - 32px)); transition: opacity .18s, transform .18s; z-index: 100; font-size: 14px;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.app ~ .toast, body:has(.app) .toast { bottom: 96px; } /* stay above the compose bar */
.toast.bad { background: var(--bad); }

/* ---- narrow screens: list or conversation ---- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .app .conv { display: none; }
  .app.show-conv .side { display: none; }
  .app.show-conv .conv { display: flex; }
  .back { display: inline-block; }
  .bubble { max-width: 88%; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .pf { grid-template-columns: minmax(0, 1fr) auto; }
  .pf-number { grid-column: 1 / -1; }
  .auth-card { padding: 20px; }
}
