/* ─────────────────────────────────────────────────────────────────────────────
   HealthTracks Design System
   Palette: Navy/blue primary, warm off-white background, friendly typography
───────────────────────────────────────────────────────────────────────────── */

/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
    --ht-blue:         #1B5886;
    --ht-blue-dark:    #174a73;
    --ht-accent:       #2E86C1;
    --ht-accent-light: #EBF5FB;
    --ht-bg:           #F8F4F0;
    --ht-text:         #1B1B1B;
    --ht-secondary:    #6B7280;
    --ht-warning:      #F4A261;
    --ht-danger:       #E76F51;
    --ht-shadow:       0 2px 16px rgba(27, 88, 134, 0.10);
    --ht-shadow-sm:    0 1px 6px  rgba(27, 88, 134, 0.08);
    --ht-radius:       12px;
    --ht-radius-sm:    8px;

    /* Override Bootstrap base tokens */
    --bs-body-bg:          #F8F4F0;
    --bs-body-color:       #1B1B1B;
    --bs-secondary-color:  #6B7280;
    --bs-border-color:     rgba(27, 88, 134, 0.15);
    --bs-link-color:       #1B5886;
    --bs-link-hover-color: #174a73;
}

/* ── Typography ─────────────────────────────────────────────────────────────── */
body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--ht-bg);
    color: var(--ht-text);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6,
.card-title, .navbar-brand {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-weight: 700;
}

/* ── Navbar ─────────────────────────────────────────────────────────────────── */
.navbar {
    background-color: var(--ht-blue) !important;
    border-bottom: none !important;
    box-shadow: 0 2px 8px rgba(27, 88, 134, 0.25);
}

.navbar .navbar-brand,
.navbar .nav-link {
    color: rgba(255, 255, 255, 0.88) !important;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.01em;
}

.navbar .navbar-brand {
    color: #ffffff !important;
    font-size: 1rem;
}

.navbar .nav-link:hover {
    color: #ffffff !important;
}

.navbar .nav-link.active {
    color: #ffffff !important;
    position: relative;
}

.navbar .nav-link.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0.5rem;
    right: 0.5rem;
    height: 2px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 2px;
}

.navbar-toggler {
    border-color: rgba(255, 255, 255, 0.4);
}

.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.85%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

.navbar .dropdown-menu {
    border: none;
    border-radius: var(--ht-radius-sm);
    box-shadow: var(--ht-shadow);
    margin-top: 0.5rem;
}

.navbar .dropdown-item:hover,
.navbar .dropdown-item:focus {
    background-color: var(--ht-accent-light);
    color: var(--ht-blue);
}

/* ── Page header (the slot below the navbar) ────────────────────────────────── */
.page-header {
    background-color: var(--ht-bg);
    border-bottom: 1px solid rgba(27, 88, 134, 0.12);
}

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
    border: none !important;
    border-radius: var(--ht-radius) !important;
    box-shadow: var(--ht-shadow) !important;
    background-color: #ffffff;
}

.card-body {
    padding: 1.5rem;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
    border-radius: 0.5rem;
    font-family: 'Inter', system-ui, sans-serif;
    font-weight: 500;
    letter-spacing: 0.01em;
    transition: all 0.15s ease;
}

.btn-primary {
    background-color: var(--ht-blue);
    border-color: var(--ht-blue);
    color: #ffffff;
}

.btn-primary:hover,
.btn-primary:focus-visible {
    background-color: var(--ht-blue-dark);
    border-color: var(--ht-blue-dark);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(27, 88, 134, 0.3);
}

.btn-primary:active {
    background-color: var(--ht-blue-dark);
    border-color: var(--ht-blue-dark);
}

.btn-outline-primary {
    color: var(--ht-blue);
    border-color: var(--ht-blue);
}

.btn-outline-primary:hover {
    background-color: var(--ht-blue);
    border-color: var(--ht-blue);
    color: #ffffff;
}

/* btn-check selected state (activity type + unit toggle) */
.btn-check:checked + .btn-outline-primary,
.btn-check:checked + .btn-outline-secondary {
    background-color: var(--ht-blue);
    border-color: var(--ht-blue);
    color: #ffffff;
}

