/* Tupo Pamoja Hub — clean, professional, mobile-first. Light theme (readable in sun).
   No webfonts: instant load on cheap phones / patchy data. Distinction via color + space. */

:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --ink: #14212e;
  --muted: #61707e;
  --line: #dde3ea;
  --primary: #0f766e;         /* deep teal */
  --primary-ink: #ffffff;
  --primary-soft: #d5efec;
  --accent: #f59e0b;          /* warm amber, used sparingly */
  --good: #0f766e;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #c02626;
  --danger-soft: #fbe3e3;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20,33,46,.06), 0 6px 20px rgba(20,33,46,.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --wrap: 720px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
}

a { color: var(--primary); }

h1 { font-size: 1.5rem; margin: 0 0 .2rem; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; letter-spacing: -.01em; }
h3 { font-size: 1rem; margin: 0 0 .3rem; }
p { margin: 0 0 .6rem; }
.muted { color: var(--muted); }
.eyebrow { font-size: .72rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--primary); margin: 0 0 .25rem; }

/* ---------- App chrome ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .7rem max(1rem, calc((100vw - var(--wrap)) / 2));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 800; text-decoration: none; color: var(--ink); }
.brand-mark {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--primary); color: #fff; font-size: .8rem; font-weight: 900; letter-spacing: -.02em;
}
.brand-lg { display: inline-flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.15rem; margin-bottom: .5rem; }
.who { font-size: .82rem; color: var(--muted); text-align: right; }

/* Bottom tab bar on mobile, top on desktop */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; text-align: center; padding: .7rem .2rem; font-size: .74rem; font-weight: 700;
  color: var(--muted); text-decoration: none; border-top: 2px solid transparent;
}
.tabbar a.active { color: var(--primary); border-top-color: var(--primary); background: var(--primary-soft); }

.wrap {
  max-width: var(--wrap); margin: 0 auto;
  padding: 1rem 1rem calc(5.5rem + env(safe-area-inset-bottom));
}
.foot { display: none; }

