/* Qbiz ERP — core stylesheet (no build step required) */
:root {
  --brand: #0a7c70;
  --accent: #ff6a00;
  --brand-ink: #fff;
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --side: #032b2a;
  --side-ink: #c5dedb;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --warn: #a16207;
  --warn-bg: #fef9c3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans Bengali", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 14px; color: var(--ink); background: var(--bg); line-height: 1.45; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.35rem; font-weight: 650; }
h2 { font-size: 1.1rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 650; }
small, .muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; }
[x-cloak] { display: none !important; }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 240px; flex: 0 0 240px; 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: .6rem; padding: 1rem 1.1rem; color: #fff; font-weight: 700; font-size: 1.05rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand img { max-height: 40px; max-width: 170px; }
.brand { min-height: 64px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; font-weight: 800; color: #fff; }
.nav { padding: .6rem .5rem 1.5rem; }
.nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #6f9c97; padding: 1rem .75rem .35rem; }
.nav a { display: flex; align-items: center; gap: .6rem; padding: .5rem .75rem; border-radius: 8px; color: var(--side-ink); font-size: .9rem; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.1); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav svg { width: 17px; height: 17px; flex: 0 0 17px; opacity: .9; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 58px; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 1.25rem; position: sticky; top: 0; z-index: 20; }
.topbar .left, .topbar .right { display: flex; align-items: center; gap: .75rem; }
.company-name { font-weight: 600; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: .78rem; font-weight: 700; }
.content { padding: 1.25rem; max-width: 1600px; width: 100%; }
.menu-toggle { display: none; background: none; border: 0; cursor: pointer; padding: .3rem; }
.footer { color: var(--muted); font-size: .78rem; padding: 1rem 1.25rem 1.5rem; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head p { margin: .15rem 0 0; color: var(--muted); }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---------- Cards ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 1rem 1.1rem; }
.card-head { padding: .8rem 1.1rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack > * + * { margin-top: 1rem; }
.kpi { padding: 1rem 1.1rem; }
.kpi .label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 1.55rem; font-weight: 700; margin-top: .25rem; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: .8rem; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid var(--line-strong); background: #fff; color: var(--ink); padding: .5rem .9rem; border-radius: 8px; font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; line-height: 1.2; }
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand); filter: brightness(.94); }
.btn-danger { color: var(--bad); border-color: #fecaca; }
.btn-danger:hover { background: var(--bad-bg); }
.btn-sm { padding: .3rem .6rem; font-size: .82rem; }
.btn-lg { padding: .75rem 1.4rem; font-size: 1rem; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; font: inherit; }
.link-btn.danger { color: var(--bad); }
form.inline { display: inline; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 550; font-size: .85rem; margin-bottom: .3rem; }
.field { margin-bottom: .9rem; }
.hint { color: var(--muted); font-size: .78rem; margin-top: .25rem; }
input:not([type]), input[type=datetime-local], input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], input[type=search], input[type=tel], select, textarea {
  width: 100%; padding: .5rem .65rem; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; font: inherit; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
input[readonly] { background: #f1f5f9; }
textarea { min-height: 70px; resize: vertical; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.check input { width: 16px; height: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.error { color: var(--bad); font-size: .8rem; margin-top: .25rem; }
.is-invalid { border-color: var(--bad) !important; }

.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; margin-bottom: 1rem; }
.filters .f { min-width: 140px; }
.filters .f label { font-size: .75rem; color: var(--muted); margin-bottom: .2rem; }
.filters input, .filters select { padding: .42rem .55rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
.table th, .table td { padding: .55rem .75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { background: #f8fafc; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; white-space: nowrap; }
.table tbody tr:hover { background: #f8fafc; }
.table .num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td, .table tr.total td { font-weight: 700; background: #f1f5f9; }
.table tr.subtotal td { font-weight: 650; background: #f8fafc; }
.table tr.group td { background: #eef2ff; font-weight: 650; }
.table.compact th, .table.compact td { padding: .35rem .5rem; font-size: .82rem; }
/* Sheet-style dense grid (mirrors Google Sheets reports) */
.sheet th { background: #334155; color: #fff; text-transform: none; letter-spacing: 0; font-size: .78rem; }
.sheet td, .sheet th { border: 1px solid var(--line); padding: .3rem .5rem; font-size: .82rem; }
.sheet td.num { min-width: 52px; }
.neg { color: var(--bad); }
.pos { color: var(--ok); }

.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }

/* ---------- Badges & alerts ---------- */
.badge { display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 650; background: #e2e8f0; color: #334155; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-brand { background: color-mix(in srgb, var(--brand) 14%, #fff); color: var(--brand); }
.alert { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-success { background: var(--ok-bg); color: #14532d; border-color: #bbf7d0; }
.alert-error { background: var(--bad-bg); color: #7f1d1d; border-color: #fecaca; }
.alert-warning { background: var(--warn-bg); color: #78350f; border-color: #fde68a; }
.alert-info { background: #e0f2fe; color: #075985; border-color: #bae6fd; }

/* ---------- Sales grid (Google-form style) ---------- */
.entry-head { display: grid; grid-template-columns: 1.3fr 1fr 1.4fr; gap: 1rem; align-items: start; }
.radio-row { display: flex; gap: .4rem; flex-wrap: wrap; }
.radio-pill { position: relative; }
.radio-pill input { position: absolute; opacity: 0; }
.radio-pill span { display: inline-block; padding: .45rem .85rem; border: 1px solid var(--line-strong); border-radius: 999px; cursor: pointer; font-weight: 600; font-size: .85rem; }
.radio-pill input:checked + span { background: var(--brand); color: #fff; border-color: var(--brand); }
.qty-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.qty-cell { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fff; }
.qty-cell .pname { text-align: center; font-size: .8rem; font-weight: 600; padding: .35rem .3rem; background: #f8fafc; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qty-cell input { border: 0; border-radius: 0; text-align: center; font-size: 1rem; padding: .55rem .3rem; }
.qty-cell input.rate { font-size: .8rem; color: var(--muted); border-top: 1px dashed var(--line); padding: .3rem; }
.qty-cell input:focus { outline: 2px solid var(--brand); outline-offset: -2px; }
.money-row { display: grid; grid-template-columns: repeat(3, minmax(110px, 1fr)) 2fr; gap: .75rem; }
.shop-chip { margin-top: .35rem; font-size: .82rem; }

/* ---------- Bars (simple chart) ---------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar .fill { width: 100%; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; opacity: .85; }
.bar .fill:hover { opacity: 1; }
.bar .lbl { font-size: .65rem; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.hbar { height: 8px; background: #e2e8f0; border-radius: 99px; overflow: hidden; }
.hbar > div { height: 100%; background: var(--brand); }

/* ---------- Report tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.tile { display: block; padding: 1rem 1.1rem; color: var(--ink); }
.tile:hover { text-decoration: none; border-color: var(--brand); }
.tile h3 { margin-bottom: .25rem; }
.tile p { margin: 0; color: var(--muted); font-size: .85rem; }
.tile .from { font-size: .72rem; color: var(--brand); margin-top: .5rem; }

/* ---------- Auth / installer ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; background: linear-gradient(135deg, #021f1e 0%, #033b3a 55%, color-mix(in srgb, var(--brand) 70%, #021f1e) 100%); }
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.25); padding: 2rem; }
.auth-card.wide { max-width: 640px; }
.auth-logo { display: flex; align-items: center; justify-content: center; gap: .6rem; font-weight: 800; font-size: 1.25rem; margin-bottom: 1.5rem; }
.auth-logo img { max-height: 64px; max-width: 240px; }
.steps { display: flex; gap: .4rem; margin-bottom: 1.25rem; }
.steps span { flex: 1; height: 4px; border-radius: 4px; background: #e2e8f0; }
.steps span.on { background: var(--brand); }
.checklist { list-style: none; padding: 0; margin: 0 0 1rem; }
.checklist li { display: flex; justify-content: space-between; padding: .4rem 0; border-bottom: 1px solid var(--line); font-size: .88rem; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: 1rem; align-items: center; }
.pagination a, .pagination span { padding: .3rem .65rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-size: .85rem; }
.pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }
.pagination .disabled { color: var(--muted); }

/* ---------- Invoice print ---------- */
.doc { max-width: 820px; margin: 0 auto; background: #fff; padding: 2rem; border: 1px solid var(--line); border-radius: var(--radius); }
.doc-head { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 2px solid var(--ink); padding-bottom: 1rem; margin-bottom: 1rem; }
.doc-head img { max-height: 60px; max-width: 200px; }
.doc-title { font-size: 1.6rem; font-weight: 800; letter-spacing: .04em; text-align: right; }
.doc-meta { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.doc-totals { margin-left: auto; width: 280px; }
.doc-totals td { padding: .35rem .5rem; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .entry-head { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: -260px; z-index: 50; transition: left .2s; }
  body.nav-open .sidebar { left: 0; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
  .menu-toggle { display: inline-block; }
  .grid-2, .grid-3, .grid-4, .form-grid, .entry-head { grid-template-columns: 1fr; }
  .money-row { grid-template-columns: 1fr 1fr; }
  .content { padding: .9rem; }
}

@media print {
  .sidebar, .topbar, .no-print, .filters, .footer, .pagination { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; max-width: none; }
  .card, .doc { box-shadow: none; border: 0; }
  .sheet th { background: #e2e8f0 !important; color: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.btn svg, .link-btn svg { width: 16px; height: 16px; flex: 0 0 16px; }
.sheet td { white-space: nowrap; }
.brand-icon { width: 32px; height: 32px; border-radius: 8px; }
.brand .brand-icon { width: 34px; height: 34px; max-height: none; }
.erp-tag { background: var(--accent); color: #fff; font-size: .62rem; font-weight: 800; letter-spacing: .08em; padding: .12rem .4rem; border-radius: 5px; vertical-align: middle; margin-left: .15rem; }

/* =====================================================================
   Mobile-first app experience (phones & installed app)
   ===================================================================== */
html { -webkit-text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; }
.menu-toggle svg { width: 24px; height: 24px; display: block; }
.table-wrap { -webkit-overflow-scrolling: touch; }
.side-foot { margin-top: auto; padding: .75rem; border-top: 1px solid rgba(255,255,255,.08); display: none; }
.side-install { display: flex; align-items: center; gap: .6rem; width: 100%; background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: .7rem .9rem; font: inherit; font-weight: 650; margin-bottom: .6rem; cursor: pointer; }
.side-install[hidden] { display: none; }
.side-install svg { width: 18px; height: 18px; }
.side-user { display: flex; align-items: center; gap: .6rem; color: #fff; }
.side-user-name { flex: 1; min-width: 0; line-height: 1.2; }
.side-user-name strong, .side-user-name small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-name small { color: var(--side-ink); }
.side-user .btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.25); }
.tabbar { display: none; }
.g-2-1 { grid-template-columns: 2fr 1fr; }
.g-1-2 { grid-template-columns: 1fr 2fr; }
.g-form-side { grid-template-columns: minmax(0, 640px) 1fr; }
.fg-inv-head { grid-template-columns: 1.4fr 1fr 1fr; }
.fg-4 { grid-template-columns: repeat(4, 1fr); }
.fg-ref { grid-template-columns: 1fr 1fr 2fr; }
.span-3 { grid-column: span 3; }
.span-2 { grid-column: span 2; }
.ios-hint { position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 60; background: #0f172a; color: #fff; border-radius: 14px; padding: .8rem 2.6rem .8rem 1rem; font-size: .9rem; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.ios-hint svg { vertical-align: -3px; }
.ios-hint button { position: absolute; right: 6px; top: 6px; background: none; border: 0; color: #fff; font-size: 1rem; width: 36px; height: 36px; }

@media (max-width: 860px) {
  body { font-size: 15px; background: var(--bg); }
  /* app shell */
  .shell { display: block; }
  .sidebar { width: 84vw; max-width: 320px; left: -340px; height: 100dvh; padding-top: env(safe-area-inset-top); box-shadow: 12px 0 40px rgba(0,0,0,.25); }
  body.nav-open { overflow: hidden; }
  .side-foot { display: block; padding-bottom: calc(.75rem + env(safe-area-inset-bottom)); }
  .nav a { padding: .72rem .8rem; font-size: 1rem; }
  .nav svg { width: 20px; height: 20px; flex-basis: 20px; }
  .topbar { height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) .75rem 0; gap: .5rem; }
  .topbar .left { min-width: 0; flex: 1; gap: .4rem; }
  .topbar .left select { min-width: 0 !important; max-width: 60vw; }
  .company-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1rem; }
  .topbar .who, .top-logout { display: none; }
  .menu-toggle { display: grid; place-items: center; width: 44px; height: 44px; margin-left: -.4rem; color: var(--ink); }
  .content { padding: .85rem .85rem calc(84px + env(safe-area-inset-bottom)); }
  .footer { display: none; }
  /* bottom tab bar */
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; background: rgba(255,255,255,.97); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 4px 4px env(safe-area-inset-bottom); }
  .tabbar a, .tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; color: var(--muted); font: inherit; font-size: .7rem; font-weight: 600; background: none; border: 0; border-radius: 10px; text-decoration: none; cursor: pointer; }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar a.on { color: var(--brand); }
  .tabbar a.on svg { stroke-width: 2.4; }
  body.nav-open .tabbar { z-index: 30; }
  /* headings & page header */
  h1 { font-size: 1.3rem; }
  .page-head { margin-bottom: .8rem; gap: .6rem; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; }
  /* touch-friendly controls: 16px text stops iPhone zooming into fields */
  input:not([type]), input[type=datetime-local], input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], input[type=search], input[type=tel], select, textarea { font-size: 16px; min-height: 46px; padding: .6rem .75rem; }
  .btn { min-height: 44px; padding: .6rem 1rem; }
  .btn-sm { min-height: 38px; padding: .45rem .75rem; font-size: .88rem; }
  .check input { width: 20px; height: 20px; }
  label { font-size: .9rem; }
  .radio-pill span { padding: .6rem 1.1rem; font-size: .95rem; }
  /* layouts collapse */
  .grid-2, .grid-3, .form-grid, .entry-head, .g-2-1, .g-1-2, .g-form-side, .fg-inv-head, .fg-ref { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .fg-4 { grid-template-columns: 1fr 1fr; }
  .span-3, .span-2 { grid-column: 1 / -1; }
  .money-row { grid-template-columns: 1fr 1fr; }
  .grid { gap: .75rem; }
  .card-body { padding: .9rem; }
  .card-head { padding: .75rem .9rem; flex-wrap: wrap; }
  .kpi { padding: .8rem .9rem; }
  .kpi .label { font-size: .7rem; }
  .kpi .value { font-size: 1.25rem; }
  /* filters: two per row, button full width */
  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
  .filters .f { min-width: 0; }
  .filters .f.full, .filters .f:has(input[type=search]), .filters .f:has(input[type=text]) { grid-column: 1 / -1; }
  .filters > .btn, .filters > button, .filters .actions { grid-column: 1 / -1; width: 100%; }
  .filters input, .filters select { padding: .55rem .65rem; }
  /* tables: readable, scroll sideways, first column stays put */
  .table th, .table td { padding: .6rem .65rem; }
  .table-wrap { margin: 0; border-radius: 0 0 var(--radius) var(--radius); }
  .sheet td, .sheet th { font-size: .85rem; }
  .sheet th:first-child, .sheet td:first-child { position: sticky; left: 0; background: #fff; z-index: 1; box-shadow: 1px 0 0 var(--line); }
  .sheet th:first-child { background: #334155; }
  .sheet tr.total td:first-child, .sheet tr.subtotal td:first-child { background: #f1f5f9; }
  /* daily entry grid */
  .qty-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .qty-cell .pname { font-size: .78rem; padding: .4rem .25rem; }
  .qty-cell input { font-size: 18px; min-height: 52px; }
  /* invoice lines become cards */
  .lines-table thead { display: none; }
  .lines-table, .lines-table tbody, .lines-table tfoot { display: block; }
  .lines-table tbody tr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .5rem; padding: .75rem .9rem; border-bottom: 1px solid var(--line); position: relative; }
  .lines-table tbody td { display: block; padding: 0; border: 0; width: auto !important; }
  .lines-table tbody td:first-child { grid-column: 1 / -1; padding-right: 2.5rem; }
  .lines-table tbody td[data-label]::before { content: attr(data-label); display: block; font-size: .72rem; color: var(--muted); font-weight: 600; margin-bottom: .2rem; text-transform: uppercase; letter-spacing: .04em; }
  .lines-table td.line-amount { align-self: end; text-align: right; font-weight: 700; padding-bottom: .7rem; }
  .lines-table td.line-remove { position: absolute; right: .6rem; top: .8rem; }
  .lines-table td.line-remove .link-btn { width: 40px; height: 40px; font-size: 1.1rem; }
  .lines-table tfoot tr { display: flex; justify-content: space-between; align-items: center; padding: .75rem .9rem; flex-wrap: wrap; gap: .5rem; }
  .lines-table tfoot td { border: 0; padding: 0; }
  /* dashboard chart & documents */
  .bars { height: 140px; gap: 3px; }
  .bar .lbl { font-size: .58rem; }
  .doc { padding: 1rem; border-radius: 0; margin: 0 -.85rem; }
  .doc-head, .doc-meta { flex-direction: column; }
  .doc-title { text-align: left; font-size: 1.3rem; }
  .doc-totals { width: 100%; }
  .tiles { grid-template-columns: 1fr; gap: .6rem; }
  .pagination a, .pagination span { padding: .55rem .85rem; }
  .alert { font-size: .92rem; }
  .auth-card { padding: 1.5rem 1.25rem; border-radius: 16px; }
  .auth-wrap { padding: 1rem .75rem; align-content: start; padding-top: max(2rem, env(safe-area-inset-top)); }
  .demo-banner { position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 15; }
}
/* installed app: no browser chrome, respect notches */
.is-app .topbar { padding-top: env(safe-area-inset-top); }
@media (display-mode: standalone) { body { overscroll-behavior-y: none; } }
.filters .f-wide { min-width: 220px; }
.filters .f-submit { min-width: auto; }
.filters .f-actions { min-width: auto; margin-left: auto; }
@media (max-width: 860px) {
  .topbar .top-logout { display: none; }
  .filters .f, .filters .f-wide { min-width: 0 !important; }
  .filters .f-wide, .filters .f-submit, .filters .f-actions { grid-column: 1 / -1; margin-left: 0; }
  .filters .f-submit .btn { width: 100%; }
  .filters .f-actions .actions { display: grid; grid-template-columns: 1fr 1fr; }
  .filters input[type=date] { min-width: 0; width: 100%; }
}
@media (max-width: 860px) {
  .filters .f:has(> .btn), .filters .f:has(.actions), .filters .f:has(.check) { grid-column: 1 / -1; margin-left: 0 !important; }
  .filters .f > .btn { width: 100%; }
  .filters .f .actions { display: grid; grid-template-columns: 1fr 1fr; }
  .filters .f .check { margin: 0 !important; }
}
@media (max-width: 860px) { .table-wrap .table td, .table-wrap .table th { white-space: nowrap; } }
.grid > *, .form-grid > * { min-width: 0; }
@media (max-width: 860px) { .grid-2[style], .grid-3[style] { grid-template-columns: 1fr !important; } }
