/* Quotiva — the tenant's app. Phone first, one column, thumb-reachable.
   Colours and type come from /shared/ui.css (day theme by default; night
   follows the system). Layout uses logical properties so Hebrew mirrors. */

:root { --tabs: 64px; --hdr: 56px; --pad: 16px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px); }
html, body { margin: 0; height: 100%; }
body.ui { font-size: 16px; -webkit-text-size-adjust: 100%; overscroll-behavior-y: none; }
#app { min-height: 100%; display: flex; flex-direction: column; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
input, select, textarea { font-size: 16px; } /* no zoom on focus */
a { color: inherit; text-decoration: none; }
/* night: ui.css's :root is the dark set; day is the light office theme */
[data-theme="night"] { color-scheme: dark; }
[dir="rtl"] .rtl-flip { transform: scaleX(-1); transform-origin: 12px 12px; }

/* ── header ─────────────────────────────────────────────────────────── */
.hdr { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 6px; height: calc(var(--hdr) + var(--safe-t)); padding: var(--safe-t) 8px 0; background: var(--bg); border-bottom: 1px solid var(--b1); }
.hdr-btn { width: 44px; height: 44px; border: 0; background: transparent; color: var(--tx1); border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.hdr-btn:active { background: var(--s3); }
.hdr-title { flex: 1; min-width: 0; font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-inline-start: 6px; }
.hdr-actions { display: flex; gap: 4px; }
.hdr-actions .hdr-btn { font-size: 15px; font-weight: 600; width: auto; padding: 0 12px; color: var(--acc); }

/* ── view ───────────────────────────────────────────────────────────── */
.view { flex: 1; padding: var(--pad); padding-bottom: calc(var(--tabs) + var(--safe-b) + 24px); display: flex; flex-direction: column; gap: 14px; }
.view.no-tabs { padding-bottom: calc(var(--safe-b) + 24px); }
.view.with-cta { padding-bottom: calc(var(--tabs) + var(--safe-b) + 92px); }
.view.no-tabs.with-cta { padding-bottom: calc(var(--safe-b) + 92px); }

/* ── tabs ───────────────────────────────────────────────────────────── */
.tabs { position: fixed; inset-inline: 0; bottom: 0; z-index: 20; height: calc(var(--tabs) + var(--safe-b)); padding-bottom: var(--safe-b); display: flex; background: var(--s1); border-top: 1px solid var(--b1); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--tx3); font-size: 11px; font-weight: 600; }
.tabs a.on { color: var(--acc); }
.tabs a .ui-ic { width: 24px; height: 24px; }