/* ---------- Blocks ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.card, .panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}
.auth-card { max-width: 420px; margin: 2rem auto; }

.stack { display: grid; gap: .9rem; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
@media (max-width: 460px) { .row-2 { grid-template-columns: 1fr; } }

/* ---------- Stat tiles ---------- */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .8rem; box-shadow: var(--shadow); }
.stat span { display: block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.stat strong { display: block; font-size: 1.5rem; margin-top: .15rem; }
.stat-warn strong { color: var(--warn); }
.stat-good strong { color: var(--good); }
@media (max-width: 460px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: .35rem; }
.field > span { font-size: .82rem; font-weight: 700; color: var(--ink); }
.field-required > span::after { content: " *"; color: var(--danger); }
.field input, .field select, .field textarea,
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; min-height: 48px; padding: .65rem .8rem;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  color: var(--ink); font-size: 1rem; font-family: inherit;
}
textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
input::placeholder, textarea::placeholder { color: #9aa7b3; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 48px; padding: .6rem 1.1rem; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font-size: 1rem; font-weight: 700; text-decoration: none;
  cursor: pointer; transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn-accent { background: var(--accent); color: #3a2600; border-color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: .4rem .8rem; font-size: .9rem; }
.btn-wa { background: #1f9f55; color: #fff; border-color: #1f9f55; }

.actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---------- Choice chips (tappable, low-literacy friendly) ---------- */
.chip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
@media (max-width: 460px) { .chip-grid { grid-template-columns: 1fr; } }
.chip {
  display: flex; align-items: center; gap: .6rem; min-height: 50px; padding: .55rem .8rem;
  background: var(--surface-2); border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  font-weight: 600; cursor: pointer; user-select: none;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip .box { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line); display: grid; place-items: center; }
.chip .box::after { content: ""; width: 10px; height: 5px; border-left: 2.5px solid #fff; border-bottom: 2.5px solid #fff; transform: rotate(-45deg) scale(0); }
.chip:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.chip input:checked ~ .box { background: var(--primary); border-color: var(--primary); }
.chip input:checked ~ .box::after { transform: rotate(-45deg) scale(1); }

/* ---------- Lists / rows ---------- */
.list { display: grid; gap: .6rem; }
.rowcard {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  padding: .85rem 1rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); text-decoration: none; color: inherit;
}
.rowcard .main { min-width: 0; }
.rowcard .main strong { display: block; overflow-wrap: anywhere; }
.rowcard .main small { color: var(--muted); }
.rowcard .end { text-align: right; white-space: nowrap; }

/* ---------- Pills / badges ---------- */
.pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 800; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pill-lead { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill-active { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.pill-overdue { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill-suspended { background: #e5e7eb; color: #4b5563; border-color: transparent; }

/* ---------- Flash ---------- */
.flash { padding: .8rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-weight: 600; }
.flash-success { background: var(--primary-soft); color: #0b5a53; }
.flash-error { background: var(--danger-soft); color: #8a1c1c; }

/* ---------- Section divider inside forms ---------- */
.form-section { padding-bottom: 1.1rem; margin-bottom: 1.1rem; border-bottom: 1px solid var(--line); }
.form-section:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }

/* ---------- Tables (scroll on mobile) ---------- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* ---------- Definition rows ---------- */
.dl { display: grid; gap: .5rem; }
.dl > div { display: flex; justify-content: space-between; gap: 1rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line); }
.dl dt { color: var(--muted); font-size: .9rem; }
.dl dd { margin: 0; font-weight: 700; text-align: right; }

/* ---------- Tabs (client detail) ---------- */
.tabs { display: flex; gap: .3rem; margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .5rem .9rem; border-radius: 999px; text-decoration: none; font-weight: 700; font-size: .9rem; color: var(--muted); background: var(--surface); border: 1px solid var(--line); white-space: nowrap; }
.tabs a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- QR ---------- */
.qr-box { display: grid; place-items: center; gap: .5rem; padding: 1rem; background: #fff; border-radius: var(--radius-sm); }
.qr-box svg, .qr-box img { width: 180px; height: 180px; }

/* ---------- Desktop: move nav to top ---------- */
@media (min-width: 860px) {
  .tabbar { position: sticky; top: 57px; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line);
    max-width: var(--wrap); margin: 0 auto; border-radius: 0 0 var(--radius) var(--radius); }
  .tabbar a { border-top: 0; border-bottom: 2px solid transparent; }
  .tabbar a.active { border-top: 0; border-bottom-color: var(--primary); }
  .wrap { padding-bottom: 2rem; }
}

@media print {
  .topbar, .tabbar, .no-print { display: none !important; }
  body { background: #fff; }
  .card, .panel { box-shadow: none; border-color: #ccc; }
}

/* ---------- Guides / tour ---------- */
.help-link { font-weight: 700; text-decoration: none; }
.tour { border-color: var(--primary); background: linear-gradient(180deg, var(--primary-soft), var(--surface)); }
.tour-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.tour-head h2 { margin: 0; }
.steps { list-style: none; counter-reset: s; margin: .6rem 0 0; padding: 0; display: grid; gap: .55rem; }
.steps > li { counter-increment: s; position: relative; padding: .7rem .8rem .7rem 2.9rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.steps > li::before { content: counter(s); position: absolute; left: .7rem; top: .7rem; width: 1.6rem; height: 1.6rem; display: grid; place-items: center; border-radius: 999px; background: var(--primary); color: #fff; font-weight: 800; font-size: .85rem; }
.steps > li strong { display: block; }
.steps > li span { color: var(--muted); font-size: .92rem; }

/* ---------- Onboarding wizard ---------- */
.chip-label { display: block; font-size: .82rem; font-weight: 700; color: var(--ink); margin: .2rem 0 .5rem; }
.wiz-dots { display: flex; gap: .4rem; justify-content: center; margin: 0 0 .8rem; }
.wiz-dot { width: 9px; height: 9px; border-radius: 999px; background: var(--line); }
.wiz-dot.now { background: var(--primary); transform: scale(1.25); }
.wiz-dot.done { background: var(--primary-soft); }
.wiz-stage h2 { margin-top: .2rem; }
.wiz-nav { display: flex; gap: .5rem; margin-top: 1.2rem; }
.wiz-nav .btn { flex: 1; }
.wiz-savenote { text-align: center; color: var(--muted); font-size: .8rem; min-height: 1rem; margin: .4rem 0 0; }

/* No-JS fallback: all stages visible, only Save button. */
.wiz-nav #wizBack, .wiz-nav #wizSkip, .wiz-nav #wizNext { display: none; }
/* JS on: wizard mode */
.wiz.js .wiz-stage { display: none; }
.wiz.js .wiz-stage.active { display: block; }
.wiz.js .wiz-nav #wizSave { display: none; }
.wiz.js .wiz-nav #wizSkip, .wiz.js .wiz-nav #wizNext { display: inline-flex; }
.wiz.js:not(.on-first) .wiz-nav #wizBack { display: inline-flex; }
.wiz.js.on-last .wiz-nav #wizNext, .wiz.js.on-last .wiz-nav #wizSkip { display: none; }
.wiz.js.on-last .wiz-nav #wizSave { display: inline-flex; }

/* Business-type picker */
.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
@media (max-width: 380px) { .type-grid { grid-template-columns: 1fr; } }
.type-btn {
  min-height: 52px; padding: .5rem .7rem; text-align: left; font-weight: 600; font-size: .95rem;
  background: var(--surface-2); color: var(--ink); border: 1.5px solid var(--line); border-radius: var(--radius-sm); cursor: pointer;
}
.type-btn.sel { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

.tip-card { margin-top: 1rem; padding: .8rem 1rem; background: var(--warn-soft); border-radius: var(--radius-sm); font-size: .92rem; color: #6b4d12; }

/* ---------- Photo gallery ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; margin-top: .6rem; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.dl dd { max-width: 62%; }

/* Taps on a chip always register on the label, never an inner span. */
.chip .box, .chip > span:last-child { pointer-events: none; }
.type-btn { -webkit-tap-highlight-color: transparent; }

/* ---------- Free-entry service tags ---------- */
.svc-tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .6rem; }
.svc-tag { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .3rem .35rem .7rem; background: var(--primary-soft); color: #0b5a53; border-radius: 999px; font-weight: 600; font-size: .92rem; }
.svc-tag button { border: 0; background: rgba(0,0,0,.08); color: inherit; width: 22px; height: 22px; border-radius: 999px; font-size: 1rem; line-height: 1; cursor: pointer; }
.svc-add { display: flex; gap: .5rem; }
.svc-add input { flex: 1; }
.svc-add .btn { flex: 0 0 auto; }
.suggest-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.suggest-chip { background: var(--surface-2); border: 1.5px solid var(--line); color: var(--ink); border-radius: 999px; padding: .35rem .7rem; font-size: .88rem; font-weight: 600; cursor: pointer; }
.suggest-chip:active { background: var(--primary-soft); }
