/* Manweta AI dashboard
   Palette: paper grey, ink, indigo for actions. WhatsApp green / read-tick blue are
   reserved for message states; brick red means overdue or failed. */

:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --ink: #131a22;
  --ink-2: #48525f;
  --ink-3: #788493;
  --line: #e2e6ec;
  --line-2: #eef1f5;

  --brand: #3b33c4;
  --brand-hover: #2f28a8;
  --brand-soft: #eceafb;

  --wa: #178a4a;
  --wa-soft: #e3f4ea;
  --read: #2575d8;
  --read-soft: #e4eefb;
  --warn: #9a5200;
  --warn-soft: #fcf0d9;
  --bad: #b3322a;
  --bad-soft: #fae8e5;

  --font-display: "Bricolage Grotesque", "IBM Plex Sans", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --r-ctl: 6px;
  --r-panel: 12px;
  --sidebar: 232px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; width: 100%; }
body {
  margin: 0;
  overflow-x: hidden;
  width: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--font-body);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em; margin: 0; line-height: 1.2; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0; }
a { color: var(--brand); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: var(--r-ctl); font-weight: 500; cursor: pointer; text-decoration: none;
  min-height: 38px;
}
.btn:hover { border-color: #c9d0da; background: #fafbfc; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: #efc4be; }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--line-2); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-weight: 500; margin-bottom: 4px; font-size: 14px; }
label.field > small { display: block; color: var(--ink-3); margin-top: 4px; font-size: 13px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=search], select {
  width: 100%; padding: 8px 10px; min-height: 38px; background: var(--surface);
  border: 1px solid #ccd3dc; border-radius: var(--r-ctl);
}
input:focus, select:focus { border-color: var(--brand); outline: 2px solid var(--brand-soft); outline-offset: 0; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 40px; height: 24px; border-radius: 99px; background: #c4cbd5; position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .track { background: var(--wa); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- layout shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.side {
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-family: var(--font-display); font-weight: 700; font-size: 19px; }
.brand img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12); }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-ctl);
  color: var(--ink-2); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--line-2); color: var(--ink); }
