/* ARS (Apex Rental System) — dark "Minimal UI" look, phone first. */
:root {
  color-scheme: dark;
  --bg: #141a21;
  --card: #1c252e;
  --card-2: #212b36;
  --raise: #28323d;
  --line: rgba(145, 158, 171, 0.16);
  --line-2: rgba(145, 158, 171, 0.28);
  --text: #ffffff;
  --text-2: #919eab;
  --text-3: #637381;
  --primary: #4a9bf7;
  --primary-strong: #1f6feb;
  --primary-soft: rgba(74, 155, 247, 0.16);
  --info: #00b8d9;
  --info-soft: rgba(0, 184, 217, 0.16);
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.16);
  --warning: #ffab00;
  --warning-soft: rgba(255, 171, 0, 0.16);
  --error: #ff5630;
  --error-soft: rgba(255, 86, 48, 0.16);
  --whatsapp: #25d366;
  /* Chart series (validated on --card: CVD ΔE 26.8, ≥3:1 contrast) */
  --series-income: #3987e5;
  --series-expense: #d95926;
  --radius: 16px;
  --radius-sm: 10px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
body.sheet-open { overflow: hidden; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 700; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
[hidden] { display: none !important; }
code { font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg); padding: 2px 6px; border-radius: 6px; word-break: break-all; }