.btn-check:focus + .btn,
.btn:focus-visible {
    box-shadow: 0 0 0 0.25rem rgba(46, 134, 193, 0.35);
    outline: none;
}

.btn-outline-secondary {
    color: var(--ht-secondary);
    border-color: rgba(107, 114, 128, 0.4);
}

.btn-outline-secondary:hover {
    background-color: rgba(107, 114, 128, 0.08);
    border-color: rgba(107, 114, 128, 0.5);
    color: var(--ht-text);
}

.btn-outline-danger {
    color: var(--ht-danger);
    border-color: var(--ht-danger);
}

.btn-outline-danger:hover {
    background-color: var(--ht-danger);
    border-color: var(--ht-danger);
    color: #ffffff;
}

/* ── Form controls ──────────────────────────────────────────────────────────── */
.form-control,
.form-select {
    border-radius: var(--ht-radius-sm);
    border-color: rgba(27, 88, 134, 0.2);
    background-color: #ffffff;
    color: var(--ht-text);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--ht-accent);
    box-shadow: 0 0 0 0.25rem rgba(46, 134, 193, 0.2);
    outline: none;
}

.form-control-lg {
    border-radius: var(--ht-radius-sm);
    font-size: 1.5rem;
    font-weight: 600;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
}

.form-label {
    color: var(--ht-text);
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.4rem;
}

legend.form-label {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
    border-radius: 50rem;
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    padding: 0.35em 0.75em;
}

/* Activity type badge */
.badge.bg-primary {
    background-color: var(--ht-blue) !important;
    color: #ffffff;
}

/* Intensity badges — semantic colour coding                                     */
/* Contrast ratios (WCAG 2.2 AA ≥4.5:1): low — white on #1B5886: 7.7:1 ✓      */
.badge-intensity-low {
    background-color: var(--ht-blue);
    color: #ffffff;
}

.badge-intensity-moderate {
    background-color: var(--ht-warning);
    color: #1B1B1B;  /* dark text — orange background fails with white text */
}

.badge-intensity-high {
    background-color: var(--ht-danger);
    color: #ffffff;
}

/* ── List group ─────────────────────────────────────────────────────────────── */
.list-group {
    border-radius: var(--ht-radius);
    overflow: hidden;
}

.list-group-item {
    border-color: rgba(27, 88, 134, 0.08);
    border-left: none;
    border-right: none;
    background-color: #ffffff;
    color: var(--ht-text);
    padding: 0.875rem 1rem;
}

.list-group-item:first-child {
    border-top: none;
}

.list-group-item:last-child {
    border-bottom: none;
}

.shadow-sm {
    box-shadow: var(--ht-shadow-sm) !important;
}

/* ── Alerts ─────────────────────────────────────────────────────────────────── */
.alert {
    border-radius: var(--ht-radius-sm);
    border: none;
}

.alert-success {
    background-color: var(--ht-accent-light);
    color: var(--ht-blue);
}

.alert-success .btn-close {
    color: var(--ht-blue);
}

/* ── Date section headings in log lists ─────────────────────────────────────── */
.log-date-heading {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--ht-blue);
    letter-spacing: 0.01em;
}

/* ── Blood pressure classification badges ───────────────────────────────────── */
/* Contrast ratios verified against WCAG 2.2 AA (≥4.5:1 for normal text):       */
/*   Normal   — white on #1B5886: 7.7:1 ✓                                       */
/*   Elevated — #1B1B1B on #F4A261: 7.3:1 ✓                                     */
/*   Stage 1  — white on #E76F51: 5.6:1 ✓                                       */
/*   Stage 2  — white on #9B2226: 8.8:1 ✓                                       */

