/* =============================================================================
   Members Portal — Stylesheet
   Aesthetic: warm cream + deep forest green, refined editorial feel.
   Inspired by Function Health: generous whitespace, serif headlines,
   subtle color cues for status.
   ============================================================================= */

:root {
    /* Surfaces */
    --bg-page:        #f5ede0;   /* warm cream */
    --bg-card:        #fbf7ee;   /* slightly lighter card */
    --bg-topbar:      #ede5d4;
    --bg-elevated:    #ffffff;

    /* Lines */
    --border-subtle: #e0d6c4;
    --divider:       #e8dfcd;

    /* Text */
    --text-primary:   #1a1a1a;
    --text-secondary: #5e5a52;
    --text-muted:     #9a8f7d;

    /* Brand */
    --brand-green:    #2c5142;   /* deep forest, primary brand */
    --brand-green-soft: rgba(44, 81, 66, 0.08);

    /* Status */
    --status-optimal:      #4a7a5e;
    --status-borderline:   #b8895a;
    --status-out-of-range: #b86a4f;

    /* Type */
    --font-serif: 'Fraunces', Georgia, 'Times New Roman', serif;
    --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Layout */
    --container-max: 1200px;
    --topbar-height: 64px;
}

/* =============================================================================
   Reset & base
   ============================================================================= */

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: inherit; text-decoration: none; }

/* =============================================================================
   Top bar
   ============================================================================= */

.topbar {
    background-color: var(--bg-topbar);
    border-bottom: 1px solid var(--border-subtle);
    height: var(--topbar-height);
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(8px);
}

.topbar-inner {
    max-width: var(--container-max);
    margin: 0 auto;
    height: 100%;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--brand-green);
}

