/* ===========================================================================
   Selo — "Sealed Horizon" stylesheet
   A toned-down, professional take on Kora's Pacific Horizon language for a
   confidential investor data room: light-first, Onest variable sans (no serif),
   teal as the single action accent, ocean/deep for structural gravitas and the
   wax-seal motif, horizon amber/coral reserved strictly for tier identity.

   Token model: this :root defines the full palette. ThemeStyle.razor (document
   head) overrides only the tenant-themeable subset (--accent, --bg, --surface,
   --ink, --muted, --line, --font-sans) for white-labelling, and follows this
   file in the cascade so its values win when present.
   =========================================================================== */

/* Onest — variable sans, self-hosted (no external font dependency: a sovereignty
   choice consistent with the rest of the product). */
@font-face {
    font-family: 'Onest';
    src: url('/fonts/Onest-VariableFont_wght.woff2') format('woff2-variations'),
         url('/fonts/Onest-VariableFont_wght.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root {
    /* Brand & action accent */
    --teal: #00D4AA;
    --teal-dark: #00A386;
    --teal-surface: rgba(0, 212, 170, 0.10);
    --teal-glow: rgba(0, 212, 170, 0.28);

    /* Pacific Horizon accents — used sparingly */
    --coral: #FF7A59;
    --amber: #FFB347;
    --violet: #6C5CE7;
    --ocean: #0E5C7A;
    --deep: #052131;

    /* Neutral canvas */
    --canvas: #FAFBFC;
    --ink: #0F172A;
    --muted: #64748B;
    --border: rgba(14, 15, 12, 0.10);
    --border-subtle: rgba(14, 15, 12, 0.06);

    /* Glass + depth */
    --glass-bg: rgba(255, 255, 255, 0.82);
    --shadow-ring: 0 0 0 1px rgba(14, 15, 12, 0.08);
    --shadow-lift: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.07);
    --shadow-hover: 0 2px 4px rgba(15, 23, 42, 0.06), 0 10px 28px rgba(15, 23, 42, 0.10);

    /* Radius + motion */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 20px;
    --r-pill: 9999px;
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

    /* ---- Tenant-themeable aliases (ThemeStyle overrides these) ---- */
    --accent: var(--teal);
    --accent-soft: var(--teal-dark);
    --bg: var(--canvas);
    --paper: var(--canvas);
    --surface: #FFFFFF;
    --line: var(--border);
    --font-sans: 'Onest', 'Segoe UI', system-ui, -apple-system, sans-serif;

    /* ---- Fixed identity tokens (not tenant-themed) ---- */
    --seal: var(--deep);
    --link: var(--teal-dark);

    /* Tier identity */
    --tier-open-bg: rgba(0, 212, 170, 0.12);
    --tier-open-fg: #0A7C64;
    --tier-gated-bg: rgba(255, 179, 71, 0.18);
    --tier-gated-fg: #8A5A12;
    --tier-restricted-bg: rgba(255, 122, 89, 0.16);
    --tier-restricted-fg: #B23A1C;
}

/* ---- Blazor framework boilerplate ---- */
h1:focus { outline: none; }
.valid.modified:not([type=checkbox]) { outline: 1px solid var(--teal-dark); }
.invalid { outline: 1px solid var(--coral); }
.validation-message { color: #B23A1C; }

.blazor-error-boundary {
    background: #B23A1C;
    padding: 1rem 1.5rem;
    color: #fff;
}
.blazor-error-boundary::after { content: "An error has occurred."; }

/* ---- Base + typography ---- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    color: var(--ink);
    background: var(--bg);
    font-family: var(--font-sans);
    font-feature-settings: "calt" 1;
    font-weight: 400;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    /* Barely-there horizon atmosphere: a faint teal/ocean wash, no hard edges. */
    background-image:
        radial-gradient(60rem 40rem at 88% -10%, rgba(0, 212, 170, 0.06), transparent 60%),
        radial-gradient(50rem 36rem at -10% 8%, rgba(14, 92, 122, 0.05), transparent 55%);
    background-attachment: fixed;
}

h1, h2, h3, .doc-title {
    font-family: var(--font-sans);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.12;
    color: var(--ink);
}

a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--teal-dark); }

:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Shared primary "pill" — teal with dark ink text (teal is too light for white text). */
.btn,
.code-form button,
.agreement-form button,
.admin-login button,
.code-reveal button,
.admin-form button[type="submit"],
.admin-form > button[type="button"]:not(.admin-action) {
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    color: var(--deep);
    background: var(--teal);
    border: 0;
    border-radius: var(--r-pill);
    padding: 0.62rem 1.25rem;
    text-decoration: none;
    text-align: center;
    transition: transform 150ms var(--ease), box-shadow 150ms ease, background 150ms ease;
}
.btn:hover,
.code-form button:hover,
.agreement-form button:hover,
.admin-login button:hover,
.code-reveal button:hover,
.admin-form button[type="submit"]:hover,
.admin-form > button[type="button"]:not(.admin-action):hover {
    background: var(--teal);
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 6px 18px var(--teal-glow);
}
.btn:active { transform: scale(0.98); }

/* ---- Recipient shell ---- */
.recipient-shell { display: flex; flex-direction: column; min-height: 100vh; }

.masthead {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 0.9rem 2rem;
    background: var(--glass-bg);
    backdrop-filter: saturate(160%) blur(16px);
    -webkit-backdrop-filter: saturate(160%) blur(16px);
    border-bottom: 1px solid var(--border-subtle);
}

.brand { display: inline-flex; align-items: center; gap: 0.7rem; color: var(--seal); text-decoration: none; }
.brand-name { font-weight: 700; font-size: 1.08rem; letter-spacing: -0.01em; color: var(--ink); }
/* White-label logo: a tenant-supplied image replaces the seal + name; cap the height so any
   aspect ratio sits neatly in the masthead. */
.brand-logo { height: 32px; width: auto; max-width: 220px; object-fit: contain; display: block; }

.recipient-main { flex: 1 1 auto; width: 100%; max-width: 58rem; margin: 0 auto; padding: 2.5rem 2rem; }

.recipient-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    border-top: 1px solid var(--border-subtle);
    padding: 1.25rem 2rem;
    color: var(--muted);
    font-size: 0.82rem;
}

.footer-links { display: inline-flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.footer-link { color: var(--muted); text-decoration: none; font-weight: 600; }
.footer-link:hover { color: var(--teal-dark); }

.admin-link {
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
}
.admin-link::after { content: " \2192"; }
.admin-link:hover { color: var(--teal-dark); }

/* Privacy link under the landing confidential line. */
.privacy-line { margin-top: 0.6rem; font-size: 0.82rem; }
.privacy-line a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.privacy-line a:hover { color: var(--teal-dark); }

/* ---- Landing ---- */
.landing { max-width: 29rem; margin: 14vh auto 0; text-align: center; }
.space-kicker {
    margin: 1.25rem 0 0; font-size: 0.76rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.16em; color: var(--muted);
}
.landing h1 { margin: 0.15rem 0 0.6rem; font-size: 2.3rem; }
.landing .lede { color: var(--muted); margin: 0 0 2.25rem; font-size: 1.02rem; }

.code-form { display: flex; flex-direction: column; gap: 0.6rem; text-align: left; }
.code-form label { font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.code-form input {
    padding: 0.95rem 1rem;
    font: inherit;
    font-size: 1.2rem;
    letter-spacing: 0.18em;
    text-align: center;
    text-transform: uppercase;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: #fff;
    box-shadow: var(--shadow-ring);
    transition: box-shadow 150ms ease, border-color 150ms ease;
}
.code-form input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-surface); }
.code-form button { margin-top: 0.4rem; padding: 0.85rem 1.25rem; font-size: 1rem; }