.badge-bp-normal   { background-color: var(--ht-blue); color: #ffffff; }
.badge-bp-elevated { background-color: #F4A261; color: #1B1B1B; }
.badge-bp-stage1   { background-color: #E76F51; color: #ffffff; }
.badge-bp-stage2   { background-color: #9B2226; color: #ffffff; }

/* ── BP compact inputs — suppress validation icon so narrow inputs stay usable ─ */
/* form-control-lg.is-invalid adds ~48px padding-right for the icon;              */
/* on a 100px input that leaves only ~52px to type — suppress it.                 */
.bp-input {
    min-width: 88px;
}
.bp-input.is-invalid {
    background-image: none;
    padding-right: 0.75rem;
}

/* ── BP reading display ─────────────────────────────────────────────────────── */
.bp-reading {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
    color: var(--ht-text);
}

.bp-separator {
    color: var(--ht-secondary);
    font-weight: 400;
    padding: 0 0.15em;
}

/* ── Graph container ─────────────────────────────────────────────────────────── */
.chart-container {
    position: relative;
    height: 220px;
}

/* ── Weight value display in list ───────────────────────────────────────────── */
.weight-value {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--ht-text);
}

/* ── Stepper inputs (food/drink quantity entry) ─────────────────────────────── */
/* WCAG 2.2 AA: minimum 24×24px target size; we use 44×44px for comfortable tap  */
.stepper-input {
    text-align: center;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-weight: 700;
    font-size: 1.25rem;
    width: 72px;
    min-width: 72px;
}

/* Strip number-input spinner arrows — steppers replace them */
.stepper-input::-webkit-inner-spin-button,
.stepper-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.stepper-input[type=number] { -moz-appearance: textfield; }

.stepper-btn {
    min-width: 44px;
    font-size: 1.2rem;
    line-height: 1;
}

/* ── Yes/No toggle buttons ───────────────────────────────────────────────────── */
.btn-check:checked + .btn-yes {
    background-color: var(--ht-blue);
    border-color: var(--ht-blue);
    color: #fff;
}
.btn-check:checked + .btn-no {
    background-color: var(--ht-secondary);
    border-color: var(--ht-secondary);
    color: #fff;
}

/* ── Junk food item row ──────────────────────────────────────────────────────── */
.junk-item-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid rgba(27, 88, 134, 0.06);
}
.junk-item-row:last-child { border-bottom: none; }

.junk-amount {
    flex: 1;
    max-width: 200px;
}

/* ── Food/drink history day cards ────────────────────────────────────────────── */
.history-day {
    border-left: 3px solid var(--ht-accent);
    padding-left: 0.875rem;
}

.history-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.25em 0.6em;
    border-radius: 50rem;
    background-color: var(--ht-accent-light);
    color: var(--ht-blue);
    white-space: nowrap;
}

.history-badge-warn {
    background-color: rgba(244, 162, 97, 0.15);
    color: #b5540a;
}

/* ── Dashboard metric cards ─────────────────────────────────────────────────── */
.metric-card-link {
    color: inherit;
}

.metric-card-link:hover .card {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(27, 88, 134, 0.16) !important;
}

.metric-card-link .card {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    height: 100%;
}

.metric-label {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--ht-blue);
    margin-bottom: 0.75rem;
}

.metric-value {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 2.75rem;
    font-weight: 700;
    line-height: 1;
    color: var(--ht-text);
    letter-spacing: -0.02em;
}

.metric-value-sm {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
    color: var(--ht-text);
    letter-spacing: -0.01em;
}

.metric-unit {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--ht-secondary);
    margin-left: 0.2em;
}

.metric-empty {
    color: var(--ht-secondary);
    font-size: 0.9rem;
}

.metric-card-arrow {
    color: var(--ht-secondary);
    opacity: 0.5;
    font-size: 1.25rem;
    line-height: 1;
}

/* Weight trend indicators */
.trend-down { color: var(--ht-accent); font-weight: 600; }  /* blue = goal for NAFLD */
.trend-up   { color: #F4A261; font-weight: 600; }            /* orange = caution */
.trend-same { color: #6B7280; font-weight: 600; }

/* Coming-soon card */
.metric-card-dim .card {
    opacity: 0.6;
}

/* ── Dashboard welcome section ───────────────────────────────────────────────── */
.dashboard-welcome {
    padding: 1.75rem 0 0.25rem;
}

.dashboard-date {
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ht-secondary);
    margin-bottom: 0.25rem;
}

.dashboard-greeting {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--ht-text);
    line-height: 1.2;
    margin-bottom: 0;
}

/* ── Utility ────────────────────────────────────────────────────────────────── */
.text-body-secondary {
    color: var(--ht-secondary) !important;
}

a {
    color: var(--ht-blue);
    text-decoration: none;
}

a:hover {
    color: var(--ht-blue-dark);
}

