/* AuraScan — one stylesheet, self-hosted. No external CDN, so the CSP stays tight. */

:root {
    --accent: #c1121f;
    --ink: #16181d;
    --muted: #6b7280;
    --line: #e5e7eb;
    --bg: #f6f7f9;
    --panel: #ffffff;
    --ok: #0f766e;
    --warn: #b45309;
    --err: #b91c1c;
    --radius: 10px;
    --font: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* ---------- Auth screens ---------- */
.auth-body { display: flex; flex-direction: column; min-height: 100vh; }
.auth-shell { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-footer { text-align: center; padding: 1rem; color: var(--muted); font-size: .8rem; }

.card {
    width: 100%; max-width: 420px; background: var(--panel);
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 2rem; box-shadow: 0 1px 3px rgba(16, 24, 40, .06);
}
.card h1 { font-size: 1.5rem; letter-spacing: -.02em; margin-bottom: .25rem; }

.badge {
    display: inline-block; font-size: .68rem; font-weight: 700; letter-spacing: .08em;
    padding: .25rem .55rem; border-radius: 999px; margin-bottom: 1rem;
    background: color-mix(in srgb, var(--accent) 12%, white); color: var(--accent);
}
.badge-error { background: #fee2e2; color: var(--err); }

/* ---------- Forms ---------- */
label { display: block; font-size: .82rem; font-weight: 600; margin: 1rem 0 .3rem; }
input[type=text], input[type=email], input[type=password], input[type=tel], select, textarea {
    width: 100%; font: inherit; font-size: .9rem; padding: .55rem .7rem;
    border: 1.5px solid var(--line); border-radius: 8px; background: #fff;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
input:disabled { background: #f3f4f6; color: var(--muted); }
.code-input { letter-spacing: .5em; text-align: center; font-size: 1.3rem; }

.check { display: flex; gap: .5rem; align-items: flex-start; font-weight: 400; margin-top: 1rem; }
.check input { width: auto; margin-top: .25rem; }

.field-error { display: block; color: var(--err); font-size: .78rem; margin-top: .25rem; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }
.form-grid .span-all { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .75rem 1rem 1rem; margin-top: 1rem; }
legend { font-size: .82rem; font-weight: 600; padding: 0 .35rem; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .25rem 1rem; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block; font: inherit; font-size: .88rem; font-weight: 600;
    padding: .6rem 1.1rem; border: 1.5px solid transparent; border-radius: 8px;
    cursor: pointer; text-decoration: none; text-align: center;
}
.btn-primary { background: var(--accent); color: #fff; width: 100%; margin-top: 1.5rem; }
.btn-secondary { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-small { padding: .3rem .6rem; font-size: .78rem; width: auto; margin: 0; }
.btn:hover { filter: brightness(.96); }

/* ---------- Alerts ---------- */
.alert { font-size: .85rem; padding: .65rem .85rem; border-radius: 8px; margin: 1rem 0; border-left: 4px solid; }
.alert-error  { background: #fef2f2; border-color: var(--err); color: #7f1d1d; }
.alert-notice { background: #eff6ff; border-color: #2563eb; color: #1e3a8a; }

/* ---------- App shell ---------- */
.topbar {
    display: flex; align-items: center; gap: 1.5rem;
    background: var(--panel); border-bottom: 1px solid var(--line); padding: .7rem 1.5rem;
}
.topbar-brand { display: flex; align-items: center; gap: .65rem; }
.topbar-brand small { display: block; font-size: .72rem; color: var(--muted); }
.mark {
    width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #fff;
    display: grid; place-items: center; font-weight: 800;
}
.topbar-nav { display: flex; gap: 1.1rem; margin-left: auto; font-size: .88rem; }
.topbar-nav a { color: var(--muted); text-decoration: none; font-weight: 600; }
.topbar-nav a:hover { color: var(--accent); }
.topbar-user { display: flex; align-items: center; gap: .6rem; }
.topbar-user .who strong { display: block; font-size: .82rem; line-height: 1.2; }
.topbar-user .who small { color: var(--muted); font-size: .72rem; }
.avatar {
    width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
    background: color-mix(in srgb, var(--accent) 15%, white); color: var(--accent);
    font-size: .78rem; font-weight: 700;
}

.container { max-width: 1120px; margin: 0 auto; padding: 1.75rem 1.5rem 3rem; }
.app-footer { text-align: center; padding: 1rem; color: var(--muted); font-size: .78rem; }

.page-head { margin-bottom: 1.5rem; }
.page-head h1 { font-size: 1.6rem; letter-spacing: -.02em; }

.hero { text-align: center; padding: 3rem 1rem; }
.hero h1 { font-size: 2.2rem; letter-spacing: -.03em; margin-bottom: .5rem; }
.hero .muted { max-width: 620px; margin: 0 auto; }
.hero-actions { display: flex; gap: .75rem; justify-content: center; margin-top: 1.5rem; }
.hero-actions .btn { width: auto; margin: 0; }

.panel {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.25rem 1.4rem; margin-bottom: 1.25rem;
}
.panel h2 { font-size: 1.02rem; margin-bottom: .6rem; }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.25rem; }
.grid-cards .panel { margin: 0; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; }
.stat-value { display: block; font-size: 1.9rem; font-weight: 800; letter-spacing: -.03em; }
.stat-label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th, td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
td.actions { display: flex; gap: .4rem; }

.pill { display: inline-block; font-size: .72rem; font-weight: 600; padding: .15rem .5rem; border-radius: 999px; background: #f3f4f6; color: var(--muted); }
.pill-active { background: #dcfce7; color: #166534; }
.pill-pending { background: #fef3c7; color: var(--warn); }
.pill-invited { background: #e0e7ff; color: #3730a3; }
.pill-suspended { background: #fee2e2; color: var(--err); }

/* ---------- Utilities ---------- */
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.clean { list-style: none; }
.clean li { padding: .35rem 0; border-bottom: 1px solid var(--line); }
.clean li:last-child { border-bottom: 0; }
.clean small { display: block; }
.code-badge { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.15rem; font-weight: 700; letter-spacing: .1em; }
.detail { background: #f3f4f6; padding: .75rem; border-radius: 8px; font-size: .78rem; overflow-x: auto; margin: 1rem 0; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85em; background: #f3f4f6; padding: .1rem .3rem; border-radius: 4px; }

@media (max-width: 720px) {
    .topbar { flex-wrap: wrap; gap: .75rem; }
    .topbar-nav { order: 3; width: 100%; margin-left: 0; }
    .hero h1 { font-size: 1.7rem; }
}

/* ---- shared: order summary, section headings, inline buttons ---- */
.kv { width: 100%; font-size: .88rem; }
.kv th { text-align: left; font-weight: 600; color: var(--muted); padding: .4rem .75rem .4rem 0; width: 38%; text-transform: none; letter-spacing: 0; font-size: .88rem; }
.kv td { padding: .4rem 0; }
.section-title { font-size: 1.05rem; margin: 1.75rem 0 1rem; }
.btn-inline { width: auto; margin: 0; }
.back-link { display: inline-block; font-size: .84rem; font-weight: 600; text-decoration: none; margin-bottom: .5rem; }
td code, .kv code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .78rem; background: #f3f4f6; padding: .1rem .35rem; border-radius: 4px; }

/* ============================================================
   CLIENT PORTAL — trends, records, remedies
   ============================================================ */

.trend-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.25rem; }
.trend-card { margin: 0; }
.trend-card h2 { font-size: .92rem; margin-bottom: .25rem; }
.trend-current { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; margin-bottom: .5rem; }
.trend-current .unit { font-size: .8rem; font-weight: 500; color: var(--muted); margin-left: .15rem; }
.trend-current .pill { vertical-align: middle; margin-left: .4rem; }
/* The chart scales with the card; the viewBox keeps the geometry. */
.trend { width: 100%; height: 96px; display: block; margin: .25rem 0 .5rem; overflow: visible; }
.trend-table { margin-top: .5rem; }
.trend-table summary { font-size: .8rem; color: var(--muted); cursor: pointer; }
.trend-table .kv { margin-top: .4rem; }

.remedy-list li { display: flex; gap: 1rem; align-items: flex-start; justify-content: space-between; padding: .75rem 0; }
.remedy-body { flex: 1; }
.remedy-actions { display: flex; gap: .35rem; flex-wrap: wrap; }
.remedy-list .is-overdue .remedy-body strong { color: var(--err); }

.report { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.75rem; }
.report .panel { border: 0; padding: 0 0 1.25rem; margin: 0 0 1.25rem; border-bottom: 1px solid var(--line); background: none; }
.report .panel:last-of-type { border-bottom: 0; }
.report-head { display: flex; justify-content: space-between; gap: 1.5rem; align-items: flex-start;
               padding-bottom: 1.25rem; margin-bottom: 1.5rem; border-bottom: 2px solid var(--ink); flex-wrap: wrap; }
.report-brand { text-align: right; }
.report-brand small { display: block; }
.report .summary p { font-size: 1rem; line-height: 1.7; }
.report-foot { border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 1.25rem; }
.report-actions { display: flex; gap: .6rem; margin-top: 1.25rem; flex-wrap: wrap; }

/* ---- confirming a purchase ----
   The three steps answer "what happens if I press this", so they sit above the
   button rather than below it. Numbered, because the order is the information. */
.buy-steps { margin: 0 0 1.25rem; padding-left: 1.35rem; }
.buy-steps li { margin-bottom: .5rem; line-height: 1.65; color: var(--muted); }
.buy-steps li::marker { color: var(--accent); font-weight: 700; }

/* ---- print: the record becomes the document ---- */
@media print {
    .topbar, .app-footer, .no-print, .whatsapp { display: none !important; }
    body { background: #fff; }
    .container { max-width: none; padding: 0; }
    .report { border: 0; padding: 0; }
    .pill { border: 1px solid #999; background: none !important; color: #000 !important; }
    a[href]::after { content: ''; }
    .trend { break-inside: avoid; }
    .panel { break-inside: avoid; }
}

/* ---- Refer & earn (portal) ---- */
.referral-code-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin: .75rem 0; }
.referral-code {
    font-size: 1.6rem; font-weight: 800; letter-spacing: .12em;
    padding: .55rem 1.1rem; border: 2px dashed var(--accent); border-radius: 10px;
    background: color-mix(in srgb, var(--accent) 6%, white); color: var(--accent);
}
.referral-share-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.referral-stats { display: flex; gap: 2.5rem; flex-wrap: wrap; margin: 1rem 0 1.5rem; }
.referral-stats .stat strong { display: block; font-size: 1.8rem; line-height: 1.2; }
.discount-line { color: var(--ok); font-weight: 600; }

/* The OTP offer at the top of the sign-in card: an equal door, not a footnote. */
.otp-cta { display: block; width: 100%; text-align: center; margin-bottom: .5rem; }
.otp-or { text-align: center; margin: .35rem 0 1rem; }

/* The one-chart client profile: full width, legend dots matching the SVG. */
.profile-chart svg.profile { width: 100%; height: auto; display: block; }
.dot-first  { color: #a9aeb5; }
.dot-latest { color: #0ca30c; }
