:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --sidebar-bg: #0f172a;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #ffffff;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
}

* {
    box-sizing: border-box;
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-top: 0;
}

h1 { font-size: 1.75rem; margin-bottom: 1rem; }
h2 { font-size: 1.25rem; margin-top: 2rem; margin-bottom: 0.75rem; }
h3 { font-size: 1.05rem; margin-top: 1.5rem; margin-bottom: 0.5rem; }

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

a:hover {
    text-decoration: underline;
}

/* Layout */

.page {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.sidebar .navbar-brand {
    color: #fff;
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    padding: 1.25rem 1rem;
    display: block;
    text-decoration: none;
}

.sidebar .navbar-brand:hover {
    text-decoration: none;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    padding: 0 0.5rem;
    gap: 0.125rem;
}

.sidebar .nav-item {
    display: block;
}

.sidebar .nav-link {
    display: block;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    color: var(--sidebar-text);
    font-size: 0.95rem;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.sidebar .nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    text-decoration: none;
}

.sidebar .nav-link.active {
    background: rgba(37, 99, 235, 0.18);
    color: var(--sidebar-active);
    font-weight: 600;
}

.navbar-toggler {
    display: none;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.top-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    /* background: var(--surface); */
    /* border-bottom: 1px solid var(--border); */
    font-size: 0.9rem;
    color: var(--muted);
}

.top-row form {
    margin: 0;
}

.content {
    padding: 1.5rem;
    max-width: 1100px;
    width: 100%;
}

/* Forms */

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

.form-control,
.form-select {
    display: block;
    width: 100%;
    padding: 0.55rem 0.75rem;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-check-input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary);
}

.form-check-label {
    font-size: 0.9rem;
    color: var(--text);
}

.mb-3 { margin-bottom: 1rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.me-3 { margin-right: 1rem; }

/* Buttons */

.btn {
    display: inline-block;
    padding: 0.55rem 1rem;
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: 500;
    line-height: 1.2;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    text-decoration: none;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-outline-secondary {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}

.btn-outline-secondary:hover {
    background: #f1f5f9;
}

.btn-outline-danger {
    background: transparent;
    color: var(--danger);
    border-color: #fecaca;
}

.btn-outline-danger:hover {
    background: #fef2f2;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    padding: 0;
    font-size: 0.9rem;
    cursor: pointer;
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.85rem;
}

/* Tables */

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 0.95rem;
}

.table th,
.table td {
    text-align: left;
    padding: 0.65rem 0.9rem;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background: #f8fafc;
}

/* Alerts */

.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Input groups */

.input-group {
    display: flex;
    gap: 0.5rem;
}

.input-group .form-control {
    flex: 1;
}

/* Grid */

.row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.g-2 > * {
    margin-bottom: 0.5rem;
}

.col-md-1 { flex: 0 0 calc(8.333% - 0.5rem); }
.col-md-2 { flex: 0 0 calc(16.666% - 0.5rem); }
.col-md-3 { flex: 0 0 calc(25% - 0.5rem); }
.col-md-5 { flex: 0 0 calc(41.666% - 0.5rem); }

/* Account pages */

.account-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
    padding: 1.5rem;
}

.account-card {
    background: var(--surface);
    padding: 2.25rem;
    border-radius: 14px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
    width: 100%;
    max-width: 420px;
}

.account-card h1 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.account-card .btn-primary {
    width: 100%;
    padding: 0.7rem;
    font-size: 1rem;
}

.account-card p {
    text-align: center;
    font-size: 0.9rem;
    color: var(--muted);
}

/* GrowthLog modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 1000;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--surface);
    border-radius: 14px;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25);
    padding: 1.5rem;
    width: calc(100% - 2rem);
    max-width: 460px;
    z-index: 1001;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.modal-header h3 {
    margin: 0;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* GrowthLog upcoming measurement cards */