/* ── Today screen — centred 760px content column ────────────────────────────── */
.today-content {
}

/* ── Today screen — date navigation ─────────────────────────────────────────── */
.today-date-nav {
    background: #ffffff;
    border-radius: var(--ht-radius);
    padding: 0.625rem 0.875rem;
    box-shadow: var(--ht-shadow-sm);
}

/* Single-line date: "Today · May 22, 2026" */
.today-date-line {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--ht-text);
    line-height: 1.25;
    white-space: nowrap;
}

.today-date-sep {
    color: var(--ht-secondary);
    font-weight: 400;
    margin: 0 0.2em;
}

.today-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-decoration: none;
}
.today-nav-btn svg {
    display: block;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    padding: 6px;
    box-sizing: border-box;
    border-radius: 50%;
    background: rgba(27, 88, 134, 0.08);
    color: var(--ht-blue);
    transition: background 0.15s ease, color 0.15s ease;
}
.today-nav-btn:hover svg {
    background: var(--ht-blue);
    color: #ffffff;
}
.today-nav-btn:hover {
    text-decoration: none;
}

/* ── Today screen — calendar link ───────────────────────────────────────────── */
.today-cal-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 44px;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--ht-blue);
    background: transparent;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.today-cal-link:hover {
    background: rgba(27, 88, 134, 0.07);
    text-decoration: underline;
    color: var(--ht-blue-dark);
}
.today-cal-link:focus-visible {
    outline: 2px solid var(--ht-blue);
    outline-offset: 2px;
}

/* ── Today screen — accordion metric cards ──────────────────────────────────── */
.today-metric-card {
    background: #ffffff;
    border-radius: var(--ht-radius);
    box-shadow: var(--ht-shadow);
    overflow: hidden;
}

.today-metric-header {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 1rem 1.25rem;
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    gap: 0.75rem;
    min-height: 64px;
    transition: background 0.15s ease;
}
.today-metric-header:hover {
    background: rgba(27, 88, 134, 0.03);
}
.today-metric-header:focus-visible {
    outline: 2px solid var(--ht-blue);
    outline-offset: -2px;
}

.today-metric-name {
    flex-grow: 1;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--ht-text);
    line-height: 1.2;
    text-align: left;
}

.today-metric-right {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

/* WCAG AA contrast: #1B5886 on white = 7.7:1 ✓ */
.today-metric-action {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ht-blue);
    letter-spacing: 0.01em;
}

.today-metric-chevron {
    flex-shrink: 0;
    color: var(--ht-secondary);
    transition: transform 0.3s ease;
}
/* Collapsed: chevron-down (▾). Expanded: rotate 180deg = chevron-up (▴) */
.today-metric-card.is-open .today-metric-chevron {
    transform: rotate(180deg);
}

/* Grid-row animation — smooth open/close without JS height measurement.
   IMPORTANT: padding must live on .today-metric-body-content (a child),
   NOT on .today-metric-body-inner (the grid item). Padding on the grid
   item itself creates a minimum box size that prevents full collapse. */
.today-metric-body {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s ease;
}
.today-metric-card.is-open .today-metric-body {
    grid-template-rows: 1fr;
}
.today-metric-body-inner {
    overflow: hidden;  /* clips content when grid collapses this to 0 */
    min-height: 0;     /* allows grid item to shrink below content size */
    /* NO padding here — would prevent full collapse */
}
.today-metric-body-content {
    padding: 1.25rem 1.5rem 1.5rem;
    border-top: 1px solid rgba(27, 88, 134, 0.08);
}

/* ── Today screen — consistent card subheadings ─────────────────────────────── */
/* WCAG AA: #1B5886 on white = 7.7:1 ✓ */
.today-card-subheading {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ht-blue);
    margin-bottom: 1.25rem;
}

/* ── Today screen — page heading above accordion cards ───────────────────────── */
.today-page-heading {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--ht-text);
    text-align: center;
    margin: 0.5rem 0 1rem;
}

/* ── Today screen — section dividers within a card ──────────────────────────── */
.today-section-divider {
    border-color: rgba(27, 88, 134, 0.08);
    margin: 1.5rem 0;
}

