/* Trackara Find for mechanics: the free mechanic portal (find.trackara.app/mechanic).
   Design values mirror the Trackara Pro shop portal (shop.trackara.app css/portal.css)
   so the two feel like one family, but nothing here loads Pro code.
   Flat fills only. Phone first: bottom tabs under 900px, a slim sidebar above. */

:root {
    --primary: #17afa5;
    --primary-dark: #0d8b82;
    --primary-subtle: rgba(23, 175, 165, 0.08);
    --primary-border: rgba(23, 175, 165, 0.28);
    --bg: #fafafa;
    --bg-card: #ffffff;
    --bg-raised: #f4f4f5;
    --border: #e7e5e4;
    --border-2: #d6d3d1;
    --text-1: #0a0a0a;
    --text-2: #525252;
    --text-3: #8a8a8a;
    --green: #10b981;
    --green-subtle: rgba(16, 185, 129, 0.1);
    --orange: #d97706;
    --orange-subtle: rgba(245, 158, 11, 0.12);
    --red: #ef4444;
    --red-subtle: rgba(239, 68, 68, 0.08);
    --backdrop: rgba(0, 0, 0, 0.5);
    --radius: 14px;
    --tabs-h: 64px;
    --top-h: 56px;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0a0a0a;
        --bg-card: #161616;
        --bg-raised: #1f1f1f;
        --border: #232323;
        --border-2: #2f2f2f;
        --text-1: #f0f0f0;
        --text-2: #a0a0a0;
        --text-3: #6b6b6b;
        --primary-subtle: rgba(23, 175, 165, 0.12);
        --backdrop: rgba(0, 0, 0, 0.72);
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px; line-height: 1.5;
    background: var(--bg); color: var(--text-1);
    min-height: 100vh; min-height: 100dvh;
}
a { color: var(--primary); }
button { font: inherit; color: inherit; }
h1, h2, h3, .fm-display { font-family: 'Inter Tight', 'Inter', sans-serif; letter-spacing: -0.03em; }
[hidden] { display: none !important; }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 10px 18px; border-radius: 10px;
    border: 1px solid transparent; background: var(--bg-raised); color: var(--text-1);
    font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-ghost { background: transparent; border-color: var(--border-2); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-raised); }
.btn-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }

/* ── Form ── */
.field { margin-bottom: 16px; }
.field label, .label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.input, .field input:not([type=checkbox]):not([type=range]), .field textarea, .field select {
    width: 100%; min-height: 44px; padding: 10px 12px;
    border: 1px solid var(--border-2); border-radius: 10px;
    background: var(--bg-card); color: var(--text-1);
    font: inherit; font-size: 16px; /* 16px stops iOS zooming into the field */
    outline: none;
}
.field textarea { min-height: 96px; resize: vertical; }
.input:focus, .field input:focus, .field textarea:focus, .field select:focus { border-color: var(--primary); }
.help { font-size: 13px; color: var(--text-3); margin-top: 6px; }
.err { font-size: 13px; color: var(--red); margin-top: 5px; }
.err:empty { display: none; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .row2 { grid-template-columns: 1fr; } }

/* ── App shell ── */
.fm-side { display: none; }
.fm-top {
    position: sticky; top: 0; z-index: 20; height: var(--top-h);
    display: flex; align-items: center; gap: 12px; padding: 0 16px;
    background: var(--bg-card); border-bottom: 1px solid var(--border);
}
.fm-logo {
    display: inline-flex; align-items: center; gap: 10px; text-decoration: none;
    font-family: 'Inter Tight', sans-serif; font-weight: 800; font-size: 18px; letter-spacing: -0.03em; color: var(--text-1);
}
.fm-logo img { width: 30px; height: 30px; border-radius: 8px; }
.fm-logo span { color: var(--primary); }
.fm-top-title { margin-left: auto; font-weight: 600; color: var(--text-2); font-size: 14px; }
.fm-main { padding: 16px 16px calc(var(--tabs-h) + 24px + env(safe-area-inset-bottom)); }
.fm-wrap { max-width: 760px; margin: 0 auto; }
.fm-tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    display: grid; grid-template-columns: repeat(3, 1fr);
    background: var(--bg-card); border-top: 1px solid var(--border);
}
.fm-tabs a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    text-decoration: none; color: var(--text-3); font-size: 12px; font-weight: 600; position: relative;
}
.fm-tabs a i { font-size: 18px; }
.fm-tabs a.on { color: var(--primary); }
.fm-badge {
    position: absolute; top: 8px; left: calc(50% + 6px);
    min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    background: var(--red); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}
