/* SMSLoud design system — extracted from the design mockup (Bulk SMS Dashboard).
   Aesthetic: warm off-white "banking dashboard", Inter + IBM Plex Mono, navy accent. */

:root {
  --bg:            #F7F6F1;
  --panel:         #FFFFFF;
  --panel-subtle:  #F3F1EA;
  --border:        #E5E2DA;
  --border-soft:   #EFEDE4;
  --ink:           #17140F;
  --ink-2:         #3A362E;
  --muted:         #8B8579;
  --muted-2:       #A39C8E;
  --brand:         #001f3f;
  --brand-tint:    #E6EDF5;
  --brand-tint-2:  #003366;

  --ok:            #15803D;  --ok-bg:    #DCFCE7;
  --warn:          #B45309;  --warn-bg:  #FEF3C7;
  --err:           #B91C1C;  --err-bg:   #FEE2E2;
  --neutral:       #64748B;  --neutral-bg:#F1F5F9;

  --radius:        10px;
  --radius-sm:     8px;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;

  /* Theme-contract tokens (modern_ui.md §2.5). Classic values; themes override. */
  --surface:       var(--panel-subtle);   /* subtle chip/box background */
  --surface-2:     var(--panel-subtle);
  --ink-1:         var(--ink);            /* emphasis text (between ink and ink-2) */
  --on-brand:      #ffffff;               /* text/icon color on brand/ink-filled surfaces */
  --border-strong: #D8D3C6;               /* dashed dropzones, scrollbar thumb */
  --accent:        var(--brand);          /* secondary accent; themes may diverge */
  --shadow-card:   none;                  /* classic structures with borders, not shadows */
  --shadow-pop:    none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.mono { font-family: var(--mono); }

/* ---------- App shell ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: 64px; flex-shrink: 0; background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; gap: 20px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--brand); }
.brand-logo { height: 26px; width: auto; max-width: 150px; object-fit: contain; display: block; }
.brand-name { font-weight: 800; font-size: 15.5px; letter-spacing: -0.2px; }
.pill {
  border: 1px solid var(--border); border-radius: 6px; padding: 3px 9px;
  font-size: 10px; font-weight: 700; color: var(--muted);
  letter-spacing: 0.6px; font-family: var(--mono);
}
.ws-chip {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 14px 4px 5px;
}
.ws-avatar {
  width: 22px; height: 22px; border-radius: 6px; background: var(--brand);
  color: var(--on-brand); font-size: 11px; font-weight: 800; font-family: var(--mono);
  display: flex; align-items: center; justify-content: center;
}
.ws-name { font-size: 12.5px; font-weight: 600; }
.ws-env  { font-size: 11px; color: var(--muted-2); font-family: var(--mono); }
.balance-chip { display: flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: 11.5px; }
.balance-chip .lbl { color: var(--muted-2); font-weight: 700; letter-spacing: 0.5px; }
.balance-chip .val { font-weight: 700; }
.link-brand { color: var(--brand); font-weight: 700; font-size: 12px; cursor: pointer; }
.divider-v { width: 1px; height: 20px; background: var(--border); }
.user-dot {
  width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--on-brand);
  font-size: 11px; font-weight: 700; font-family: var(--mono);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.shell-row { display: flex; flex: 1; min-height: 0; }

.sidebar {
  width: 232px; flex-shrink: 0; background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto;
  position: sticky; top: 64px; height: calc(100vh - 64px);
}
.sidebar-inner { flex: 1; padding: 16px 12px; }
.nav-group-label {
  color: var(--muted-2); font-size: 11px; font-weight: 700; letter-spacing: 0.7px;
  text-transform: uppercase; padding: 14px 10px 6px; font-family: var(--mono);
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; margin-bottom: 2px;
  border-radius: 7px; cursor: pointer; color: var(--ink-2); font-size: 14px; font-weight: 500;
}
.nav-item:hover { background: var(--panel-subtle); }
.nav-item.active { background: var(--ink); color: var(--on-brand); font-weight: 700; }
.nav-item .ni { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.5; }
.nav-item.active .ni { opacity: 1; }
.nav-item.round .ni { }

.sidebar-balance { margin: 0 14px 16px; background: var(--panel-subtle); border-radius: var(--radius); padding: 16px; }
.sidebar-balance .lbl { color: var(--muted-2); font-size: 10px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; font-family: var(--mono); margin-bottom: 8px; }
.sidebar-balance .amt { font-size: 22px; font-weight: 800; font-family: var(--mono); margin-bottom: 10px; }
.meter { height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
.meter > span { display: block; height: 100%; background: var(--brand); }
.sidebar-balance .sub { font-size: 11px; color: var(--muted); font-family: var(--mono); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.impersonation-banner {
  background: var(--brand); color: var(--on-brand); font-size: 12.5px; font-weight: 600;
  padding: 8px 24px; display: flex; align-items: center; justify-content: center; gap: 10px;
}
.impersonation-banner a { text-decoration: underline; font-weight: 700; }
.page-titlebar {
  height: 52px; flex-shrink: 0; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 26px;
}
.page-titlebar .t { font-size: 15px; font-weight: 700; }
.page-body { flex: 1; min-width: 0; overflow-y: auto; overflow-x: auto; padding: 22px 26px 60px; }

/* ---------- Cards / panels ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 14px; font-weight: 700; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; border-radius: var(--radius-sm);
  padding: 9px 18px; font-size: 12.5px; font-weight: 700; cursor: pointer;
  border: 1px solid transparent; font-family: var(--sans);
}
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 86%, black); }
.btn-ghost { background: var(--panel); border-color: var(--border); color: var(--ink); font-weight: 600; }
.btn-ghost:hover { background: var(--panel-subtle); }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 5px 11px; font-size: 11.5px; }

/* ---------- Stat grid ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.stat-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.stat { padding: 18px 20px; border-right: 1px solid var(--border); }
.stat:last-child { border-right: none; }
.stat .lbl { font-size: 10.5px; font-weight: 700; letter-spacing: 0.5px; color: var(--muted); text-transform: uppercase; font-family: var(--mono); margin-bottom: 12px; }
.stat .val { font-size: 28px; font-weight: 800; font-family: var(--mono); margin-bottom: 8px; }
.stat .delta { font-size: 11.5px; font-weight: 600; font-family: var(--mono); color: var(--muted); }
.stat .delta.up { color: var(--ok); }
.stat .delta.down { color: var(--err); }

/* ---------- Tables ---------- */
table { border-collapse: collapse; width: 100%; }
.table thead tr { background: var(--panel-subtle); }
.table th {
  text-align: left; padding: 9px 18px; font-size: 10px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.4px; font-family: var(--mono);
  border-bottom: 1px solid var(--border);
}
.table th.r, .table td.r { text-align: right; }
.table td { padding: 9px 18px; border-bottom: 1px solid var(--border-soft); }
.table tbody tr:last-child td { border-bottom: none; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover { background: #FAF9F5; }

/* ---------- Status badges (3-color system) ---------- */
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 5px; }
.badge.ok      { background: var(--ok-bg);      color: var(--ok); }
.badge.warn    { background: var(--warn-bg);    color: var(--warn); }
.badge.err     { background: var(--err-bg);     color: var(--err); }
.badge.neutral { background: var(--neutral-bg); color: var(--neutral); }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.label { display: block; font-size: 11.5px; font-weight: 700; color: var(--ink-2); margin-bottom: 7px; }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 13px; color: var(--ink); font-family: var(--sans); background: #fff;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 12%, transparent); }
.textarea { min-height: 110px; resize: vertical; }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius-sm); padding: 10px 13px; font-size: 12.5px; line-height: 1.45; margin-bottom: 14px; border: 1px solid transparent; }
.alert.error   { background: var(--err-bg);  color: var(--err);  border-color: #FECACA; }
.alert.success { background: var(--ok-bg);   color: var(--ok);   border-color: #BBF7D0; }
.alert.warn    { background: var(--warn-bg); color: var(--warn); border-color: #FDE68A; }
.alert.info    { background: var(--brand-tint); color: var(--brand-tint-2); border-color: #B3C7DF; }

/* ---------- Auth screens ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 32px; box-shadow: 0 10px 40px rgba(23,20,15,0.06); }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.auth-title { font-size: 22px; font-weight: 800; letter-spacing: -0.4px; margin: 0 0 4px; }
.auth-sub { font-size: 13px; color: var(--muted); margin: 0 0 22px; }
.auth-foot { margin-top: 18px; font-size: 12.5px; color: var(--muted); text-align: center; }
.auth-foot a { color: var(--brand); font-weight: 700; }

/* ---------- Floating softphone (call center) ---------- */
.sp-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 90;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--brand); color: var(--on-brand); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--brand) 35%, transparent);
}
.sp-fab:hover { background: color-mix(in srgb, var(--brand) 86%, black); }
.sp-fab-panel {
  display: none; position: fixed; right: 22px; bottom: 84px; z-index: 90;
  width: 290px; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  box-shadow: 0 12px 34px color-mix(in srgb, var(--brand) 18%, transparent);
}
.sp-fab-panel.open { display: block; }