.landing .error, .error { color: #B23A1C; font-weight: 600; }
.landing .confidential, .confidential { margin-top: 2.25rem; color: var(--muted); font-size: 0.82rem; }
.about-line { margin: 0.4rem 0 0; font-size: 0.82rem; }

/* staggered reveal on first paint */
@media (prefers-reduced-motion: no-preference) {
    .landing > * { opacity: 0; animation: rise 560ms var(--ease) forwards; }
    .landing > *:nth-child(1) { animation-delay: 60ms; }
    .landing > *:nth-child(2) { animation-delay: 130ms; }
    .landing > *:nth-child(3) { animation-delay: 200ms; }
    .landing > *:nth-child(4) { animation-delay: 270ms; }
    .landing > *:nth-child(5) { animation-delay: 340ms; }
    .landing > *:nth-child(6) { animation-delay: 410ms; }
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- Welcome / product overview (/welcome) ---- */
.welcome { max-width: 44rem; margin: 6vh auto 0; padding: 0 1.25rem; display: flex; flex-direction: column; gap: 2.75rem; }

.welcome-hero { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.9rem; }
.welcome-hero::before {
    content: ""; position: absolute; top: -2.5rem; left: 50%; width: 320px; height: 320px;
    transform: translateX(-50%); pointer-events: none; z-index: 0;
    background: radial-gradient(circle, rgba(0, 212, 170, 0.12), transparent 68%);
}
.welcome-hero > * { position: relative; z-index: 1; }
.welcome-mark { color: var(--seal); display: inline-flex; }
.welcome-title { margin: 0.5rem 0 0; max-width: 20ch; font-size: 2.15rem; line-height: 1.12; letter-spacing: -0.02em; }
.welcome-intro { margin: 0; max-width: 54ch; color: var(--muted); line-height: 1.65; font-size: 1.02rem; }
.welcome-cta { margin-top: 0.5rem; }
.welcome-cta .btn { padding: 0.72rem 1.5rem; font-size: 1rem; }
.welcome-note { margin: 0; color: var(--muted); font-size: 0.85rem; }

.welcome-features { list-style: none; margin: 0; padding: 2rem 0 0; border-top: 1px solid var(--border-subtle); display: grid; gap: 1.5rem; }
.welcome-feature { display: flex; align-items: flex-start; gap: 1rem; }
.welcome-feature-icon {
    flex: none; display: inline-flex; align-items: center; justify-content: center;
    width: 2.6rem; height: 2.6rem; border-radius: var(--r-md);
    background: var(--teal-surface); color: var(--ocean); box-shadow: var(--shadow-ring);
}
.welcome-feature h2 { margin: 0 0 0.2rem; font-size: 1.02rem; }
.welcome-feature p { margin: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.55; }

.welcome-trust { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; margin: 0 auto 2rem; color: var(--muted); font-size: 0.85rem; text-align: left; }
.welcome-trust .seal-mark { color: var(--deep); flex: none; }

@media (prefers-reduced-motion: no-preference) {
    .welcome-hero > *, .welcome-feature { opacity: 0; animation: rise 560ms var(--ease) forwards; }
    .welcome-hero > *:nth-child(1) { animation-delay: 60ms; }
    .welcome-hero > *:nth-child(2) { animation-delay: 130ms; }
    .welcome-hero > *:nth-child(3) { animation-delay: 200ms; }
    .welcome-hero > *:nth-child(4) { animation-delay: 270ms; }
    .welcome-hero > *:nth-child(5) { animation-delay: 340ms; }
    .welcome-feature:nth-child(1) { animation-delay: 380ms; }
    .welcome-feature:nth-child(2) { animation-delay: 440ms; }
    .welcome-feature:nth-child(3) { animation-delay: 500ms; }
    .welcome-feature:nth-child(4) { animation-delay: 560ms; }
}

@media (max-width: 576px) {
    .welcome { margin-top: 3vh; gap: 2rem; }
    .welcome-title { font-size: 1.75rem; }
}

/* ---- Document list ---- */
.docs-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.filter {
    padding: 0.55rem 0.8rem; border: 1px solid var(--border); border-radius: var(--r-pill);
    min-width: 16rem; background: #fff; font: inherit;
}
.filter:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-surface); }