@media (min-width: 900px) {
    .fm-top, .fm-tabs { display: none; }
    .fm-side {
        display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; width: 240px;
        padding: 22px 14px; background: var(--bg-card); border-right: 1px solid var(--border);
    }
    .fm-side .fm-logo { padding: 0 8px; margin-bottom: 26px; }
    .fm-nav a {
        display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
        color: var(--text-2); text-decoration: none; font-weight: 600; position: relative;
    }
    .fm-nav a i { width: 18px; text-align: center; }
    .fm-nav a:hover { background: var(--bg-raised); }
    .fm-nav a.on { background: var(--primary-subtle); color: var(--primary); }
    .fm-nav .fm-badge { position: static; margin-left: auto; }
    .fm-side-foot { margin-top: auto; }
    .fm-main { margin-left: 240px; padding: 32px 40px 48px; }
}
.fm-plan {
    border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 14px; font-size: 13px; color: var(--text-2);
}
.fm-plan strong { color: var(--text-1); display: block; font-size: 14px; margin-bottom: 2px; }
.fm-plan a { display: inline-block; margin-top: 8px; font-weight: 700; text-decoration: none; }
.fm-who { font-size: 13px; color: var(--text-3); padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Page bits ── */
.page-head { margin-bottom: 18px; }
.page-head h1 { font-size: 26px; font-weight: 800; }
.page-head p { color: var(--text-2); margin-top: 4px; }
@media (max-width: 899px) { .page-head h1 { font-size: 22px; } }
.card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px; margin-bottom: 14px;
}
.card h2 { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.card .sub { color: var(--text-2); font-size: 14px; margin-bottom: 14px; }
.notice {
    display: flex; gap: 12px; align-items: flex-start;
    border-radius: 12px; padding: 14px; margin-bottom: 14px; font-size: 14px;
    background: var(--primary-subtle); border: 1px solid var(--primary-border);
}
.notice i { color: var(--primary); margin-top: 3px; }
.notice.warn { background: var(--orange-subtle); border-color: rgba(245, 158, 11, 0.35); }
.notice.warn i { color: var(--orange); }
.notice .btn { margin-top: 10px; }
.pill {
    display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 700; background: var(--bg-raised); color: var(--text-2);
}
.pill.good { background: var(--green-subtle); color: var(--green); }
.pill.warn { background: var(--orange-subtle); color: var(--orange); }
.pill.bad { background: var(--red-subtle); color: var(--red); }
.pill.teal { background: var(--primary-subtle); color: var(--primary); }
.meter { height: 8px; border-radius: 4px; background: var(--bg-raised); overflow: hidden; margin-top: 8px; }
.meter > div { height: 100%; background: var(--primary); }
.loading { display: flex; align-items: center; gap: 10px; color: var(--text-2); padding: 40px 0; justify-content: center; }
.empty { text-align: center; padding: 40px 16px; color: var(--text-2); }
.empty i { font-size: 28px; color: var(--text-3); margin-bottom: 10px; display: block; }
.empty h3 { color: var(--text-1); font-size: 17px; margin-bottom: 4px; }

/* Segmented control */
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--bg-raised); margin-bottom: 14px; }
.seg button {
    flex: 1; min-height: 38px; border: 0; border-radius: 9px; background: transparent;
    font-weight: 600; font-size: 14px; color: var(--text-2); cursor: pointer;
}
.seg button.on { background: var(--bg-card); color: var(--text-1); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
.seg .n { font-size: 12px; color: var(--text-3); margin-left: 4px; }

/* Switch */
.switch { position: relative; width: 48px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 14px; background: var(--border-2); cursor: pointer; transition: background 0.15s; }
.switch span::before { content: ''; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::before { transform: translateX(20px); }
.switch input:disabled + span { opacity: 0.5; cursor: not-allowed; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.toggle-row .lbl { font-weight: 600; }
.toggle-row .sub2 { font-size: 13px; color: var(--text-3); }

/* List rows (account page) */
.rows { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); margin-bottom: 14px; overflow: hidden; }
.rows > * {
    display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; min-height: 56px;
    border: 0; border-bottom: 1px solid var(--border); background: transparent; text-align: left; text-decoration: none; color: var(--text-1); cursor: pointer;
}
.rows > *:last-child { border-bottom: 0; }
.rows > * > i:first-child { width: 20px; text-align: center; color: var(--text-3); }
.rows .r-main { flex: 1; min-width: 0; }
.rows .r-sub { font-size: 13px; color: var(--text-3); }
.rows .chev { color: var(--text-3); font-size: 12px; }
.rows .danger { color: var(--red); }
.rows .danger > i:first-child { color: var(--red); }

/* ── Leads ── */
.lead {
    display: block; width: 100%; text-align: left; cursor: pointer;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; margin-bottom: 10px;
}
.lead:hover { border-color: var(--border-2); }
.lead.new { border-color: var(--primary-border); }
.lead-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.lead-work { font-weight: 700; font-size: 16px; }
.lead-meta { color: var(--text-2); font-size: 14px; margin-top: 2px; }
.lead-when { font-size: 12px; color: var(--text-3); margin-top: 8px; }

/* Lead detail: full-screen sheet on phones, right panel on desktop */
.sheet-back { position: fixed; inset: 0; background: var(--backdrop); z-index: 50; }
.sheet {
    position: fixed; z-index: 51; inset: 0; background: var(--bg);
    display: flex; flex-direction: column;
}
@media (min-width: 900px) {
    .sheet { inset: 0 0 0 auto; width: 520px; border-left: 1px solid var(--border); }
}
.sheet-head {
    display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 16px; min-height: var(--top-h);
    background: var(--bg-card); border-bottom: 1px solid var(--border);
}
.sheet-head h2 { font-size: 17px; flex: 1; }
.icon-btn { width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; font-size: 18px; color: var(--text-2); }
.icon-btn:hover { background: var(--bg-raised); }
.sheet-body { flex: 1; overflow-y: auto; padding: 16px; }
.sheet-foot {
    display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--bg-card); border-top: 1px solid var(--border);
}
.sheet-foot .btn { flex: 1; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--text-3); }
.kv dd { color: var(--text-1); overflow-wrap: anywhere; }
.notes { white-space: pre-wrap; font-size: 14px; color: var(--text-2); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photos a { display: block; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--bg-raised); }
.photos img { width: 100%; height: 100%; object-fit: cover; }
.contact-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.contact-actions .btn { flex-direction: column; gap: 4px; font-size: 13px; min-height: 64px; }

