/* ============================================================
   B4Billing - shared design (new look, light mode only)
   Same brand as today (teal and amber, Space Grotesk / Inter), cleaner:
   flat paper ground, thinner lines, bigger touch targets, 16px inputs
   (so phones do not zoom in), visible keyboard focus.
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;600&display=swap');

:root {
  color-scheme: light;
  --ink: #16211E;
  --ink-2: #44514D;          /* secondary text */
  --ink-3: #6B7A75;          /* hints, captions */
  --teal: #0F5C5C;
  --teal-deep: #0A3F3F;
  --teal-soft: #E6F0EE;
  --amber: #E8A33D;
  --amber-deep: #B97812;     /* amber that is readable as text on white */
  --paper: #F6F5F1;
  --card: #FFFFFF;
  --line: #DDE3E0;
  --brick: #B23A2E;
  --brick-soft: #FBEAE7;
  --green: #2E7D4F;
  --green-soft: #E7F3EC;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(22,33,30,.05), 0 8px 24px rgba(22,33,30,.06);
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 16px/1.5 var(--font-body); -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; margin: 0; text-wrap: balance; }
p { margin: 0 0 .75rem; }
a { color: var(--teal); text-underline-offset: 2px; }
a:hover { color: var(--teal-deep); }
a.btn-teal, a.btn-teal:hover { color: #fff; }
a.btn-primary, a.btn-primary:hover { color: var(--teal-deep); }
a.btn-outline, a.btn-outline:hover { color: var(--teal); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label, label.lbl { display: block; font-size: 14px; font-weight: 500; color: var(--ink-2); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; font: inherit; font-size: 16px; color: var(--ink);
  background: #fff; border: 1px solid #C9D2CE; border-radius: var(--radius-sm);
}
textarea { min-height: 88px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #8A9792; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(232,163,61,.55); outline-offset: 0; border-color: var(--teal); }
.hint { font-size: 13px; color: var(--ink-3); margin-top: 4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px; font: 600 15px/1 var(--font-body);
  border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: background .12s ease, border-color .12s ease;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--amber); color: var(--teal-deep); }
.btn-primary:hover:not(:disabled) { background: #F0B253; }
.btn-teal { background: var(--teal); color: #fff; }
.btn-teal:hover:not(:disabled) { background: var(--teal-deep); }
.btn-outline { background: #fff; color: var(--teal); border-color: #B9C8C4; }
.btn-outline:hover:not(:disabled) { background: var(--teal-soft); border-color: var(--teal); }
.btn-quiet { background: transparent; color: var(--teal); padding-inline: 6px; min-height: 40px; }
.btn-quiet:hover:not(:disabled) { text-decoration: underline; }
.btn-block { display: flex; width: 100%; }
.btn-lg { min-height: 50px; font-size: 16px; }

/* ---------- Cards, messages, badges ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.msg { border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; margin-bottom: 14px; }
.msg-error { background: var(--brick-soft); color: #7D241B; }
.msg-ok { background: var(--green-soft); color: #1E5A38; }
.msg-info { background: var(--teal-soft); color: var(--teal-deep); }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--teal-soft); color: var(--teal-deep); }
.badge-warn { background: #FBF1DE; color: #7A5410; }
.badge-bad { background: var(--brick-soft); color: #7D241B; }
.badge-good { background: var(--green-soft); color: #1E5A38; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 13px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- Message thread (registration status, restore) ---------- */
.thread { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; padding: 2px; }
.bubble { max-width: 88%; border-radius: 12px; padding: 8px 12px; background: var(--brick-soft); align-self: flex-start; }
.bubble.mine { background: var(--teal-soft); align-self: flex-end; }
.bubble .who { font-size: 12px; font-weight: 700; color: var(--brick); }
.bubble.mine .who { color: var(--teal-deep); }
.bubble .text { font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .when { font-size: 11px; color: var(--ink-3); margin-top: 2px; }

/* ---------- Sign-in layout ---------- */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.brand-panel {
  background: var(--teal-deep); color: #fff; padding: clamp(32px, 6vw, 72px);
  display: flex; flex-direction: column; justify-content: center; gap: 22px;
}
.wordmark { font: 700 clamp(34px, 4vw, 46px)/1 var(--font-display); letter-spacing: -.02em; margin: 0; }
.wordmark span { color: var(--amber); }
.brand-panel .lead { font: 500 clamp(18px, 1.8vw, 22px)/1.4 var(--font-display); max-width: 34ch; margin: 0; color: rgba(255,255,255,.92); }
.brand-panel .body { font-size: 15px; line-height: 1.7; color: rgba(255,255,255,.78); max-width: 58ch; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: 13px; font-weight: 600; color: var(--amber); border: 1px solid rgba(232,163,61,.5); border-radius: 99px; padding: 5px 13px; }
.data-note { border-top: 1px solid rgba(255,255,255,.16); padding-top: 18px; max-width: 58ch; }
.data-note h2 { font: 700 12px/1 var(--font-body); letter-spacing: .1em; text-transform: uppercase; color: var(--amber); margin-bottom: 10px; }
.data-note p { font-size: 13px; line-height: 1.65; color: rgba(255,255,255,.72); margin-bottom: 8px; }
.data-note a { color: var(--amber); font-weight: 600; font-size: 13px; }
.form-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px; gap: 22px; }
.form-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: clamp(22px, 4vw, 32px); box-shadow: var(--shadow); }
.form-card h2 { font-size: 22px; margin-bottom: 4px; }
.form-card .sub { color: var(--ink-3); font-size: 14px; margin-bottom: 20px; }
.mobile-mark { display: none; font: 700 30px/1 var(--font-display); letter-spacing: -.02em; color: var(--teal-deep); }
.mobile-mark span { color: var(--amber-deep); }
.legal { max-width: 420px; text-align: center; font-size: 13px; color: var(--ink-3); }
.legal nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; margin-bottom: 10px; }
.legal a { color: var(--ink-2); }

/* ---------- Registration (wider card, two-column rows, e-mail code box) ---------- */
.form-card.wide { max-width: 600px; }
.auth-shell.tall .brand-panel { position: sticky; top: 0; height: 100vh; align-self: start; overflow-y: auto; }
.legal.wide { max-width: 600px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.req { color: var(--brick); }
.otp-input { letter-spacing: .4em; font: 600 22px/1 var(--font-mono); text-align: center; }
.form-sep { border: 0; border-top: 1px solid var(--line); margin: 6px 0 16px; }
.done-mark { width: 52px; height: 52px; border-radius: 50%; background: var(--green-soft); color: var(--green); display: grid; place-items: center; font-size: 26px; margin-bottom: 12px; }
.code-box { font: 600 20px/1 var(--font-mono); letter-spacing: .12em; background: var(--teal-soft); color: var(--teal-deep); border-radius: var(--radius-sm); padding: 12px 14px; text-align: center; margin: 8px 0 14px; user-select: all; }

@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .form-panel { order: -1; padding: 24px 16px 12px; gap: 18px; }
  .mobile-mark { display: block; }
  .brand-panel { padding: 28px 20px 36px; gap: 16px; }
  .auth-shell.tall .brand-panel { position: static; height: auto; }
  .brand-panel .body { font-size: 14px; }
}
@media (max-width: 560px) { .row2 { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ============================================================
   App shell (sidebar + top bar) and the Dashboard
   ============================================================ */
:root {
  --blue: #1B4B7A; --blue-soft: #E7F0FB;
  --gold-soft: #FBF1DE; --violet: #6B3FA0; --violet-soft: #F3EAFB;
  --side-w: 284px; --side-w-min: 72px;
}
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); transition: grid-template-columns .15s ease; }
.app-shell.collapsed { grid-template-columns: var(--side-w-min) minmax(0, 1fr); }
.side { background: var(--teal-deep); color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow: hidden; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 18px 16px 14px 20px; min-height: 64px; }
.side-brand { font: 700 22px/1 var(--font-display); letter-spacing: -.02em; color: #fff; text-decoration: none; white-space: nowrap; }
.side-brand span { color: var(--amber); }
.icon-btn { background: transparent; border: 1px solid transparent; color: inherit; width: 40px; height: 40px; border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.side .icon-btn { color: rgba(255,255,255,.75); }
.side .icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.side-nav { flex: 1; overflow-y: auto; padding: 6px 10px 12px; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.25) transparent; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px; color: rgba(255,255,255,.82); text-decoration: none; font-size: 14.5px; font-weight: 500; min-height: 44px; position: relative; }
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active { background: rgba(232,163,61,.16); color: #fff; box-shadow: inset 3px 0 0 var(--amber); }
.nav-link.is-off { opacity: .42; cursor: not-allowed; }
.nav-link.is-off:hover { background: transparent; color: rgba(255,255,255,.82); }
.nav-link.hot .nav-ic { background: var(--amber); color: var(--teal-deep); }
.nav-ic { width: 34px; height: 34px; border-radius: 9px; background: rgba(255,255,255,.1); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--brick); color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.nav-lock { color: rgba(255,255,255,.55); }
.nav-lock .ic { width: 15px; height: 15px; }
.side-foot { border-top: 1px solid rgba(255,255,255,.14); padding: 12px 14px 14px 20px; display: grid; gap: 4px; font-size: 13px; }
.side-foot b { font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .em { color: rgba(255,255,255,.62); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .btn-quiet { color: var(--amber); justify-content: flex-start; padding-inline: 0; min-height: 36px; }
.app-shell.collapsed .nav-label, .app-shell.collapsed .nav-badge, .app-shell.collapsed .nav-lock, .app-shell.collapsed .side-brand, .app-shell.collapsed .side-foot { display: none; }
.app-shell.collapsed .side-head { justify-content: center; padding-inline: 8px; }
.app-shell.collapsed .nav-link { justify-content: center; }
.app-shell.collapsed .nav-link .nav-badge.dot { display: inline-flex; position: absolute; top: 4px; right: 8px; min-width: 10px; height: 10px; padding: 0; font-size: 0; }

.app-main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px clamp(16px, 3vw, 32px); background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; min-height: 64px; }
.top .icon-btn { color: var(--ink); border-color: var(--line); display: none; }
.top-title { flex: 1; min-width: 0; }
.top-title h1 { font-size: 20px; line-height: 1.2; }
.top-sub { color: var(--ink-3); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.top-sub button { background: none; border: 0; padding: 0; font: inherit; color: var(--teal); text-decoration: underline; cursor: pointer; }
.page { padding: clamp(16px, 3vw, 32px); max-width: 1280px; width: 100%; }
.app-backdrop { display: none; }
.boot { display: grid; place-items: center; min-height: 40vh; color: var(--ink-3); }

@media (max-width: 900px) {
  .app-shell, .app-shell.collapsed { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 60; inset: 0 auto 0 0; width: min(86vw, 300px); transform: translateX(-102%); transition: transform .18s ease; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .app-shell.open .side { transform: none; }
  .app-shell.open .app-backdrop { display: block; position: fixed; inset: 0; background: rgba(10,30,28,.45); z-index: 55; }
  .top .icon-btn { display: inline-flex; }
  #sideCollapse { display: none; }
  .app-shell.collapsed .nav-label, .app-shell.collapsed .nav-badge, .app-shell.collapsed .nav-lock, .app-shell.collapsed .side-foot, .app-shell.collapsed .side-brand { display: revert; }
  .app-shell.collapsed .nav-link { justify-content: flex-start; }
}

/* ---------- Dashboard ---------- */
.attn { border: 1px solid #EFD9AE; background: #FFFBF2; border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.attn.red { border-color: #E3A9A0; background: #FFF5F3; }
.attn h2 { font-size: 16px; margin-bottom: 4px; }
.attn .sub { color: var(--ink-2); font-size: 14px; margin-bottom: 12px; }
.attn-row { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid rgba(22,33,30,.08); }
.attn-row .what { flex: 1 1 260px; min-width: 0; font-size: 14px; }
.attn-row .what small { display: block; color: var(--ink-3); font-size: 12.5px; }
.attn-row .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-sm { min-height: 38px; padding: 6px 14px; font-size: 14px; }
.btn-danger { background: #fff; color: var(--brick); border-color: #E3A9A0; }
.btn-danger:hover:not(:disabled) { background: var(--brick-soft); }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; position: relative; text-align: left; font: inherit; color: inherit; width: 100%; }
button.stat { cursor: pointer; }
button.stat:hover { border-color: var(--teal); box-shadow: var(--shadow); }
.stat .lbl { font-size: 13px; color: var(--ink-3); font-weight: 500; }
.stat .val { font: 600 28px/1.2 var(--font-display); margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .meta { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; min-height: 18px; }
.stat.sales { background: var(--teal-deep); border-color: var(--teal-deep); color: #fff; }
.stat.sales .lbl, .stat.sales .meta { color: rgba(255,255,255,.72); }
.stat.warn { background: #FBF1DE; border-color: #EFD9AE; }
.stat.crit { background: var(--brick-soft); border-color: #E3A9A0; }
.stat.crit .val { color: #7D241B; }
.blur-val { filter: blur(9px); user-select: none; }
.eye { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.eye:hover { border-color: var(--teal); color: var(--teal); }

.group { margin-bottom: 26px; }
.group > h2 { font: 700 12px/1 var(--font-body); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.tile { display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 68px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; font: inherit; text-align: left; cursor: pointer; width: 100%; }
.tile:hover { border-color: var(--teal); box-shadow: var(--shadow); color: var(--ink); }
.tile .t-ic { width: 40px; height: 40px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--teal-soft); color: var(--teal); }
.tile .t-tx { flex: 1; min-width: 0; }
.tile .t-name { font-weight: 600; font-size: 15px; line-height: 1.25; }
.tile .t-sub { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .nav-badge { flex-shrink: 0; }
.tone-amber .t-ic { background: var(--gold-soft); color: var(--amber-deep); }
.tone-green .t-ic { background: var(--green-soft); color: var(--green); }
.tone-brick .t-ic { background: var(--brick-soft); color: var(--brick); }
.tone-blue .t-ic { background: var(--blue-soft); color: var(--blue); }
.tone-violet .t-ic { background: var(--violet-soft); color: var(--violet); }
.account-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; max-width: 460px; margin-bottom: 26px; }
.account-card h2 { font-size: 16px; margin-bottom: 8px; }

/* dialogs */
dialog.dlg { border: 0; border-radius: 16px; padding: 0; width: min(560px, 94vw); max-height: 90vh; box-shadow: 0 24px 60px rgba(10,30,28,.3); color: var(--ink); background: var(--card); }
dialog.dlg::backdrop { background: rgba(10,30,28,.5); }
dialog.dlg.wide { width: min(860px, 96vw); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { font-size: 18px; }
.dlg-body { padding: 16px 20px; overflow-y: auto; max-height: calc(90vh - 140px); }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--line); }
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl tr.cancelled td { color: var(--brick); }
.empty { color: var(--ink-3); padding: 18px 4px; text-align: center; font-size: 14px; }

@media (max-width: 900px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .stat .val { font-size: 22px; } .tiles { grid-template-columns: 1fr; } }