.doc-group { margin-top: 1.75rem; }
.doc-group h2 {
    font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--muted); border-bottom: 1px solid var(--border-subtle); padding-bottom: 0.45rem; margin-bottom: 0.25rem;
}
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-row {
    display: flex; align-items: center; gap: 1rem; padding: 0.95rem 0.75rem;
    border-bottom: 1px solid var(--border-subtle); border-radius: var(--r-md);
    transition: background 150ms ease;
}
.doc-row:hover { background: #fff; box-shadow: var(--shadow-lift); }
.doc-title { flex: 1 1 auto; font-size: 1.02rem; font-weight: 600; letter-spacing: -0.01em; }

.btn.locked { background: transparent; color: var(--teal-dark); border: 1px solid var(--teal); box-shadow: none; }
.btn.locked:hover { background: var(--teal-surface); color: var(--teal-dark); box-shadow: none; transform: none; }
.locked-note { color: var(--muted); font-size: 0.85rem; }

.logout-form { margin-top: 2.5rem; }
.logout-form .link, button.link {
    background: none; border: 0; color: var(--muted); cursor: pointer;
    text-decoration: underline; padding: 0; font: inherit;
}
.logout-form .link:hover { color: var(--ink); }

/* ---- Tier badge ---- */
.tier-badge {
    display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.22rem 0.65rem;
    border-radius: var(--r-pill); font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
}
.tier-badge.tier-open { background: var(--tier-open-bg); color: var(--tier-open-fg); }
.tier-badge.tier-gated { background: var(--tier-gated-bg); color: var(--tier-gated-fg); }
.tier-badge.tier-restricted { background: var(--tier-restricted-bg); color: var(--tier-restricted-fg); }

/* ---- Agreement ---- */
.agreement { max-width: 44rem; }
.agreement-body {
    border: 1px solid var(--border); border-radius: var(--r-md); padding: 1.25rem 1.5rem;
    max-height: 24rem; overflow-y: auto; background: #fff; line-height: 1.65; box-shadow: var(--shadow-ring);
}
.agreement-form { display: flex; flex-direction: column; gap: 0.9rem; margin-top: 1.5rem; }
.agreement-form .check { display: flex; align-items: center; gap: 0.5rem; }
.agreement-form button { align-self: flex-start; }
.agreement-form input[name="name"] {
    padding: 0.6rem 0.8rem; border: 1px solid var(--border); border-radius: var(--r-sm); font: inherit; max-width: 24rem;
}

/* ---- Viewer (overlay watermark) ---- */
.viewer-head { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 1rem; }
.viewer-frame { position: relative; }
.viewer-pdf {
    width: 100%; height: 82vh; border: 1px solid var(--border); border-radius: var(--r-md);
    background: #fff; box-shadow: var(--shadow-lift);
}
.viewer-watermark {
    position: absolute; inset: 0; pointer-events: none; display: flex; flex-wrap: wrap;
    gap: 5rem 7rem; transform: rotate(-30deg); opacity: 0.14; overflow: hidden;
}
.wm { font-weight: 700; white-space: nowrap; color: var(--ocean); font-size: 0.9rem; }

/* Download panel for non-PDF documents (e.g. spreadsheets) that cannot render in-browser. */
.download-panel {
    max-width: 40rem; padding: 1.5rem 1.75rem; background: #fff;
    border: 1px solid var(--border-subtle); border-radius: var(--r-md); box-shadow: var(--shadow-lift);
}
.download-panel p { margin-top: 0; color: var(--muted); }
.download-panel .btn { display: inline-block; }

/* ---- Admin shell — light, professional (no dark chrome) ---- */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
    flex: 0 0 15rem; background: #fff; border-right: 1px solid var(--border-subtle);
    display: flex; flex-direction: column; padding: 1.25rem 0;
}
.admin-brand {
    display: flex; align-items: center; gap: 0.6rem; padding: 0.25rem 1.5rem 1.5rem;
    color: var(--seal); text-decoration: none; font-weight: 700; letter-spacing: -0.01em;
}
.admin-brand span, .admin-brand .brand-name { color: var(--ink); }
.admin-nav { display: flex; flex-direction: column; gap: 1px; }
.admin-nav a {
    color: var(--muted); text-decoration: none; padding: 0.6rem 1.5rem; font-size: 0.92rem;
    font-weight: 500; border-left: 3px solid transparent; transition: background 120ms ease, color 120ms ease;
}
.admin-nav a:hover { color: var(--ink); background: var(--canvas); }
.admin-nav a.active { color: var(--teal-dark); border-left-color: var(--teal); background: var(--teal-surface); font-weight: 600; }