/* ── Profile ── */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 14px;
    border: 1px solid var(--border-2); border-radius: 999px; background: var(--bg-card);
    font-size: 14px; font-weight: 600; color: var(--text-2); cursor: pointer; user-select: none;
}
.chip input { display: none; }
.chip.on { border-color: var(--primary); background: var(--primary-subtle); color: var(--primary); }
.avatar {
    width: 64px; height: 64px; border-radius: 16px; overflow: hidden; flex-shrink: 0;
    background: var(--bg-raised); display: flex; align-items: center; justify-content: center;
    color: var(--text-3); font-size: 22px; font-weight: 800;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.range { width: 100%; accent-color: var(--primary); height: 32px; }
.savebar {
    position: fixed; left: 0; right: 0; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); z-index: 25;
    display: flex; align-items: center; gap: 12px; padding: 12px 16px;
    background: var(--bg-card); border-top: 1px solid var(--border);
}
.savebar span { flex: 1; font-size: 14px; color: var(--text-2); }
@media (min-width: 900px) { .savebar { left: 240px; bottom: 0; padding: 14px 40px; } }
.missing { list-style: none; margin: 8px 0 0; font-size: 14px; color: var(--text-2); }
.missing li { display: flex; gap: 8px; align-items: center; padding: 3px 0; }
.missing li i { color: var(--text-3); font-size: 7px; }
.review { border-top: 1px solid var(--border); padding: 12px 0; }
.review:first-child { border-top: 0; padding-top: 0; }
.stars { color: #f59e0b; letter-spacing: 1px; }
.cert-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-bottom: 8px; align-items: center; }
@media (max-width: 520px) { .cert-row { grid-template-columns: 1fr auto; } .cert-row .cert-num { grid-column: 1 / 2; } }

/* ── Upgrade ── */
.up-hero { text-align: center; padding: 8px 0 18px; }
.up-hero h1 { font-size: 30px; font-weight: 800; line-height: 1.1; }
.up-hero p { color: var(--text-2); margin-top: 8px; }
.up-card { border: 2px solid var(--primary); }
.up-price { font-family: 'Inter Tight', sans-serif; font-size: 40px; font-weight: 800; line-height: 1; margin: 14px 0 4px; }
.up-price small { font-size: 15px; color: var(--text-3); font-weight: 600; }
.up-list { list-style: none; margin: 16px 0; display: grid; gap: 10px; }
.up-list li { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.up-list li i { color: var(--primary); margin-top: 4px; }
.up-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 4px; }
.up-compare div { border: 1px solid var(--border); border-radius: 12px; padding: 12px; text-align: center; }
.up-compare b { display: block; font-size: 24px; font-family: 'Inter Tight', sans-serif; }
.up-compare .pro { border-color: var(--primary-border); background: var(--primary-subtle); }
details.faq { border-top: 1px solid var(--border); padding: 12px 0; }
details.faq summary { font-weight: 600; cursor: pointer; }
details.faq p { color: var(--text-2); margin-top: 6px; font-size: 14px; }

/* ── Toast ── */
.toasts { position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom)); z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
@media (min-width: 900px) { .toasts { left: auto; right: 24px; bottom: 24px; align-items: flex-end; } }
.toast {
    pointer-events: auto; max-width: 420px; padding: 12px 16px; border-radius: 12px;
    background: var(--text-1); color: var(--bg); font-size: 14px; font-weight: 500;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.toast.error { background: var(--red); color: #fff; }
