/* ---------------------------------------------------------------------------------------------
   Pickle Portal — design system

   Palette, type and radii carried over from the Nrdvana artifacts so the platform and the marketing
   surface look like one product. Bright and airy is the brief: a pale blue canvas, white cards, a
   lot of breathing room, and colour used only where it means something.
   --------------------------------------------------------------------------------------------- */

@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600&family=Nunito:wght@400;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
    --bg: #EEF5FF;
    --surface: #FFFFFF;
    --surface-sunk: #F7FAFF;
    --ink: #12263A;
    --ink-soft: #26415C;
    --muted: #5A7189;
    --line: #D6E4F7;
    --line-soft: #E7EEFC;

    --brand: #2E7DF6;
    --brand-deep: #1B5FD9;
    --brand-wash: #E4EEFE;
    --aqua: #34D2E8;
    --good: #129E6B;
    --good-wash: #E2F6EE;
    --coral: #FF6A5A;
    --coral-wash: #FFECE9;
    --sun: #FFD44D;
    --sun-wash: #FFF6DC;

    --display: 'Fredoka', system-ui, sans-serif;
    --body: 'Nunito', system-ui, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, monospace;

    --r: 14px;
    --r-lg: 20px;
    --r-pill: 999px;

    --shadow: 0 1px 2px rgba(18, 38, 58, .04), 0 8px 24px rgba(18, 38, 58, .06);
    --shadow-lift: 0 2px 6px rgba(18, 38, 58, .06), 0 16px 40px rgba(18, 38, 58, .10);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--body);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; color: var(--ink); margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }

a { color: var(--brand-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Shell ──────────────────────────────────────────────────────────────────── */

.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 248px;
    flex: 0 0 248px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 22px; }
.brand img { width: 40px; height: 40px; }
.brand-name { font-family: var(--display); font-size: 1.35rem; font-weight: 600; color: var(--ink); line-height: 1; }
.brand-sub { font-size: .72rem; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }

.nav-group { margin-bottom: 20px; }
.nav-group-label {
    font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
    color: var(--muted); padding: 0 10px 8px;
}

.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; margin-bottom: 2px;
    border-radius: var(--r);
    color: var(--ink-soft); font-weight: 600; font-size: .92rem;
    transition: background .12s ease, color .12s ease;
}
.nav-link:hover { background: var(--brand-wash); color: var(--brand-deep); text-decoration: none; }
.nav-link.active { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(46, 125, 246, .28); }
.nav-link .ico { width: 18px; text-align: center; font-size: 1rem; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 18px 28px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.topbar h1 { font-size: 1.35rem; }
.topbar-sub { color: var(--muted); font-size: .85rem; margin-top: 2px; }

.content { padding: 24px 28px 56px; }

/* ── Cards ──────────────────────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow);
}
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head p { margin: 3px 0 0; color: var(--muted); font-size: .85rem; }

.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

/* ── Stat tiles ─────────────────────────────────────────────────────────────── */

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; box-shadow: var(--shadow); }
.stat-label { font-size: .72rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.stat-value { font-family: var(--display); font-size: 1.9rem; font-weight: 600; line-height: 1.15; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-note { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.stat-value.pos { color: var(--good); }
.stat-value.neg { color: var(--coral); }

/* ── Pills and badges ───────────────────────────────────────────────────────── */

.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 11px; border-radius: var(--r-pill);
    font-size: .76rem; font-weight: 700; letter-spacing: .02em;
}
.pill-good { background: var(--good-wash); color: var(--good); }
.pill-warn { background: var(--sun-wash); color: #9A6A00; }
.pill-bad { background: var(--coral-wash); color: #C93A2C; }
.pill-info { background: var(--brand-wash); color: var(--brand-deep); }
.pill-mute { background: var(--surface-sunk); color: var(--muted); border: 1px solid var(--line); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-good { background: var(--good); }
.dot-warn { background: var(--sun); }
.dot-bad { background: var(--coral); }

/* ── Tables ─────────────────────────────────────────────────────────────────── */

.tbl { width: 100%; border-collapse: collapse; font-size: .89rem; }
.tbl th {
    text-align: left; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
    color: var(--muted); padding: 0 12px 10px; border-bottom: 1px solid var(--line);
}
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: var(--surface-sunk); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.pos { color: var(--good); font-weight: 600; }
.neg { color: var(--coral); font-weight: 600; }
.mono { font-family: var(--mono); font-size: .84rem; }

/* ── Buttons ────────────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 18px; border-radius: var(--r-pill); border: 1px solid transparent;
    font-family: var(--body); font-weight: 700; font-size: .87rem; cursor: pointer;
    transition: transform .08s ease, box-shadow .12s ease, background .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 4px 14px rgba(46, 125, 246, .3); }
.btn-primary:hover { background: var(--brand-deep); }
.btn-ghost { background: var(--surface); color: var(--ink-soft); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-sunk); }
.btn-danger { background: var(--coral); color: #fff; box-shadow: 0 4px 14px rgba(255, 106, 90, .32); }
.btn-danger:hover { background: #EE5342; }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

/* ── The disconnect banner ──────────────────────────────────────────────────────
   A dropped Blazor Server circuit freezes the page on stale content. A trader must never act on a
   frozen screen believing it is live, so this is deliberately loud, full-width and impossible to
   mistake for a toast — and everything behind it is visibly invalidated.
   ------------------------------------------------------------------------------ */

#components-reconnect-modal { display: none; }

#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    display: flex; position: fixed; inset: 0; z-index: 2000;
    align-items: flex-start; justify-content: center;
    background: rgba(18, 38, 58, .55); backdrop-filter: saturate(.4) blur(2px);
}

#components-reconnect-modal .reconnect-card {
    margin-top: 0; width: 100%;
    background: var(--coral); color: #fff;
    padding: 18px 28px; text-align: center;
    font-family: var(--display); font-size: 1.05rem; font-weight: 600;
    box-shadow: 0 10px 40px rgba(18, 38, 58, .3);
}
#components-reconnect-modal .reconnect-card small { display: block; font-family: var(--body); font-weight: 600; font-size: .85rem; opacity: .92; margin-top: 4px; }

/* ── Focus ──────────────────────────────────────────────────────────────────────
   One policy for the whole app, because there was none and the browser's defaults
   were showing through.

   `<FocusOnNavigate Selector="h1" />` in Routes.razor moves focus to the page
   heading on every navigation so a screen reader announces the new page. To do
   that Blazor stamps `tabindex="-1"` on the <h1>, and the browser then draws its
   default ring around it — so the words "Sign in" arrived outlined, looking
   focused and broken, before the visitor had touched anything.

   The fix is NOT to delete FocusOnNavigate. Moving focus is the accessible
   behaviour; drawing a ring around it is not. `:focus-visible` is exactly this
   distinction — the browser sets it only when it judges a ring warranted, which
   means keyboard navigation and not a programmatic .focus() or a mouse click.

   So: suppress the ring when focus was not keyboard-driven, and give keyboard
   users a deliberate branded one instead of whatever each browser picks.
   ──────────────────────────────────────────────────────────────────────────── */

:focus:not(:focus-visible) { outline: none; }

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    border-radius: 3px;
}

/* A heading is focusable only so focus can LAND there. It is never a control, so
   it gets no ring even under keyboard navigation — the announcement is the point. */
h1[tabindex="-1"]:focus-visible,
[tabindex="-1"]:focus-visible { outline: none; }

/* ── Forms ──────────────────────────────────────────────────────────────────── */

.field { margin-bottom: 16px; }
/* The enrolment QR. Sized in CSS on an inline <svg>, so it stays sharp at any zoom and on any
   display — a rasterised code that a phone camera has to resolve is exactly the wrong thing to
   leave blurry. White plate because scanners want light quiet-zone, whatever the page is doing. */
.qr-block {
    display: flex; justify-content: center; padding: 14px;
    background: #fff; border: 1px solid var(--line); border-radius: var(--r);
}
.qr-block svg { width: 208px; height: 208px; display: block; }

.app-links { margin: 12px 0 4px; }
.app-links ul { margin: 6px 0 8px; padding-left: 18px; }
.app-links li { margin-bottom: 3px; }

.qr-manual { margin: -6px 0 16px; }
.qr-manual summary {
    cursor: pointer; font-size: .82rem; color: var(--brand-deep);
    padding: 6px 0; list-style: revert;
}

/* .field-label is for captioning a read-only block. Same look, but not a <label> — a label pointing
   at no control is announced as a form field that does not exist. */
.field label,
.field .field-label { display: block; font-size: .8rem; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; }
.field .hint { font-size: .78rem; color: var(--muted); margin-top: 5px; }
.input {
    width: 100%; padding: 9px 13px; border: 1px solid var(--line); border-radius: var(--r);
    font-family: var(--body); font-size: .92rem; color: var(--ink); background: var(--surface);
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-wash); }

.note {
    border-left: 3px solid var(--brand); background: var(--brand-wash);
    padding: 12px 16px; border-radius: 0 var(--r) var(--r) 0; font-size: .87rem; color: var(--ink-soft);
}
.note-warn { border-left-color: var(--sun); background: var(--sun-wash); }
.note-danger { border-left-color: var(--coral); background: var(--coral-wash); }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty .big { font-size: 2.4rem; }

.role-switch { display: flex; align-items: center; gap: 8px; }
.role-switch .who { text-align: right; line-height: 1.2; }
.role-switch .who strong { display: block; font-size: .9rem; }
.role-switch .who span { font-size: .75rem; color: var(--muted); }

/* ── Sign-in and the other pre-principal pages ──────────────────────────────── */

.auth-shell {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 32px 20px;
    background: radial-gradient(1200px 600px at 50% -10%, #FFFFFF 0%, var(--bg) 55%);
}

.auth-card {
    width: 100%; max-width: 400px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
    padding: 30px 30px 26px; box-shadow: var(--shadow-lift);
}

.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 24px; }
.auth-brand img { width: 42px; height: 42px; }

.auth-card h1 { font-size: 1.4rem; margin-bottom: 4px; }
.auth-sub { color: var(--muted); font-size: .87rem; margin: 0 0 22px; }
.auth-foot { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line-soft); font-size: .84rem; color: var(--muted); text-align: center; }

.code-input { font-family: var(--mono); font-size: 1.35rem; letter-spacing: .32em; text-align: center; }

.secret-block {
    background: var(--surface-sunk); border: 1px dashed var(--line);
    border-radius: var(--r); padding: 12px 14px;
    font-size: .95rem; letter-spacing: .06em; word-break: break-all; user-select: all;
}

.validation-message { color: var(--coral); font-size: .8rem; font-weight: 600; margin-top: 5px; }

@media (max-width: 900px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; flex: none; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--line); }
}
