/* HeyRanks app styles: login, signup, reset, dashboard, admin. Landing page keeps its own inline CSS. */
:root {
  --bg: #faf8f4; --surface: #ffffff; --surface-2: #f6f7f9; --line: #e5e7eb; --line-2: #eef0f3;
  --ink: #0f1720; --ink-2: #334155; --muted: #64748b; --faint: #94a3b8;
  --accent: #ff5a1f; --accent-ink: #ffffff; --mint: #d9f99d; --brand-dark: #0f1720;
  --series: #1f6fff; --series-wash: rgba(31, 111, 255, .10); --grid: #eef0f3; --axis: #94a3b8;
  --good: #15803d; --good-bg: #dcfce7; --warn: #b45309; --warn-bg: #fef3c7; --bad: #b91c1c; --bad-bg: #fee2e2;
  --info-bg: #e8efff; --code-bg: #0f1720; --code-ink: #d9f99d;
  --shadow: 0 1px 2px rgba(15, 23, 32, .04), 0 8px 24px -12px rgba(15, 23, 32, .12);
  --r: 16px; --r-sm: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1218; --surface: #161d27; --surface-2: #1c2531; --line: #273241; --line-2: #212b38;
    --ink: #e6edf3; --ink-2: #c3cdd8; --muted: #8b98a8; --faint: #6b7787;
    --series: #5b8cff; --series-wash: rgba(91, 140, 255, .14); --grid: #222c39; --axis: #6b7787;
    --good: #4ade80; --good-bg: rgba(74, 222, 128, .12); --warn: #fbbf24; --warn-bg: rgba(251, 191, 36, .12);
    --bad: #f87171; --bad-bg: rgba(248, 113, 113, .12); --info-bg: rgba(91, 140, 255, .14); --code-bg: #0a0f14;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1218; --surface: #161d27; --surface-2: #1c2531; --line: #273241; --line-2: #212b38;
  --ink: #e6edf3; --ink-2: #c3cdd8; --muted: #8b98a8; --faint: #6b7787;
  --series: #5b8cff; --series-wash: rgba(91, 140, 255, .14); --grid: #222c39; --axis: #6b7787;
  --good: #4ade80; --good-bg: rgba(74, 222, 128, .12); --warn: #fbbf24; --warn-bg: rgba(251, 191, 36, .12);
  --bad: #f87171; --bad-bg: rgba(248, 113, 113, .12); --info-bg: rgba(91, 140, 255, .14); --code-bg: #0a0f14;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: Inter, system-ui, sans-serif; background: var(--bg); color: var(--ink); line-height: 1.55; -webkit-font-smoothing: antialiased; min-height: 100vh; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2 { font-family: Fraunces, Georgia, serif; letter-spacing: -.02em; line-height: 1.15; }
h1 { font-size: clamp(1.6rem, 3.5vw, 2.1rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: .95rem; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--series); outline-offset: 2px; }

/* ─── top bar ─── */
.topbar { background: var(--brand-dark); color: #fff; position: sticky; top: 0; z-index: 40; }
.topbar .in { max-width: 1180px; margin: 0 auto; padding: 0 16px; height: 60px; display: flex; align-items: center; gap: 14px; }
.logo { display: flex; align-items: center; gap: 9px; font-weight: 700; text-decoration: none; color: #fff; flex: none; }
.logo-mark { width: 30px; height: 30px; border-radius: 8px; background: rgba(255, 255, 255, .1); display: grid; place-items: center; }
.topbar .spacer { flex: 1; }
.topbar select { background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .15); color: #fff; border-radius: 8px; padding: 6px 10px; max-width: 220px; }
.topbar select option { color: #0f1720; }
.topbar .link { color: #cbd5e1; text-decoration: none; font-size: .9rem; padding: 6px 8px; border-radius: 8px; background: none; border: 0; cursor: pointer; white-space: nowrap; }
.topbar .link:hover, .topbar .link[aria-current="page"] { color: #fff; background: rgba(255, 255, 255, .08); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--mint); color: var(--brand-dark); font-weight: 700; display: grid; place-items: center; font-size: .85rem; flex: none; }
@media (max-width: 640px) {
  .topbar .in { gap: 6px; }
  .topbar .hide-sm { display: none; }
  .topbar select { max-width: 130px; }
  .topbar .link { padding: 6px; }
}

/* ─── layout ─── */
.page { max-width: 1180px; margin: 0 auto; padding: 24px 16px 64px; }
.grid { display: grid; gap: 16px; }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 960px) { .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-3 { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .cols-2 { grid-template-columns: 1fr; } }
@media (max-width: 420px) { .cols-4 { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head p { font-size: .85rem; color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 16px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }

/* ─── buttons & forms ─── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: .92rem; border: 1.5px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer; text-decoration: none; transition: background .15s, color .15s, border-color .15s; white-space: nowrap; }
.btn:hover { background: var(--ink); color: var(--bg); }
.btn.primary { background: var(--ink); color: var(--bg); }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent:hover { filter: brightness(1.05); }
.btn.ghost { border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.danger:hover { background: var(--bad); color: #fff; }
.btn.sm { padding: 6px 12px; font-size: .82rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: wait; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.input, .field input, .field select, .field textarea { width: 100%; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: var(--r-sm); background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus, .field input:focus, .field select:focus { border-color: var(--ink); box-shadow: 0 0 0 3px var(--line-2); }
.hint { font-size: .78rem; color: var(--muted); margin-top: 5px; }
.pw-wrap { position: relative; }
.pw-wrap button { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); font-size: .8rem; font-weight: 600; cursor: pointer; padding: 4px 6px; }

/* ─── messages ─── */
.alert { border-radius: var(--r-sm); padding: 11px 14px; font-size: .88rem; margin-bottom: 14px; }
.alert.error { background: var(--bad-bg); color: var(--bad); }
.alert.ok { background: var(--good-bg); color: var(--good); }
.alert.info { background: var(--info-bg); color: var(--ink-2); }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-radius: var(--r); padding: 14px 18px; margin-bottom: 16px; font-size: .92rem; }
.banner.info { background: var(--info-bg); }
.banner.warn { background: var(--warn-bg); }
.banner.brand { background: var(--mint); color: #0f1720; }
.banner.brand .btn { border-color: #0f1720; color: #0f1720; }
.banner.brand .btn:hover { background: #0f1720; color: #fff; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--brand-dark); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: .88rem; opacity: 0; pointer-events: none; transition: .2s; z-index: 100; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }

/* ─── badges ─── */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ─── stat tiles ─── */
.tile { padding: 18px 20px; }
.tile .label { font-size: .82rem; color: var(--muted); font-weight: 500; }
.tile .value { font-size: 2rem; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; line-height: 1.1; }
.tile .value small { font-size: .95rem; color: var(--muted); font-weight: 500; }
.tile .delta { font-size: .8rem; margin-top: 6px; color: var(--muted); }
.tile .delta b { font-weight: 700; }
.tile .delta .up { color: var(--good); }
.tile .delta .down { color: var(--bad); }
.tile.hero .value { font-size: 3rem; }
.meter { height: 8px; border-radius: 99px; background: var(--line-2); overflow: hidden; margin-top: 10px; }
.meter div { height: 100%; border-radius: 99px; }

/* ─── tabs ─── */
.tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: none; padding: 6px 14px; border-radius: 999px; font-size: .85rem; font-weight: 600; color: var(--muted); cursor: pointer; flex: none; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }

/* ─── tables ─── */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover, tbody tr[aria-selected="true"] { background: var(--surface-2); }
.up { color: var(--good); } .down { color: var(--bad); }

/* ─── charts ─── */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-text { fill: var(--axis); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .series-line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series-area { fill: var(--series-wash); }
.chart .series-dot { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.chart .series-bar { fill: var(--series); transition: opacity .12s; }
.chart .series-bar.dim { opacity: .45; }
.chart .end-label { fill: var(--ink); font-size: 12px; font-weight: 700; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; }
.chart .empty { fill: var(--muted); font-size: 13px; }
.tooltip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 10px; padding: 8px 11px; font-size: .8rem; white-space: nowrap; z-index: 5; transform: translate(-50%, calc(-100% - 10px)); }
.tooltip b { font-size: .95rem; display: block; }
.tooltip .k { display: inline-block; width: 12px; height: 2px; background: var(--series); vertical-align: middle; margin-right: 6px; }
.tooltip span { color: var(--muted); }

/* ─── fixes list ─── */
.fix { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.fix + .fix { margin-top: 10px; }
.fix-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fix-head b { font-size: .93rem; }
.fix p { font-size: .88rem; color: var(--ink-2); margin-top: 6px; }
.fix details { margin-top: 10px; }
.fix summary { cursor: pointer; font-size: .82rem; font-weight: 600; color: var(--series); }
.code { position: relative; margin-top: 8px; background: var(--code-bg); border-radius: 10px; padding: 12px 14px; }
.code pre { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .76rem; color: var(--code-ink); white-space: pre-wrap; word-break: break-word; line-height: 1.55; padding-right: 56px; }
.code button { position: absolute; top: 8px; right: 8px; background: rgba(255, 255, 255, .1); color: #fff; border: 0; border-radius: 6px; font-size: .72rem; padding: 4px 8px; cursor: pointer; }
.check-list { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 16px; font-size: .86rem; color: var(--ink-2); }
.check-list li::before { content: "✓ "; color: var(--good); font-weight: 700; }
.pill-list { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.pill-list li { font-size: .82rem; background: var(--surface-2); border-radius: 999px; padding: 4px 11px; }

/* ─── drawer (report detail) ─── */
.drawer-bg { position: fixed; inset: 0; background: rgba(15, 23, 32, .45); z-index: 60; opacity: 0; pointer-events: none; transition: .2s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--bg); z-index: 61; transform: translateX(100%); transition: transform .25s ease; overflow-y: auto; padding: 22px 20px 40px; box-shadow: -10px 0 40px rgba(0, 0, 0, .2); }
.drawer.open { transform: none; }
.drawer-bg.open { opacity: 1; pointer-events: auto; }

/* ─── auth pages ─── */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: var(--brand-dark); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h2 { font-size: clamp(1.6rem, 3vw, 2.3rem); margin: 24px 0 12px; color: #fff; }
.auth-side p { color: #cbd5e1; max-width: 420px; }
.auth-side ul { list-style: none; margin-top: 24px; }
.auth-side li { padding: 7px 0; color: #e2e8f0; }
.auth-side li::before { content: "✓ "; color: var(--mint); font-weight: 700; }
.auth-main { display: grid; place-items: center; padding: 40px 16px; }
.auth-box { width: 100%; max-width: 400px; }
.auth-box h1 { margin-bottom: 6px; }
.auth-box .sub { color: var(--muted); margin-bottom: 24px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: .8rem; margin: 18px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-foot { margin-top: 20px; font-size: .88rem; color: var(--muted); text-align: center; }
.auth-foot a { color: var(--ink); font-weight: 600; }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth-side { display: none; } }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 48px 20px; }
.empty-state h2 { margin-bottom: 8px; }
.empty-state p { color: var(--muted); max-width: 440px; margin: 0 auto 20px; }
