/* ==========================================================================
   VerifyUniverse — dashboard + admin app shell
   Builds on styles.css tokens (paper, ink, violet/coral/mint, Geist + Instrument Serif)
   ========================================================================== */

[hidden] { display: none !important; }
.app-body { background: var(--paper); min-height: 100vh; }
.app-body::before {
  content: ""; position: fixed; inset: -20% -10% auto auto; width: 720px; height: 720px; z-index: 0; pointer-events: none;
  background: radial-gradient(closest-side, rgba(124,108,240,.10), transparent 70%),
              radial-gradient(closest-side at 70% 60%, rgba(240,122,138,.07), transparent 70%);
  filter: blur(8px);
}

/* ---------- Top bar ---------- */
.app-top {
  position: sticky; top: 0; z-index: 40; height: 64px;
  display: flex; align-items: center; gap: var(--s2); padding: 0 var(--s3);
  background: rgba(251, 248, 255, .82); backdrop-filter: saturate(140%) blur(14px); -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.app-top .brand { margin-right: auto; }
.app-top .brand small { font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--violet); background: var(--violet-soft); border-radius: 999px; padding: 3px 8px; margin-left: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 500;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.chip:hover { border-color: var(--violet); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 3px rgba(77,182,160,.18); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--violet), var(--coral)); color: #fff; font-weight: 600; font-size: 14px;
}
.top-user { display: flex; align-items: center; gap: 10px; }
.top-user .meta { display: none; line-height: 1.2; }
.top-user .meta strong { display: block; font-size: 13px; font-weight: 500; color: var(--ink); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-user .meta span { font-size: 12px; color: var(--muted); }
@media (min-width: 900px) { .top-user .meta { display: block; } }

/* ---------- Shell ---------- */
.app-shell { position: relative; z-index: 1; display: grid; grid-template-columns: 1fr; min-height: calc(100vh - 64px); }
@media (min-width: 900px) { .app-shell { grid-template-columns: 240px 1fr; } }

.app-side { border-right: 1px solid var(--line); padding: var(--s3) var(--s2); display: none; }
@media (min-width: 900px) { .app-side { display: flex; flex-direction: column; position: sticky; top: 64px; height: calc(100vh - 64px); } }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-label { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); padding: var(--s2) 12px 6px; }
.side-nav a, .tab-nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px;
  font-size: 14px; color: var(--ink-2); transition: background-color .15s ease, color .15s ease;
}
.side-nav a svg, .tab-nav a svg { width: 18px; height: 18px; flex: none; color: var(--faint); transition: color .15s ease; }
.side-nav a:hover { background: rgba(124,108,240,.06); color: var(--ink); }
.side-nav a[aria-current="page"] { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: 0 0 0 1px var(--line), 0 6px 16px -10px rgba(92,79,224,.35); }
.side-nav a[aria-current="page"] svg { color: var(--accent); }
.side-nav .badge, .tab-nav .badge { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--accent); background: var(--violet-soft); border-radius: 999px; padding: 1px 8px; }
.side-foot { margin-top: auto; padding: var(--s2) 12px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); }
.side-foot a { color: var(--accent); }