.brand-mark {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: radial-gradient(
        circle at 35% 30%,
        #4a7a5e 0%,
        var(--brand-green) 60%,
        #1f3a2e 100%
    );
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.brand-name {
    font-family: var(--font-serif);
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.brand-divider {
    color: var(--text-muted);
    font-weight: 300;
    margin: 0 2px;
}

.brand-suffix {
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}

.topbar-account {
    display: flex;
    align-items: center;
    gap: 12px;
}

.account-name {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.account-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--brand-green);
    color: var(--bg-page);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0;
}

/* =============================================================================
   Container & page header
   ============================================================================= */

.container {
    max-width: var(--container-max);
    width: 100%;
    margin: 0 auto;
    padding: 56px 32px 80px;
    flex: 1;
}

.page-header {
    margin-bottom: 56px;
    max-width: 720px;
}

.eyebrow {
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

h1 {
    font-family: var(--font-serif);
    font-weight: 500;
    font-size: 42px;
    line-height: 1.05;
    letter-spacing: -0.025em;
    color: var(--text-primary);
    margin: 0;
}

.lede {
    font-family: var(--font-sans);
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1.5;
    margin-top: 14px;
    max-width: 560px;
}

/* =============================================================================
   Category section — left label, right biomarker list
   ============================================================================= */

.category {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 36px;
    padding: 28px 0;
    border-top: 1px solid var(--divider);
}

.category:first-of-type { border-top: none; padding-top: 8px; }

.category-label h2 {
    font-family: var(--font-serif);
    font-size: 24px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.015em;
    line-height: 1.2;
}

.category-meta {
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 6px;
}

.meta-flag {
    color: var(--status-out-of-range);
    font-weight: 600;
    margin-left: 4px;
}

/* =============================================================================
   Biomarker rows
   ============================================================================= */

.biomarker-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.biomarker-row {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 16px;
    align-items: center;
}

.biomarker-info {
    background-color: var(--bg-card);
    padding: 14px 18px;
    border-radius: 0 4px 4px 0;
    border-left: 3px solid var(--status-optimal);
    min-height: 64px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: background-color 120ms ease;
}

.biomarker-info:hover {
    background-color: #f9f3e6;
}

.biomarker-info.status-optimal      { border-left-color: var(--status-optimal); }
.biomarker-info.status-borderline   { border-left-color: var(--status-borderline); }
.biomarker-info.status-out-of-range { border-left-color: var(--status-out-of-range); }

.biomarker-name {
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.biomarker-meta {
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-pill { font-weight: 500; }

.status-optimal      .status-pill { color: var(--status-optimal); }
.status-borderline   .status-pill { color: var(--status-borderline); }
.status-out-of-range .status-pill { color: var(--status-out-of-range); }

.meta-sep { color: #c8bfae; }

.biomarker-value {
    color: var(--text-secondary);
}

.biomarker-trend {
    padding: 0 8px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sparkline {
    width: 100%;
    height: 100%;
    max-height: 60px;
    overflow: visible;  /* let circles extend slightly past viewBox */
}

.biomarker-rangebar {
    display: inline-block;
    margin-left: 12px;
    vertical-align: middle;
    /* The bar has its own padding around the SVG, so it sits aligned with
       the text baseline naturally. */
}

.biomarker-rangebar .range-bar {
    width: 180px;
    height: 28px;
    overflow: visible;
}

.trend-pending {
    font-family: var(--font-sans);
    font-size: 12px;
    font-style: italic;
    color: var(--text-muted);
    line-height: 1.4;
}

/* =============================================================================
   Empty / footer states
   ============================================================================= */

.empty-state {
    background-color: var(--bg-card);
    border: 1px dashed var(--border-subtle);
    border-radius: 6px;
    padding: 48px;
    text-align: center;
    color: var(--text-secondary);
}

.page-footer {
    border-top: 1px solid var(--divider);
    padding: 20px 0;
    margin-top: 48px;
}

.page-footer-inner {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-sans);
    font-size: 12px;
    color: var(--text-muted);
}

.footer-secure {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--brand-green);
    font-weight: 500;
}

/* =============================================================================
   Responsive
   ============================================================================= */

@media (max-width: 800px) {
    .container { padding: 32px 20px 60px; }
    .topbar-inner { padding: 0 20px; }
    .page-footer-inner { padding: 0 20px; }
    .page-header { margin-bottom: 36px; }

    h1 { font-size: 32px; }

    .category {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 24px 0;
    }

    .biomarker-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .biomarker-trend {
        padding: 0 18px 12px;
        height: 56px;
        justify-content: flex-start;
    }

    .brand-suffix { display: none; }
    .account-name { display: none; }
}

/* =============================================================================
   Auth pages — login, code entry, account picker
   ============================================================================= */

.auth-card {
    max-width: 460px;
    margin: 56px auto 0;
    padding: 36px 32px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
}

.auth-heading {
    font-family: var(--font-serif);
    font-size: 26px;
    font-weight: 500;
    color: var(--brand-green);
    margin: 0 0 12px;
    line-height: 1.2;
}

.auth-lede {
    font-size: 15px;
    color: var(--text-primary);
    margin: 0 0 24px;
    line-height: 1.55;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 18px;
}

.auth-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.auth-input {
    font-family: var(--font-sans);
    font-size: 16px;
    padding: 12px 14px;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    background-color: var(--bg-page);
    color: var(--text-primary);
    transition: border-color 120ms ease;
}

.auth-input:focus {
    outline: none;
    border-color: var(--brand-green);
}

.auth-input-code {
    letter-spacing: 0.4em;
    text-align: center;
    font-size: 22px;
    font-family: var(--font-mono, "SF Mono", Menlo, monospace);
}

.auth-submit {
    margin-top: 8px;
    padding: 12px 16px;
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 500;
    color: white;
    background-color: var(--brand-green);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: opacity 120ms ease;
}

.auth-submit:hover {
    opacity: 0.92;
}

.auth-error {
    padding: 12px 14px;
    margin-bottom: 18px;
    font-size: 14px;
    color: var(--status-outofrange);
    background-color: #f7e9e3;
    border-left: 3px solid var(--status-outofrange);
    border-radius: 4px;
}

.auth-help {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.55;
    margin: 16px 0 0;
}

.auth-help a {
    color: var(--brand-green);
}

.auth-picker {
    gap: 10px;
}

.auth-picker-button {
    padding: 14px 16px;
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    background-color: var(--bg-page);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    transition: border-color 120ms ease, background-color 120ms ease;
}

.auth-picker-button:hover {
    border-color: var(--brand-green);
    background-color: white;
}

/* =============================================================================
   Topbar nav + logout (added in three-tier redesign)
   ============================================================================= */

.topbar-nav {
    display: flex;
    gap: 8px;
    margin-left: 32px;
    flex: 1;
}

.topbar-nav-link {
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background-color 120ms ease, color 120ms ease;
}

.topbar-nav-link:hover {
    background-color: rgba(44, 81, 66, 0.06);
    color: var(--text-primary);
}

.topbar-nav-link.is-active {
    background-color: var(--brand-green);
    color: white;
}

.logout-form {
    display: inline;
    margin: 0;
    padding: 0;
}

.logout-button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    transition: color 120ms ease, background-color 120ms ease;
}

.logout-button:hover {
    color: var(--brand-green);
    background-color: rgba(44, 81, 66, 0.06);
}

/* =============================================================================
   Categories landing page
   ============================================================================= */

.section-bar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 32px 0 16px;
}

.section-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--brand-green);
    text-decoration: none;
    font-weight: 500;
}