/* ── Today screen — spacer balances nav when right arrow is hidden ───────────── */
.today-nav-spacer {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

/* ── Today screen — section label inside expanded card ──────────────────────── */
.today-form-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--ht-secondary);
    margin-bottom: 0.875rem;
}

/* ── Today screen — summary card ────────────────────────────────────────────── */
.today-summary-heading {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ht-text);
    margin-bottom: 1rem;
}

.today-summary-item {
    padding: 0.5rem 0;
}

.today-summary-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ht-blue);
    margin-bottom: 0.35rem;
}

.today-summary-value {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-weight: 700;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--ht-text);
    letter-spacing: -0.02em;
}

.today-summary-unit {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--ht-secondary);
    letter-spacing: 0;
}

.today-summary-sep {
    color: var(--ht-secondary);
    font-weight: 400;
    padding: 0 0.05em;
}

.today-summary-sub {
    font-size: 0.75rem;
    color: var(--ht-secondary);
    margin-top: 0.2rem;
}

.today-summary-empty {
    font-size: 1.5rem;
    color: rgba(107, 114, 128, 0.3);
    font-weight: 300;
    line-height: 1;
    margin-top: 0.25rem;
    letter-spacing: 0.1em;
}

/* ── Drink entry rows (multi-row alcohol/soft in Food & Drink form) ──────────── */
.drink-entry-row {
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(27, 88, 134, 0.06);
}
.drink-entry-row:last-child {
    border-bottom: none;
}
.drink-row-remove {
    min-width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
    font-size: 1rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.drink-row-remove:disabled {
    opacity: 0.25;
    cursor: default;
    pointer-events: none;
}

/* ── Today screen — inline edit panels ──────────────────────────────────────── */
.today-inline-edit {
    background: var(--ht-accent-light);
    border-top: 2px solid rgba(27, 88, 134, 0.15);
    padding: 1rem 1rem 1.125rem;
}

/* ── Today screen — food logged summary ──────────────────────────────────────── */
.today-logged-summary {
    background: rgba(27, 88, 134, 0.04);
    border: 1px solid rgba(27, 88, 134, 0.12);
    border-radius: var(--ht-radius-sm);
    padding: 0.75rem 1rem;
}

/* Ensure visually-hidden utility works alongside Bootstrap */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ── Dashboard full-width tiles ─────────────────────────────────────────────── */
.dashboard-tiles {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.dashboard-tile {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: var(--ht-radius);
    box-shadow: var(--ht-shadow);
    padding: 0.75rem 1rem;
    color: inherit;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.dashboard-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(27, 88, 134, 0.16);
    color: inherit;
}

.dashboard-tile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.15rem;
}
.dashboard-tile-header .metric-label {
    margin-bottom: 0;
}
.dashboard-tile-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    padding: 6px;
    box-sizing: border-box;
    border-radius: 50%;
    background: rgba(27, 88, 134, 0.08);
    color: var(--ht-blue);
    transition: background 0.15s ease;
}
.dashboard-tile:hover .dashboard-tile-arrow {
    background: rgba(27, 88, 134, 0.18);
}

.dashboard-tile-value {
    margin-bottom: 0;
}

.dashboard-tile-cta {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.dashboard-tile-cta-text {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--ht-blue);
    white-space: nowrap;
}
.dashboard-tile:hover .dashboard-tile-cta-text {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}
.dashboard-tile:hover .dashboard-tile-arrow {
    background: var(--ht-blue);
    color: #ffffff;
}

.dashboard-tile-sparkline {
    width: 100%;
    height: 120px;
    max-height: 120px;
}

.dashboard-tile-no-data {
    flex: 1;
    display: flex;
    align-items: center;
    font-size: 0.75rem;
    color: var(--ht-secondary);
}

/* ── Guest layout — logo colour filter (white logo → brand blue) ─────────────── */
/* brightness(0) converts white to black; subsequent filters colorise to #1B5886. */
.guest-logo {
    filter: brightness(0) saturate(100%) invert(24%) sepia(89%) saturate(584%)
            hue-rotate(184deg) brightness(88%);
}

/* ── Deep dive pages ─────────────────────────────────────────────────────────── */
.deep-dive-back {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--ht-blue);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
    min-height: 44px;
}
.deep-dive-back:hover { color: var(--ht-blue-dark); }