.upcoming-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.upcoming-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.upcoming-card.status-overdue { border-left-color: #dc2626; }
.upcoming-card.status-due-today { border-left-color: #ea580c; }
.upcoming-card.status-due-soon { border-left-color: #d97706; }
.upcoming-card.status-upcoming { border-left-color: #2563eb; }
.upcoming-card.status-completed { border-left-color: #16a34a; }

.upcoming-card-name {
    font-weight: 600;
}

.upcoming-card-meta {
    font-size: 0.85rem;
    color: var(--muted);
}

.upcoming-card-meta .dot {
    margin: 0 0.35rem;
}

.upcoming-card-status {
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 0.15rem;
}

.status-overdue .upcoming-card-status { color: #dc2626; }
.status-due-today .upcoming-card-status { color: #ea580c; }
.status-due-soon .upcoming-card-status { color: #d97706; }
.status-upcoming .upcoming-card-status { color: #2563eb; }
.status-completed .upcoming-card-status { color: #16a34a; }

.upcoming-card-last {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.15rem;
}

.upcoming-card-action {
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .upcoming-card {
        flex-direction: column;
        align-items: stretch;
    }

    .upcoming-card-action .btn {
        width: 100%;
    }
}

/* GrowthLog family header */
.family-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.family-header-main h1 {
    margin-bottom: 0.25rem;
}

.family-header-counts {
    font-size: 0.9rem;
    color: var(--muted);
}

.family-header-counts .dot {
    margin: 0 0.35rem;
}

.family-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* GrowthLog people toolbar */
.people-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.people-filters {
    display: flex;
    gap: 0.35rem;
}

.filter-chip {
    padding: 0.3rem 0.75rem;
    font-size: 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

.filter-chip.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.people-search {
    flex: 1;
    max-width: 280px;
}

/* GrowthLog person rows */
.person-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.person-row {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.person-row-shared {
    border-left: 4px solid #a5b4fc;
}

.person-row-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e0e7ff;
    color: #3730a3;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

.person-row-main {
    flex: 1;
    min-width: 0;
}

.person-row-name {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.person-row-kind {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    background: #f1f5f9;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
}

.person-row-origin {
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 400;
}

.person-row-meta,
.person-row-latest {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 0.1rem;
}

.person-row-meta .dot,
.person-row-latest .dot {
    margin: 0 0.35rem;
}

.person-row-actions {
    display: flex;
    gap: 0.35rem;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .person-row {
        flex-wrap: wrap;
    }

    .person-row-actions {
        width: 100%;
    }

    .person-row-actions .btn {
        flex: 1;
    }
}

/* GrowthLog add person panel */
.add-person-panel {
    margin: 1rem 0;
}

.add-person-body {
    margin-top: 0.75rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.add-person-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.add-person-tab {
    padding: 0.5rem 0.85rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-size: 0.9rem;
    cursor: pointer;
}

.add-person-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

/* GrowthLog misc */
.badge-unassigned {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 999px;
}

/* GrowthLog chart styles */
.line-chart {
    margin: 1rem 0;
}

/* Chart card: gives the plot a clean light surface and clear separation
   from the page background. Used by Compare and the Dashboard snapshot so
   both charts share the same visual treatment. */
.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1rem 0.75rem;
}

.chart-card svg {
    display: block;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.75rem;
    font-size: 0.9rem;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 500;
}

.legend-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.12);
}

/* GrowthLog empty states */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.35rem;
    padding: 1.75rem 1rem;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.empty-state-icon {
    font-size: 1.75rem;
    line-height: 1;
}

.empty-state-title {
    font-weight: 600;
    margin: 0;
}

.empty-state-description {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 0 0 0.5rem 0;
    max-width: 32rem;
}

/* GrowthLog loading skeletons */
.loading-block {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.loading-row {
    height: 3.25rem;
    border-radius: var(--radius);
    background: linear-gradient(90deg, #eef2f7 25%, #f8fafc 37%, #eef2f7 63%);
    background-size: 400% 100%;
    animation: loading-shimmer 1.4s ease infinite;
}

@keyframes loading-shimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

@media (prefers-reduced-motion: reduce) {
    .loading-row {
        animation: none;
    }
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* GrowthLog section headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

.section-header h2 {
    margin: 0;
}

/* GrowthLog metric cards */
.metric-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.metric-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    box-shadow: var(--shadow);
}

.metric-card-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.metric-card-value {
    font-size: 1.35rem;
    font-weight: 600;
    margin-top: 0.15rem;
}

/* GrowthLog dashboard two-column block */
.dashboard-two-col {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    gap: 1.25rem;
    align-items: start;
    margin-top: 0.5rem;
}

.dashboard-col-upcoming,
.dashboard-col-growth {
    min-width: 0;
    width: 100%;
}

.dashboard-col-upcoming .section-header,
.dashboard-col-growth .section-header {
    margin-top: 0;
}

@media (max-width: 992px) {
    .dashboard-two-col {
        grid-template-columns: 1fr;
    }
}

/* GrowthLog dashboard */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.dashboard-header h1 {
    margin-bottom: 0.25rem;
}

.dashboard-header-actions {
    flex-shrink: 0;
}

.summary-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.summary-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    box-shadow: var(--shadow);
}

.summary-card-value {
    font-size: 1.5rem;
    font-weight: 600;
}

.summary-card-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.activity-feed {
    list-style: none;
    margin: 0 0 1rem 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.activity-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.activity-main {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.activity-values {
    color: var(--muted);
    font-size: 0.9rem;
}

.activity-when {
    color: var(--muted);
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* GrowthLog person header */
.person-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.person-header-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #e0e7ff;
    color: #3730a3;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    font-weight: 600;
    flex-shrink: 0;
}

.person-header-main {
    flex: 1;
    min-width: 0;
}

.person-header-main h1 {
    margin-bottom: 0.15rem;
}

.person-header-meta {
    font-size: 0.9rem;
    color: var(--muted);
}

.person-header-meta .dot {
    margin: 0 0.35rem;
}

.person-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* GrowthLog vertical bar chart (Dashboard "By age" + Compare "Same age") */
.vbar-chart {
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.vbar-plot {
    display: flex;
    align-items: flex-end;
    gap: clamp(0.4rem, 1.5vw, 1.25rem);
    min-height: 260px;
    padding: 0.5rem 0.25rem 0;
    border-bottom: 2px solid #94a3b8;
}

.vbar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    flex: 1 1 0;
    min-width: 3rem;
    height: 260px;
}

.vbar-value {
    font-size: 0.8rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    margin-bottom: 0.25rem;
}

.vbar-track {
    display: flex;
    align-items: flex-end;
    width: 100%;
    max-width: 3.5rem;
    flex: 1;
    background: #f1f3f5;
    border-radius: 0.375rem 0.375rem 0 0;
    overflow: hidden;
}

.vbar-bar {
    width: 100%;
    border-radius: 0.375rem 0.375rem 0 0;
    transition: height 0.2s ease;
}

/* "Both" mode: height columns with a weight line overlay. */
.both-chart {
    position: relative;
    margin-bottom: 1.5rem;
    padding-top: 1.25rem;
}

.both-chart-axis-label {
    position: absolute;
    top: 0;
    font-size: 0.75rem;
    font-weight: 700;
    color: #334155;
}

.both-chart-axis-left {
    left: 0;
}

.both-chart-axis-right {
    right: 0;
    color: #dc2626;
}

.both-chart-plot {
    display: flex;
    align-items: flex-end;
    gap: clamp(0.4rem, 1.5vw, 1.25rem);
    min-height: 260px;
    padding: 0.5rem 0.25rem 0;
    border-bottom: 2px solid #94a3b8;
}

.both-chart-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    flex: 1 1 0;
    min-width: 3rem;
    height: 260px;
}

.both-chart-value {
    font-size: 0.8rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    margin-bottom: 0.25rem;
}

.both-chart-track {
    display: flex;
    align-items: flex-end;
    width: 100%;
    max-width: 3.5rem;
    flex: 1;
    background: #f1f3f5;
    border-radius: 0.375rem 0.375rem 0 0;
    overflow: hidden;
}

.both-chart-bar {
    width: 100%;
    border-radius: 0.375rem 0.375rem 0 0;
    transition: height 0.2s ease;
}

.both-chart-name {
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 0.4rem;
    max-width: 6rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

/* Weight line overlay sits on top of the columns. The SVG spans the plot
   area only (above the name labels) so the line aligns with the bars and
   never crosses the name row. */
.both-chart-line {
    position: absolute;
    left: 0.25rem;
    right: 0.25rem;
    top: 1.25rem;
    height: 260px;
    width: calc(100% - 0.5rem);
    pointer-events: none;
    overflow: visible;
}

/* Clickable person name labels on the chart x-axis. */
.chart-name-toggle {
    background: none;
    border: none;
    padding: 0.1rem 0.25rem;
    font: inherit;
    color: inherit;
    cursor: pointer;
    border-radius: 4px;
}

.chart-name-toggle:hover {
    background: #f1f5f9;
    text-decoration: underline;
}

/* Weight value labels, positioned in the overlay's pixel space. */
.both-chart-weight-label {
    position: absolute;
    transform: translateX(-50%);
    font-size: 0.72rem;
    font-weight: 700;
    color: #dc2626;
    white-space: nowrap;
    pointer-events: none;
    text-shadow: 0 0 3px #fff, 0 0 3px #fff;
}

@media (max-width: 768px) {
    .both-chart-plot {
        gap: 0.4rem;
    }

    .both-chart-col {
        min-width: 2.75rem;
    }

    .both-chart-name {
        max-width: 4rem;
    }
}

.vbar-name {
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 0.4rem;
    max-width: 6rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

@media (max-width: 768px) {
    .vbar-plot {
        gap: 0.4rem;
    }

    .vbar-col {
        min-width: 2.75rem;
    }

    .vbar-name {
        max-width: 4rem;
    }
}

/* GrowthLog dashboard chart family chips */
.chart-family-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}

/* Family star/default controls live on the Families pages, not the Dashboard. */
.family-star {
    background: none;
    border: none;
    padding: 0 0.25rem;
    font-size: 1rem;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
}

.family-star.active {
    color: #f59e0b;
}

.content {
    padding: 1.5rem;
    max-width: 1100px;
    width: 100%;
}

/* GrowthLog chart toolbar */
.chart-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.chart-metric-toggle,
.chart-range-toggle {
    display: flex;
    gap: 0.35rem;
}

/* GrowthLog compare */
.compare-mode-toggle {
    display: flex;
    gap: 0.35rem;
}

/* The Compare chart must be visually identical to the Dashboard snapshot.
   Both render the same LineChart component with Class="chart-card", so no
   Compare-specific stroke/marker/opacity overrides are allowed here. */
.compare-chart-area .chart-card {
    padding: 1rem 1rem 0.75rem;
}

.same-age-controls-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.same-age-controls-row input[type="range"] {
    flex: 1;
}

.same-age-number {
    max-width: 6rem;
}

/* GrowthLog legend buttons */
.legend-item {
    background: none;
    border: none;
    padding: 0.15rem 0.35rem;
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.legend-item:hover {
    background: #f1f5f9;
}

.legend-item-active {
    font-weight: 600;
    background: #eff6ff;
}

.legend-item-muted {
    opacity: 0.55;
}

/* GrowthLog focus visibility */
.btn:focus-visible,
.btn-link:focus-visible,
.filter-chip:focus-visible,
.legend-item:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible,
.nav-link:focus-visible,
a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* GrowthLog nav toggle (mobile) */
.nav-toggle {
    display: none;
}

/* GrowthLog sidebar branding */
.brand-mark {
    margin-right: 0.4rem;
}

.brand-text {
    vertical-align: middle;
}

.nav-icon {
    display: inline-block;
    width: 1.25rem;
    margin-right: 0.4rem;
    text-align: center;
}

/* GrowthLog mobile sidebar backdrop */
.sidebar-backdrop {
    display: none;
}

/* Error UI */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fee2e2;
    color: #991b1b;
    padding: 0.75rem 1rem;
    z-index: 1000;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    float: right;
}

/* Responsive */

@media (max-width: 768px) {
    .page {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        display: none;
    }

    .sidebar.sidebar-open {
        display: flex;
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.35);
        z-index: 900;
    }

    .sidebar nav {
        flex-direction: column;
        padding: 0 0.5rem 0.75rem;
    }

    .nav-toggle {
        display: inline-block;
        margin-right: auto;
    }

    .col-md-1, .col-md-2, .col-md-3, .col-md-5 {
        flex: 1 1 100%;
    }

    .metric-cards,
    .summary-strip {
        grid-template-columns: 1fr;
    }

    .dashboard-header,
    .person-header,
    .family-header {
        flex-direction: column;
        align-items: stretch;
    }

    .dashboard-header-actions,
    .person-header-actions,
    .family-header-actions {
        width: 100%;
    }

    .dashboard-header-actions .btn,
    .person-header-actions .btn,
    .family-header-actions .btn {
        flex: 1;
    }

    .chart-toolbar,
    .people-toolbar,
    .section-header {
        flex-direction: column;
        align-items: stretch;
    }

    .same-age-row {
        grid-template-columns: 1.5rem 1fr 4.5rem;
    }

    .same-age-bar-track {
        grid-column: 1 / -1;
        order: 3;
    }

    .same-age-controls-row {
        flex-direction: column;
        align-items: stretch;
    }

    .same-age-number {
        max-width: none;
    }

    .activity-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
}

/* Touch targets: keep primary actions comfortably tappable. */
.btn,
.filter-chip,
.legend-item,
.nav-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.btn-sm {
    min-height: 36px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}