/* ── bottom CTA ─────────────────────────────────────────────────────── */
.cta { position: fixed; inset-inline: 0; bottom: calc(var(--tabs) + var(--safe-b)); z-index: 19; padding: 10px var(--pad) 12px; background: linear-gradient(to top, var(--bg) 70%, transparent); display: flex; gap: 10px; }
.cta.no-tabs { bottom: 0; padding-bottom: calc(12px + var(--safe-b)); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 18px; border-radius: 14px; font-size: 16px; font-weight: 700; border: 1px solid var(--b2); background: var(--s2); color: var(--tx1); cursor: pointer; flex: 0 0 auto; white-space: nowrap; }
.cta .btn, .in-row .btn, .sheet-ft .btn { flex: 1; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; }
.btn.primary { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.btn.danger { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.btn.quiet { background: transparent; border-color: transparent; color: var(--tx2); }
.btn.sm { min-height: 40px; font-size: 14px; padding: 0 14px; border-radius: 11px; flex: 0 0 auto; }
.btn.block { width: 100%; }
.auth-logo { width: 64px; height: 64px; border-radius: 18px; box-shadow: 0 10px 24px rgba(37,99,235,.25); }
.auth-hd { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 28px 0 10px; }
.auth-hd h1 { font-size: 26px; font-weight: 800; margin: 8px 0 0; }
.auth-hd p { margin: 0; color: var(--tx2); font-size: 15px; }
.pw-wrap { position: relative; }
.pw-wrap .in { padding-inline-end: 64px; }
.pw-toggle { position: absolute; inset-inline-end: 8px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--acc); font-weight: 700; font-size: 14px; padding: 8px; cursor: pointer; }
.plan-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.plan-pick button { border: 2px solid var(--b1); background: var(--s1); border-radius: 12px; padding: 10px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; color: var(--tx1); }
.plan-pick button b { font-size: 15px; } .plan-pick button span { font-size: 12px; color: var(--tx3); }
.plan-pick button.on { border-color: var(--acc); background: var(--adim); }
.btn .ui-ic { width: 20px; height: 20px; }

/* ── cards / rows / lists ───────────────────────────────────────────── */
.card { background: var(--s1); border: 1px solid var(--b1); border-radius: 16px; overflow: hidden; }
.card-hd { padding: 12px 16px; font-size: 12px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--tx3); border-bottom: 1px solid var(--b1); display: flex; align-items: center; justify-content: space-between; }
.card-bd { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.row, .row .name, .row .main { color: var(--tx1); }
.row { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 16px; border-bottom: 1px solid var(--b1); cursor: pointer; color: inherit; }
.row:last-child { border-bottom: 0; }
.row:active { background: var(--s2); }
.row .main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row .name { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { font-size: 13px; color: var(--tx2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.row .amt { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.row .chev { color: var(--tx3); flex-shrink: 0; }
.avatar { width: 40px; height: 40px; border-radius: 999px; background: var(--adim); color: var(--acc); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex-shrink: 0; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--b1); font-size: 15px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--tx2); }
.kv .v { font-weight: 600; text-align: end; font-variant-numeric: tabular-nums; }
.kv.total .v { font-size: 20px; font-weight: 800; }
.kv.due { background: var(--adim); margin: 0 -16px; padding: 12px 16px; border-radius: 10px; border: 0; }
.kv.due .v { font-size: 20px; font-weight: 800; color: var(--acc); }

/* ── pills ──────────────────────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; background: var(--muted-soft); color: var(--tx2); white-space: nowrap; }
.pill[data-tone="good"] { background: var(--good-soft); color: var(--good); }
.pill[data-tone="warn"] { background: var(--warn-soft); color: var(--warn); }
.pill[data-tone="bad"] { background: var(--bad-soft); color: var(--bad); }
.pill[data-tone="info"] { background: var(--info-soft); color: var(--info); }

/* ── chips (filters) ────────────────────────────────────────────────── */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--pad)); padding: 0 var(--pad); }
.chips::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--b2); background: var(--s1); color: var(--tx2); font-size: 14px; font-weight: 600; cursor: pointer; }
.chip.on { background: var(--tx1); color: var(--bg); border-color: var(--tx1); }