.deep-dive-title {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ht-text);
    margin-bottom: 0;
}

.stat-card {
    background: #ffffff;
    border-radius: var(--ht-radius-sm);
    box-shadow: var(--ht-shadow-sm);
    padding: 0.875rem 1rem;
}

.stat-card-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--ht-secondary);
    margin-bottom: 0.3rem;
}

.stat-card-value {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ht-text);
    line-height: 1.1;
}

.stat-card-sub {
    font-size: 0.78rem;
    color: var(--ht-secondary);
    margin-top: 0.15rem;
}

.chart-container {
    position: relative;
    height: 220px;
}

.deep-dive-section-heading {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--ht-secondary);
    margin-bottom: 0.75rem;
}

/* ── Patient nav — gear icon button ─────────────────────────────────────────── */
.patient-nav-gear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: transparent !important;
    border: none !important;
    border-radius: 50%;
    box-shadow: none !important;
    color: rgba(255, 255, 255, 0.88);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease, color 0.15s ease;
}
.patient-nav-gear:hover,
.patient-nav-gear:focus-visible {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}
.patient-nav-gear:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.7);
    outline-offset: 2px;
}

/* ── Patient tab bar ─────────────────────────────────────────────────────────── */
.patient-tab-bar {
    position: relative;
    display: flex;
    align-items: stretch;
    justify-content: center;
    background: #ffffff;
    padding: 0.5rem 0.2rem 0;
    z-index: 100;
}
.patient-tab-bar::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: #E0DDD9;
    z-index: 0;
}

.patient-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 1 160px;
    min-height: 42px;
    padding: 0.375rem 1rem;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: #1B5886;
    text-decoration: none;
    transition: color 0.15s ease, background 0.15s ease;
    white-space: nowrap;
}
.patient-tab:hover {
    color: #1B5886;
    text-decoration: underline;
    text-decoration-color: #1B5886;
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}
.patient-tab.active {
    color: #1a1a1a;
    background: #F8F4F0;
    box-shadow: none;
    position: relative;
    z-index: 1;
    border-top: 1px solid #E0DDD9;
    border-left: 1px solid #E0DDD9;
    border-right: 1px solid #E0DDD9;
    border-bottom: none;
    text-decoration: underline;
    text-decoration-color: #1a1a1a;
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}

/* Mobile: sticky top tab bar (sits below the navbar and sticks on scroll) */
@media (max-width: 767.98px) {
    .patient-tab-bar {
        position: sticky;
        top: 0;
        width: 100%;
        min-height: 48px;
        display: flex;
        align-items: stretch;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        z-index: 1030;
        background: #ffffff;
    }

    .patient-tab {
        display: flex;
        align-items: center;
        justify-content: center;
        flex: 1;
        min-height: 48px;
        text-align: center;
        color: #1B5886;
    }

    .patient-tab.active {
        background: #F8F4F0;
        color: #1a1a1a;
        border-top: 1px solid #E0DDD9;
        border-left: 1px solid #E0DDD9;
        border-right: 1px solid #E0DDD9;
        border-bottom: none;
        margin-bottom: 0;
        text-decoration: none !important;
        text-decoration-line: none !important;
        -webkit-text-decoration: none !important;
    }
}

/* ── Practitioner patient list ──────────────────────────────────────────────── */
.practitioner-patient-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--ht-accent-light);
    color: var(--ht-blue);
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.badge-inactive {
    background-color: var(--ht-warning);
    color: #3d1e00;
}

/* ── Badge: BP risk levels ───────────────────────────────────────────────────── */
.badge-bp-stage2 {
    background-color: var(--ht-danger);
    color: #fff;
}

.badge-bp-stage1 {
    background-color: var(--ht-warning);
    color: #3d1e00;
}

.badge-bp-elevated {
    background-color: #f0c040;
    color: #3d1e00;
}

.badge-bp-normal {
    background-color: #d1fae5;
    color: #065f46;
}

/* ── Health Status Card ──────────────────────────────────────────────────────── */
.health-status-card {
    background: #ffffff;
    border-radius: var(--ht-radius);
    box-shadow: var(--ht-shadow);
    padding: 1.25rem 1.5rem;
}

.health-status-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
    margin-bottom: 0.9rem;
}