.admin-content { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
.admin-topbar {
    display: flex; align-items: center; justify-content: flex-end; gap: 1rem;
    padding: 0.85rem 2rem; border-bottom: 1px solid var(--border-subtle);
    background: var(--glass-bg); backdrop-filter: saturate(160%) blur(16px);
    -webkit-backdrop-filter: saturate(160%) blur(16px); min-height: 1.5rem; position: sticky; top: 0; z-index: 5;
}
.admin-who { font-weight: 600; font-size: 0.9rem; }
.admin-logout { margin: 0; }
.admin-space-switch { display: flex; align-items: center; gap: 0.5rem; margin: 0 auto 0 0; }
.admin-space-label {
    font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
}
.admin-space-switch select {
    padding: 0.4rem 0.6rem; font: inherit; font-size: 0.9rem; border: 1px solid var(--border);
    border-radius: var(--r-sm); background: #fff; color: var(--ink); max-width: 16rem;
}
.admin-space-switch select:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-surface); }
.admin-main { flex: 1 1 auto; padding: 2rem 2.25rem; max-width: 66rem; }

/* ---- Admin login ---- */
.admin-login { max-width: 23rem; margin: 14vh auto 0; text-align: center; }
.admin-login h1 { margin: 1.1rem 0 1.75rem; font-size: 1.6rem; }
.admin-login form { display: flex; flex-direction: column; gap: 0.9rem; text-align: left; }
.admin-login label { display: flex; flex-direction: column; gap: 0.35rem; font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.admin-login input { padding: 0.7rem 0.85rem; font: inherit; border: 1px solid var(--border); border-radius: var(--r-sm); background: #fff; }
.admin-login input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-surface); }
.admin-login button { margin-top: 0.4rem; }

