/* Billwise admin — matches the Android app's navy/blue brand */
:root {
  --navy: #0f1b33; --navy-2: #172a4f; --blue: #275be8; --blue-2: #1e47c2; --blue-soft: #eaf0ff;
  --teal: #0f9d7a; --gold: #c58a12; --violet: #7c3aed; --red: #dc2626; --amber: #d97706; --green: #16a34a;
  --bg: #f4f6fb; --card: #ffffff; --line: #e6eaf2; --text: #0f172a; --muted: #64748b; --soft: #f8fafc;
  --r: 16px; --shadow: 0 1px 2px rgba(15,27,51,.04), 0 6px 24px rgba(15,27,51,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 600; }
small { font-size: 12px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.pre { white-space: pre-line; }
.hidden { display: none !important; }
.green-t { color: var(--green); } .amber-t { color: var(--amber); } .red-t { color: var(--red); } .danger-t { color: var(--red) !important; }
.ic { width: 20px; height: 20px; fill: currentColor; flex: none; }

/* ---------- shell */
.shell { display: flex; min-height: 100vh; }
.side { width: 248px; flex: none; background: linear-gradient(180deg, var(--navy) 0%, #13254a 100%); color: #c8d4ee; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 18px 14px; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; padding: 6px 8px 22px; font-weight: 700; font-size: 17px; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: #8fa6d8; letter-spacing: .08em; text-transform: uppercase; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: #c8d4ee; font-weight: 500; transition: background .15s, color .15s; }
.side nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side nav a.on { background: var(--blue); color: #fff; box-shadow: 0 6px 16px rgba(39,91,232,.35); }
.side-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding-top: 14px; }
.me { display: flex; align-items: center; gap: 10px; padding: 0 6px 10px; }
.me b { display: block; color: #fff; font-weight: 600; } .me small { color: #8fa6d8; }
.ghost-btn { width: 100%; display: flex; align-items: center; gap: 10px; background: none; border: 0; color: #c8d4ee; padding: 9px 12px; border-radius: 10px; font: inherit; cursor: pointer; }
.ghost-btn:hover { background: rgba(255,255,255,.06); color: #fff; }
.main { flex: 1; min-width: 0; padding: 26px 32px 60px; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.top h1 { font-size: 26px; font-weight: 700; }
.top p { margin: 2px 0 0; color: var(--muted); }
.menu-btn { display: none; }
.scrim { display: none; }

/* ---------- cards & grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px; }
.card > h2 { margin-bottom: 6px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.grid-side { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.grid-side.rev { grid-template-columns: minmax(0, 1fr) 400px; }
.sticky { position: sticky; top: 20px; }
.link { font-weight: 600; font-size: 13px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; margin: -8px 0 14px; }
.back:hover { color: var(--text); }
.back .ic { width: 18px; height: 18px; }
.empty { color: var(--muted); text-align: center; padding: 28px 12px; margin: 0; }
.pad { padding: 10px 4px 0; margin: 0; }
.mt { margin-top: 18px; }

/* ---------- KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; display: flex; gap: 14px; align-items: center; min-width: 0; }
.kpi small { color: var(--muted); font-weight: 500; display: block; }
.kpi b { display: block; font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.kpi .delta { color: var(--muted); font-size: 12px; }
.kpi .delta.up { color: var(--green); font-weight: 600; }
.kpi-ic { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.kpi-ic .ic { width: 24px; height: 24px; }
.kpi-ic.blue { background: var(--blue-soft); color: var(--blue); } .kpi-ic.teal { background: #e3f6f0; color: var(--teal); }
.kpi-ic.gold { background: #fdf3dc; color: var(--gold); } .kpi-ic.violet { background: #f1e9ff; color: var(--violet); }
.kpis.money .kpi { background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%); border: 0; color: #fff; }
.kpis.money .kpi small, .kpis.money .kpi .delta { color: #a9bce8; }
.kpis.money .kpi a { color: #fff; text-decoration: underline; }
.kpis.money .green-t { color: #5ee6a8; } .kpis.money .amber-t { color: #ffc46b; } .kpis.money .red-t { color: #ff9393; }

/* ---------- charts */
.chart-box { position: relative; height: 260px; }
.chart-box.small { height: 220px; }
.bars { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.bars li { display: grid; grid-template-columns: 96px 1fr 40px; align-items: center; gap: 10px; }
.bars b { text-align: right; }
.bar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--muted); }
.bar i.green { background: var(--green); } .bar i.amber { background: var(--amber); } .bar i.blue { background: var(--blue); } .bar i.red { background: var(--red); } .bar i.grey { background: #94a3b8; }
.plan-split { display: flex; align-items: center; gap: 24px; padding: 6px 4px; }
.ring { --p: 0; width: 132px; height: 132px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--gold) calc(var(--p) * 1%), #e8edf5 0); }
.ring span { width: 98px; height: 98px; border-radius: 50%; background: #fff; display: grid; place-content: center; text-align: center; font-size: 24px; font-weight: 700; }
.ring small { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend b { margin-left: auto; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.legend i.gold { background: var(--gold); } .legend i.grey { background: #cbd5e1; } .legend i.red { background: var(--red); }

/* ---------- lists */
.list { list-style: none; margin: 0 -8px; padding: 0; }
.list li > a, .list li > .row { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 12px; color: inherit; }
.list li > a:hover { background: var(--soft); }
.list .grow { flex: 1; min-width: 0; }
.list b, .list small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list small { color: var(--muted); }
.list .end { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.doc-ic { width: 38px; height: 38px; border-radius: 12px; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; flex: none; }
.doc-ic.green { background: #e3f6ea; color: var(--green); }

/* ---------- avatars & badges */
.av { --h: 220; width: 38px; height: 38px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: hsl(var(--h) 70% 92%); color: hsl(var(--h) 60% 32%); font-weight: 600; font-size: 13px; }
.av.xl { width: 72px; height: 72px; font-size: 24px; }
.side .av { background: rgba(255,255,255,.12); color: #fff; }
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap; line-height: 1.6; }
.badge.green { background: #e3f6ea; color: #13803d; } .badge.amber { background: #fdf0dc; color: #b45309; } .badge.blue { background: var(--blue-soft); color: var(--blue-2); }
.badge.red { background: #fde8e8; color: #b91c1c; } .badge.grey { background: #eef1f6; color: #5b6b84; }
.badge.gold { background: linear-gradient(135deg, #f8d77a, #e9a92b); color: #4a3100; letter-spacing: .04em; }
.badge.outline { border: 1px solid var(--line); color: var(--muted); background: #fff; }
.badge.outline.red { color: #b91c1c; border-color: #f5c2c2; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ---------- toolbar, forms, buttons */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 12px; margin-bottom: 16px; }
.search { flex: 1; min-width: 220px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; background: var(--soft); }
.search .ic { color: var(--muted); width: 18px; }
.search input { border: 0 !important; background: none !important; box-shadow: none !important; padding: 10px 0 !important; }
input, select, textarea { font: inherit; color: inherit; width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(39,91,232,.12); }
select { width: auto; padding-right: 30px; }
.form select, .form-grid select { width: 100%; }
textarea { resize: vertical; }
label { display: block; font-weight: 500; font-size: 13px; color: #334155; }
.form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.form label input, .form label select, .form label textarea, .form-grid label input, .form-grid label textarea, .form-grid label select { margin-top: 6px; }
.form-grid .card { display: flex; flex-direction: column; gap: 12px; }
.form-grid .card > p { margin: -6px 0 0; }
.form-foot { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; border-radius: 12px; padding: 10px 16px;
  border: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer; transition: transform .05s, background .15s, box-shadow .15s; white-space: nowrap; }
.btn:hover { background: var(--soft); }
.btn:active { transform: translateY(1px); }
.btn .ic { width: 18px; height: 18px; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 6px 16px rgba(39,91,232,.25); }
.btn.primary:hover { background: var(--blue-2); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger:hover { background: #b91c1c; }
.btn.ghost { background: none; border-color: transparent; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn.wide { width: 100%; padding: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
form.inline { margin-top: 8px; }
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 0; }
.switch span { width: 44px; height: 26px; border-radius: 99px; background: #cbd5e1; position: relative; transition: background .2s; flex: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--blue); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 4px rgba(39,91,232,.2); }

/* ---------- tables */
.table-card { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--soft); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.table small.sub { display: block; color: var(--muted); }
.table.compact td, .table.compact th { padding: 9px 12px; }
.card .table th:first-child, .card .table td:first-child { padding-left: 20px; }
.rowlink { cursor: pointer; transition: background .12s; }
.rowlink:hover { background: #f7f9fd; }
.who { display: flex; align-items: center; gap: 12px; color: inherit; min-width: 0; }
.who b, .who small { display: block; } .who small { color: var(--muted); }
.muted-link { color: var(--muted); }
.muted-link:hover { color: var(--blue); }
.pager { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 16px; color: var(--muted); }
.pager a, .pager .off { padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-weight: 600; }
.pager .off { opacity: .45; }

/* ---------- flash */
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 500; border: 1px solid; }
.flash.ok { background: #ecfdf3; border-color: #b7ebc9; color: #146c34; }
.flash.err { background: #fef2f2; border-color: #f9caca; color: #b42318; }
.flash.big { font-size: 15px; }
code.copy { background: #fff; border: 1px dashed #94a3b8; border-radius: 8px; padding: 2px 8px; cursor: pointer; font-family: ui-monospace, Menlo, Consolas, monospace; }
code.copy.block { display: block; padding: 10px 12px; word-break: break-all; }
code.copy.done { border-color: var(--green); color: var(--green); }

/* ---------- user profile */
.profile { display: flex; align-items: center; gap: 20px; margin-bottom: 18px; flex-wrap: wrap; }
.profile .grow { flex: 1; min-width: 220px; }
.profile h2 { font-size: 22px; }
.profile p { margin: 2px 0 10px; }
.facts { display: grid; grid-template-columns: repeat(4, auto); gap: 6px 28px; margin: 0; }
.facts dt { color: var(--muted); font-size: 12px; } .facts dd { margin: 0; font-weight: 600; }
.danger-zone { border-color: #f5c2c2; }
.kv { margin: 10px 0 0; display: flex; flex-direction: column; gap: 10px; }
.kv div { display: flex; justify-content: space-between; gap: 12px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 500; text-align: right; overflow-wrap: anywhere; }

/* ---------- document preview */
.paper { padding: 28px; }
.paper-h { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid var(--navy); padding-bottom: 18px; margin-bottom: 18px; }
.paper-h h2 { font-size: 20px; } .paper-h h3 { font-size: 22px; letter-spacing: .06em; color: var(--navy); }
.paper-h p { margin: 4px 0; }
.paper-h .right { text-align: right; }
.bill-to { display: flex; flex-direction: column; margin-bottom: 18px; }
.bill-to small, .notes small { color: var(--muted); font-weight: 600; letter-spacing: .06em; }
.bill-to b { font-size: 16px; }
.items th:first-child, .items td:first-child { padding-left: 0 !important; }
.items th:last-child, .items td:last-child { padding-right: 0; }
.totals { margin: 16px 0 0 auto; max-width: 320px; display: flex; flex-direction: column; gap: 6px; }
.totals div { display: flex; justify-content: space-between; }
.totals dt { color: var(--muted); } .totals dd { margin: 0; font-weight: 500; }
.totals .grand { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; font-size: 17px; font-weight: 700; }
.totals .grand dt { color: var(--text); }
.notes { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); }

/* ---------- announcements */
.announce { border-left: 5px solid var(--blue); }
.announce.success { border-left-color: var(--green); } .announce.warning { border-left-color: var(--amber); }
.announce.faded { opacity: .6; }
.announce p { margin: 0 0 10px; }
.announce .foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- auth */
body.auth { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; background: #fff; }
.auth-art { background: radial-gradient(circle at 20% 15%, #2f5fe0 0%, transparent 45%), radial-gradient(circle at 85% 85%, #0f9d7a 0%, transparent 40%), linear-gradient(160deg, #0f1b33, #1b3366);
  color: #fff; display: flex; align-items: center; justify-content: center; padding: 48px; }
.auth-copy { max-width: 420px; }
.auth-copy h2 { font-size: 34px; margin: 18px 0 10px; }
.auth-copy p { color: #c8d4ee; font-size: 16px; }
.auth-copy ul { list-style: none; padding: 0; margin: 26px 0 0; display: flex; flex-direction: column; gap: 12px; }
.auth-copy li { padding-left: 30px; position: relative; color: #e2e9f8; }
.auth-copy li::before { content: "✓"; position: absolute; left: 0; top: -1px; width: 20px; height: 20px; border-radius: 50%; background: rgba(255,255,255,.15); display: grid; place-items: center; font-size: 12px; }
.auth-card { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.login { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; box-shadow: none; border: 0; }
.login h1 { font-size: 28px; }
.login p { margin: -8px 0 6px; }
.login label input { margin-top: 6px; }

/* ---------- responsive */
@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .grid-side, .grid-side.rev { grid-template-columns: 1fr; }
  .sticky { position: static; }
}
@media (max-width: 900px) {
  .side { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .25s ease, visibility .25s; visibility: hidden; }
  body.nav-open .side { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(15,27,51,.45); z-index: 20; }
  .menu-btn { display: inline-grid; }
  .main { padding: 18px 16px 48px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .facts { grid-template-columns: repeat(2, auto); }
  body.auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr; }
  .top h1 { font-size: 22px; }
  .two { grid-template-columns: 1fr; }
  .paper { padding: 18px; }
  .paper-h { flex-direction: column; } .paper-h .right { text-align: left; }
}
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: #fff; place-items: center; cursor: pointer; color: var(--text); }
