/* Forefront Window Cleaning — customer app. Same brand as the business app: black and white like the logo,
   colour only for status (paid, owed, confirmed). Light + dark. */
:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #efefed;
  --text: #111111;
  --muted: #6b6b6b;
  --border: #e3e3e0;
  --border-strong: #cfcfcb;
  --primary: #111111;
  --primary-soft: #e8e8e5;
  --on-primary: #ffffff;
  --brand-font: Futura, 'Avenir Next', Montserrat, 'Century Gothic', 'Arial Black', system-ui, sans-serif;
  --success: #059669;
  --success-soft: #d1fae5;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 2px 8px rgba(0, 0, 0, 0.05);
  --radius: 16px;
  --radius-sm: 10px;
  --tabbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0c0c;
    --surface: #171717;
    --surface-2: #212121;
    --text: #f2f2f2;
    --muted: #a0a0a0;
    --border: #2b2b2b;
    --border-strong: #3d3d3d;
    --primary: #f2f2f2;
    --primary-soft: #2c2c2c;
    --on-primary: #111111;
    --success: #34d399;
    --success-soft: #06322a;
    --danger: #f87171;
    --danger-soft: #3b1414;
    --warn: #fbbf24;
    --warn-soft: #3a2a07;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); min-height: 100vh;
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
[hidden] { display: none !important; }
.ic { width: 20px; height: 20px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ── Header ── */
.app-header {
  position: sticky; top: 0; z-index: 20; padding-top: env(safe-area-inset-top);
  background: var(--bg); background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.header-inner { display: flex; align-items: center; gap: 10px; height: 60px; padding: 0 16px; max-width: 720px; margin: 0 auto; }
.header-inner img { width: 34px; height: 34px; border-radius: 8px; }
.header-inner .biz { font-family: var(--brand-font); font-weight: 700; font-size: 17px; text-transform: uppercase; letter-spacing: 0.02em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Layout ── */
main { display: block; padding: 4px 16px calc(var(--tabbar-h) + 40px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; outline: none; }
body.signed-out main { padding-bottom: 40px; }
.page-title { font-family: var(--brand-font); font-size: 26px; font-weight: 700; margin: 10px 0 14px; }
.boot { padding: 60px 0; text-align: center; color: var(--muted); }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 0 max(8px, env(safe-area-inset-left)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-right));
}
body.signed-out .tabbar { display: none; }
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  height: var(--tabbar-h); font-size: 12px; font-weight: 600; color: var(--muted); text-decoration: none;
}
.tabbar a .ic { width: 24px; height: 24px; }
.tabbar a.active, .tabbar a[aria-current=page] { color: var(--primary); }

/* ── Cards ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card h2 { font-size: 15px; font-weight: 600; color: var(--muted); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.card h2 .ic { width: 17px; height: 17px; }
.big { font-size: 28px; font-weight: 750; letter-spacing: -0.02em; }
.sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.card.owed { background: var(--warn-soft); border-color: transparent; }
.card.owed .big { color: var(--warn); }
.card.paid .big { color: var(--success); }
.pill { display: inline-block; font-size: 13px; font-weight: 600; border-radius: 999px; padding: 2px 10px; margin-top: 8px; }
.pill.confirmed { background: var(--success-soft); color: var(--success); }
.pill.estimate { background: var(--surface-2); color: var(--muted); }
.notice { border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 14px; background: var(--primary-soft); font-size: 15px; }
.notice.warn { background: var(--warn-soft); }
.notice.bad { background: var(--danger-soft); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .card { margin-bottom: 0; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.quick a { display: flex; align-items: center; gap: 10px; padding: 14px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--text); font-weight: 600; }

/* ── Lists ── */
.section-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 22px 0 8px; }
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-top: 1px solid var(--border); }
.row:first-child { border-top: 0; }
a.row, button.row { text-decoration: none; color: var(--text); font: inherit; }
button.row { width: 100%; border: 0; border-top: 1px solid var(--border); background: none; text-align: left; }
.row .grow { flex: 1; min-width: 0; }
.row strong { display: block; font-weight: 600; }
.row .amt { font-weight: 650; white-space: nowrap; }
.row .amt.in { color: var(--success); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); flex: none; }
.dot.done { background: var(--success); }
.dot.pay { background: var(--primary); }
.empty { color: var(--muted); text-align: center; padding: 18px; }
dl.details { margin: 0; }
dl.details div { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid var(--border); }
dl.details div:first-child { border-top: 0; }
dl.details dt { color: var(--muted); }
dl.details dd { margin: 0; text-align: right; font-weight: 600; overflow-wrap: anywhere; }