.icon { width: 22px; height: 22px; flex: none; }
.icon.inline { width: 1em; height: 1em; vertical-align: -0.15em; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.center { text-align: center; }
.lead { color: var(--text-2); font-size: 15px; margin-bottom: 16px; }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }
.text-success { color: var(--success); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.pad { padding: 16px; }

/* ── Boot / spinner ─────────────────────────────────────── */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner, .btn.busy::after {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--line-2); border-top-color: var(--primary);
  animation: spin 0.8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--raise); color: var(--text);
  font-weight: 700; font-size: 15px; white-space: nowrap; text-decoration: none;
  transition: background 0.15s, opacity 0.15s; position: relative;
}
.btn .icon { width: 20px; height: 20px; }
.btn.primary { background: #fff; color: #1c252e; }
.btn.primary:hover { background: #e7ebef; }
.btn.ghost { background: transparent; border-color: var(--line-2); color: var(--text); }
.btn.ghost:hover { background: rgba(145, 158, 171, 0.08); }
.btn.success { background: var(--success); color: #062b14; }
.btn.danger { background: var(--error); color: #fff; }
.btn.danger-soft { background: var(--error-soft); color: #ffac82; }
.btn.whatsapp { background: var(--whatsapp); color: #052e16; }
.btn.danger-text { color: #ff8a6c; }
.btn.block { display: flex; width: 100%; }
.btn.lg { min-height: 52px; font-size: 16px; border-radius: 12px; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.icon-only { width: 48px; padding: 0; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn.busy { color: transparent !important; }
.btn.busy .icon { opacity: 0; }
.btn.busy::after { content: ""; position: absolute; width: 18px; height: 18px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border-radius: 50%; border: 0; background: transparent; color: var(--text-2);
}
.icon-btn:hover { background: rgba(145, 158, 171, 0.08); color: var(--text); }
.icon-btn.sm { width: 36px; height: 36px; }
.link-btn { border: 0; background: none; color: var(--primary); font-weight: 600; padding: 0 12px; min-height: 44px; }

/* ── Pills / chips / avatars ───────────────────────────── */
.pill {
  display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; font-weight: 700; white-space: nowrap; background: rgba(145, 158, 171, 0.16); color: var(--text-2);
}
.pill.success { background: var(--success-soft); color: #77ed8b; }
.pill.warning { background: var(--warning-soft); color: #ffd666; }
.pill.error { background: var(--error-soft); color: #ffac82; }
.pill.info { background: var(--primary-soft); color: #8fc3ff; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 20px; }
.chip { display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 13px; color: var(--text-2); }
.chip.warning { color: #ffd666; border-color: rgba(255, 171, 0, 0.32); }
.chip-btn { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; color: var(--text); font-size: 14px; font-weight: 600; }
.chip-btn:hover { background: rgba(145, 158, 171, 0.08); }
.avatar {
  display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%;
  font-weight: 700; font-size: 14px; color: #fff; background: #3b82f6;
}
.avatar.lg { width: 48px; height: 48px; font-size: 16px; }
.avatar.xl { width: 72px; height: 72px; font-size: 24px; }
.avatar.tone-blue { background: #1f6feb; }
.avatar.tone-cyan { background: #0891b2; }
.avatar.tone-green { background: #15803d; }
.avatar.tone-orange { background: #c2410c; }
.avatar.tone-violet { background: #6d28d9; }
.avatar.tone-red { background: #b91c1c; }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--error); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }

/* ── Layout: phone first ───────────────────────────────── */
.sidebar { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  height: calc(56px + var(--safe-t)); padding: var(--safe-t) 16px 0;
  background: rgba(20, 26, 33, 0.86); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .company { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar-link .avatar { width: 36px; height: 36px; font-size: 13px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; font-size: 20px; }
.logo-mark { width: 32px; height: 32px; flex: none; }
.view { padding: 16px 16px calc(var(--tabbar-h) + var(--safe-b) + 24px); max-width: 1120px; margin: 0 auto; outline: none; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(28, 37, 46, 0.96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-3); font-size: 11px; font-weight: 600; position: relative; min-width: 0;
}
.tabbar a .icon { width: 24px; height: 24px; }
.tabbar a.on { color: var(--text); }
.tabbar a.on .icon { color: var(--primary); }
.tabbar .badge { position: absolute; top: 6px; left: calc(50% + 6px); }

@media (min-width: 900px) {
  body.authed #app { display: grid; grid-template-columns: 264px 1fr; grid-template-rows: auto 1fr; min-height: 100vh; }
  .sidebar {
    display: block; grid-row: 1 / span 2; position: sticky; top: 0; height: 100vh; overflow-y: auto;
    padding: 20px 16px 32px; border-right: 1px dashed var(--line-2); background: var(--bg);
  }
  .sidebar .brand { padding: 4px 12px 20px; }
  .nav-title { margin: 18px 12px 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }
  .nav-item { display: flex; align-items: center; gap: 14px; min-height: 44px; padding: 0 12px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
  .nav-item:hover { background: rgba(145, 158, 171, 0.08); }
  .nav-item.on { background: var(--primary-soft); color: #8fc3ff; font-weight: 600; }
  .nav-item .badge { margin-left: auto; }
  .topbar { grid-column: 2; height: 64px; padding: 0 32px; background: rgba(20, 26, 33, 0.8); border-bottom: 0; }
  .mobile-only, .tabbar { display: none; }
  .view { grid-column: 2; width: 100%; padding: 8px 32px 64px; }
}

/* ── Page structure ─────────────────────────────────────── */
.greeting { margin: 4px 0 18px; }
.greeting h1 { font-size: 26px; }
.greeting p { color: var(--text-2); }
.page-head { display: flex; align-items: center; gap: 8px; margin: 4px 0 18px; }
.page-head .back { margin-left: -12px; }
.page-title { flex: 1; min-width: 0; }
.page-title h1 { font-size: 24px; overflow-wrap: anywhere; }
.page-title p { color: var(--text-2); font-size: 14px; margin-top: 2px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 12px; }
.section-head h2 { font-size: 17px; }
.section-head a { display: inline-flex; align-items: center; gap: 2px; font-size: 14px; font-weight: 600; color: var(--text-2); }
.section-head a .icon { width: 16px; height: 16px; }
.view > .section-head { margin-top: 8px; }

.card { background: var(--card); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: 0 0 2px rgba(0, 0, 0, 0.2), 0 12px 24px -4px rgba(0, 0, 0, 0.12); }
.card-title { font-size: 17px; margin-bottom: 14px; }
.card.accent-warning { box-shadow: inset 0 0 0 1px rgba(255, 171, 0, 0.32); }
.card.accent-error { box-shadow: inset 0 0 0 1px rgba(255, 86, 48, 0.32); }
.card.list, .list.card { padding: 4px 0; }
.list.card .row, .link-list .row { padding-left: 16px; padding-right: 16px; }
.link-list { padding: 4px 0; }

/* Rows: the phone-friendly replacement for table rows */
.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 0; width: 100%;
  color: var(--text); border: 0; background: none; text-align: left; border-bottom: 1px dashed var(--line);
}
.list > .row:last-of-type, .list > .row:last-child { border-bottom: 0; }
a.row:hover, button.row:hover { background: rgba(145, 158, 171, 0.04); }
.row.tall { min-height: 72px; }
.row.inactive { opacity: 0.55; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; color: var(--text); }
.row-main strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main small { color: var(--text-2); font-size: 13px; overflow-wrap: anywhere; }
.row-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; flex: none; }
.row-end small { color: var(--text-2); font-size: 12px; }
.row-end strong { font-weight: 700; white-space: nowrap; }
.row-actions { flex-direction: row; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.row-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--primary-soft); color: #8fc3ff; }
.row-icon.warn { background: var(--warning-soft); color: var(--warning); }
.row-icon.error { background: var(--error-soft); color: #ff8a6c; }
.row-icon.success { background: var(--success-soft); color: var(--success); }
.row .chev { color: var(--text-3); width: 18px; height: 18px; }
.card-row { background: var(--card); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; border: 0; }
.row.me { min-height: 80px; }
.dot-list span + span::before { content: " · "; color: var(--text-3); }
.req-desc { color: var(--text-2); white-space: normal; }
.row.req, .row.he { align-items: flex-start; }

/* ── Stats ─────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(4, 1fr); gap: 16px; } }
.stat { display: flex; flex-direction: column; gap: 4px; background: var(--card); border-radius: var(--radius); padding: 16px; color: var(--text); min-width: 0; position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; left: 0; top: 16px; bottom: 16px; width: 3px; border-radius: 0 3px 3px 0; background: transparent; }
.stat.success::before { background: var(--success); }
.stat.warning::before { background: var(--warning); }
.stat.error::before { background: var(--error); }
.stat-label { font-size: 13px; color: var(--text-2); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 20px; font-weight: 700; overflow-wrap: anywhere; line-height: 1.2; }
@media (min-width: 420px) { .stat-value { font-size: 22px; } }
.stat-sub { font-size: 12px; color: var(--text-2); }
a.stat:hover { background: var(--card-2); }

.cta { display: flex; align-items: center; gap: 14px; padding: 16px; margin-bottom: 16px; border-radius: var(--radius); background: linear-gradient(135deg, #1f6feb, #0e4fb5); color: #fff; min-height: 76px; }
button.cta { width: 100%; border: 0; text-align: left; font: inherit; cursor: pointer; }
.cta strong { display: block; font-size: 17px; }
.cta small { color: rgba(255, 255, 255, 0.8); }
.cta > span:nth-child(2) { flex: 1; }
.cta-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: rgba(255, 255, 255, 0.16); }

.banner { display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin-bottom: 16px; border-radius: var(--radius); background: var(--primary-soft); border: 1px solid rgba(74, 155, 247, 0.3); }
.banner.warn { background: var(--warning-soft); border-color: rgba(255, 171, 0, 0.3); }
.banner > div { flex: 1; min-width: 0; }
.banner p { color: var(--text-2); font-size: 13px; }
.banner-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: rgba(74, 155, 247, 0.2); color: #8fc3ff; flex: none; }

.balance { display: flex; flex-direction: column; gap: 4px; border-left: 4px solid var(--success); }
.balance.warning { border-left-color: var(--warning); }
.balance.error { border-left-color: var(--error); }
.balance-value { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; }

/* ── Setup steps ───────────────────────────────────────── */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.steps li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.steps li:last-child { border-bottom: 0; }
.step-dot { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--raise); font-weight: 700; font-size: 14px; }
.steps li.done .step-dot { background: var(--success-soft); color: var(--success); }
.steps li.done .step-text strong { color: var(--text-2); text-decoration: line-through; }
.step-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.step-text small { color: var(--text-2); font-size: 13px; }

/* ── Approvals ─────────────────────────────────────────── */
.approvals { display: flex; flex-direction: column; gap: 12px; }
.view > .approvals { margin-bottom: 16px; }
.approval { background: var(--card-2); border-radius: 14px; padding: 14px; }
.view > .approvals .approval { background: var(--card); }
.approval-top { display: flex; align-items: center; gap: 12px; }
.approval-amount { font-size: 18px; font-weight: 800; white-space: nowrap; }
.approval-meta { margin: 10px 0 12px; font-size: 13px; color: var(--text-2); }
.approval-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.approval-actions .btn { min-height: 48px; }

/* ── Charts ────────────────────────────────────────────── */
.chart-note { margin: -6px 0 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 8px; font-size: 13px; color: var(--text-2); }
.legend strong { color: var(--text); margin-left: 4px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }
.sw.income { background: var(--series-income); }
.sw.expense { background: var(--series-expense); }
.chart { position: relative; width: 100%; height: 200px; touch-action: pan-y; }
.chart svg { display: block; }
.chart .grid { stroke: var(--line); stroke-dasharray: 3 4; }
.chart .axis { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .bar.income { fill: var(--series-income); }
.chart .bar.expense { fill: var(--series-expense); }
.chart .band { fill: transparent; cursor: pointer; }
.chart .band.on { fill: rgba(145, 158, 171, 0.08); }
.chart .tip { position: absolute; top: 0; width: 168px; padding: 8px 10px; border-radius: 10px; background: var(--raise); box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3); font-size: 12px; display: flex; flex-direction: column; gap: 2px; pointer-events: none; }
.chart .tip strong { font-size: 13px; }
.table-view { margin-top: 8px; }
.table-view summary { color: var(--text-2); font-size: 13px; cursor: pointer; min-height: 32px; display: inline-flex; align-items: center; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
table.data th { text-align: left; color: var(--text-2); font-weight: 600; padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.data td { padding: 8px 6px; border-bottom: 1px dashed var(--line); vertical-align: top; }
table.data .num { text-align: right; white-space: nowrap; }
table.data tr.hl td { background: var(--primary-soft); }
.aging { display: flex; flex-direction: column; gap: 10px; }
.aging-row { display: grid; grid-template-columns: 112px 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
.aging-label { color: var(--text-2); }
.aging-track { height: 12px; }
.aging-bar { display: block; height: 12px; border-radius: 0 4px 4px 0; background: var(--series-income); }
.aging-value { font-weight: 700; white-space: nowrap; min-width: 64px; text-align: right; }

/* ── Properties ────────────────────────────────────────── */
.grid-cards { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .grid-cards { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1100px) { .grid-cards { grid-template-columns: 1fr 1fr 1fr; } }
.prop-card { display: flex; flex-direction: column; gap: 14px; margin: 0; color: var(--text); }
.prop-card:hover { background: var(--card-2); }
.prop-top { display: flex; align-items: center; gap: 12px; }
.meter { height: 6px; border-radius: 3px; background: var(--raise); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--primary); border-radius: 3px; }
.prop-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--text-2); }
.danger-zone { margin-top: 24px; }

/* ── Search / tabs ─────────────────────────────────────── */
.search { display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 14px; margin-bottom: 12px; border-radius: 12px; border: 1px solid var(--line-2); background: transparent; }
.search:focus-within { border-color: var(--text); }
.search .icon { color: var(--text-3); width: 20px; height: 20px; }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font-size: 16px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 12px; padding: 0 16px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px; color: var(--text-2); font-weight: 600; font-size: 14px; border: 1px solid var(--line); }
.tabs a.on { background: var(--text); color: var(--bg); border-color: var(--text); }
@media (min-width: 900px) { .tabs { margin: 0 0 12px; padding: 0; } }

/* ── Key/value lists ───────────────────────────────────── */
.kv { margin: 0 0 12px; display: flex; flex-direction: column; }
.kv > div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--text-2); flex: none; }
.kv dd { margin: 0; text-align: right; overflow-wrap: anywhere; min-width: 0; }
.kv.boxed { border: 1px dashed var(--line-2); border-radius: 12px; padding: 4px 16px; margin-bottom: 16px; }
.kv .big { font-size: 22px; font-weight: 700; letter-spacing: 0.05em; }

.action-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.action-bar > * { flex: 1 1 140px; }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 40px 20px; background: var(--card); border-radius: var(--radius); margin-bottom: 16px; }
.empty-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; background: var(--primary-soft); color: #8fc3ff; margin-bottom: 4px; }
.empty-icon .icon { width: 30px; height: 30px; }
.empty h3 { font-size: 18px; }
.empty p { color: var(--text-2); max-width: 340px; }
.empty .btn { margin-top: 10px; }

/* ── Forms ─────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: 14px; }
.form.card { gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0; border: 0; padding: 0; min-width: 0; }
.field > label, .field > legend { font-size: 13px; font-weight: 600; color: var(--text-2); padding: 0; }
.field input, .field select, .field textarea, .input-prefix, .input-suffix {
  width: 100%; min-height: 52px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-2);
  background: transparent; font-size: 16px; outline: none;
}
.field textarea { padding: 14px; resize: vertical; min-height: 88px; }
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 20px) 23px, calc(100% - 15px) 23px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.field select option { background: var(--card-2); }
.field input:focus, .field select:focus, .field textarea:focus, .input-prefix:focus-within, .input-suffix:focus-within { border-color: var(--text); }
.field input[type="date"], .field input[type="time"] { color-scheme: dark; }
.input-prefix, .input-suffix { display: flex; align-items: center; padding: 0; }
.input-prefix span { padding: 0 4px 0 14px; color: var(--text-2); font-weight: 600; }
.input-prefix input, .input-suffix input { border: 0 !important; min-height: 50px; flex: 1; min-width: 0; }
.input-prefix input { font-size: 20px; font-weight: 700; padding-left: 6px; }
.hint { color: var(--text-3); font-size: 12px; }
.form-error { padding: 12px 14px; border-radius: 10px; background: var(--error-soft); color: #ffac82; font-size: 14px; font-weight: 600; }
.form-section { font-size: 14px; margin-top: 8px; padding-top: 14px; border-top: 1px dashed var(--line); color: var(--text); }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice-btn { position: relative; }
.choice-btn input { position: absolute; opacity: 0; inset: 0; }
.choice-btn span { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line-2); font-weight: 600; font-size: 14px; line-height: 1.2; cursor: pointer; }
.choice-btn input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: #fff; box-shadow: inset 0 0 0 1px var(--primary); }
.choice-btn input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch-row { display: flex; align-items: center; gap: 12px; justify-content: space-between; min-height: 52px; cursor: pointer; }
.switch-row > span { display: flex; flex-direction: column; }
.switch-label { font-weight: 600; }
.switch { appearance: none; width: 44px; height: 26px; flex: none; border-radius: 13px; background: var(--raise); border: 1px solid var(--line-2); position: relative; cursor: pointer; transition: background 0.15s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch:checked { background: var(--primary-strong); border-color: var(--primary-strong); }
.switch:checked::after { transform: translateX(18px); }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: -6px; }
.sticky-action { position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-b) + 8px); padding-top: 8px; z-index: 5; }
@media (min-width: 900px) { .sticky-action { bottom: 16px; } }
.note-box { padding: 14px; border-radius: 12px; background: var(--bg); font-size: 13px; display: flex; flex-direction: column; gap: 8px; }
.payer { display: flex; align-items: center; gap: 12px; }
.mini-select { min-height: 40px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--card-2); padding: 0 8px; font-size: 13px; }

/* ── Done screen ───────────────────────────────────────── */
.done-page { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 32px 0; max-width: 440px; margin: 0 auto; }
.done-page h1 { font-size: 24px; }
.done-icon { display: grid; place-items: center; width: 80px; height: 80px; border-radius: 50%; margin-bottom: 8px; }
.done-icon .icon { width: 40px; height: 40px; }
.done-icon.success { background: var(--success-soft); color: var(--success); }
.done-icon.warning { background: var(--warning-soft); color: var(--warning); }
.stack { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 20px; }

/* ── Receipt ───────────────────────────────────────────── */
.receipt { max-width: 560px; }
.receipt-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 16px; border-bottom: 1px dashed var(--line-2); }
.receipt-head .auth-brand { margin: 0; font-size: 16px; }
.receipt-no { display: flex; flex-direction: column; align-items: flex-end; }
.receipt-no small { color: var(--text-2); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.receipt-amount { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px 0; }
.receipt-amount small { color: var(--text-2); }
.receipt-amount strong { font-size: 32px; font-weight: 800; }
.receipt-warn { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--warning-soft); color: #ffd666; font-size: 13px; font-weight: 600; }
.receipt.not-final .receipt-amount strong { opacity: 0.7; }

/* ── Ledger ────────────────────────────────────────────── */
.jentry { padding: 0; margin-bottom: 10px; }
.jentry summary { display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; list-style: none; min-height: 60px; }
.jentry summary::-webkit-details-marker { display: none; }
.jentry table, .jentry p { margin: 0 16px 12px; width: calc(100% - 32px); }
.accounts-box summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.accounts-box td a { color: var(--text); }

/* ── Settings ──────────────────────────────────────────── */
.settings-row .row-end { flex-direction: row; }

/* ── Profile ───────────────────────────────────────────── */
.profile-head { display: flex; align-items: center; gap: 16px; }
.profile-head h2 { font-size: 20px; }

/* ── Assistant ─────────────────────────────────────────── */
.chat { display: flex; flex-direction: column; gap: 10px; }
.chat-log { display: flex; flex-direction: column; gap: 10px; min-height: 40vh; max-height: calc(100vh - 300px); overflow-y: auto; padding: 4px 0; }
.chat-empty { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.bubble { max-width: 86%; padding: 12px 14px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.user { align-self: flex-end; background: var(--primary-strong); border-bottom-right-radius: 4px; }
.bubble.assistant { align-self: flex-start; background: var(--card); border-bottom-left-radius: 4px; }
.bubble-actions { list-style: none; margin: 8px 0 0; padding: 8px 0 0; border-top: 1px dashed var(--line-2); font-size: 13px; }
.bubble-actions .ok { color: #77ed8b; }
.bubble-actions .bad { color: #ffac82; }
.typing { display: flex; gap: 4px; }
.typing span { width: 8px; height: 8px; border-radius: 50%; background: var(--text-2); animation: blink 1s infinite; }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 50% { opacity: 0.3; } }
.chat-input { display: flex; gap: 8px; align-items: flex-end; position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-b) + 8px); background: var(--bg); padding-top: 6px; }
@media (min-width: 900px) { .chat-input { bottom: 16px; } }
.chat-input textarea { flex: 1; min-height: 48px; max-height: 160px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--card); font-size: 16px; resize: none; outline: none; }
.chat-input textarea:focus { border-color: var(--text); }

/* ── Auth ──────────────────────────────────────────────── */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: calc(24px + var(--safe-t)) 16px 24px; background: radial-gradient(circle at 20% 0%, rgba(31, 111, 235, 0.18), transparent 50%), var(--bg); }
.auth-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 16px; }
.auth-card h1 { font-size: 26px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 22px; margin-bottom: 8px; }

/* ── Sheets ────────────────────────────────────────────── */
.sheet-layer { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); opacity: 0; transition: opacity 0.18s; }
.sheet {
  position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; background: var(--card-2);
  transform: translateY(24px); opacity: 0; transition: transform 0.18s, opacity 0.18s;
  padding-top: var(--safe-t);
}
.sheet-layer.in .sheet-backdrop { opacity: 1; }
.sheet-layer.in .sheet { transform: none; opacity: 1; }
.sheet-head { display: flex; align-items: center; gap: 4px; min-height: 60px; padding: 0 12px 0 4px; border-bottom: 1px solid var(--line); flex: none; }
.sheet-head h2 { font-size: 18px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sheet-body { flex: 1; overflow-y: auto; padding: 20px 16px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet-foot { display: flex; gap: 10px; padding: 12px 16px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); flex: none; background: var(--card-2); }
.sheet-foot .btn { flex: 1; min-height: 52px; font-size: 16px; }
@media (min-width: 640px) {
  .sheet-layer { align-items: center; padding: 24px; }
  .sheet { height: auto; max-height: min(88vh, 860px); max-width: 520px; border-radius: var(--radius); padding-top: 0; box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5); }
  .sheet.wide { max-width: 760px; }
}

/* ── Toasts ────────────────────────────────────────────── */
.toasts { position: fixed; z-index: 200; left: 16px; right: 16px; top: calc(12px + var(--safe-t)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; max-width: 480px; width: 100%; padding: 12px 14px; border-radius: 12px; background: var(--raise); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); font-weight: 600; font-size: 14px; animation: toast-in 0.2s; transition: opacity 0.3s, transform 0.3s; }
.toast.success .icon { color: var(--success); }
.toast.error { background: #3a1f1b; }
.toast.error .icon { color: var(--error); }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* ── Print: receipts only ──────────────────────────────── */
@media print {
  body { background: #fff; color: #000; }
  .sidebar, .topbar, .tabbar, .page-head, .action-bar, .no-print, #toasts, #sheets { display: none !important; }
  .view { padding: 0; }
  .card { box-shadow: none; background: #fff; color: #000; border: 1px solid #ccc; }
  .kv dt, .receipt-amount small, .receipt-no small, .muted { color: #555; }
  .pill { border: 1px solid #999; background: none; color: #000; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ── Simple dashboard ──────────────────────────────────── */
:root { --series-due: #3987e5; --series-paid: #199e70; --series-late: #d95926; }
.sw.due { background: var(--series-due); }
.sw.paid { background: var(--series-paid); }
.sw.late { background: var(--series-late); }
.simple-totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.simple-totals div { display: flex; flex-direction: column; min-width: 0; }
.simple-totals small { color: var(--text-2); font-size: 12px; }
.simple-totals strong { font-size: 16px; font-weight: 700; overflow-wrap: anywhere; line-height: 1.25; }
@media (min-width: 420px) { .simple-totals strong { font-size: 18px; } }
.prop-chart .section-head { margin-bottom: 14px; }
.pbars { display: flex; flex-direction: column; gap: 12px; }
.pbar-row { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "label value" "track track"; gap: 4px 12px; font-size: 14px; }
.pbar-label { grid-area: label; color: var(--text-2); }
.pbar-value { grid-area: value; font-weight: 700; text-align: right; white-space: nowrap; }
.pbar-track { grid-area: track; height: 16px; border-radius: 4px; background: rgba(145, 158, 171, 0.08); }
.pbar { display: block; height: 16px; border-radius: 0 4px 4px 0; }
.pbar.due { background: var(--series-due); }
.pbar.paid { background: var(--series-paid); }
.pbar.late { background: var(--series-late); }
.cta.warn { background: linear-gradient(135deg, #b76e00, #8a4b00); }
.topbar .icon-btn.claude { color: #c4b5fd; }
.row-icon.claude { background: rgba(167, 139, 250, 0.16); color: #c4b5fd; }
.inline-switch { display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.inline-switch .switch { transform: scale(0.85); transform-origin: left center; }
.wordmark { display: inline-flex; flex-direction: column; line-height: 1.05; }
.wordmark b { font-size: 20px; font-weight: 800; letter-spacing: 0.06em; }
.wordmark small { font-size: 10px; font-weight: 600; letter-spacing: 0.04em; color: var(--text-2); text-transform: uppercase; }
.auth-brand .wordmark b { font-size: 24px; }
.auth-brand .logo-mark { width: 44px; height: 44px; }
.banner.demo { background: rgba(167, 139, 250, 0.12); border-color: rgba(167, 139, 250, 0.32); }
.banner.demo .banner-icon { background: rgba(167, 139, 250, 0.2); color: #c4b5fd; }
.demo-box { display: flex; flex-direction: column; gap: 8px; padding: 16px; border-radius: var(--radius); background: var(--card); border: 1px dashed rgba(167, 139, 250, 0.4); }
.demo-login { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 56px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line-2); background: transparent; text-align: left; }
.demo-login:hover { background: rgba(145, 158, 171, 0.08); }
.demo-login small { color: var(--text-2); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ── Quick menu & usage panel ──────────────────────────── */
.quick-row { min-height: 56px; }
.sheet-body .nav-title { margin: 16px 0 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }
.rings { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin: 12px 0 16px; }
.ring-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); text-align: center; min-height: 44px; }
.ring-card small { color: var(--text-2); font-size: 11px; }
.ring-wrap { position: relative; display: grid; place-items: center; }
.ring-num { position: absolute; font-weight: 800; font-size: 15px; }
.ring circle { fill: none; stroke-width: 5; }
.ring .ring-bg { stroke: var(--raise); }
.ring .ring-fg { stroke: var(--primary); stroke-linecap: round; transition: stroke-dashoffset 0.4s; }
.ring.warning .ring-fg { stroke: var(--warning); }
.ring.error .ring-fg { stroke: var(--error); }
.form-section.first { margin-top: 0; padding-top: 0; border-top: 0; }
.card.flat { box-shadow: none; background: transparent; padding: 0; }
.limit-note { display: flex; align-items: center; gap: 6px; }

/* ── Payment split (security / rent heads) ─────────────── */
.split { border: 1px dashed var(--line-2); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.split-head { display: flex; align-items: center; justify-content: space-between; }
.split-head .link-btn { min-height: 36px; padding: 0; }
.split-row { display: flex; align-items: center; gap: 12px; min-height: 48px; border-top: 1px dashed var(--line); }
.split-row.zero .split-amt { color: var(--text-3); font-weight: 500; }
.split-label { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.split-label small { color: var(--text-2); font-size: 12px; }
.split-amt { font-weight: 700; white-space: nowrap; }
.split-input { width: 120px; min-height: 44px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line-2); background: transparent; font-size: 16px; text-align: right; }
.split-foot { display: flex; flex-direction: column; gap: 2px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: 13px; }
.head-security { color: #c4b5fd; font-weight: 600; }
.head-rent { color: #8fc3ff; font-weight: 600; }
.approval-split { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 13px; }
.receipt-split { margin-top: 8px; padding-top: 12px; border-top: 1px dashed var(--line-2); }
.receipt-split h3 { font-size: 13px; color: var(--text-2); font-weight: 600; margin-bottom: 4px; }
.kv-line { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
@media print { .head-security, .head-rent { color: #000; } }
.sec-note { margin-top: 10px; }

/* ── Not-paying alerts ─────────────────────────────────── */
.red-alert { background: linear-gradient(135deg, rgba(255, 86, 48, 0.22), rgba(183, 29, 24, 0.18)); border: 1px solid rgba(255, 86, 48, 0.55); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.red-alert-head { display: flex; align-items: center; gap: 8px; color: #ffac82; font-size: 17px; }
.red-alert-head .icon { color: var(--error); }
.red-alert p { margin: 6px 0 0; color: #ffd6c9; }
.red-alert ul { list-style: none; margin: 8px 0 0; padding: 0; }
.red-alert li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px dashed rgba(255, 86, 48, 0.3); font-size: 14px; }
.card.is-red { box-shadow: inset 0 0 0 2px rgba(255, 86, 48, 0.6); }
.prop-late { display: flex; flex-direction: column; gap: 2px; margin: 0; font-size: 12px; color: #ffac82; }
.unit-row.late { background: rgba(255, 86, 48, 0.06); }
.grid-cards > *, .stats > * { min-width: 0; }
.prop-top .pill { flex: none; }

/* ── Wide phones (e.g. Galaxy Z Fold unfolded) and tablets: two columns ── */
.fold-grid { display: flex; flex-direction: column; }
@media (min-width: 700px) {
  .fold-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 14px; align-items: start; }
  .view > .approvals { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
}

/* ── Claude: floating button, voice and language ─────────────────────────── */
.fab-claude {
  position: fixed; z-index: 35; right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px);
  display: flex; align-items: center; gap: 6px; height: 52px; padding: 0 18px 0 14px; border: 0; border-radius: 999px;
  background: linear-gradient(135deg, #7c5cff, #4a9bf7); color: #fff; font: inherit; font-weight: 700; font-size: 15px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); cursor: pointer;
}
.fab-claude svg { width: 22px; height: 22px; }
.fab-claude:active { transform: scale(0.97); }
body.sheet-open .fab-claude { display: none; }
@media (min-width: 900px) { .fab-claude { bottom: 24px; right: 24px; } }

.claude-panel { display: flex; flex-direction: column; gap: 12px; }
.claude-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--card); border: 1px solid var(--line-2); }
.seg button { min-height: 38px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; color: var(--text-2); font: inherit; font-weight: 700; cursor: pointer; }
.seg button.on { background: var(--text); color: var(--bg); }
.claude-panel .chat-log { min-height: 28vh; max-height: 52vh; }
.claude-sheet .chat-input { position: static; background: transparent; }
.bubble.error { border: 1px solid rgba(255, 86, 48, 0.4); }
.voice-error { margin: 0; padding: 10px 12px; border-radius: 12px; background: var(--error-soft, rgba(255, 86, 48, 0.12)); color: #ffac82; font-size: 14px; }
.voice-zone { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 8px 0 4px; }
.mic-big {
  display: grid; place-items: center; width: 96px; height: 96px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(135deg, #7c5cff, #4a9bf7); color: #fff; box-shadow: 0 10px 30px rgba(74, 155, 247, 0.35);
}
.mic-big svg { width: 40px; height: 40px; }
.mic-big.listening { background: #ff5630; animation: mic-pulse 1.2s ease-out infinite; }
.mic-big.speaking { background: var(--card); border: 2px solid var(--line-2); box-shadow: none; }
.mic-big:disabled { opacity: 0.55; cursor: default; }
@keyframes mic-pulse { 0% { box-shadow: 0 0 0 0 rgba(255, 86, 48, 0.55); } 100% { box-shadow: 0 0 0 26px rgba(255, 86, 48, 0); } }
@media (prefers-reduced-motion: reduce) { .mic-big.listening { animation: none; } }
.voice-status { margin: 0; min-height: 22px; text-align: center; color: var(--text-2); font-size: 16px; max-width: 32ch; }
.chat-input .rec { color: #ff5630; border-color: #ff5630; }
.claude-foot { margin: 0; }
/* Room under the last item so the floating Claude button never hides it. */
body.authed:has(.fab-claude:not([hidden])) .view { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 96px); }
@media (min-width: 900px) { body.authed:has(.fab-claude:not([hidden])) .view { padding-bottom: 104px; } }
