/* =========================================================================
   MicraCoatings Installer Portal — dark "mineral" theme
   Phone-first. Single column, max 520px. Signature = segmented photo meter.
   Swap --font-* for your self-hosted faces to match the main app.
   ========================================================================= */
:root {
  --bg: #0e0f10;
  --surface: #161819;
  --surface-2: #1d2023;
  --line: #2a2e31;
  --text: #e9e6e1;        /* warm mineral off-white */
  --muted: #9aa0a6;
  --muted-2: #6c7176;
  --accent: #d4202a;      /* CANADA red */
  --accent-dim: #7d1a20;
  --gold: #c9a227;        /* verified / paid tier */
  --gold-dim: #5a4a14;
  --ok: #3fae6b;
  --warn: #d99a2b;
  --font-head: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-body); }
body {
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---- Header ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  padding: 14px 18px calc(14px + env(safe-area-inset-top)) 18px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: linear-gradient(180deg, #121415, #0e0f10);
  border-bottom: 1px solid var(--line);
}
.wordmark { font-family: var(--font-head); font-weight: 800; letter-spacing: .06em; font-size: 18px; }
.wordmark .ca { color: var(--accent); }
.subtitle { color: var(--muted); font-size: 11px; letter-spacing: .04em; margin-top: 2px; }
.link-btn {
  position: absolute; top: calc(14px + env(safe-area-inset-top)); right: 16px;
  background: none; border: none; color: var(--muted); font-size: 13px; cursor: pointer;
}
.link-btn:hover { color: var(--text); }

/* ---- Layout ---- */
.app { max-width: 520px; margin: 0 auto; padding: 18px 16px 96px; }
.center { display: grid; place-items: center; min-height: 50vh; text-align: center; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
h2.section { font-family: var(--font-head); font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 22px 2px 10px; }

/* ---- Cards ---- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 16px; margin-bottom: 12px;
}
.card.gold { border-color: var(--gold-dim); box-shadow: inset 0 0 0 1px rgba(201,162,39,.18); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: grid; gap: 6px; }

/* ---- Tier + meter (signature) ---- */
.tier-name { font-family: var(--font-head); font-weight: 800; font-size: 22px; letter-spacing: .02em; }
.tier-name.paid { color: var(--gold); }
.meter { display: flex; gap: 3px; margin-top: 12px; }
.meter .seg {
  flex: 1; height: 10px; border-radius: 2px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.meter .seg.fill { background: linear-gradient(180deg, #e3e0da, #b9b6af); border-color: #cfccc5; }
.meter .seg.fill.paid { background: linear-gradient(180deg, var(--gold), #9c7d1d); border-color: var(--gold); }
.meter-label { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
}
.badge.verified { color: var(--gold); border-color: var(--gold-dim); background: rgba(201,162,39,.08); }
.badge.warn { color: var(--warn); border-color: #6a4f15; background: rgba(217,154,43,.08); }
.badge.live { color: var(--ok); border-color: #1f5e3a; background: rgba(63,174,107,.08); }
.badge.pending { color: var(--muted); }

/* ---- Stars ---- */
.stars { color: var(--gold); letter-spacing: 2px; }
.stars .empty { color: var(--muted-2); }

/* ---- Buttons + fields ---- */
button.btn, a.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-body); font-size: 15px; font-weight: 600;
  padding: 12px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); cursor: pointer; text-decoration: none;
  width: 100%;
}
button.btn:active { transform: translateY(1px); }
button.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.btn.gold { background: var(--gold); border-color: var(--gold); color: #1a1500; }
button.btn.ghost { background: transparent; }
button.btn.danger { color: #f3a3a7; border-color: var(--accent-dim); }
button.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: grid; gap: 8px; margin-top: 8px; }

label.field { display: block; margin: 10px 0; }
label.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text); padding: 12px; font-size: 15px; font-family: inherit;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--muted); }
.check input { width: auto; margin-top: 2px; }

/* ---- Photo grid ---- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); aspect-ratio: 1; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .pill { position: absolute; top: 6px; left: 6px; font-size: 10px; padding: 2px 7px; border-radius: 999px; background: rgba(0,0,0,.65); color: #fff; text-transform: uppercase; letter-spacing: .04em; }
.photo .pill.approved { color: #9be8ba; }
.photo .pill.pending { color: #f0d28a; }
.photo .pill.rejected { color: #f3a3a7; }
.photo .del { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 999px; border: none; background: rgba(0,0,0,.65); color: #fff; font-size: 15px; cursor: pointer; line-height: 1; }
.photo .meta { position: absolute; bottom: 0; left: 0; right: 0; padding: 6px 8px; font-size: 11px; background: linear-gradient(0deg, rgba(0,0,0,.8), transparent); }

/* ---- Tabs ---- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: #121415; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab { background: none; border: none; color: var(--muted); font-size: 11px; padding: 12px 4px; cursor: pointer; border-top: 2px solid transparent; }
.tab[aria-current="true"] { color: var(--text); border-top-color: var(--accent); }

/* ---- Reviews ---- */
.review { border-bottom: 1px solid var(--line); padding: 12px 0; }
.review:last-child { border-bottom: none; }
.review .head { display: flex; justify-content: space-between; align-items: baseline; }
.review .resp { margin-top: 8px; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; font-size: 13px; }

/* ---- Toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 50; max-width: 90vw;
}
.toast.err { border-color: var(--accent-dim); color: #f3a3a7; }

#clerk-auth { min-height: 420px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
