/* Rent Manager — design system. Plain CSS, no build step. Fonts/icons are local (CSP: default-src 'self'). */
:root {
  --bg: #f6f7f9;
  --surface: #fff;
  --surface-2: #f9fafb;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #475467;
  --text-3: #667085;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft: #eff4ff;
  --success: #067647;
  --success-soft: #ecfdf3;
  --warning: #b54708;
  --warning-soft: #fffaeb;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --focus: 0 0 0 3px rgba(29, 78, 216, .25);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);
  --sidebar-w: 236px;
  --topbar-h: 60px;
  --bottom-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: var(--primary); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.icon { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }
:focus-visible { outline: none; box-shadow: var(--focus); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }

/* ---------- App shell ---------- */
.app { min-height: 100vh; min-height: 100dvh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 16px 12px; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; letter-spacing: .5px; }
.brand-name { font-weight: 650; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--text-3); }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 16px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--text-2); text-decoration: none; font-weight: 500; font-size: 14px; border: 0; background: none; cursor: pointer; width: 100%; text-align: left; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.nav-foot { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 10px; }

.main { margin-left: var(--sidebar-w); min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 32px; background: rgba(246, 247, 249, .92); backdrop-filter: saturate(180%) blur(8px); border-bottom: 1px solid transparent; }
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar h1 { font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }
.content { padding: 8px 32px 48px; max-width: 1240px; }
.view { display: none; }
.view.active { display: block; animation: fade .15s ease-out; }
@keyframes fade { from { transform: translateY(2px); } to { transform: none; } }

.bottom-nav { display: none; }