.section-action:hover {
    text-decoration: underline;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.category-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    text-decoration: none;
    transition: border-color 120ms ease, transform 120ms ease;
}

.category-card:hover {
    border-color: var(--brand-green);
    transform: translateY(-1px);
}

.category-card-icon {
    flex: 0 0 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-green);
    background-color: rgba(44, 81, 66, 0.08);
    border-radius: 8px;
}

.category-card-body {
    flex: 1;
    min-width: 0;
}

.category-card-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.category-card-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.category-bar {
    display: flex;
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    background-color: rgba(0,0,0,0.05);
}

.category-bar-segment {
    height: 100%;
}

.seg-optimal     { background-color: var(--status-optimal); }
.seg-borderline  { background-color: var(--status-borderline); }
.seg-out         { background-color: var(--status-outofrange); }

.category-card-counts {
    display: flex;
    gap: 6px;
}

.count-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: 10px;
    line-height: 1.6;
}

.count-pill::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.count-optimal {
    color: var(--status-optimal);
    background-color: rgba(74, 122, 94, 0.1);
}
.count-optimal::before { background-color: var(--status-optimal); }

.count-borderline {
    color: var(--status-borderline);
    background-color: rgba(184, 137, 90, 0.1);
}
.count-borderline::before { background-color: var(--status-borderline); }

.count-out {
    color: var(--status-outofrange);
    background-color: rgba(184, 106, 79, 0.1);
}
.count-out::before { background-color: var(--status-outofrange); }

.page-header {
    margin-bottom: 32px;
}

.page-subheading {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.55;
    max-width: 620px;
    margin: 8px 0 0;
}

/* =============================================================================
   Breadcrumbs
   ============================================================================= */

.breadcrumb {
    margin: 0 0 24px;
    font-size: 13px;
    color: var(--text-muted);
}

.breadcrumb-link {
    color: var(--text-secondary);
    text-decoration: none;
}

.breadcrumb-link:hover {
    color: var(--brand-green);
    text-decoration: underline;
}

.breadcrumb-sep {
    margin: 0 6px;
    color: var(--text-muted);
}

.breadcrumb-current {
    color: var(--text-primary);
    font-weight: 500;
}

/* =============================================================================
   Category detail page
   ============================================================================= */

.category-detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.category-detail-icon {
    flex: 0 0 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-green);
    background-color: rgba(44, 81, 66, 0.08);
    border-radius: 10px;
}

.category-detail-count {
    font-size: 14px;
    color: var(--text-muted);
    margin: 4px 0 0;
}

.biomarker-section {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 32px;
}

.biomarker-section .biomarker-row + .biomarker-row {
    border-top: 1px solid var(--border-subtle);
}

/* =============================================================================
   Per-category clinician note (on the category detail page)
   ============================================================================= */

.category-note {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 24px 28px;
    margin-bottom: 32px;
}

.category-note-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 12px;
}

.category-note-body {
    font-size: 15px;
    line-height: 1.65;
    color: var(--text-primary);
    margin: 0 0 12px;
}

.category-note-date {
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
    margin: 0;
}

/* =============================================================================
   Notes page (full clinician interpretation, with sidebar)
   ============================================================================= */

.notes-page {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 32px;
    align-items: start;
}

.notes-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
}