/* ---- Admin pages ---- */
.admin-main h1 { margin-top: 0; font-size: 1.7rem; }
.admin-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 1rem; margin: 1.75rem 0; }
.admin-card {
    display: block; border: 1px solid var(--border-subtle); border-radius: var(--r-md);
    padding: 1.1rem 1.35rem; background: #fff; text-decoration: none; color: var(--ink);
    box-shadow: var(--shadow-lift); transition: transform 200ms var(--ease), box-shadow 200ms ease;
}
.admin-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.admin-card .card-label { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.admin-card .card-value { font-size: 2.1rem; font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; }
.admin-card .card-detail { font-size: 0.82rem; color: var(--muted); margin-top: 0.35rem; }

.admin-empty { border: 1px dashed var(--border); border-radius: var(--r-md); padding: 1.5rem; color: var(--muted); background: #fff; }

.admin-table { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: 0.9rem; background: #fff; border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow-lift); }
.admin-table th, .admin-table td { text-align: left; padding: 0.7rem 0.85rem; border-bottom: 1px solid var(--border-subtle); vertical-align: top; }
.admin-table th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); background: var(--canvas); }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table .actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.admin-table .actions button, .admin-action {
    cursor: pointer; font: inherit; font-size: 0.8rem; padding: 0.28rem 0.6rem;
    border: 1px solid var(--border); border-radius: var(--r-pill); background: #fff; color: var(--ink);
    transition: border-color 120ms ease, color 120ms ease;
}
.admin-table .actions button:hover, .admin-action:hover { border-color: var(--teal); color: var(--teal-dark); }
.admin-table .actions button.danger { border-color: var(--coral); color: var(--coral); }
.admin-table .actions button.danger:hover { background: var(--coral); border-color: var(--coral); color: #fff; }

/* ---- Admin forms ---- */
.admin-form {
    display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: flex-end; margin: 1rem 0;
    padding: 1.25rem; border: 1px solid var(--border-subtle); border-radius: var(--r-md); background: #fff; box-shadow: var(--shadow-lift);
}
.admin-form input, .admin-form select, .admin-form textarea {
    padding: 0.5rem 0.65rem; border: 1px solid var(--border); border-radius: var(--r-sm); font: inherit; background: #fff;
}
.admin-form input:focus, .admin-form select:focus, .admin-form textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-surface); }
.admin-form textarea { flex-basis: 100%; resize: vertical; }
.admin-form > button[type="button"]:disabled { cursor: default; opacity: 0.45; }
.admin-form > button.admin-action { color: var(--ink); background: #fff; }

.admin-form--stacked { flex-direction: column; align-items: stretch; max-width: 36rem; }
.admin-form--stacked label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.admin-form--stacked button { align-self: flex-start; }

/* ---- One-time code reveal ---- */
.code-reveal {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin: 1.25rem 0;
    padding: 1.1rem 1.35rem; border: 1px solid var(--teal); border-radius: var(--r-md); background: var(--teal-surface);
}
.code-reveal code {
    font-size: 1.25rem; font-weight: 700; letter-spacing: 0.12em; color: var(--ink);
    background: #fff; padding: 0.35rem 0.7rem; border: 1px solid var(--border); border-radius: var(--r-sm);
}
.code-reveal .entry-link { flex-basis: 100%; font-size: 0.82rem; color: var(--muted); }
.code-reveal button { padding: 0.4rem 0.9rem; font-size: 0.85rem; }

/* ---- Analytics ---- */
.analytics-panel { margin: 1.75rem 0; }
.analytics-panel h2 { font-size: 1.05rem; margin-bottom: 0.6rem; }
.bar-cell { min-width: 8rem; }
.bar-track { display: flex; align-items: center; gap: 0.5rem; }
.bar { height: 0.55rem; border-radius: var(--r-pill); background: linear-gradient(90deg, var(--ocean), var(--teal)); min-width: 2px; }
.bar-count { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.82rem; }

/* ===========================================================================
   Responsive — desktop / tablet / mobile
   =========================================================================== */

/* Tablet and below: stack the admin shell, turn the sidebar into a horizontal
   scrolling tab bar, and tighten gutters. */
@media (max-width: 992px) {
    .masthead { padding: 0.9rem 1.25rem; }
    .recipient-main { padding: 1.75rem 1.25rem; }
    .recipient-footer { padding: 1rem 1.25rem; }

    .admin-shell { flex-direction: column; }
    .admin-sidebar {
        flex: 0 0 auto; width: 100%; flex-direction: column;
        border-right: 0; border-bottom: 1px solid var(--border-subtle); padding: 0.5rem 0;
        position: sticky; top: 0; z-index: 6; background: var(--glass-bg);
        backdrop-filter: saturate(160%) blur(16px); -webkit-backdrop-filter: saturate(160%) blur(16px);
    }
    .admin-brand { padding: 0.5rem 1.25rem; }
    .admin-nav { flex-direction: row; gap: 0; overflow-x: auto; padding: 0 0.75rem; -webkit-overflow-scrolling: touch; }
    .admin-nav a {
        border-left: 0; border-bottom: 3px solid transparent;
        white-space: nowrap; padding: 0.55rem 0.85rem;
    }
    .admin-nav a.active { border-left: 0; border-bottom-color: var(--teal); background: transparent; }
    .admin-topbar { padding: 0.75rem 1.25rem; }
    .admin-main { padding: 1.5rem 1.25rem; }
}

/* Mobile: single column, full-width controls, wrapping rows, scrollable tables. */
@media (max-width: 576px) {
    .recipient-main { padding: 1.25rem 1rem; }
    .landing { margin-top: 8vh; }
    .landing h1 { font-size: 1.9rem; }

    .docs-head { flex-direction: column; align-items: stretch; }
    .filter { min-width: 0; width: 100%; }

    .doc-row { flex-wrap: wrap; gap: 0.5rem 0.75rem; padding: 0.85rem 0.5rem; }
    .doc-title { flex-basis: 100%; }
    .doc-row .btn, .doc-row .locked-note, .doc-row .tier-badge { flex: 0 0 auto; }

    .viewer-pdf { height: 70vh; }
    .viewer-watermark { gap: 3.5rem 4.5rem; }

    .admin-main { padding: 1rem; }
    .admin-cards { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
    /* Wide admin tables scroll horizontally within their own box (keeps headings put). */
    .admin-table { display: block; overflow-x: auto; overflow-y: hidden; white-space: nowrap; }
    .admin-form { padding: 1rem; }
}

/* Very small phones: single-column stat cards. */
@media (max-width: 380px) {
    .admin-cards { grid-template-columns: 1fr; }
    .landing h1 { font-size: 1.7rem; }
}
