/* RentFlow – UI */
:root {
  --brand: #0f766e;
  --brand-ink: #0b4f4a;
  --brand-soft: #e6f4f2;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #f1f5f9;
  --bg: #f6f7f9;
  --card: #ffffff;
  --side: #0c1424;
  --side-2: #131e33;
  --side-ink: #a9b4c7;
  --ok: #059669; --ok-soft: #d1fae5;
  --warn: #d97706; --warn-soft: #fef3c7;
  --bad: #dc2626; --bad-soft: #fee2e2;
  --info: #2563eb; --info-soft: #dbeafe;
  --grey-soft: #eef1f5;
  --r: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .04);
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; }
.lucide, [data-lucide] { width: 18px; height: 18px; stroke-width: 1.9; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.hide { display: none !important; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px; color: #fff; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), #22c55e); display: grid; place-items: center; font-weight: 800; color: #fff; }
.brand b { display: block; font-size: 15px; }
.brand span { font-size: 11.5px; color: var(--side-ink); display: block; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { padding: 4px 12px 24px; }
.nav-group { font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: #5f6c84; padding: 16px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-ink); font-weight: 500; }
.nav a:hover { background: var(--side-2); color: #fff; text-decoration: none; }
.nav a.active { background: var(--side-2); color: #fff; box-shadow: inset 3px 0 0 var(--brand); }
.nav a .lucide { width: 17px; height: 17px; opacity: .9; }
.side-foot { margin-top: auto; padding: 14px 20px; border-top: 1px solid #1c2840; font-size: 12px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; background: var(--card); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 24px; position: sticky; top: 0; z-index: 30; }
.topbar .menu-btn { display: none; }
.gsearch { position: relative; flex: 1; max-width: 460px; }
.gsearch input { width: 100%; padding: 9px 12px 9px 36px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font: inherit; }
.gsearch input:focus { outline: none; border-color: var(--brand); background: #fff; }
.gsearch .lucide { position: absolute; left: 11px; top: 10px; color: var(--muted); width: 16px; height: 16px; }
.gsearch-results { position: absolute; top: 44px; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(15,23,42,.12); max-height: 380px; overflow: auto; }
.gsearch-results a { display: flex; gap: 10px; align-items: center; padding: 9px 12px; color: var(--ink); border-bottom: 1px solid var(--line-2); }
.gsearch-results a:hover { background: var(--bg); text-decoration: none; }
.gsearch-results .tag { font-size: 10.5px; font-weight: 700; color: var(--brand); background: var(--brand-soft); padding: 2px 6px; border-radius: 5px; min-width: 62px; text-align: center; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn { position: relative; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: var(--bg); }
.dot-count { position: absolute; top: -5px; right: -5px; background: var(--bad); color: #fff; font-size: 10px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; border: 2px solid #fff; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 4px 10px 4px 4px; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; background: #fff; position: relative; }
.avatar { width: 30px; height: 30px; border-radius: 8px; background: var(--brand-soft); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.user-chip b { display: block; font-size: 12.5px; }
.user-chip span { display: block; font-size: 11px; color: var(--muted); text-transform: capitalize; }
.dropdown { position: absolute; right: 0; top: 46px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(15,23,42,.14); min-width: 220px; z-index: 50; overflow: hidden; }
.dropdown a { display: flex; gap: 8px; align-items: center; padding: 10px 14px; color: var(--ink); }
.dropdown a:hover { background: var(--bg); text-decoration: none; }
.notif-panel { width: 360px; max-height: 460px; display: flex; flex-direction: column; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.notif-list { overflow: auto; }
.notif-item { display: block; padding: 11px 14px; border-bottom: 1px solid var(--line-2); color: var(--ink) !important; }
.notif-item.unread { background: #f3faf9; }
.notif-item b { font-size: 13px; display: block; }
.notif-item span { font-size: 12.5px; color: var(--ink-2); display: block; margin: 2px 0; }
.notif-item small { color: var(--muted); font-size: 11px; }

.content { padding: 24px; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 750; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- components ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-head h3 { font-size: 14.5px; font-weight: 700; }
.card-body { padding: 18px; }
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-main { grid-template-columns: 2fr 1fr; }

.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi .k-label { color: var(--muted); font-size: 12.5px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.kpi .k-label .ico { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.kpi .k-value { font-size: 24px; font-weight: 800; margin-top: 10px; letter-spacing: -.02em; }
.kpi .k-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi.bad .ico { background: var(--bad-soft); color: var(--bad); }
.kpi.warn .ico { background: var(--warn-soft); color: var(--warn); }
.kpi.info .ico { background: var(--info-soft); color: var(--info); }
.meter { height: 6px; background: var(--line-2); border-radius: 3px; margin-top: 10px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--brand); border-radius: 3px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn .lucide { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-danger { color: var(--bad); border-color: #fecaca; }
.btn-danger:hover { background: var(--bad-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn[disabled] { opacity: .6; pointer-events: none; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; background: var(--grey-soft); color: var(--ink-2); text-transform: capitalize; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.b-ok { background: var(--ok-soft); color: #047857; }
.b-warn { background: var(--warn-soft); color: #b45309; }
.b-bad { background: var(--bad-soft); color: #b91c1c; }
.b-info { background: var(--info-soft); color: #1d4ed8; }

/* ---------- table ---------- */
.toolbar { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.toolbar .search { position: relative; flex: 1 1 220px; min-width: 200px; max-width: 340px; }
.toolbar .search input { width: 100%; min-width: 0; }
.toolbar .search input { padding-left: 34px; }
.toolbar .search .lucide { position: absolute; left: 10px; top: 9px; color: var(--muted); width: 16px; }
.toolbar select, .toolbar input { width: auto; min-width: 140px; }
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 10px 14px; background: #fafbfc; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
.tbl th.no-sort { cursor: default; }
.tbl th .arrow { opacity: .5; font-size: 10px; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tbody tr:hover { background: #fbfcfd; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tfoot td { font-weight: 700; background: #fafbfc; border-top: 1px solid var(--line); }
.tbl .actions { text-align: right; white-space: nowrap; }
.row-menu { position: relative; display: inline-block; }
.row-menu .dropdown { top: 34px; min-width: 200px; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty .lucide { width: 34px; height: 34px; opacity: .5; display: block; margin: 0 auto 10px; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; color: var(--muted); font-size: 12.5px; gap: 10px; flex-wrap: wrap; }
.pager .btns { display: flex; gap: 6px; }

/* ---------- forms ---------- */
label.lbl { display: block; font-size: 12.5px; font-weight: 650; color: var(--ink-2); margin-bottom: 6px; }
label.lbl .req { color: var(--bad); }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid #d7dde6; border-radius: 9px; font: inherit; color: var(--ink); background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15, 118, 110, .12); }
textarea { min-height: 84px; resize: vertical; }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--brand); vertical-align: middle; }
input[type=color] { height: 40px; padding: 3px; }
.form-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px 14px; }
.form-grid .f-full { grid-column: span 6; }
.form-grid .f-half { grid-column: span 3; }
.form-grid .f-third { grid-column: span 2; }
.help { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.check { display: flex; align-items: center; gap: 9px; padding-top: 6px; font-weight: 600; font-size: 13px; color: var(--ink-2); }
.lines { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.lines-row.tax { grid-template-columns: 1fr 140px 64px 36px; }
.lines-row { display: grid; grid-template-columns: 1fr 140px 36px; gap: 8px; padding: 8px; border-bottom: 1px solid var(--line-2); }
.lines-foot { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; background: #fafbfc; font-weight: 700; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; margin: 8px 0 10px; grid-column: span 6; border-bottom: 1px solid var(--line); padding-bottom: 6px; }

/* ---------- modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(12, 20, 36, .5); backdrop-filter: blur(2px); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 100; overflow-y: auto; animation: fade .15s; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 640px; box-shadow: 0 30px 80px rgba(0,0,0,.25); animation: pop .18s; }
.modal.lg { max-width: 820px; }
.modal.sm { max-width: 420px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 16px; font-weight: 750; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: #fafbfc; border-radius: 0 0 16px 16px; }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.2); min-width: 260px; max-width: 380px; display: flex; gap: 10px; align-items: flex-start; animation: slide .2s; }
.toast.ok { background: #065f46; } .toast.err { background: #991b1b; } .toast.info { background: #1e3a8a; }
.notice { background: var(--info-soft); color: #1e3a8a; padding: 10px 14px; border-radius: 10px; font-size: 13px; display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.alert-err { background: var(--bad-soft); color: #991b1b; padding: 10px 12px; border-radius: 9px; font-size: 13px; margin-bottom: 12px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
@keyframes slide { from { transform: translateX(20px); opacity: 0; } }

/* ---------- lists / misc ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 18px; border-bottom: 1px solid var(--line-2); }
.list li:last-child { border-bottom: 0; }
.list .t b { display: block; font-size: 13px; }
.list .t span { font-size: 12px; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 14px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 12px 12px; font: inherit; font-weight: 650; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--brand); border-color: var(--brand); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.chart-box { position: relative; height: 280px; }
.thread { display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 78%; padding: 12px 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.msg.me { align-self: flex-end; background: var(--brand-soft); border-color: #b7e1db; }
.msg .meta { font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.msg p { margin: 0; white-space: pre-wrap; }
.fc { --fc-border-color: var(--line); --fc-button-bg-color: var(--brand); --fc-button-border-color: var(--brand); --fc-button-hover-bg-color: var(--brand-ink); --fc-button-active-bg-color: var(--brand-ink); --fc-today-bg-color: #f0fbf9; font-size: 13px; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-art { background: radial-gradient(1200px 600px at -10% -10%, #14b8a6 0%, transparent 50%), radial-gradient(900px 500px at 120% 120%, #22c55e 0%, transparent 45%), var(--side); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-art h2 { font-size: 34px; line-height: 1.15; max-width: 460px; font-weight: 800; }
.auth-art p { color: #c7d2e3; max-width: 440px; line-height: 1.6; }
.auth-points { display: grid; gap: 12px; margin-top: 26px; }
.auth-points div { display: flex; gap: 10px; align-items: center; color: #dbe4f0; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 32px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 24px; font-weight: 800; }
.auth-card .sub { color: var(--muted); margin: 6px 0 24px; }
.auth-card .field { margin-bottom: 14px; }

/* ---------- portal ---------- */
.portal-top { background: var(--side); color: #fff; }
.portal-top .inner { max-width: 1100px; margin: 0 auto; padding: 16px 20px; display: flex; align-items: center; gap: 12px; }
.portal-hero { background: linear-gradient(120deg, var(--brand), #14b8a6); color: #fff; }
.portal-hero .inner { max-width: 1100px; margin: 0 auto; padding: 28px 20px 70px; }
.portal-body { max-width: 1100px; margin: -50px auto 40px; padding: 0 20px; }

/* ---------- print ---------- */
.print-page { background: #e9edf2; padding: 30px 16px; min-height: 100vh; }
.paper { background: #fff; max-width: 820px; margin: 0 auto; padding: 44px 48px; border-radius: 6px; box-shadow: 0 8px 30px rgba(0,0,0,.08); position: relative; }
.paper .doc-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid var(--brand); padding-bottom: 18px; margin-bottom: 22px; }
.paper .doc-title { font-size: 28px; font-weight: 800; color: var(--brand); text-align: right; letter-spacing: .02em; }
.paper .logo { max-height: 64px; max-width: 200px; margin-bottom: 6px; }
.paper .meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 22px; }
.paper h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 6px; }
.paper table { width: 100%; border-collapse: collapse; margin-bottom: 18px; }
.paper th { background: var(--brand); color: #fff; text-align: left; padding: 9px 10px; font-size: 12px; }
.paper td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
.paper .totals { margin-left: auto; width: 300px; }
.paper .totals td { border: 0; padding: 5px 10px; }
.paper .totals tr.grand td { border-top: 2px solid var(--ink); font-weight: 800; font-size: 15px; }
.paper .foot { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; text-align: center; }
.stamp { display: inline-block; margin: 14px 0 0 10px; transform: rotate(-10deg); border: 3px solid; padding: 6px 16px; font-weight: 900; font-size: 26px; border-radius: 8px; opacity: .75; letter-spacing: .1em; }
.stamp.paid { color: var(--ok); } .stamp.overdue { color: var(--bad); } .stamp.cancelled { color: var(--muted); } .stamp.reversed { color: var(--bad); }
.print-bar { max-width: 820px; margin: 0 auto 14px; display: flex; justify-content: flex-end; gap: 8px; }
@media print {
  .print-page { background: #fff; padding: 0; }
  .paper { box-shadow: none; padding: 10px 6px; max-width: none; }
  .print-bar, .no-print { display: none !important; }
  .paper th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .g-4 { grid-template-columns: repeat(2, 1fr); } .g-main { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -270px; width: 252px; z-index: 60; transition: left .2s; }
  body.nav-open .sidebar { left: 0; box-shadow: 20px 0 60px rgba(0,0,0,.3); }
  .topbar .menu-btn { display: grid; }
  .user-chip > div:not(.avatar):not(.dropdown) { display: none; }
  .content { padding: 16px; }
  .g-2, .g-3 { grid-template-columns: 1fr; }
  .form-grid .f-half, .form-grid .f-third { grid-column: span 6; }
  .auth { grid-template-columns: 1fr; } .auth-art { display: none; }
  .paper { padding: 24px 18px; } .paper .meta-grid { grid-template-columns: 1fr; }
  .notif-panel { width: 300px; }
}
@media (max-width: 520px) { .g-4 { grid-template-columns: 1fr; } }

/* =====================================================================
   APP SHELL – fixed height, only the content area scrolls
   ===================================================================== */
body.app { height: 100vh; height: 100dvh; overflow: hidden; }
.app .shell { height: 100vh; height: 100dvh; min-height: 0; }
.app .sidebar { position: relative; top: auto; height: 100%; }
.brand img.brand-mark { width: 34px; height: 34px; border-radius: 10px; }
.side-foot .install-link { display: flex; gap: 8px; align-items: center; color: #dbe4f0; margin-bottom: 8px; }
.app .main { height: 100vh; height: 100dvh; overflow: hidden; position: relative; }
.app .topbar { position: relative; flex: 0 0 auto; }
.app .content { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 22px 24px; max-width: none; -webkit-overflow-scrolling: touch; }
.content-inner { max-width: 1480px; margin: 0 auto; }
.content-inner.fill { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.fill > .page-head, .fill > .notice { flex: 0 0 auto; }
.fill > #resource { flex: 1; min-height: 0; display: flex; }
.fill > #resource > .card, .fill > .card { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.fill .toolbar, .fill .tabs, .fill .pager { flex: 0 0 auto; }
.fill .table-wrap { flex: 1; min-height: 0; overflow: auto; }
.tbl thead th { position: sticky; top: 0; z-index: 2; }
.tbl td.nowrap { white-space: nowrap; }
.m-title, .m-only, .tabbar, .more-sheet, .m-cards, .fab { display: none; }
.filters { display: contents; }

/* ---------- dashboard that fits one screen ---------- */
.dash { display: flex; flex-direction: column; gap: 14px; height: 100%; min-height: 0; }
.dash .page-head { margin: 0; }
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; flex: 0 0 auto; }
.dash .kpi { padding: 13px 16px; }
.dash .kpi .k-value { font-size: 22px; margin-top: 8px; }
.gla-strip { flex: 0 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; padding: 12px 18px; }
.gla-strip > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.gla-strip span { font-size: 12px; color: var(--muted); font-weight: 600; }
.gla-strip b { font-size: 17px; font-weight: 800; }
.gla-strip small { font-size: 11.5px; color: var(--muted); }
.gla-strip .meter { margin-top: 6px; }
.dash-main { flex: 1; min-height: 260px; display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 14px; }
.panel { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.panel > .card-head, .panel > .tabs { flex: 0 0 auto; }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.chart-wrap { position: relative; padding: 10px 14px 6px; }
.chart-wrap canvas { position: absolute; inset: 10px 14px 6px; }
.list li a.t { color: inherit; text-decoration: none; display: block; min-width: 0; }
.list .t { min-width: 0; }
.list .t b, .list .t span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.list .amt { white-space: nowrap; font-variant-numeric: tabular-nums; }
.amt.ok { color: var(--ok); } .amt.bad { color: var(--bad); }
.tabs.seg { padding: 0 10px; }
.tabs.seg button { padding: 13px 10px; font-size: 13px; }

@media (max-width: 1100px), (max-height: 640px) {
  .content-inner.fill { height: auto; display: block; }
  .fill .table-wrap { overflow-x: auto; overflow-y: visible; }
  .dash { height: auto; }
  .dash-main { grid-template-columns: 1fr 1fr; }
  .dash-main .panel:first-child { grid-column: span 2; height: 300px; }
  .panel { max-height: 380px; }
}

/* ---------- install sheet & pull to refresh ---------- */
.install-sheet { position: fixed; inset: 0; z-index: 300; background: rgba(12,20,36,0); display: flex; align-items: flex-end; justify-content: center; transition: background .25s; }
.install-sheet.open { background: rgba(12,20,36,.45); }
.install-card { width: 100%; max-width: 480px; background: #fff; border-radius: 22px 22px 0 0; padding: 10px 20px calc(18px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .28s cubic-bezier(.2,.8,.2,1); box-shadow: 0 -10px 40px rgba(0,0,0,.2); }
.install-sheet.open .install-card { transform: none; }
@media (min-width: 861px) { .install-sheet { align-items: center; } .install-card { border-radius: 18px; } }
.install-grab, .sheet-grab { width: 40px; height: 5px; border-radius: 3px; background: #d6dbe3; margin: 2px auto 14px; }
.install-row { display: flex; gap: 14px; align-items: center; margin: 6px 0 16px; }
.install-row img { width: 56px; height: 56px; border-radius: 14px; box-shadow: 0 4px 14px rgba(15,118,110,.35); }
.install-row b { display: block; font-size: 16px; }
.install-row span { display: block; color: var(--muted); font-size: 13px; line-height: 1.45; margin-top: 2px; }
.install-steps { margin: 0 0 16px; padding-left: 22px; line-height: 2; font-size: 14px; }
.install-steps svg { vertical-align: -3px; color: #0a84ff; }
.install-actions { display: flex; gap: 10px; }
.install-actions .btn { flex: 1; padding: 12px; font-size: 14px; border-radius: 12px; }
.ptr { position: absolute; left: 50%; top: 64px; width: 40px; height: 40px; margin-top: env(safe-area-inset-top); border-radius: 50%; background: #fff; box-shadow: 0 4px 16px rgba(15,23,42,.18); display: grid; place-items: center; color: var(--brand); opacity: 0; transform: translate(-50%, -44px); z-index: 25; pointer-events: none; transition: opacity .2s, transform .2s; }
.ptr.ptr-fixed { position: fixed; top: calc(10px + env(safe-area-inset-top)); }
.ptr.spin svg { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* page transitions (Chrome / Edge / Safari 18) */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .16s; }
.topbar { view-transition-name: topbar; }
.tabbar { view-transition-name: tabbar; }
.sidebar { view-transition-name: sidebar; }

/* =====================================================================
   NATIVE MOBILE APP (phones / installed PWA)
   ===================================================================== */
@media (max-width: 860px) {
  html { -webkit-tap-highlight-color: transparent; }
  body.app, .app .main, .app .content { overflow-x: hidden; }
  body { overscroll-behavior: none; }
  input, select, textarea { font-size: 16px !important; } /* no iOS zoom */
  .app .shell { display: block; }
  .app .sidebar { display: none !important; }
  .app .main { width: 100%; }
  .d-only { display: none !important; }
  .m-only { display: grid; }

  /* app bar */
  .app .topbar { height: auto; min-height: 56px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px 16px; gap: 6px; background: #fff; border-bottom: 1px solid rgba(15,23,42,.06); z-index: 40; }
  .fill > #resource { display: block; } .card, #resource > .card { min-width: 0; }
  .m-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
  .m-title b { font-size: 18px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .m-title span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .app .user-chip { display: none; }
  .app .icon-btn { border: 0; background: transparent; width: 40px; height: 40px; border-radius: 12px; }
  .app .icon-btn:active { background: var(--line-2); }
  .gsearch { display: none; }
  .searching .gsearch { display: flex; position: fixed; z-index: 60; left: 0; right: 0; top: 0; max-width: none; padding: calc(8px + env(safe-area-inset-top)) 10px 8px; background: #fff; gap: 6px; align-items: center; box-shadow: 0 1px 0 var(--line); }
  .searching .gsearch input { flex: 1; padding-left: 38px; border-radius: 12px; height: 42px; }
  .searching .gsearch > .lucide { left: 22px; top: calc(21px + env(safe-area-inset-top)); }
  .searching .gsearch-results { position: fixed; top: calc(58px + env(safe-area-inset-top)); left: 0; right: 0; bottom: 0; border-radius: 0; border: 0; max-height: none; box-shadow: none; }
  .searching .gsearch-results a { padding: 14px 16px; }
  .notif-panel { position: fixed !important; left: 8px; right: 8px; width: auto !important; top: calc(60px + env(safe-area-inset-top)) !important; max-height: 70dvh; border-radius: 16px; }

  /* content area */
  .app .content { padding: 14px 14px calc(92px + env(safe-area-inset-bottom)); }
  .content-inner.fill { height: auto; display: block; }
  .page-head { margin-bottom: 12px; align-items: center; }
  .page-head h1 { font-size: 20px; }
  .page-head p { display: none; }
  .app .page-head > div:first-child:not(.keep) { display: none; }
  .page-head .keep h1 { font-size: 18px; } .page-head .keep p { display: block; font-size: 12.5px; }
  .action-list { margin-top: 14px; border-top: 1px solid var(--line); }
  .dash .page-head > div:first-child { display: block; }
  .dash .page-head h1 { font-size: 21px; }
  .page-actions { width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -14px; padding: 0 14px; width: calc(100% + 28px); }
  .page-actions::-webkit-scrollbar { display: none; }
  .page-actions .btn { border-radius: 999px; padding: 9px 14px; }
  .page-actions #btn-create { display: none; }
  .card { border-radius: 16px; box-shadow: 0 1px 2px rgba(15,23,42,.04); }

  /* bottom tab bar */
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: rgba(255,255,255,.96); backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px); border-top: 1px solid rgba(15,23,42,.08); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); user-select: none; -webkit-user-select: none; }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0; color: #6b7280; text-decoration: none !important; font-size: 10.5px; font-weight: 650; }
  .tabbar a .lucide { width: 46px; height: 28px; padding: 4px 12px; border-radius: 999px; transition: background .15s; }
  .tabbar a.active { color: var(--brand); }
  .tabbar a.active .lucide { background: color-mix(in srgb, var(--brand) 14%, transparent); }
  .tabbar a:active .lucide { transform: scale(.92); }

  /* "More" sheet */
  .more-sheet { display: flex; position: fixed; inset: 0; z-index: 70; background: rgba(12,20,36,0); align-items: flex-end; pointer-events: none; transition: background .25s; }
  .more-sheet.open { background: rgba(12,20,36,.45); pointer-events: auto; }
  .more-card { width: 100%; max-height: 88dvh; background: #fff; border-radius: 22px 22px 0 0; display: flex; flex-direction: column; transform: translateY(100%); transition: transform .3s cubic-bezier(.2,.8,.2,1); padding-top: 10px; }
  .more-sheet.open .more-card { transform: none; }
  .more-head { display: flex; gap: 12px; align-items: center; padding: 0 18px 12px; border-bottom: 1px solid var(--line); }
  .more-head .avatar { width: 42px; height: 42px; border-radius: 12px; }
  .more-head b { display: block; font-size: 15px; } .more-head span { font-size: 12px; color: var(--muted); text-transform: capitalize; }
  .more-body { overflow-y: auto; padding: 4px 14px calc(18px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
  .more-group { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 16px 4px 8px; }
  .more-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .more-grid a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 2px; border-radius: 14px; color: var(--ink); font-size: 11.5px; font-weight: 600; text-align: center; text-decoration: none !important; line-height: 1.2; }
  .more-grid a:active { background: var(--line-2); }
  .more-grid .mi { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
  .more-grid a.active .mi { background: var(--brand); color: #fff; }
  .more-list a { display: flex; gap: 12px; align-items: center; padding: 14px 6px; border-bottom: 1px solid var(--line-2); color: var(--ink); text-decoration: none !important; font-weight: 600; }
  .more-list a.danger { color: var(--bad); border-bottom: 0; }

  /* floating action button */
  .fab { display: inline-flex; align-items: center; gap: 8px; position: fixed; right: 16px; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 45; height: 54px; padding: 0 20px 0 16px; border: 0; border-radius: 18px; background: var(--brand); color: #fff; font: inherit; font-weight: 700; font-size: 14px; box-shadow: 0 8px 24px color-mix(in srgb, var(--brand) 45%, transparent); }
  .fab:active { transform: scale(.96); }
  .fab .lucide { width: 22px; height: 22px; }

  /* lists become cards */
  .app #resource .table-wrap, .app #resource .pager .btns .btn { display: none; }
  .m-cards { display: block; }
  .m-card { display: flex; gap: 12px; align-items: center; padding: 13px 14px; border-bottom: 1px solid var(--line-2); background: #fff; }
  .m-card:active { background: var(--line-2); }
  .m-card .mc-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: 0 0 auto; font-weight: 800; font-size: 13px; }
  .m-card .mc-main { flex: 1; min-width: 0; }
  .m-card .mc-title { font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .m-card .mc-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
  .m-card .mc-side { text-align: right; flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
  .m-card .mc-amt { font-weight: 750; font-variant-numeric: tabular-nums; font-size: 14px; }
  .m-more { display: block; width: calc(100% - 28px); margin: 12px 14px; padding: 12px; border-radius: 12px; }
  .toolbar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; position: sticky; top: 0; z-index: 3; background: #fff; border-radius: 16px 16px 0 0; }
  .toolbar .search { max-width: none; flex: 1 1 100%; }
  .toolbar .search input { height: 42px; border-radius: 12px; background: var(--bg); border-color: transparent; }
  .filters { display: flex; gap: 8px; overflow-x: auto; flex: 1 1 100%; scrollbar-width: none; margin: 0 -12px; padding: 0 12px; }
  .filters::-webkit-scrollbar { display: none; }
  .filters select, .filters input { flex: 0 0 auto; width: auto !important; min-width: 0 !important; max-width: 200px; height: 36px; padding: 6px 30px 6px 12px; border-radius: 999px; font-size: 14px !important; background-color: var(--bg); border-color: transparent; }
  .toolbar [data-export] { display: none; }
  .pager { justify-content: center; padding: 10px; }
  .pager [data-limit] { display: none; }

  /* bottom-sheet modals */
  .modal-bg { align-items: flex-end; padding: 0; animation: fade .2s; }
  .modal, .modal.lg, .modal.sm { max-width: none; width: 100%; border-radius: 22px 22px 0 0; max-height: 94dvh; display: flex; flex-direction: column; animation: sheetUp .28s cubic-bezier(.2,.8,.2,1); }
  .modal-head { position: relative; padding: 22px 18px 12px; border-bottom: 0; touch-action: none; }
  .modal-head::before { content: ''; position: absolute; top: 8px; left: 50%; transform: translateX(-50%); width: 40px; height: 5px; border-radius: 3px; background: #d6dbe3; }
  .modal-head h3 { font-size: 18px; }
  .modal-body { overflow-y: auto; flex: 1; min-height: 0; padding: 6px 18px 18px; overscroll-behavior: contain; }
  .modal-foot { padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-radius: 0; background: #fff; box-shadow: 0 -1px 0 var(--line); }
  .modal-foot .btn { flex: 1; padding: 13px; font-size: 15px; border-radius: 12px; }
  .form-grid .f-half, .form-grid .f-third { grid-column: span 6; }
  .row-menu .dropdown { position: fixed; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); top: auto; border-radius: 16px; }

  /* dashboard on phones */
  .kpi-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .dash { gap: 12px; }
  .dash .kpi { padding: 12px 13px; }
  .dash .kpi .k-label { font-size: 11.5px; gap: 6px; }
  .dash .kpi .k-label .ico { width: 24px; height: 24px; border-radius: 7px; }
  .dash .kpi .k-label .ico .lucide { width: 14px; height: 14px; }
  .dash .kpi .k-value { font-size: 18px; }
  .dash .kpi .k-sub { font-size: 11px; }
  .gla-strip { grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px 14px; }
  .dash-main { grid-template-columns: 1fr; gap: 12px; }
  .dash-main .panel:first-child { grid-column: auto; height: 250px; }
  .panel { max-height: 360px; }

  /* other screens */
  .tabs { scrollbar-width: none; } .tabs::-webkit-scrollbar { display: none; }
  .fp-tile { flex: 1 1 calc(50% - 4px) !important; min-height: 84px; }
  .toasts { left: 12px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom)); align-items: center; }
  .toast { min-width: 0; width: 100%; border-radius: 14px; }
  .kv { grid-template-columns: 120px 1fr; }
  .ptr { top: 56px; }
}
@keyframes sheetUp { from { transform: translateY(100%); } }
.pwa .app .topbar, .pwa body.app .topbar { padding-top: calc(8px + env(safe-area-inset-top)); }

/* ---------- tenant portal on phones ---------- */
.portal-tabs-icons .lucide { display: none; }
.portal-tabs-icons .m-tab { display: none; }
@media (max-width: 860px) { .portal-tabs-icons .m-tab { display: flex; } }
@media (max-width: 860px) {
  .portal-top .inner { padding: calc(10px + env(safe-area-inset-top)) 14px 10px; }
  .portal-top .top-right .btn span.lbl { display: none; }
  .portal-top .btn-sm { padding: 7px 9px; }
  .portal-hero .inner { padding: 18px 16px 60px; }
  .portal-body { padding: 0 14px calc(90px + env(safe-area-inset-bottom)); margin-top: -46px; }
  .portal-body .grid.g-3 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .portal-body .grid.g-3 .kpi:first-child { grid-column: span 2; }
  .portal-tabs-icons { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: grid !important; grid-auto-flow: column; grid-auto-columns: 1fr; background: rgba(255,255,255,.96); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid rgba(15,23,42,.08); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)) !important; }
  .portal-tabs-icons button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0 !important; border: 0 !important; font-size: 10.5px !important; color: #6b7280; }
  .portal-tabs-icons .lucide { display: block; width: 46px; height: 28px; padding: 4px 12px; border-radius: 999px; }
  .portal-tabs-icons button.active { color: var(--brand); }
  .portal-tabs-icons button.active .lucide { background: color-mix(in srgb, var(--brand) 14%, transparent); }
  .portal .toasts { bottom: calc(80px + env(safe-area-inset-bottom)); }
  .portal .grid.g-main { grid-template-columns: 1fr; }
  body.portal { overflow-x: hidden; }
  .portal-top .inner b { font-size: 14px; display: block; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .portal-top .top-right { gap: 6px; }
  .portal-top .icon-btn { width: 36px; height: 36px; }
  .portal-hero h1 { font-size: 22px !important; }
  .portal .tbl thead { display: none; }
  .portal .tbl, .portal .tbl tbody { display: block; width: 100%; }
  .portal .tbl tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 12px; padding: 12px 14px; border-bottom: 1px solid var(--line-2); }
  .portal .tbl td { padding: 0; border: 0; }
  .portal .tbl td:nth-child(1) { grid-column: 1; grid-row: 1 / span 3; min-width: 0; font-weight: 700; }
  .portal .tbl td:nth-child(1) .small { font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .portal .tbl td:nth-child(2) { grid-column: 2; grid-row: 3; font-size: 11.5px; color: var(--muted); text-align: right; }
  .portal .tbl td:nth-child(3) { display: none; }
  .portal .tbl td:nth-child(4) { grid-column: 2; grid-row: 1; font-weight: 800; text-align: right; }
  .portal .tbl td:nth-child(5) { grid-column: 2; grid-row: 2; text-align: right; }
  .portal .tbl td[colspan] { grid-column: 1 / -1; grid-row: auto; }
  .portal .card .tabs.portal-tabs-icons + div, .portal [data-pane] { border-radius: 16px; }
  .portal [data-notices] { display: none; }
  .portal.show-notices [data-notices] { display: block; }
  .portal.show-notices .grid.g-main > .card:first-child > :not(.tabs) { display: none; }
  .portal.show-notices .grid.g-main > .card:first-child { background: transparent; border: 0; box-shadow: none; }
}

/* =====================================================================
   FLAT, BORDERLESS LOOK
   ===================================================================== */
:root { --fill: #f1f4f8; --fill-2: #e9edf3; }
.nav a.active { box-shadow: none; background: rgba(255,255,255,.08); }
.card, .kpi, .modal, .dropdown, .gsearch-results, .notif-panel, .row-menu .dropdown { border: 0 !important; }
.card { box-shadow: 0 1px 3px rgba(15,23,42,.05); }
.topbar { border-bottom: 0 !important; box-shadow: 0 1px 0 rgba(15,23,42,.04); }
.card-head, .modal-head, .modal-foot, .toolbar, .notif-head, .more-head, .tabs, .alloc-bar, .side-foot { border: 0 !important; }
.tabs { gap: 6px; padding: 8px 12px; }
.tabs button { border: 0 !important; border-radius: 999px; padding: 8px 14px; }
.tabs button.active { background: var(--brand-soft); color: var(--brand); }
.tabs.seg { padding: 8px 10px; } .tabs.seg button { padding: 7px 12px; }
.tbl th { background: transparent; border: 0; color: var(--muted); }
.tbl td { border: 0; }
.tbl tbody tr:nth-child(even) td { background: #fafbfc; }
.tbl tbody tr:hover td { background: #f3f6f9; }
.tbl tfoot td { border: 0; background: var(--fill); }
.list li, .notif-item, .gsearch-results a, .more-list a, .m-card { border: 0 !important; }
.list li:nth-child(even) { background: #fafbfc; }
input, select, textarea { border: 0 !important; background-color: var(--fill); border-radius: 10px; }
input:focus, select:focus, textarea:focus { background-color: #fff; box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 45%, transparent); }
input[type=checkbox] { background: none; }
.btn { border: 0 !important; background: var(--fill); }
.btn:hover { background: var(--fill-2); }
.btn-primary { background: var(--brand); } .btn-primary:hover { background: var(--brand-ink); }
.btn-danger { background: var(--bad-soft); }
.btn-ghost { background: transparent; }
.icon-btn, .user-chip { border: 0 !important; background: transparent; }
.icon-btn:hover, .user-chip:hover { background: var(--fill); }
.gsearch input { border: 0 !important; background: var(--fill); }
.lines { border: 0 !important; background: var(--fill); }
.lines-row { border: 0 !important; }
.lines-row input { background: #fff; }
.lines-foot { background: transparent; }
.section-title { border: 0 !important; padding-bottom: 0; }
.kv dt, .kv dd { border: 0; }
.fp-zone { border: 0 !important; }
.tabbar { border-top: 0 !important; box-shadow: 0 -1px 12px rgba(15,23,42,.06); }
.meter { background: var(--fill); }
.notice { border: 0; }
.dot-count { border: 0; box-shadow: 0 0 0 2px #fff; }
.msg { border: 0 !important; }

/* ---------- payment / balances / statements ---------- */
.input-xl { font-size: 26px !important; font-weight: 800; height: 60px; letter-spacing: -.01em; }
.input-apply { text-align: right; max-width: 150px; margin-left: auto; display: block; background: #fff !important; box-shadow: inset 0 0 0 1px var(--fill-2); }
.alloc-bar { display: grid; grid-template-columns: repeat(3, 1fr) auto; gap: 14px; align-items: center; padding: 14px 18px; background: var(--fill); border-radius: 0 0 var(--r) var(--r); }
.alloc-bar span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.alloc-bar b { font-size: 17px; font-variant-numeric: tabular-nums; }
.alloc-bar .btn { padding: 12px 22px; font-size: 14px; }
.bad { color: var(--bad) !important; } .ok { color: var(--ok) !important; }
.sum-big span { display: block; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.sum-big b { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.sum-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.sum-grid > div { background: var(--fill); border-radius: 10px; padding: 10px 12px; }
.sum-grid span { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.sum-grid b { font-size: 15px; }
.clip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 420px; }
.done-tick { width: 56px; height: 56px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; margin: 0 auto; }
.done-tick .lucide { width: 28px; height: 28px; }
.bal-kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 14px; flex: 0 0 auto; }
.bal-kpis > div { background: #fff; border-radius: var(--r); padding: 13px 16px; box-shadow: 0 1px 3px rgba(15,23,42,.05); }
.bal-kpis span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.bal-kpis b { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.st-boxes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.st-boxes > div { background: var(--fill); border-radius: 12px; padding: 12px 14px; }
.st-boxes > div.hl { background: var(--brand-soft); }
.st-boxes span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.st-boxes b { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.aging-chips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.aging-chips > div { background: var(--fill); border-radius: 10px; padding: 9px 12px; }
.aging-chips > div.late { background: var(--bad-soft); }
.aging-chips span { display: block; font-size: 11.5px; color: var(--muted); }
.aging-chips b { font-variant-numeric: tabular-nums; }
.tbl tr.total-row td { font-weight: 800; background: var(--fill) !important; }
.toolbar > div > .lbl { margin-bottom: 4px; }
#setup .toolbar { align-items: flex-end; }

/* print documents */
.st-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px; }
.st-summary > div { background: #f4f6f9; border-radius: 8px; padding: 10px 12px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.st-summary > div.hl { background: var(--brand-soft); }
.st-summary span { display: block; font-size: 11px; color: var(--muted); }
.st-summary b { font-size: 15px; }
.paper table.aging th, .paper table.aging td { text-align: right; }
.paper table.compact td, .paper table.compact th { padding: 6px 8px; font-size: 12.5px; }
.paper + .paper { margin-top: 24px; }
@media print {
  .statement-page { page-break-after: always; }
  .statement-page:last-of-type { page-break-after: auto; }
  .paper + .paper { margin-top: 0; }
  body.app { height: auto; overflow: visible; }
  .app .sidebar, .app .topbar, .tabbar, .fab, .more-sheet, .toasts, .page-actions, .no-print { display: none !important; }
  .app .shell, .app .main, .app .content { height: auto; overflow: visible; display: block; }
  .card { box-shadow: none; }
}
@media (max-width: 1100px) { .bal-kpis { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 860px) {
  .bal-kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .bal-kpis > div:first-child { grid-column: span 2; }
  .st-boxes, .st-summary { grid-template-columns: 1fr 1fr; }
  .aging-chips { grid-template-columns: 1fr 1fr; }
  .alloc-bar { grid-template-columns: repeat(3, 1fr); position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 5; border-radius: 16px; box-shadow: 0 -4px 20px rgba(15,23,42,.08); background: #fff; }
  .alloc-bar .btn { grid-column: 1 / -1; padding: 14px; font-size: 15px; border-radius: 12px; }
  .alloc-bar b { font-size: 14.5px; }
  #inv thead { display: none; }
  #inv tr { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 2px 10px; padding: 12px 14px; align-items: center; }
  #inv td { padding: 0; background: transparent !important; }
  #inv td:nth-child(1) { grid-row: 1 / span 3; }
  #inv td:nth-child(2) { grid-column: 2; }
  #inv td:nth-child(3) { grid-column: 2; font-size: 12.5px; color: var(--muted); }
  #inv td:nth-child(4) { grid-column: 2; font-size: 12px; color: var(--muted); }
  #inv td:nth-child(5) { grid-column: 3; grid-row: 1; font-weight: 700; }
  #inv td:nth-child(6) { grid-column: 3; grid-row: 2 / span 2; }
  #inv td[colspan] { grid-column: 1 / -1; grid-row: auto; }
  .input-apply { max-width: 120px; }
  #setup .toolbar > div { flex: 1 1 45%; }
  #bt thead { display: none; }
  #setup #bt tr { display: grid; grid-template-columns: minmax(0, 1fr) 130px; gap: 6px 10px; padding: 12px 14px; }
  #setup #bt td { padding: 0; background: transparent !important; }
  #setup #bt td:nth-child(2) { display: none; }
  #setup #bt td:nth-child(3) { grid-column: 1; grid-row: 2; text-align: left; font-size: 13px; }
  #setup #bt td:nth-child(4) { grid-column: 2; grid-row: 1 / span 2; }
  #setup #bt td:nth-child(5) { grid-column: 1 / -1; }
  #setup #bt td[colspan] { grid-column: 1 / -1; }
  .bal-kpis + .card .table-wrap { display: none; }
  .bal-kpis + .card .m-cards { display: block; }
}
.fp-tile { border: 0 !important; }
@media (max-width: 860px) {
  #st-table thead { display: none; }
  #st-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 11px 14px; }
  #st-table td { padding: 0; }
  #st-table td:nth-child(1) { grid-column: 1; grid-row: 1; font-size: 12px; color: var(--muted); }
  #st-table td:nth-child(2) { grid-column: 1; grid-row: 2; font-weight: 700; }
  #st-table td:nth-child(3) { grid-column: 1; grid-row: 3; font-size: 12.5px; color: var(--muted); }
  #st-table td:nth-child(4), #st-table td:nth-child(5) { grid-column: 2; grid-row: 1 / span 2; font-weight: 750; align-self: center; }
  #st-table td:nth-child(4):empty, #st-table td:nth-child(5):empty { display: none; }
  #st-table td:nth-child(5):not(:empty) { color: var(--ok); }
  #st-table td:nth-child(6) { grid-column: 2; grid-row: 3; font-size: 12px; color: var(--muted); }
  #st-table td[colspan] { grid-column: 1; grid-row: 1; font-size: 14px; color: inherit; }
  #st-table td[colspan] + td { grid-column: 2; grid-row: 1; font-size: 14px; color: inherit; }
}
@media (max-width: 860px) {
  #st-table td { background: transparent !important; }
  #st-table tbody tr:nth-child(even) { background: #fafbfc; }
  #st-table tr.total-row { background: var(--fill); border-radius: 10px; }
}