/* ---------- Layout helpers ---------- */
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-end { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.section-title { font-size: 15px; font-weight: 650; }
.section-sub { font-size: 13px; color: var(--text-3); margin-top: 2px; }
.page-intro { color: var(--text-2); font-size: 14px; margin-bottom: 16px; }

/* ---------- Card ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head > div:first-child { flex: 1; min-width: 0; }
.card-body { padding: 20px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm); border: 1px solid transparent; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background-color .12s, border-color .12s; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #912018; }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-icon { min-height: 40px; width: 40px; padding: 0; }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-color: rgba(255,255,255,.9) rgba(255,255,255,.9) transparent transparent; animation: spin .7s linear infinite; }
.btn-secondary.loading::after, .btn-ghost.loading::after { border-color: var(--text-3) var(--text-3) transparent transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.hint { font-size: 12px; color: var(--text-3); }
.input, .select, .textarea { width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); font-size: 14px; }
.textarea { min-height: 96px; font-family: var(--mono); font-size: 13px; resize: vertical; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--danger); }
.field-error { font-size: 12px; color: var(--danger); }
.input-group { display: flex; gap: 8px; }
.input-group > .input { flex: 1; }
.input-prefix { position: relative; }
.input-prefix > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-prefix > .input { padding-left: 26px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; min-height: 32px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.segmented button { border: 0; background: none; padding: 7px 14px; min-height: 38px; font-size: 14px; font-weight: 500; color: var(--text-2); cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--border-strong); }
.segmented button[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-paid, .status-paid { background: var(--success-soft); color: var(--success); }
.badge-partial, .status-partial { background: var(--warning-soft); color: var(--warning); }
.badge-pending, .status-pending { background: var(--danger-soft); color: var(--danger); }
.badge-neutral { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.badge-info { background: var(--primary-soft); color: var(--primary); }
.badge-plain::before { display: none; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { padding: 16px 18px; }
.stat-label { font-size: 13px; color: var(--text-3); font-weight: 500; }
.stat-value { font-size: 24px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.stat-value.ok { color: var(--success); }
.stat-value.due { color: var(--danger); }
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--success); border-radius: 999px; }

/* ---------- Tables (become cards on phones) ---------- */
.table-wrap { overflow-x: auto; position: relative; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fcfcfd; }
.table .r { text-align: right; font-variant-numeric: tabular-nums; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text); }
.table th[aria-sort="ascending"]::after { content: ' ↑'; }
.table th[aria-sort="descending"]::after { content: ' ↓'; }
.table tfoot td { font-weight: 650; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.selected td { background: var(--primary-soft); }
.table input.input, .table select.select { min-height: 34px; padding: 4px 8px; font-size: 13px; }
.table .select { padding-right: 28px; background-position: right 6px center; }
.cell-strong { font-weight: 600; }
.cell-sub { font-size: 12px; color: var(--text-3); }

.show-sm, .show-md { display: none; }
@media (min-width: 721px) and (max-width: 1180px) {
  .table .bk { display: none; }
  .table .show-md { display: block; }
}
.dash-cols { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }

/* ---------- List rows ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-title { font-weight: 600; font-size: 14px; }
.list-sub { font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.search { position: relative; flex: 1 1 220px; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 18px; height: 18px; }
.search .input { padding-left: 36px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px; padding: 5px 12px; min-height: 34px; font-size: 13px; font-weight: 500; color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"] { background: var(--primary-soft); border-color: #b2ccff; color: var(--primary); }
.chip .count { font-size: 12px; color: var(--text-3); }
.chip[aria-pressed="true"] .count { color: var(--primary); }

/* ---------- Popover (month picker) ---------- */
.popover-wrap { position: relative; }
.popover { position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); min-width: 220px; max-height: 320px; overflow-y: auto; padding: 6px; }
.popover-actions { display: flex; justify-content: space-between; padding: 6px 8px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.popover-actions button { border: 0; background: none; color: var(--primary); font-weight: 600; font-size: 13px; cursor: pointer; padding: 4px; }
.popover .check { display: flex; padding: 6px 8px; border-radius: var(--radius-sm); }
.popover .check:hover { background: var(--surface-2); }

/* ---------- Feedback ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; border: 1px solid; }
.alert .icon { margin-top: 1px; }
.alert-success { background: var(--success-soft); border-color: #abefc6; color: var(--success); }
.alert-error { background: var(--danger-soft); border-color: #fecdca; color: var(--danger); }
.alert-info { background: var(--primary-soft); border-color: #c7d7fe; color: #1e3a8a; }
.alert-warn { background: var(--warning-soft); border-color: #fedf89; color: var(--warning); }
.response:empty { display: none; }
.response.success { display: block; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--success-soft); border: 1px solid #abefc6; color: var(--success); font-size: 14px; }
.response.error { display: block; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--danger-soft); border: 1px solid #fecdca; color: var(--danger); font-size: 14px; }
.empty { text-align: center; padding: 40px 20px; color: var(--text-3); }
.empty .icon { width: 36px; height: 36px; color: var(--border-strong); margin-bottom: 8px; }
.empty-title { font-weight: 600; color: var(--text-2); }
.skeleton { background: linear-gradient(90deg, #f2f4f7 25%, #e9ecf1 50%, #f2f4f7 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; height: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.output-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; white-space: pre-wrap; font-family: var(--mono); font-size: 13px; line-height: 1.6; overflow-x: auto; margin: 0; }
.output-box:empty { display: none; }

.toasts { position: fixed; z-index: 100; right: 24px; bottom: 24px; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; background: #101828; color: #fff; padding: 12px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: 14px; animation: toast-in .18s ease-out; }
.toast.error { background: var(--danger); }
.toast .icon { margin-top: 1px; }
@keyframes toast-in { from { transform: translateY(8px); } }

/* ---------- Dialog ---------- */
dialog.dialog { border: 0; padding: 0; border-radius: 14px; box-shadow: var(--shadow-lg); width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); color: var(--text); }
dialog.dialog.dialog-wide { width: min(760px, calc(100vw - 32px)); }
dialog.dialog::backdrop { background: rgba(16, 24, 40, .45); }
dialog.dialog[open] { animation: pop .16s ease-out; }
@keyframes pop { from { transform: scale(.98); } }
.dialog-head { padding: 20px 24px 0; }
.dialog-head h2 { font-size: 18px; font-weight: 650; }
.dialog-body { padding: 16px 24px; overflow-y: auto; }
.dialog-foot { padding: 0 24px 20px; display: flex; gap: 8px; justify-content: flex-end; }
.summary-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 14px; }
.summary-list dt { color: var(--text-3); }
.summary-list dd { margin: 0; font-weight: 600; }