/* Mobile tabs */
.tab-nav {
  display: flex; gap: 4px; overflow-x: auto; padding: 8px var(--s2); border-bottom: 1px solid var(--line);
  position: sticky; top: 64px; z-index: 30; background: rgba(251,248,255,.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  scrollbar-width: none;
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab-nav a { flex: none; padding: 8px 12px; gap: 8px; white-space: nowrap; }
.tab-nav a[aria-current="page"] { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: 0 0 0 1px var(--line); }
.tab-nav a[aria-current="page"] svg { color: var(--accent); }
@media (min-width: 900px) { .tab-nav { display: none; } }

.app-main { padding: var(--s4) var(--s3) var(--s10); min-width: 0; }
@media (min-width: 900px) { .app-main { padding: var(--s5) var(--s6) var(--s12); } }
.view { max-width: 1040px; animation: viewIn .28s ease both; }
.view[hidden] { display: none; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s4); }
.view-head h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(34px, 4vw, 46px); line-height: 1.05; letter-spacing: -0.015em; }
.view-head h1 em { background: linear-gradient(120deg, var(--violet), var(--coral) 60%, var(--sky)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.view-head p { color: var(--muted); margin-top: 6px; max-width: 46ch; }

/* ---------- Cards / grids ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: var(--s3); }
@media (min-width: 600px) { .card { padding: var(--s4); } }
.card + .card, .grid + .card, .card + .grid, .notice + .grid, .notice + .card, .grid + .grid { margin-top: var(--s3); }
.grid > .card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s3); }
.card-head h2 { font-size: 17px; font-weight: 500; letter-spacing: -0.01em; }
.card-head p { color: var(--muted); font-size: 14px; }
.grid { display: grid; gap: var(--s3); }
.grid-2 { grid-template-columns: 1fr; }
.grid-3, .grid-4 { grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1000px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } .grid-4 { grid-template-columns: repeat(4, 1fr); } }

.stat { position: relative; overflow: hidden; }
.stat-k { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.stat-v { font-size: 32px; font-weight: 500; color: var(--ink); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 6px; line-height: 1.1; }
.stat-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.stat-hero { background: linear-gradient(140deg, #1A1633 0%, #2B2360 60%, #4B3FB8 100%); border-color: transparent; color: #fff; }
.stat-hero .stat-k { color: rgba(221, 214, 254, .8); }
.stat-hero .stat-v { color: #fff; font-size: 40px; }
.stat-hero .stat-sub { color: rgba(255,255,255,.66); }
.stat-hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 200px; height: 200px; border-radius: 50%; border: 1px solid rgba(255,255,255,.14); box-shadow: 0 0 0 30px rgba(255,255,255,.03), 0 0 0 60px rgba(255,255,255,.02); }

.notice {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px;
  background: linear-gradient(90deg, var(--violet-soft), rgba(253,232,236,.7)); border: 1px solid rgba(124,108,240,.18);
  color: var(--ink-2); font-size: 14px; margin-bottom: var(--s3);
}
.notice svg { width: 18px; height: 18px; flex: none; color: var(--accent); margin-top: 2px; }
.notice strong { color: var(--ink); font-weight: 500; }
.notice-warn { background: #FFF8EB; border-color: rgba(220,150,40,.3); }
.notice-warn svg { color: #B26A00; }

/* ---------- Pills ---------- */
.status { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .02em; padding: 3px 9px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; text-transform: capitalize; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .75; }
.s-active, .s-answered, .s-credit, .s-topup, .s-refund, .s-release, .s-admin { background: var(--mint-soft); color: #2F8A76; border-color: rgba(77,182,160,.22); }
.s-open, .s-pending, .s-provisioning, .s-hold, .s-user { background: var(--violet-soft); color: #5B4FE0; border-color: rgba(124,108,240,.2); }
.s-expiring { background: #FFF4E0; color: #B26A00; border-color: rgba(220,150,40,.25); }
.s-grace { background: #FFEDE3; color: #C2531B; border-color: rgba(230,110,50,.25); }
.s-closed, .s-expired, .s-released, .s-cancelled, .s-capture, .s-debit, .s-inactive { background: var(--paper-2); color: var(--muted); border-color: var(--line); }
.s-failed, .s-suspended, .s-urgent, .s-high { background: var(--coral-soft); color: #C94F62; border-color: rgba(240,122,138,.25); }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; margin: 0 calc(var(--s3) * -1); padding: 0 var(--s3); }
@media (min-width: 600px) { .tbl-wrap { margin: 0 calc(var(--s4) * -1); padding: 0 var(--s4); } }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 0 12px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 14px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--ink-2); }
.tbl th:first-child, .tbl td:first-child { padding-left: 0; }
.tbl th:last-child, .tbl td:last-child { padding-right: 0; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl .pos { color: #2F8A76; }
.tbl .neg { color: var(--ink); }
.tbl .muted { color: var(--muted); font-size: 13px; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: rgba(124,108,240,.04); }
.mono { font-family: var(--mono); font-size: 13px; }
.trunc { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Empty states ---------- */
.empty { text-align: center; padding: var(--s6) var(--s3); }
.empty-icon { width: 64px; height: 64px; margin: 0 auto var(--s2); border-radius: 20px; display: grid; place-items: center; background: linear-gradient(135deg, var(--violet-soft), var(--coral-soft)); color: var(--accent); }
.empty-icon svg { width: 28px; height: 28px; }
.empty h3 { font-family: var(--serif); font-weight: 400; font-size: 26px; color: var(--ink); margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 40ch; margin: 0 auto var(--s3); font-size: 15px; }

/* ---------- Buy / plans ---------- */
.seg-tabs { display: inline-flex; padding: 4px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; gap: 2px; }
.seg-tabs button { border: 0; background: transparent; font: inherit; font-size: 14px; color: var(--muted); padding: 8px 16px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.seg-tabs button .cc { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.seg-tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: 0 1px 2px rgba(26,22,51,.06), 0 0 0 1px var(--line); }
.plan-grid { display: grid; gap: var(--s2); grid-template-columns: 1fr; margin-top: var(--s3); }
@media (min-width: 640px) { .plan-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1100px) { .plan-grid { grid-template-columns: repeat(4, 1fr); } }
.plan { position: relative; display: flex; flex-direction: column; gap: 6px; padding: var(--s3); border-radius: 18px; border: 1px solid var(--line); background: var(--surface); transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease; }
.plan:hover { border-color: rgba(124,108,240,.4); transform: translateY(-2px); box-shadow: var(--shadow); }
.plan-term { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--violet); }
.plan-price { font-size: 30px; font-weight: 500; color: var(--ink); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.plan-per { font-size: 13px; color: var(--muted); min-height: 20px; }
.plan-caps { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 var(--s2); }
.plan-caps span { font-family: var(--mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); border: 1px solid var(--line-2); border-radius: 999px; padding: 2px 8px; }
.plan .btn { margin-top: auto; }
.plan-best { position: absolute; top: 14px; right: 14px; font-family: var(--mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: #fff; background: linear-gradient(135deg, #6B5FF0, #F07A8A); border-radius: 999px; padding: 3px 8px; }
.btn-soon { background: var(--paper-2); color: var(--muted); border-color: var(--line); cursor: not-allowed; }
.btn-soon:hover { color: var(--muted); border-color: var(--line); }

/* ---------- Forms (compact) ---------- */
.form-grid { display: grid; gap: 0 var(--s2); grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-grid.two { grid-template-columns: 1fr 1fr; } }
.field textarea {
  width: 100%; min-height: 120px; resize: vertical; padding: 12px 14px; font: inherit; font-size: 15px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px; transition: border-color .2s ease, box-shadow .2s ease;
}
.field textarea:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 4px rgba(124,108,240,.14); }
.field .hint { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); }
.form-ok { margin-bottom: var(--s3); padding: 12px 14px; border-radius: 12px; border: 1px solid rgba(77,182,160,.3); background: var(--mint-soft); color: #22715F; font-size: 14px; }
.form-ok[hidden] { display: none !important; }
.inline-input { height: 36px; width: 110px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 10px; font: inherit; font-size: 14px; font-variant-numeric: tabular-nums; background: var(--surface); color: var(--ink); }
.inline-input:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(124,108,240,.14); }
.search { height: 40px; min-width: 240px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 999px; font: inherit; font-size: 14px; background: var(--surface); }
.search:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 4px rgba(124,108,240,.12); }
.amounts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: var(--s2); }
.amounts button { height: 44px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); font: inherit; font-weight: 500; color: var(--muted); cursor: not-allowed; }
.coins { display: flex; gap: 6px; flex-wrap: wrap; margin-top: var(--s2); }
.coins span { font-family: var(--mono); font-size: 11px; color: var(--muted); border: 1px dashed var(--line-2); border-radius: 999px; padding: 3px 10px; }

/* ---------- Tickets ---------- */
.ticket-row { display: grid; grid-template-columns: 1fr auto; gap: 4px var(--s2); padding: 14px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.ticket-row:last-child { border-bottom: 0; }
.ticket-row:hover .ticket-subj { color: var(--accent); }
.ticket-subj { font-weight: 500; color: var(--ink); transition: color .15s ease; }
.ticket-meta { font-size: 13px; color: var(--muted); grid-column: 1 / -1; }
.thread { display: flex; flex-direction: column; gap: 12px; margin: var(--s3) 0; }
.msg { max-width: 86%; padding: 12px 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); white-space: pre-wrap; word-wrap: break-word; font-size: 15px; }
.msg-user { align-self: flex-end; background: var(--violet-soft); border-color: rgba(124,108,240,.2); border-bottom-right-radius: 6px; }
.msg-admin { align-self: flex-start; border-bottom-left-radius: 6px; }
.msg-meta { display: block; font-family: var(--mono); font-size: 11px; color: var(--muted); margin-bottom: 4px; white-space: normal; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; margin-bottom: var(--s2); cursor: pointer; background: none; border: 0; padding: 0; font: inherit; }
.back-link:hover { color: var(--accent); }

/* ---------- Definition rows ---------- */
.kv { margin: 0; }
.kv > div { display: grid; grid-template-columns: 140px 1fr; gap: var(--s2); padding: 12px 0; border-top: 1px solid var(--line); font-size: 14px; }
.kv > div:first-child { border-top: 0; padding-top: 0; }
.kv dt { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--violet); padding-top: 2px; }
.kv dd { margin: 0; color: var(--ink); word-break: break-all; }

/* ---------- Skeleton / toast / modal ---------- */
.sk { display: block; height: 14px; border-radius: 8px; background: linear-gradient(90deg, var(--paper-2) 0%, #fff 50%, var(--paper-2) 100%); background-size: 200% 100%; animation: sk 1.4s ease infinite; }
.sk + .sk { margin-top: 10px; }
.sk-lg { height: 34px; width: 60%; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.toasts { position: fixed; z-index: 100; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; background: var(--ink); color: #fff; font-size: 14px; padding: 10px 16px; border-radius: 999px; box-shadow: 0 12px 32px -12px rgba(26,22,51,.5); animation: toastIn .25s ease both; }
.toast.err { background: #B42318; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: var(--s2); background: rgba(26,22,51,.35); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal[hidden] { display: none; }
.modal .card { width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow: auto; animation: viewIn .2s ease both; }

.app-loading { display: grid; place-items: center; min-height: 60vh; color: var(--muted); }
.spinner-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--violet); animation: pulse 1s ease infinite; }
@keyframes pulse { 0%,100% { opacity: .3; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.margin-neg { color: #C94F62; font-weight: 500; }
.margin-pos { color: #2F8A76; }

@media (prefers-reduced-motion: reduce) {
  .view, .toast, .modal .card { animation: none; }
  .sk, .spinner-dot { animation: none; }
  .plan:hover { transform: none; }
}

/* ---------- Responsive refinements ---------- */
.grid-4 { grid-template-columns: 1fr 1fr; }
.grid-4 > .stat-hero { grid-column: 1 / -1; }
@media (min-width: 1000px) { .grid-4 { grid-template-columns: repeat(4, 1fr); } .grid-4 > .stat-hero { grid-column: auto; } }
@media (max-width: 639px) {
  .grid-4 .stat-v { font-size: 26px; }
  .grid-4 .card { padding: var(--s2) var(--s3); }
  .hide-sm { display: none; }
  .tbl td, .tbl th { padding-left: 8px; padding-right: 8px; }
}
.tbl td.mono, .tbl td.nowrap { white-space: nowrap; }
.tbl .inline-input { width: 92px; }
.tbl .notes { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.checklist li { position: relative; padding-left: 28px; font-size: 14px; color: var(--ink-2); }
.checklist li::before { content: ""; position: absolute; left: 0; top: 2px; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--line-2); }
.checklist li.done { color: var(--muted); text-decoration: line-through; }
.checklist li.done::before { background: var(--mint); border-color: var(--mint); }

/* ---------- Voice calls (inbox + admin) ---------- */
.s-otp_confirmed, .s-completed { background: var(--mint-soft); color: #2F8A76; border-color: rgba(77,182,160,.22); }
.s-otp_likely { background: var(--violet-soft); color: #5B4FE0; border-color: rgba(124,108,240,.2); }
.s-otp_uncertain, .s-max_duration { background: #FFF4E0; color: #B26A00; border-color: rgba(220,150,40,.25); }
.s-no_audio { background: var(--paper-2); color: var(--muted); border-color: var(--line); }
.inbox-sec { margin: 0 0 var(--s2); }
.inbox-sec + .call-card, .inbox-sec + .ticket-row { margin-top: 0; }
.call-card + .inbox-sec, .ticket-row + .inbox-sec { margin-top: var(--s4); }
.inbox-sec h2 { font-size: 20px; margin: 0; }
.inbox-sec p { margin: 2px 0 0; font-size: 13px; }
.call-card { border: 1px solid var(--line); border-radius: 16px; padding: var(--s2) var(--s3); background: var(--surface); }
.call-card + .call-card { margin-top: var(--s2); }
.call-head { display: flex; align-items: center; gap: 12px; }
.call-ic { width: 36px; height: 36px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--violet-soft); color: var(--accent); }
.call-ic svg { width: 18px; height: 18px; }
.call-who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.call-who strong { font-size: 14px; font-weight: 500; color: var(--ink); }
.call-who .muted { font-size: 13px; }
.call-otp { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: var(--s2); }
.call-otp-code { font-size: 28px; letter-spacing: .14em; color: var(--ink); font-weight: 500; }
.call-otp-none { font-size: 14px; }
.call-keys { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 12px; font-size: 13px; }
.call-keys .muted { margin-right: 4px; }
.key-chip { min-width: 26px; height: 26px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); background: var(--paper-2); color: var(--ink); }
.call-tx { margin-top: 12px; font-size: 14px; }
.call-tx summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.call-tx p { margin: 8px 0 0; color: var(--ink-2); white-space: pre-wrap; line-height: 1.6; }
.call-rec { margin-top: 12px; }
.call-audio { width: 100%; max-width: 420px; margin-top: 12px; height: 40px; }
.call-admin { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 13px; color: var(--muted); display: grid; gap: 4px; }
.call-admin code { font-family: var(--mono); font-size: 12px; color: var(--ink-2); word-break: break-all; }
@media (max-width: 640px) { .call-card { padding: var(--s2); } .call-otp-code { font-size: 24px; } }

/* ---------- v15: realtime inbox, OTP toast, inventory, API settings ---------- */
.s-live, .s-in_progress { background: #FDECEC; color: #C2362B; border-color: rgba(194,54,43,.22); }
.s-live::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; animation: livePulse 1.2s ease-in-out infinite; }
@keyframes livePulse { 50% { opacity: .25; } }
.call-card.is-live { border-color: rgba(194,54,43,.35); }
.call-card.flash { animation: cardFlash 2.4s ease; }
@keyframes cardFlash { 0%, 30% { box-shadow: 0 0 0 3px rgba(124,108,240,.45); background: var(--violet-soft); } 100% { box-shadow: none; } }
.call-rec { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; margin-top: var(--s2); font-size: 13px; }
.sms-body { margin: var(--s1) 0 0; white-space: pre-wrap; word-break: break-word; font-size: 14px; }
#otp-toasts { position: fixed; z-index: 120; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; max-width: calc(100vw - 40px); }
.otp-toast { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 12px 12px 16px;
  box-shadow: 0 18px 44px -18px rgba(26,22,51,.45); animation: toastIn .25s ease both; transition: opacity .35s, transform .35s; }
.otp-toast.out { opacity: 0; transform: translateY(8px); }
.otp-toast > div { display: flex; flex-direction: column; min-width: 0; }
.otp-toast .muted { font-size: 12px; }
.otp-toast strong { font-size: 24px; letter-spacing: 3px; color: var(--ink); }
.otp-toast-x { border: 0; background: none; font-size: 20px; line-height: 1; color: var(--muted, #6B6785); cursor: pointer; padding: 4px 6px; }
.rt-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted, #6B6785); }
.rt-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #C9C6D9; }
.rt-dot.on::before { background: #2F8A76; }
.feed-filters { display: flex; gap: var(--s1); flex-wrap: wrap; align-items: center; }
.feed-filters select, .feed-filters input { height: 38px; border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; background: var(--surface); font: inherit; font-size: 14px; }
.match { font-size: 12px; font-weight: 500; }
.match.yes { color: #2F8A76; }
.match.no { color: #B26A00; }
.feed-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; margin-top: var(--s1); }
.key-reveal { display: flex; gap: var(--s1); align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--violet-soft); margin: var(--s2) 0; word-break: break-all; }
.key-reveal code { flex: 1; font-size: 13px; }

/* ==========================================================================
   v16 — fluid wide layout, app-like mobile shell (bottom tabs + More sheet),
   stacked tables, autopilot controls. Overrides earlier rules on purpose.
   ========================================================================== */
html { -webkit-text-size-adjust: 100%; }
body.app-body { overflow-x: clip; }
.app-main { padding: var(--s3) clamp(16px, 2.6vw, 48px) var(--s10); }
@media (min-width: 900px) { .app-main { padding: var(--s5) clamp(24px, 2.8vw, 56px) var(--s12); } }
.view { max-width: 1560px; margin: 0 auto; }
@media (min-width: 1700px) { .app-shell { grid-template-columns: 260px 1fr; } }
.view-head { align-items: flex-end; }
.view-head > div:first-child { min-width: 0; flex: 1 1 360px; }
.view-head p { max-width: 64ch; }
.view-head .feed-filters, .view-head > form, .view-head > .seg-tabs { margin-left: auto; }

/* One responsive stat row everywhere (no orphan cards on wide screens) */
.grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 1100px) { .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
.grid-4 > .stat-hero { grid-column: auto; }
.stat-grid .card.stat { padding: var(--s2) var(--s3); }
.stat-grid .stat-v { font-size: 28px; }
@media (min-width: 1280px) { .grid-2.wide-3 { grid-template-columns: repeat(3, 1fr); } }

/* Feed: cards flow into columns on wide screens and use the full width */
.feed-grid { display: grid; gap: var(--s2); grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); align-items: start; }
.feed-grid > .call-card { margin-top: 0 !important; height: 100%; }
.feed-grid > .empty, .feed-grid > .form-alert, .feed-grid > .feed-span { grid-column: 1 / -1; }
.grid + .feed-grid, .stat-grid + .feed-grid, .feed-grid + .card { margin-top: var(--s3); }
.feed-grid > .empty { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.call-card { box-shadow: var(--shadow); }
.handled { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper-2); color: var(--ink-2); white-space: nowrap; }
.handled.agent { background: #EAF4FF; color: #1F5FAD; border-color: rgba(31,95,173,.22); }
.handled.missed { background: #FFF0F2; color: #B23A4E; border-color: rgba(201,79,98,.22); }
.call-card.is-missed { background: linear-gradient(180deg, #FFFBFC, var(--surface)); }
.ap-notes { margin: var(--s3) 0 0; padding: 0 0 0 18px; color: var(--muted); font-size: 14px; display: grid; gap: 6px; }
.ap-notes strong { color: var(--ink); font-weight: 500; }

/* Autopilot */
.ap-hero { display: grid; gap: var(--s3); grid-template-columns: 1fr; }
@media (min-width: 1100px) { .ap-hero { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); } }
.ap-switch { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.switch { position: relative; width: 64px; height: 36px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line-2); transition: background .2s ease; }
.switch span::after { content: ""; position: absolute; top: 4px; left: 4px; width: 28px; height: 28px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(26,22,51,.25); transition: transform .2s ease; }
.switch input:checked + span { background: linear-gradient(135deg, #6B5FF0, #8C7CF5); }
.switch input:checked + span::after { transform: translateX(28px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 4px rgba(124,108,240,.25); }
.ap-state { font-size: 22px; font-weight: 500; color: var(--ink); }
.ap-state small { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }
.ap-form { display: grid; gap: var(--s2); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-top: var(--s3); align-items: end; }
.ap-form .field { margin: 0; }
.ap-form select, .ap-form input { width: 100%; height: 44px; border: 1px solid var(--line-2); border-radius: 12px; padding: 0 12px; font: inherit; background: var(--surface); }
.dot-state { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.dot-state::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #C9C6D9; }
.dot-state.ok::before { background: #2F8A76; box-shadow: 0 0 0 4px rgba(47,138,118,.15); }
.dot-state.bad::before { background: #C94F62; box-shadow: 0 0 0 4px rgba(201,79,98,.12); }
.ap-pill { margin-left: 8px; }
.num-ap { height: 36px; border: 1px solid var(--line-2); border-radius: 10px; padding: 0 8px; font: inherit; font-size: 13px; background: var(--surface); }

/* ---------- Mobile app shell (< 900px) ---------- */
.more-sheet { display: none; }
@media (max-width: 899px) {
  .app-top { height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); gap: 10px; }
  .app-top .btn-ghost { display: none; }
  .app-top .chip { height: 34px; padding: 0 12px; }
  .app-top .brand span { font-size: 16px; }
  .app-shell { min-height: calc(100vh - 56px); }
  body.app-body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .tab-nav {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 60; overflow: visible;
    display: grid; grid-template-columns: repeat(var(--tabs, 5), 1fr); gap: 0;
    padding: 6px max(6px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-right));
    background: rgba(251,248,255,.94); border-top: 1px solid var(--line); border-bottom: 0;
    backdrop-filter: saturate(160%) blur(16px); -webkit-backdrop-filter: saturate(160%) blur(16px);
    box-shadow: 0 -10px 30px -22px rgba(26,22,51,.35);
  }
  .tab-nav a, .tab-nav button.tab-more {
    flex-direction: column; justify-content: center; gap: 3px; min-height: 52px; padding: 4px 2px; border-radius: 14px;
    font-size: 11px; font-weight: 500; color: var(--muted); position: relative; background: none; border: 0; font-family: inherit; cursor: pointer;
  }
  .tab-nav a svg, .tab-nav button.tab-more svg { width: 22px; height: 22px; color: currentColor; }
  .tab-nav a span:not(.badge) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab-nav a[aria-current="page"], .tab-nav button.tab-more[aria-expanded="true"], .tab-nav button.tab-more.cur { color: var(--accent); background: var(--violet-soft); box-shadow: none; }
  .tab-nav a[aria-current="page"] svg { color: var(--accent); }
  .tab-nav .badge { position: absolute; top: 2px; right: calc(50% - 22px); margin: 0; padding: 0 5px; min-width: 16px; font-size: 10px; line-height: 16px; background: var(--accent); color: #fff; }
  .more-sheet { display: block; position: fixed; inset: 0; z-index: 70; pointer-events: none; }
  .more-sheet .sheet-bg { position: absolute; inset: 0; background: rgba(26,22,51,.32); opacity: 0; transition: opacity .2s ease; }
  .more-sheet .sheet { position: absolute; left: 8px; right: 8px; bottom: calc(76px + env(safe-area-inset-bottom)); background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 10px; box-shadow: 0 24px 60px -20px rgba(26,22,51,.45); transform: translateY(16px); opacity: 0; transition: transform .2s ease, opacity .2s ease; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .more-sheet .sheet a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 76px; border-radius: 16px; font-size: 13px; color: var(--ink-2); text-align: center; padding: 8px 4px; }
  .more-sheet .sheet a svg { width: 24px; height: 24px; color: var(--accent); }
  .more-sheet .sheet a[aria-current="page"] { background: var(--violet-soft); color: var(--ink); font-weight: 500; }
  .more-sheet .sheet .badge { font-family: var(--mono); font-size: 11px; color: var(--accent); background: var(--violet-soft); border-radius: 999px; padding: 1px 8px; }
  .more-sheet.open { pointer-events: auto; }
  .more-sheet.open .sheet-bg { opacity: 1; }
  .more-sheet.open .sheet { transform: none; opacity: 1; }

  .app-main { padding: var(--s3) 14px var(--s5); }
  .view-head { margin-bottom: var(--s3); gap: 12px; }
  .view-head h1 { font-size: 32px; }
  .view-head .feed-filters, .view-head > form, .view-head > .seg-tabs { margin-left: 0; width: 100%; }
  .feed-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .feed-filters input[type="search"], .feed-filters .btn { grid-column: 1 / -1; }
  .feed-filters select, .feed-filters input, .search { width: 100%; min-width: 0; height: 44px; font-size: 16px; }
  .seg-tabs { display: flex; overflow-x: auto; scrollbar-width: none; }
  .seg-tabs button { flex: 1 0 auto; min-height: 40px; }
  .card { border-radius: 18px; padding: var(--s2); }
  .btn { min-height: 44px; }
  .btn-sm { min-height: 40px; padding-left: 14px; padding-right: 14px; }
  .field input, .field select, .field textarea, .inline-input, .num-ap { font-size: 16px; min-height: 44px; }
  .row-actions { justify-content: flex-start; }
  .toasts { bottom: calc(84px + env(safe-area-inset-bottom)); }
  #otp-toasts { right: 10px; left: 10px; bottom: calc(84px + env(safe-area-inset-bottom)); max-width: none; }
  .modal { align-items: end; padding: 0; }
  .modal .card { max-width: none; border-radius: 22px 22px 0 0; padding-bottom: calc(var(--s3) + env(safe-area-inset-bottom)); max-height: 88vh; }
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stat-grid .card.stat { padding: 10px 12px; border-radius: 14px; }
  .stat-grid .stat-k { font-size: 9px; letter-spacing: .06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .stat-grid .stat-v { font-size: 20px !important; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .grid-4 > .stat-hero { grid-column: 1 / -1; }
  .grid-4 .card.stat, .stat-grid .card.stat { padding: 14px 16px; }
  .grid-4 .stat-v, .stat-grid .stat-v { font-size: 24px; }
  .grid { gap: 12px; }
  .card + .card, .grid + .card, .card + .grid, .grid + .grid, .notice + .grid, .notice + .card, .grid + .feed-grid, .stat-grid + .feed-grid { margin-top: 12px; }
  .grid > .card, .grid > .card + .card { margin-top: 0; }
  .grid-4 > .stat-hero:first-child ~ .card:last-child:nth-child(even) { grid-column: 1 / -1; }
  .call-head { flex-wrap: wrap; align-items: flex-start; }
  .call-head .call-who { flex: 1 1 calc(100% - 60px); }
  .call-head > .handled, .call-head > .status { order: 3; margin-left: 48px; }
  .call-who .muted { font-size: 12.5px; }
  .feed-grid { gap: 12px; }
  .call-otp-code { font-size: 26px; }
  .kv > div { grid-template-columns: 1fr; gap: 2px; }
  .card .tbl-wrap { margin: 0 calc(var(--s2) * -1); padding: 0 var(--s2); }
  .msg { max-width: 94%; }
}
/* Stacked "table cards" on phones: every row becomes a card, header text becomes the label */
@media (max-width: 719px) {
  .tbl-wrap, .card .tbl-wrap { overflow: visible; margin: 0; padding: 0; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl thead { display: none; }
  .tbl tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .tbl tr:last-child { border-bottom: 0; }
  .tbl td, .tbl td:first-child, .tbl td:last-child { border: 0; padding: 4px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; white-space: normal; }
  .tbl td.num { text-align: right; }
  .tbl td::before { content: attr(data-label); font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-align: left; flex: none; }
  .tbl td[data-label=""]::before, .tbl td:not([data-label])::before { content: none; }
  .tbl td:first-child { display: block; text-align: left; padding-bottom: 6px; }
  .tbl td:first-child::before { content: none; }
  .tbl td > div, .tbl td .trunc { max-width: 100%; }
  .tbl .trunc { white-space: normal; word-break: break-word; }
  .tbl td .row-actions { justify-content: flex-start; width: 100%; }
  .tbl td:has(.row-actions) { display: block; padding-top: 8px; }
  .tbl td:has(.row-actions)::before { content: none; }
  .tbl .inline-input { width: 120px; }
  .tbl .notes { max-width: 100%; white-space: normal; }
}
@media (display-mode: standalone) { .app-top { padding-top: env(safe-area-inset-top); } }
.feed-grid > .inbox-sec { margin: 0; }
.ap-hero > .card, .ap-hero > .card + .card { margin-top: 0; }
.ap-hero .kv dd { word-break: normal; overflow-wrap: anywhere; }
.ap-hero .kv > div { grid-template-columns: 150px 1fr; }
@media (max-width: 899px) { .ap-hero .kv > div { grid-template-columns: 1fr; } .ap-state { font-size: 19px; } }
.ap-switch { flex-wrap: nowrap; align-items: flex-start; } .ap-state { flex: 1; min-width: 0; }
.more-sheet .sheet a[hidden] { display: none; }
.dot-state.warn::before { background: #D99A2B; box-shadow: 0 0 0 4px rgba(217,154,43,.15); }