.health-status-emoji {
    font-size: 1.4rem;
    line-height: 1;
}

.health-status-label {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-weight: 700;
    font-size: 1rem;
}

.health-status-green  { color: #2E7D32; }
.health-status-yellow { color: #B45309; }
.health-status-red    { color: #B91C1C; }

.health-status-date {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--ht-secondary);
    white-space: nowrap;
}

.health-status-sentences {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.health-status-sentence {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--ht-text);
}

.health-status-sentence::before {
    content: '●';
    flex-shrink: 0;
    margin-top: 0.2em;
    font-size: 0.55rem;
    line-height: 1.6;
}

.health-status-sentence-green::before  { color: #2E7D32; }
.health-status-sentence-yellow::before { color: #F59E0B; }
.health-status-sentence-red::before    { color: var(--ht-danger); }

/* ── Health Status History ───────────────────────────────────────────────────── */
.health-status-history {
    background: #ffffff;
    border-radius: var(--ht-radius);
    box-shadow: var(--ht-shadow);
    overflow: hidden;
}

.health-status-history > summary {
    list-style: none;
    cursor: pointer;
    padding: 0.9rem 1.5rem;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--ht-blue);
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.health-status-history > summary::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--ht-blue);
    margin-left: auto;
    transition: transform 0.15s ease;
}

.health-status-history[open] > summary::after {
    transform: rotate(-180deg);
}

.health-status-history > summary::-webkit-details-marker { display: none; }

.health-status-history-list {
    border-top: 1px solid #E0DDD9;
}

.health-status-history-day {
    border-bottom: 1px solid #E0DDD9;
}

.health-status-history-day:last-child {
    border-bottom: none;
}

.health-status-history-day > summary {
    list-style: none;
    cursor: pointer;
    padding: 0.65rem 1.5rem;
    display: grid;
    grid-template-columns: 6rem 1.25rem auto 1fr;
    align-items: center;
    gap: 0.4rem;
    user-select: none;
    background: #ffffff;
    transition: background 0.1s ease;
}

.health-status-history-day > summary:hover {
    background: #fafafa;
}

.health-status-history-day > summary::-webkit-details-marker { display: none; }

.history-date {
    font-size: 0.78rem;
    color: var(--ht-secondary);
    white-space: nowrap;
}

.history-emoji {
    font-size: 0.95rem;
    line-height: 1;
}

.history-label {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-weight: 600;
    font-size: 0.78rem;
    white-space: nowrap;
}

.history-worst {
    font-size: 0.78rem;
    color: var(--ht-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 0.25rem;
}

.health-status-history-full {
    padding: 0.6rem 1.5rem 0.8rem 1.5rem;
    background: var(--ht-bg);
    margin: 0;
}

/* ── Status badge (practitioner patient list) ────────────────────────────────── */
.health-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    white-space: nowrap;
}

.health-status-badge-green  { background: #E8F5E9; color: #2E7D32; }
.health-status-badge-yellow { background: #FEF3C7; color: #B45309; }
.health-status-badge-red    { background: #FEE2E2; color: #B91C1C; }

/* ── Patient navbar status colours ──────────────────────────────────────────── */
.navbar.navbar-status-good  { background-color: #1A6B3C !important; box-shadow: 0 2px 8px rgba(0, 80, 40, 0.35) !important; }
.navbar.navbar-status-fair  { background-color: #92610A !important; box-shadow: 0 2px 8px rgba(80, 50, 0, 0.35) !important; }
.navbar.navbar-status-alert { background-color: #9B1C1C !important; box-shadow: 0 2px 8px rgba(80, 0, 0, 0.35) !important; }

/* ── Today page status mini-card ─────────────────────────────────────────────── */
.today-status-card {
    background: #ffffff;
    border-radius: var(--ht-radius);
    box-shadow: var(--ht-shadow);
    padding: 0.65rem 1.25rem;
    font-size: 0.9rem;
    color: var(--ht-text);
}

.today-status-link {
    font-weight: 700;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
}

.today-status-link.today-status-green  { color: #1A6B3C !important; }
.today-status-link.today-status-yellow { color: #92610A !important; }
.today-status-link.today-status-red    { color: #9B1C1C !important; }
.today-status-link.today-status-navy   { color: #1B5886 !important; }