/* ---------- Tabs (in-page) ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: none; padding: 10px 14px; font-size: 14px; font-weight: 500; color: var(--text-3); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---------- Timeline (tenant history) ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 24px; }
.timeline li::before { content: ''; position: absolute; left: 5px; top: 8px; bottom: -2px; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ''; position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); }
.timeline li.current::after { background: var(--primary); border-color: var(--primary); }

/* ---------- Documents ---------- */
.doc-row { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.doc-row:last-of-type { border-bottom: 0; }
.doc-main { display: flex; align-items: center; gap: 12px; }
.doc-main .grow { flex: 1; min-width: 0; }
.doc-icon { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); flex-shrink: 0; }
.doc-icon.has { background: var(--success-soft); color: var(--success); border-color: #abefc6; }
.doc-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.doc-del { color: var(--danger); padding-left: 8px; padding-right: 8px; }
.doc-progress { margin-top: 10px; }
.doc-old { margin-top: 6px; font-size: 13px; }
.doc-old summary { cursor: pointer; color: var(--text-3); padding: 4px 0; }

/* ---------- Login ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.login-card { width: 100%; max-width: 380px; padding: 32px 28px; }
.login-card .brand { padding: 0 0 20px; }
.login-card h2 { font-size: 22px; font-weight: 650; margin-bottom: 4px; }

/* ---------- Bottom sheet (mobile "More") ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(16, 24, 40, .4); z-index: 60; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; background: var(--surface); border-radius: 16px 16px 0 0; padding: 8px 12px calc(16px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg); animation: sheet-in .18s ease-out; }
.sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 4px auto 10px; }
.sheet .nav-item { padding: 14px 12px; font-size: 15px; }
@keyframes sheet-in { from { transform: translateY(100%); } }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  :root { --sidebar-w: 76px; }
  .dash-cols { grid-template-columns: minmax(0, 1fr); }
  .sidebar { padding: 16px 10px; align-items: center; }
  .sidebar .brand-name, .sidebar .brand-sub, .sidebar .nav-label, .sidebar .nav-item span { display: none; }
  .sidebar .brand { padding: 4px 0 18px; }
  .sidebar .nav-item { justify-content: center; padding: 11px; }
  .sidebar .nav-label + .nav-item { margin-top: 12px; }
  .topbar, .content { padding-left: 24px; padding-right: 24px; }
}
@media (max-width: 720px) {
  body { font-size: 16px; }
  .sidebar { display: none; }
  .main { margin-left: 0; padding-bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom)); }
  .topbar { padding: env(safe-area-inset-top) 16px 0; height: calc(56px + env(safe-area-inset-top)); }
  .topbar h1 { font-size: 18px; }
  .content { padding: 4px 16px 32px; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
  .card-pad, .card-body { padding: 16px; }
  .card-head { padding: 14px 16px; }
  .card-foot { padding: 12px 16px; }
  .list-item { padding: 12px 16px; }
  .input, .select, .textarea, .segmented button { font-size: 16px; min-height: 44px; }
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }
  .check input { width: 20px; height: 20px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stats.stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stats-3 .stat { padding: 10px 12px; }
  .stats-3 .stat-label { font-size: 12px; }
  .stats-3 .stat-value { font-size: 16px; }
  .card-foot .btn { flex: 1; }
  .doc-main { flex-wrap: wrap; }
  .doc-actions { width: 100%; justify-content: stretch; }
  .doc-actions .btn { flex: 1; min-height: 44px; }
  .doc-actions .doc-del { flex: 0 0 48px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 20px; }
  .toasts { left: 16px; right: 16px; bottom: calc(var(--bottom-h) + 12px + env(safe-area-inset-bottom)); max-width: none; }
  dialog.dialog, dialog.dialog.dialog-wide { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 16px 16px 0 0; max-height: 92dvh; }
  .dialog-foot { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .dialog-foot .btn { flex: 1; }

  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; height: calc(var(--bottom-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: rgba(255, 255, 255, .97); border-top: 1px solid var(--border); backdrop-filter: blur(8px); }
  .bottom-nav button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 500; color: var(--text-3); cursor: pointer; padding: 6px 0; }
  .bottom-nav button[aria-current="page"] { color: var(--primary); }
  .bottom-nav .icon { width: 22px; height: 22px; }
  .bottom-nav .pay-fab { width: 46px; height: 46px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; margin-top: -14px; box-shadow: 0 4px 12px rgba(29, 78, 216, .35); }
  .bottom-nav .pay-fab .icon { width: 22px; height: 22px; }

  /* Tables → cards */
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .table-cards tbody tr:hover td { background: none; }
  .table-cards td { padding: 2px 0; border: 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table-cards td::before { content: attr(data-label); color: var(--text-3); font-size: 14px; text-align: left; }
  .table-cards td.card-title { font-weight: 650; font-size: 16px; text-align: left; justify-content: flex-start; padding-bottom: 4px; }
  .table-cards td.card-title::before, .table-cards td.no-label::before { content: none; }
  .table-cards td.hide-sm { display: none; }
  .table-cards td.show-sm { display: block; }
  .table-cards .flags { justify-content: flex-end; }
  .table-cards span.show-sm { display: inline; }
  .table-cards .r { text-align: right; }
  .table-cards tfoot { display: block; }
  .table-cards tfoot tr { display: block; background: var(--surface-2); }
  .table-cards tfoot td { background: none; border: 0; }
}
@media (min-width: 540px) and (max-width: 720px) {
  .table-cards tbody { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-cards tbody tr:nth-child(odd) { border-right: 1px solid var(--border); }
}
@media (max-width: 360px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
  .content { padding-left: 12px; padding-right: 12px; }
}
@media (min-width: 1600px) {
  .content { max-width: 1400px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
@media print {
  .sidebar, .bottom-nav, .topbar-actions, .toolbar, .no-print { display: none !important; }
  .main { margin: 0; }
  body { background: #fff; }
}