/* ── forms ──────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--tx2); }
.field .hint { font-size: 12.5px; color: var(--tx3); }
.field .err { font-size: 13px; color: var(--bad); font-weight: 600; }
.in { width: 100%; min-height: 50px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--b2); background: var(--s1); color: var(--tx1); outline: none; }
.in:focus { border-color: var(--acc); box-shadow: 0 0 0 3px var(--adim); }
.in.error { border-color: var(--bad); }
textarea.in { min-height: 96px; padding: 12px 14px; resize: vertical; line-height: 1.4; }
select.in { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237b8496' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; padding-inline-end: 40px; }
[dir="rtl"] select.in { background-position: left 12px center; }
.in-row { display: flex; gap: 10px; }
.in-row > * { flex: 1; min-width: 0; }
.money-in { position: relative; }
.money-in .in { padding-inline-start: 30px; font-variant-numeric: tabular-nums; font-weight: 600; }
.money-in::before { content: "$"; position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--tx3); font-weight: 600; pointer-events: none; }
.seg { display: flex; background: var(--s2); border: 1px solid var(--b1); border-radius: 12px; padding: 3px; }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--tx2); font-size: 14px; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--s1); color: var(--tx1); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.switch input { appearance: none; width: 50px; height: 30px; border-radius: 999px; background: var(--b2); position: relative; flex-shrink: 0; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 24px; height: 24px; border-radius: 999px; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked { background: var(--acc); }
.switch input:checked::after { transform: translateX(20px); }
[dir="rtl"] .switch input:checked::after { transform: translateX(-20px); }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 15px; line-height: 1.4; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--acc); flex-shrink: 0; }

/* ── empty / hero / misc ────────────────────────────────────────────── */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 40px 20px; color: var(--tx2); }
.empty .ui-ic { width: 44px; height: 44px; color: var(--tx3); }
.empty b { font-size: 17px; color: var(--tx1); }
.hero { display: flex; flex-direction: column; gap: 8px; padding: 10px 0 4px; }
.hero h1 { font-size: 26px; font-weight: 800; margin: 0; line-height: 1.15; }
.hero p { margin: 0; color: var(--tx2); font-size: 15px; line-height: 1.45; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { background: var(--s1); border: 1px solid var(--b1); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.stat .n { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 11.5px; color: var(--tx3); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.stat.warn .n { color: var(--warn); }
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--info-soft); color: var(--info); font-size: 14px; font-weight: 500; line-height: 1.4; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.good { background: var(--good-soft); color: var(--good); }
.banner a, .banner button { color: inherit; font-weight: 700; text-decoration: underline; background: none; border: 0; padding: 0; cursor: pointer; }
.muted { color: var(--tx3); font-size: 13px; }
.center { text-align: center; }
.grow { flex: 1; }
.spacer { height: 8px; }
.logo-box { width: 88px; height: 88px; border-radius: 18px; border: 1px dashed var(--b2); background: var(--s1); display: inline-flex; align-items: center; justify-content: center; overflow: hidden; color: var(--tx3); }
.logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lang-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.lang-tile { min-height: 72px; border-radius: 16px; border: 2px solid var(--b1); background: var(--s1); font-size: 22px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 12px; cursor: pointer; color: var(--tx1); }
.lang-tile.on { border-color: var(--acc); background: var(--adim); }
.lang-tile small { font-size: 13px; font-weight: 500; color: var(--tx3); }
.steps { display: flex; gap: 6px; }
.steps i { flex: 1; height: 4px; border-radius: 999px; background: var(--b1); }
.steps i.on { background: var(--acc); }

/* ── estimate line editor ───────────────────────────────────────────── */
.line { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--b1); align-items: flex-start; cursor: pointer; }
.line:last-child { border-bottom: 0; }
.line .grip { color: var(--tx3); padding-top: 2px; touch-action: none; cursor: grab; }
.line .main { flex: 1; min-width: 0; }
.line .title { font-size: 16px; font-weight: 600; }
.line .desc { font-size: 13px; color: var(--tx2); margin-top: 2px; white-space: pre-wrap; }
.line .sub { font-size: 13px; color: var(--tx3); margin-top: 3px; font-variant-numeric: tabular-nums; }
.line .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.line.optional .title::after { content: " · optional"; font-size: 12px; font-weight: 600; color: var(--ai); }
.line.off { opacity: .55; }
.line.dragging { opacity: .4; }

/* ── paper (document preview) ───────────────────────────────────────── */
.paper { background: #fff; color: #121620; border-radius: 12px; padding: 18px; border: 1px solid var(--b1); font-size: 13.5px; }
[data-theme="night"] .paper { border-color: #2e3748; }

/* ── sheets ─────────────────────────────────────────────────────────── */
.sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgba(8,10,16,.55); display: flex; align-items: flex-end; animation: fade .15s; }
.sheet { width: 100%; max-height: 92vh; background: var(--bg); border-radius: 20px 20px 0 0; display: flex; flex-direction: column; animation: up .2s cubic-bezier(.2,.8,.2,1); padding-bottom: var(--safe-b); }
.sheet-hd { display: flex; align-items: center; gap: 8px; padding: 10px 8px 8px 16px; }
.sheet-hd .ttl { flex: 1; font-size: 18px; font-weight: 700; }
.sheet-grab { width: 40px; height: 4px; border-radius: 999px; background: var(--b2); margin: 8px auto 0; }
.sheet-bd { padding: 4px 16px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.sheet-ft { display: flex; gap: 10px; padding: 10px 16px 12px; border-top: 1px solid var(--b1); }
.menu { display: flex; flex-direction: column; }
.menu button { display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 0 8px; border: 0; background: transparent; color: var(--tx1); font-size: 16px; font-weight: 600; text-align: start; cursor: pointer; border-bottom: 1px solid var(--b1); }
.menu button:last-child { border-bottom: 0; }
.menu button.danger { color: var(--bad); }
.menu button .ui-ic { width: 22px; height: 22px; color: var(--tx2); }
.menu button.danger .ui-ic { color: var(--bad); }
@keyframes up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ── toast ──────────────────────────────────────────────────────────── */
#toast-root { position: fixed; inset-inline: 0; bottom: calc(var(--tabs) + var(--safe-b) + 14px); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; max-width: 92vw; padding: 12px 18px; border-radius: 14px; background: var(--tx1); color: var(--bg); font-size: 15px; font-weight: 600; box-shadow: var(--shadow); animation: up .2s; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.good { background: var(--good); color: #fff; }

/* ── timeline ───────────────────────────────────────────────────────── */
.tl { display: flex; flex-direction: column; }
.tl div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--b1); font-size: 14px; }
.tl div:last-child { border-bottom: 0; }
.tl span:last-child { color: var(--tx3); white-space: nowrap; font-size: 13px; }

@media (min-width: 720px) {
  #app { max-width: 520px; margin: 0 auto; box-shadow: 0 0 0 1px var(--b1); min-height: 100vh; }
  .tabs, .cta, #toast-root { max-width: 520px; margin: 0 auto; }
  .sheet-bg { justify-content: center; }
  .sheet { max-width: 520px; }
}