/* ---------- Utilities ---------- */
.muted { color: var(--muted); }
.hero-eyebrow { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.hero-eyebrow .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
.hero-eyebrow .txt { font-size: 11px; font-weight: 700; letter-spacing: 0.6px; color: var(--muted); font-family: var(--mono); text-transform: uppercase; }
.hero-title { font-size: 34px; font-weight: 800; letter-spacing: -0.8px; margin: 0 0 8px; }
.hero-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.grid-2 { display: grid; gap: 16px; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px; padding: 40px 20px; }
.empty-state .mark { width: 40px; height: 40px; border-radius: 10px; background: var(--brand-tint); }

/* ---------- Responsive — tablet (≤880px) ---------- */
@media (max-width: 880px) {
  .shell-row { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar-inner { display: flex; flex-wrap: nowrap; overflow-x: auto; padding: 8px 10px; gap: 2px; }
  .nav-group-label, .sidebar-balance { display: none; }
  .nav-item { white-space: nowrap; flex-shrink: 0; padding: 10px 12px; font-size: 13px; }
  .nav-item .ni { display: none; }
  .stat-grid, .stat-grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
  .hero-title { font-size: 24px; }
  .hero-row { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-body { padding: 16px 18px 40px; }
  .topbar { padding: 0 14px; }
  .topbar-left { gap: 10px; }
  .grid-2 { grid-template-columns: 1fr !important; }
  .card-pad { padding: 16px; }
  .table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table th, .table td { padding: 9px 12px; white-space: nowrap; }
  .stat { padding: 14px 16px; }
  .stat .val { font-size: 22px; }
  .btn-toolbar { flex-wrap: wrap; }
}

/* ---------- Responsive — phone (≤540px) ---------- */
@media (max-width: 540px) {
  .app { padding-bottom: 56px; } /* space for bottom nav */

  .topbar { height: 52px; padding: 0 10px; gap: 8px; }
  .brand-name { font-size: 14px; }
  .brand-mark { width: 22px; height: 22px; border-radius: 6px; }
  .brand-logo { height: 22px; max-width: 110px; }
  .ws-chip, .balance-chip, .link-brand, .divider-v, .pill { display: none; }
  .topbar-right { gap: 8px; }
  .user-dot { width: 26px; height: 26px; font-size: 10px; }

  /* Bottom tab bar — icons only */
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    width: 100%; height: 56px;
    flex-direction: row; border-right: none;
    border-bottom: none; border-top: 1px solid var(--border);
    background: var(--panel);
  }
  .sidebar-inner {
    display: flex; flex-direction: row; flex-wrap: nowrap;
    overflow-x: auto; padding: 2px 4px; gap: 0;
    width: 100%; justify-content: space-around;
  }
  .nav-item {
    flex-direction: column; align-items: center; justify-content: center;
    padding: 4px 10px; border-radius: 10px; gap: 0;
    min-width: 44px; flex: 0 1 auto;
  }
  .nav-item span { display: none; }
  .nav-item .ni { display: block; width: 22px; height: 22px; opacity: 0.45; flex-shrink: 0; }
  .nav-item.active .ni { opacity: 1; }
  .nav-item.active { background: transparent; color: var(--brand); }

  .page-body { padding: 12px 10px 24px; }
  .page-titlebar { height: 42px; padding: 0 12px; }
  .page-titlebar .t { font-size: 13px; }

  .hero-title { font-size: 20px; }
  .hero-eyebrow .txt { font-size: 9px; }

  .stat-grid, .stat-grid.cols-3 { grid-template-columns: 1fr 1fr; }
  .stat { padding: 10px 12px; }
  .stat .val { font-size: 18px; }
  .stat .lbl { font-size: 9px; margin-bottom: 6px; }
  .stat .delta { font-size: 10px; }

  .card-pad { padding: 12px; }
  .card-head { padding: 10px 12px; }

  .btn { padding: 10px 16px; font-size: 13px; min-height: 44px; }
  .btn-primary:hover { background: var(--brand); }

  .table th, .table td { padding: 7px 8px; font-size: 10px; }
  .table th { font-size: 8px; }

  .impersonation-banner { font-size: 10px; padding: 6px 10px; flex-direction: column; gap: 4px; text-align: center; }

  /* Keep the floating softphone clear of the bottom tab bar. */
  .sp-fab { right: 12px; bottom: 72px; }
  .sp-fab-panel { right: 12px; bottom: 132px; width: calc(100vw - 24px); }
}

/* ── Compose wizard (Typeform-style, one field per step) ───────────────────── */
.wizard { max-width: 600px; margin: 0 auto; padding-top: 8px; }
.wiz-progress { height: 5px; background: var(--border-soft); border-radius: 99px; overflow: hidden; }
.wiz-progress-bar { height: 100%; width: 20%; background: var(--brand); border-radius: 99px; transition: width .35s cubic-bezier(.4,0,.2,1); }
.wiz-meta { display: flex; justify-content: space-between; align-items: center; font-family: var(--mono); font-size: 11px; letter-spacing: .5px; text-transform: uppercase; color: var(--muted-2); margin: 10px 0 34px; }

/* No-JS: all steps stacked. With JS: one at a time. */
.js-wizard .wiz-step { display: none; }
.js-wizard .wiz-step.is-active { display: block; animation: wizIn .3s ease; }
.wiz-step + .wiz-step { margin-top: 40px; }
.js-wizard .wiz-step + .wiz-step { margin-top: 0; }
@keyframes wizIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.wiz-kicker { display: inline-flex; align-items: center; gap: 9px; font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--brand); margin-bottom: 14px; }
.wiz-dot { width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: var(--on-brand); display: inline-flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 700; }
.wiz-q { font-size: 29px; line-height: 1.18; font-weight: 800; letter-spacing: -0.6px; color: var(--ink); margin: 0 0 8px; }
.wiz-help { font-size: 14.5px; color: var(--muted); margin: 0 0 26px; line-height: 1.5; }

.wiz-field { margin: 0 0 4px; }
.wiz-field .label { display: block; font-size: 13px; margin-bottom: 8px; }
.wiz-field .input, .wiz-field .select, .wiz-field .textarea { width: 100%; font-size: 17px; padding: 14px 16px; border-radius: var(--radius); }
.wiz-field .textarea { line-height: 1.55; }
.wiz-sub { margin-top: 18px; }

.wiz-counter { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; font-size: 12.5px; }
.wiz-tally { margin-top: 16px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.wiz-err { margin-top: 14px; font-size: 13px; font-weight: 600; color: var(--err); }

.wiz-nav { display: flex; align-items: center; gap: 12px; margin-top: 34px; }
.wiz-nav .btn { font-size: 15px; padding: 12px 22px; }
.wiz-spacer { flex: 1; }

/* Review step */
.wiz-review { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-top: 4px; }
.wiz-review-row { display: flex; justify-content: space-between; gap: 16px; padding: 13px 16px; border-bottom: 1px solid var(--border-soft); font-size: 14px; cursor: pointer; transition: background .12s ease; }
.wiz-review-row:last-child { border-bottom: none; }
.wiz-review-row:hover { background: var(--surface); }
.wiz-review-row .k { color: var(--muted); font-weight: 500; flex-shrink: 0; }
.wiz-review-row .v { color: var(--ink); font-weight: 600; text-align: right; word-break: break-word; max-width: 74%; }
.wiz-review-row .v.msg { white-space: pre-wrap; font-weight: 500; line-height: 1.45; }
.wiz-cost { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 20px; padding: 16px 18px; background: var(--surface); border-radius: var(--radius); font-size: 13px; }
.wiz-cost .btn { font-size: 15px; padding: 12px 24px; }

@media (max-width: 560px) {
  .wiz-q { font-size: 24px; }
  .wiz-cost { flex-direction: column; align-items: stretch; }
  .wiz-cost .btn { width: 100%; }
}