/* ── Forms / buttons ── */
.signin { max-width: 420px; margin: 24px auto 0; }
.signin .logo { display: block; width: 88px; height: 88px; border-radius: 20px; margin: 0 auto 18px; }
.signin h1 { font-family: var(--brand-font); text-align: center; font-size: 24px; margin-bottom: 8px; }
.signin p { text-align: center; }
form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 15px; }
input { height: 50px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface); padding: 0 14px; font-size: 17px; }
input.code { letter-spacing: 0.3em; font-size: 22px; text-align: center; font-variant-numeric: tabular-nums; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 18px;
  border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface); font-weight: 600; text-decoration: none; color: var(--text);
}
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.link { border: 0; background: none; min-height: 40px; text-decoration: underline; color: var(--muted); font-weight: 500; }
.msg { border-radius: 10px; padding: 10px 12px; font-size: 15px; background: var(--danger-soft); }
.msg.ok { background: var(--success-soft); }
.accounts button { width: 100%; text-align: left; display: flex; align-items: center; gap: 12px; padding: 13px 16px; border: 0; border-top: 1px solid var(--border); background: none; }
.accounts button:first-child { border-top: 0; }
.accounts button[aria-pressed=true] { background: var(--primary-soft); }
.updated { text-align: center; color: var(--muted); font-size: 13px; margin: 18px 0 0; }

/* ── Privacy page ── */
.prose { padding-top: 16px; padding-bottom: 40px; }
.prose h2 { font-size: 18px; margin: 24px 0 6px; }
.prose p, .prose li { margin: 6px 0; }
.prose ul { padding-left: 22px; }

p .ic { width: 16px; height: 16px; vertical-align: -3px; }

/* ── Requests (Stage 3) ── */
button, input, select, textarea { font: inherit; color: inherit; }
select, textarea { border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface); padding: 12px 14px; font-size: 17px; }
select { height: 50px; padding: 0 14px; }
textarea { resize: vertical; min-height: 80px; line-height: 1.4; }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 15px; }
.btn .ic { width: 18px; height: 18px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ask-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.ask { display: flex; align-items: center; gap: 10px; padding: 14px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--text); font-weight: 600; font-size: 15px; }
.request strong { display: block; }
.req-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; margin-bottom: 6px; }
.req-top h2 { flex: 1 0 auto; margin: 0; }
.req-top .pill { margin-top: 0; white-space: nowrap; }
.pill.reply { background: var(--warn-soft); color: var(--warn); }
.pill.declined { background: var(--danger-soft); color: var(--danger); }
.quote { border-left: 3px solid var(--border-strong); padding-left: 10px; margin: 8px 0; overflow-wrap: anywhere; }
.request p { margin: 6px 0; }
.thread { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.msg-line { border-radius: 12px; padding: 8px 12px; background: var(--surface-2); max-width: 92%; overflow-wrap: anywhere; }
.msg-line.me { align-self: flex-end; background: var(--primary-soft); }
.req-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.request form.answer { margin-top: 10px; }
.notice.ok { background: var(--success-soft); }
.reply-note { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); background: var(--warn-soft); }
.back { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; color: var(--muted); text-decoration: none; font-weight: 600; }
.row-links { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 6px; font-size: 14px; }
.row-links a { color: var(--text); font-weight: 600; }
.pre { white-space: pre-line; overflow-wrap: anywhere; margin: 0 0 10px; }
.tabbar a { position: relative; }
.tabbar a.badge::after { content: ''; position: absolute; top: 10px; left: calc(50% + 8px); width: 9px; height: 9px; border-radius: 50%; background: var(--danger); }
form .grid2 { gap: 10px; }
form .grid2 input { min-width: 0; width: 100%; }
/* Stage 4: Messages and Notifications */
.msg-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px; }
.msg-actions .btn { flex: 1 1 auto; }
.feed { display: flex; flex-direction: column; gap: 10px; }
.feed > .card { margin: 0; }
.bubble { border-radius: 14px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); max-width: 88%; align-self: flex-start; overflow-wrap: anywhere; box-shadow: var(--shadow); }
.bubble.me { align-self: flex-end; background: var(--primary-soft); border-color: transparent; box-shadow: none; }
.bubble .pre { margin: 4px 0 2px; }
.bubble .seen { display: inline-flex; align-items: center; gap: 4px; }
.bubble .seen .ic { width: 14px; height: 14px; }
.note-msg h2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.note-msg .pre { margin: 6px 0; }
.note-msg.kind-news { border-left: 4px solid var(--primary); }
.new { display: inline-block; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 1px 8px; background: var(--danger); color: #fff; letter-spacing: 0.02em; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.prefs-table { width: 100%; border-collapse: collapse; }
.prefs-table th, .prefs-table td { padding: 10px 4px; border-bottom: 1px solid var(--border); text-align: center; vertical-align: middle; }
.prefs-table tbody tr:last-child th, .prefs-table tbody tr:last-child td { border-bottom: 0; }
.prefs-table thead th { font-size: 13px; font-weight: 600; color: var(--muted); }
.prefs-table thead th .ic { width: 18px; height: 18px; display: block; margin: 0 auto 2px; }
.prefs-table tbody th { text-align: left; font-weight: 400; }
.prefs-table tbody th .sub { display: block; }
.switch { appearance: none; -webkit-appearance: none; width: 46px; height: 28px; border-radius: 999px; background: var(--border-strong); position: relative; cursor: pointer; margin: 0; transition: background 0.15s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); transition: transform 0.15s; }
.switch:checked { background: var(--success); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
#phone-card .btn { margin-top: 8px; }