.notes-sidebar {
    position: sticky;
    top: 96px;
}

.notes-sidebar-heading {
    font-family: var(--font-serif);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 0 0 12px;
    padding: 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.notes-date-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.notes-date-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
    color: var(--text-secondary);
    transition: background-color 120ms ease, color 120ms ease;
}

.notes-date-link:hover {
    background-color: rgba(44, 81, 66, 0.06);
    color: var(--text-primary);
}

.notes-date-link.is-active {
    background-color: var(--brand-green);
    color: white;
}

.notes-document {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 36px 40px;
}

.notes-doc-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.notes-doc-date {
    font-family: var(--font-serif);
    font-size: 32px;
    font-weight: 500;
    color: var(--brand-green);
    margin: 0;
    line-height: 1.1;
}

.notes-doc-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin: 6px 0 0;
}

.notes-section + .notes-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle);
}

.notes-section-heading {
    font-family: var(--font-serif);
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0 0 8px;
}

.notes-section-body {
    font-size: 15px;
    line-height: 1.65;
    color: var(--text-primary);
    margin: 0;
}

.notes-empty-doc {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 32px 0;
}

@media (max-width: 768px) {
    .notes-page {
        grid-template-columns: 1fr;
    }
    .notes-sidebar {
        position: static;
    }
    .notes-document {
        padding: 24px 20px;
    }
    .topbar-nav {
        margin-left: 0;
    }
}

/* Notes page: continuous letter style (no section headers) */
.notes-paragraph {
    font-size: 15px;
    line-height: 1.65;
    color: var(--text-primary);
    margin: 0 0 18px;
}
.notes-paragraph:last-child {
    margin-bottom: 0;
}

/* Category card with no biomarker counts (note-only) */
.category-card-note-only {
    font-size: 13px;
    color: var(--brand-green);
    font-weight: 500;
}

/* =============================================================================
   Staff app
   ============================================================================= */

.staff-login-card {
    text-align: center;
}

.google-signin-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    margin: 16px 0;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    background-color: white;
    color: #3c4043;
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 120ms ease, border-color 120ms ease;
}

.google-signin-button:hover {
    background-color: #f8f9fa;
    border-color: #c0c8cc;
}

.staff-page {
    max-width: 1100px;
    margin: 0 auto;
}

.staff-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
}

.secondary-button {
    background-color: transparent;
    color: var(--brand-green);
    border: 1px solid var(--border-subtle);
    font-size: 13px;
    padding: 8px 14px;
}

.secondary-button:hover {
    background-color: rgba(44, 81, 66, 0.06);
}

.queue-table-wrap {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    overflow-x: auto;
}

.queue-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.queue-table thead {
    background-color: var(--bg-page);
    border-bottom: 1px solid var(--border-subtle);
}

.queue-table th {
    text-align: left;
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.queue-table td {
    padding: 14px 16px;
    border-top: 1px solid var(--border-subtle);
    vertical-align: middle;
}

.queue-table tbody tr:first-child td {
    border-top: none;
}

.queue-table tbody tr:hover {
    background-color: rgba(44, 81, 66, 0.03);
}

.queue-patient-name {
    font-weight: 500;
    color: var(--text-primary);
}

.queue-patient-id {
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--font-mono, "SF Mono", Menlo, monospace);
}

.queue-counts {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
}

.queue-counts .count-pill {
    font-size: 11px;
    padding: 1px 6px;
}

.queue-edit-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--brand-green);
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
}

.queue-edit-link:hover {
    text-decoration: underline;
}

.status-draft {
    background-color: rgba(184, 137, 90, 0.15);
    color: var(--status-borderline);
}

.status-in-review {
    background-color: rgba(44, 81, 66, 0.1);
    color: var(--brand-green);
}

.status-published {
    background-color: rgba(74, 122, 94, 0.15);
    color: var(--status-optimal);
}

.claimed-by {
    color: var(--text-primary);
    font-weight: 500;
}

.raw-provider {
    color: var(--text-secondary);
    font-style: italic;
}

.badge-unclaimed {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 3px;
    background-color: var(--bg-page);
    border: 1px dashed var(--border-subtle);
    font-size: 11px;
    color: var(--text-muted);
    font-style: normal;
}