.nav a[aria-current=page] { background: var(--brand-soft); color: var(--brand); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .badge { margin-left: auto; }
.side .who { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); }
.side .who b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .who span { font-size: 13px; color: var(--ink-3); }
.main { padding: 32px 40px 64px; max-width: 1180px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { color: var(--ink-2); margin-top: 4px; max-width: 62ch; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); }
.panel + .panel, .panel + .section, .section + .panel { margin-top: 20px; }
.panel-head { padding: 16px 20px; border-bottom: 1px solid var(--line-2); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.panel-body { padding: 20px; }
.section + .section { margin-top: 28px; }
.section > h2 { margin-bottom: 12px; }

.notice { padding: 12px 14px; border-radius: 8px; border: 1px solid; font-size: 14px; }
.notice.warn { background: var(--warn-soft); border-color: #efd7a4; color: #5f3300; }
.notice.bad { background: var(--bad-soft); border-color: #efc4be; color: #7c1f19; }
.notice.good { background: var(--wa-soft); border-color: #bfe3cd; color: #0c5a2e; }
.notice.info { background: var(--brand-soft); border-color: #cfcbf4; color: #27208a; }
.notice + .notice, .notice + .panel, .panel + .notice { margin-top: 16px; }

/* ---------- chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12.5px; font-weight: 500; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.chip.good { background: var(--wa-soft); color: var(--wa); }
.chip.read { background: var(--read-soft); color: var(--read); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.brand { background: var(--brand-soft); color: var(--brand); }
.chip svg { width: 15px; height: 11px; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--brand); color: #fff; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }

/* ---------- onboarding stepper ---------- */
.steps { display: grid; grid-template-columns: repeat(4, 1fr); counter-reset: s; }
.step { padding: 20px; border-right: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 8px; }
.step:last-child { border-right: 0; }
.step .n { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #c4cbd5; display: grid; place-items: center; font-weight: 600; font-size: 13px; color: var(--ink-3); }
.step.done .n { background: var(--wa); border-color: var(--wa); color: #fff; }
.step.in_progress .n { border-color: var(--brand); color: var(--brand); }
.step.current { background: var(--brand-soft); }
.step h3 { font-size: 16px; }
.step p { color: var(--ink-2); font-size: 13.5px; flex: 1; }
.step .btn { align-self: flex-start; }

/* ---------- live pipeline (Tally -> Manweta -> WhatsApp -> customers) ---------- */
.pipe { display: grid; grid-template-columns: repeat(4, 1fr); }
.node { padding: 18px 20px 18px 22px; position: relative; border-right: 1px solid var(--line-2); min-width: 0; }
.node:last-child { border-right: 0; }
.node:not(:last-child)::after {
  content: ""; position: absolute; right: -7px; top: 50%; width: 12px; height: 12px; background: var(--surface);
  border-top: 1px solid var(--line); border-right: 1px solid var(--line); transform: translateY(-50%) rotate(45deg); z-index: 1;
}
.node .lbl { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #c4cbd5; flex: none; }
.dot.good { background: var(--wa); }
.dot.warn { background: #d98a00; }
.dot.bad { background: var(--bad); }
.node .big { font-family: var(--font-display); font-size: 22px; font-weight: 700; line-height: 1.2; }
.node .sub { color: var(--ink-2); font-size: 13.5px; margin-top: 2px; }
.node a.more { font-size: 13px; display: inline-block; margin-top: 8px; }

/* ---------- receivables ---------- */
.kv { display: grid; grid-template-columns: 1fr auto; gap: 10px 20px; align-items: baseline; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }
.kv dd.big { font-family: var(--font-display); font-size: 26px; }
.bar { height: 10px; border-radius: 99px; background: var(--line-2); overflow: hidden; margin: 14px 0 6px; display: flex; }
.bar i { display: block; height: 100%; background: var(--bad); }
.bar i.ok { background: #b8c2cf; }
.cols { display: grid; grid-template-columns: 1.15fr 1fr; gap: 20px; }
.cols > .panel { margin-top: 0 !important; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; font-size: 13px; color: var(--ink-3); padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafbfc; }
td { padding: 11px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.name { font-weight: 500; }
th.right, td.right { text-align: right; }
.owed { font-weight: 600; }
.owed.over { color: var(--bad); }
.empty { padding: 44px 20px; text-align: center; color: var(--ink-2); }
.empty b { display: block; font-family: var(--font-display); font-size: 18px; color: var(--ink); margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; padding: 7px 12px; border-radius: 99px; cursor: pointer; color: var(--ink-2); font-weight: 500; }
.tabs button:hover { background: var(--line-2); }
.tabs button[aria-pressed=true] { background: var(--ink); color: #fff; }
.toolbar { padding: 14px 16px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; border-bottom: 1px solid var(--line-2); }
.toolbar input[type=search] { width: 260px; max-width: 100%; }
.pager { padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line-2); }

.phone-edit { display: flex; gap: 6px; align-items: center; }
.phone-edit input { width: 160px; min-height: 32px; padding: 4px 8px; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--brand); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- tally / whatsapp pages ---------- */
.code { font-family: var(--font-display); font-size: 34px; font-weight: 700; letter-spacing: .06em; padding: 14px 20px; border: 2px dashed #b9b4ee; background: var(--brand-soft); border-radius: 10px; display: inline-block; user-select: all; }
ol.how { margin: 0; padding: 0; list-style: none; counter-reset: h; }
ol.how > li { counter-increment: h; display: grid; grid-template-columns: 34px 1fr; gap: 6px 12px; padding: 16px 0; border-bottom: 1px solid var(--line-2); }
ol.how > li:last-child { border-bottom: 0; }
ol.how > li::before { content: counter(h); width: 26px; height: 26px; border-radius: 50%; background: var(--line-2); display: grid; place-items: center; font-weight: 600; font-size: 13px; color: var(--ink-2); }
ol.how > li.ok::before { background: var(--wa); color: #fff; content: "\2713"; }
ol.how h3 { font-size: 16px; margin-bottom: 4px; }
ol.how .body { grid-column: 2; }
.kbd { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; background: var(--line-2); padding: 1px 6px; border-radius: 4px; }

.flow-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 16px 0 20px; background: var(--surface); }
.flow-list div { padding: 12px 14px; border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); font-size: 13.5px; }
.flow-list div:nth-child(3n) { border-right: 0; }
.flow-list div:nth-last-child(-n+3) { border-bottom: 0; }
.flow-list b { display: block; font-size: 14px; }

.identity { display: flex; gap: 16px; align-items: center; }
.avatar { width: 52px; height: 52px; border-radius: 12px; background: var(--wa-soft); color: var(--wa); display: grid; place-items: center; flex: none; }
.avatar svg { width: 28px; height: 28px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px 24px; margin-top: 20px; }
.facts dt { font-size: 13px; color: var(--ink-3); }
.facts dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }

details.adv { margin-top: 20px; }
details.adv summary { cursor: pointer; font-weight: 500; color: var(--ink-2); padding: 6px 0; }
details.adv[open] summary { margin-bottom: 10px; }

.sticky-actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.fieldset { border: 1px solid var(--line-2); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.fieldset legend { padding: 0 6px; font-weight: 600; font-size: 14px; }
.inline-num { display: inline-block; width: 72px !important; margin: 0 6px; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-pitch { background: var(--ink); color: #e8ecf2; padding: 56px 56px 40px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; }
.auth-pitch .brand { padding: 0; color: #fff; }
.auth-pitch h1 { font-size: 40px; color: #fff; max-width: 14ch; line-height: 1.1; }
.auth-pitch p.lead { font-size: 17px; margin-top: 16px; max-width: 44ch; color: #b6c0ce; }
.route {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin-top: 16px;
  border: 1px solid #2c3746;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
  width: 100%;
}
.route > div, .route-item {
  border: none;
  border-right: 1px solid #2c3746;
  padding: 12px 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.route > div:last-child, .route-item:last-child {
  border-right: none;
}
.route-step {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  margin-top: 2px;
}
.route b {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  line-height: 1.25;
}
.route small {
  display: block;
  color: #8b97a8;
  font-size: 12px;
  font-weight: 400;
  margin-top: 3px;
  line-height: 1.35;
}

@media (min-width: 521px) and (max-width: 900px) {
  .route {
    grid-template-columns: 1fr 1fr;
  }
  .route > div, .route-item {
    border-right: 1px solid #2c3746;
    border-bottom: 1px solid #2c3746;
    padding: 12px 14px;
  }
  .route > div:nth-child(2n), .route-item:nth-child(2n) {
    border-right: none;
  }
  .route > div:nth-child(3), .route > div:nth-child(4),
  .route-item:nth-child(3), .route-item:nth-child(4) {
    border-bottom: none;
  }
}

@media (max-width: 520px) {
  .route {
    grid-template-columns: 1fr;
  }
  .route > div, .route-item {
    border-right: none !important;
    border-bottom: 1px solid #2c3746;
    padding: 11px 14px;
  }
  .route > div:last-child, .route-item:last-child {
    border-bottom: none;
  }
}
.auth-form { display: grid; place-items: center; padding: 32px 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: 26px; margin-bottom: 6px; }
.auth-card .switch-mode { margin-top: 18px; color: var(--ink-2); }

/* ---------- modal + toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(19, 26, 34, .45); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; box-shadow: 0 24px 60px rgba(0, 0, 0, .25); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line-2); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 10px; }
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: min(420px, calc(100vw - 40px)); }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 8px; font-size: 14px; }
.toast.bad { background: var(--bad); }
.toast.good { background: #0f6b38; }

.loading { padding: 60px 0; color: var(--ink-3); text-align: center; }

/* ---------- public header (legal & contact public pages) ---------- */
.public-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 20;
}
.public-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}
.public-nav a.linkbtn {
  text-decoration: none;
  font-weight: 500;
  color: var(--ink-2);
}
.public-nav a.linkbtn:hover {
  color: var(--brand);
}

/* ---------- multi-bills, reminder choice, legal & contact additions ---------- */
.modal.wide { max-width: 840px; }
.chip-multi {
  cursor: pointer;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
  border: 1px solid rgba(59, 51, 196, 0.25);
  transition: all .15s ease;
}
.chip-multi:hover {
  background: #dedbf8;
  transform: translateY(-1px);
}

.bills-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--line-2);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.bills-summary-bar .metric-val {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
}

.remind-choice-card {
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.remind-choice-card:hover {
  border-color: var(--brand);
  box-shadow: 0 4px 12px rgba(59, 51, 196, .08);
}
.remind-choice-card h4 {
  margin: 0 0 4px 0;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.remind-choice-card p {
  margin: 0 0 10px 0;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.45;
}

.legal-page {
  max-width: 860px;
  margin: 0 auto;
}
.legal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  padding: 32px 36px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .03);
}
.legal-card h1 {
  font-size: 28px;
  margin-top: 0;
  margin-bottom: 6px;
}
.legal-card h2 {
  font-size: 18px;
  margin-top: 28px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line-2);
  padding-bottom: 6px;
  color: var(--ink);
}
.legal-card p, .legal-card li {
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.65;
}
.legal-card ul {
  padding-left: 20px;
  margin-bottom: 16px;
}
.contact-hero {
  background: linear-gradient(135deg, var(--brand-soft) 0%, #ffffff 100%);
  border: 1px solid #dcd8f8;
  border-radius: var(--r-ctl);
  padding: 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}
.contact-email-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid #c9c3f2;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  color: var(--brand);
}
.sidebar-legal-links {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 11px;
}
.sidebar-legal-links a {
  color: var(--ink-3);
  text-decoration: none;
}
.sidebar-legal-links a:hover {
  color: var(--brand);
  text-decoration: underline;
}
.auth-legal-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--ink-3);
  flex-wrap: wrap;
}
.auth-legal-footer a {
  color: var(--ink-2);
  text-decoration: none;
}
.auth-legal-footer a:hover {
  color: var(--brand);
  text-decoration: underline;
}

/* ---------- responsive mobile styles ---------- */
.mobile-bar { display: none; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; inset: 0 auto 0 0; width: 264px;
    transform: translateX(-100%); transition: transform .2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 40; height: 100%; box-shadow: none;
  }
  body.nav-open {
    overflow: hidden;
  }
  body.nav-open .side {
    transform: none;
    box-shadow: 0 0 0 100vmax rgba(19, 26, 34, .45);
  }
  .mobile-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 25;
  }
  .mobile-bar .brand { padding: 0; font-size: 17px; }
  .mobile-bar .brand img { width: 26px; height: 26px; }
  .mobile-bar button { min-height: 38px; min-width: 38px; font-size: 20px; }

  .main { padding: 20px 16px 48px; }
  .steps, .pipe { grid-template-columns: 1fr 1fr; }
  .step, .node { border-bottom: 1px solid var(--line-2); }
  .node::after { display: none; }
  .cols { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-pitch { padding: 32px 24px; gap: 20px; }
  .auth-pitch h1 { font-size: 30px; }
}

@media (max-width: 768px) {
  /* Prevent iOS Safari 16px zoom bug on inputs */
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=search], select, textarea {
    font-size: 16px !important;
  }

  .table-wrap {
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
  }

  .auth {
    grid-template-columns: 1fr;
  }
  .auth-pitch {
    padding: 24px 20px 20px;
    gap: 12px;
  }
  .auth-pitch h1 {
    font-size: 24px;
    max-width: 100%;
  }
  .auth-pitch p.lead {
    font-size: 14px;
    margin-top: 6px;
    max-width: 100%;
  }
  .auth-form {
    padding: 20px 16px 36px;
  }
  .auth-card {
    max-width: 100%;
  }
}

@media (max-width: 640px) {
  /* Public Header for Legal / Contact */
  .public-header {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 10px;
  }
  .public-nav {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }
  .public-nav .btn.small {
    padding: 4px 10px;
    font-size: 12px;
    white-space: nowrap;
  }
  .public-nav a.linkbtn {
    font-size: 12.5px;
    white-space: nowrap;
  }

  /* Modals on Mobile */
  .modal-back {
    padding: 10px 8px;
    align-items: flex-end;
  }
  .modal {
    max-height: 92vh;
    border-radius: 16px 16px 8px 8px;
    width: 100%;
    margin: 0;
  }
  .modal-head {
    padding: 14px 16px;
  }
  .modal-head h2 {
    font-size: 16px;
  }
  .modal-body {
    padding: 14px 12px;
  }
  .modal-foot {
    padding: 12px 14px;
    flex-direction: column-reverse;
    gap: 8px;
  }
  .modal-foot > * {
    width: 100%;
  }
  .modal-foot button {
    width: 100%;
    min-height: 38px;
    justify-content: center;
  }
  .modal-foot div {
    width: 100%;
    flex-direction: column;
    gap: 8px;
  }
  .modal-foot div button {
    width: 100%;
  }

  /* Multi-Bills summary & choice cards */
  .bills-summary-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 10px 12px;
  }
  .bills-summary-bar .metric-val {
    font-size: 16px;
  }
  .remind-choice-card {
    padding: 12px;
  }
  .remind-choice-card h4 {
    font-size: 14px;
  }
  .remind-choice-card p {
    font-size: 12.5px;
  }
  .remind-choice-card button {
    width: 100%;
    min-height: 38px;
  }

  /* Table styling on mobile */
  th, td {
    padding: 8px 10px;
    font-size: 13px;
  }
  th {
    font-size: 12px;
  }
  td.name button.linkbtn {
    font-size: 13.5px;
  }
  td.name .chip {
    margin-top: 3px;
  }
  .phone-cell {
    white-space: nowrap;
    font-size: 12.5px;
  }
  .phone-edit input {
    width: 120px;
  }

  /* Customer list Toolbar */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px 12px;
  }
  .toolbar .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }
  .toolbar .tabs button {
    white-space: nowrap;
    font-size: 13px;
    padding: 6px 12px;
  }
  .toolbar input[type=search] {
    width: 100%;
    max-width: 100%;
  }
  .pager {
    flex-direction: column;
    gap: 8px;
    align-items: center;
    text-align: center;
    padding: 10px 12px;
  }
  .pager .row {
    width: 100%;
    justify-content: center;
  }

  /* Panels & Headings on Mobile */
  .panel-head {
    padding: 12px 14px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .panel-head h2 {
    font-size: 16px;
  }
  .panel-body {
    padding: 14px 12px;
  }
  .page-head {
    margin-bottom: 16px;
  }
  .page-head h1 {
    font-size: 22px;
  }
  .page-head p {
    font-size: 13.5px;
  }

  /* Legal and Contact Pages */
  .legal-card {
    padding: 20px 16px;
  }
  .legal-card h1 {
    font-size: 22px;
  }
  .legal-card h2 {
    font-size: 16px;
    margin-top: 20px;
  }
  .contact-hero {
    padding: 16px 14px;
    flex-direction: column;
    align-items: stretch;
  }
  .contact-email-badge {
    font-size: 14px;
    padding: 6px 10px;
    width: 100%;
    justify-content: center;
    word-break: break-all;
  }
  .contact-hero button, .contact-hero a.btn {
    width: 100%;
    justify-content: center;
  }

  /* Floating Toasts */
  #toasts {
    left: 14px;
    right: 14px;
    bottom: 14px;
    max-width: none;
  }
}

@media (max-width: 560px) {
  .steps, .pipe, .grid2 { grid-template-columns: 1fr; }
  .step { border-right: 0; padding: 14px; }
  .node { border-right: 0; padding: 14px; }
  .flow-list { grid-template-columns: 1fr; }
  .flow-list div { border-right: 0 !important; }
  .code { font-size: 22px; padding: 10px 14px; }
  h1 { font-size: 22px; }
  h2 { font-size: 18px; }
  .auth-legal-footer {
    flex-direction: column;
    gap: 6px;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: .01ms !important; }
}

