:root {
    --header-bg: #0f2d52;
    --header-text: #ffffff;
    --tabs-bg: #1a4a7a;
    --tabs-active-bg: #ffffff;
    --tabs-active-text: #1a4a7a;
    --tabs-text: rgba(255, 255, 255, 0.88);
    --page-bg: #eef2f7;
    --card-bg: #ffffff;
    --text-primary: #1a2332;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --accent: #2563eb;
    --accent-teal: #0d9488;
    --accent-purple: #6366f1;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --shadow: 0 1px 3px rgba(15, 45, 82, 0.08), 0 4px 16px rgba(15, 45, 82, 0.04);
    --radius: 12px;
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    /* Fluid typography: 360px phone → 1800px desktop */
    --text-xs: clamp(11px, 0.12vw + 10.5px, 12px);
    --text-sm: clamp(12px, 0.22vw + 11px, 14px);
    --text-base: clamp(13px, 0.28vw + 12px, 15px);
    --text-md: clamp(14px, 0.35vw + 13px, 16px);
    --text-lg: clamp(15px, 0.45vw + 14px, 18px);
    --text-xl: clamp(18px, 0.7vw + 15px, 24px);
    --text-2xl: clamp(20px, 0.9vw + 16px, 26px);
    --text-kpi: clamp(26px, 1.6vw + 20px, 38px);
    --text-table: clamp(12px, 0.28vw + 11px, 14px);
    --text-table-compact: clamp(11px, 0.24vw + 10px, 13px);
    --text-table-head: clamp(10px, 0.18vw + 9px, 12px);
    --text-calendar: clamp(11px, 0.24vw + 10px, 13px);
    --text-calendar-sm: clamp(10px, 0.15vw + 9px, 11px);
    /* Unified table columns (% of table width; only present cols share the row) */
    --tbl-col-num: 3.5%;
    --tbl-col-id: 7.5%;
    --tbl-col-name: 19%;
    --tbl-col-regimen: 24%;
    --tbl-col-doctor: 11%;
    --tbl-col-status: 13%;
    --tbl-col-date: 9%;
    --tbl-col-notes: 13%;
    --tbl-col-action: 4%;
    --tbl-col-visits: 5%;
    --tbl-min-width: 100%;
    --space-page-x: clamp(12px, 2.5vw, 36px);
    --space-page-y: clamp(14px, 2vw, 28px);
    --space-grid: clamp(12px, 1.6vw, 20px);
    --touch-min: 44px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--text-base);
    line-height: 1.5;
    background: var(--page-bg);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

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

/* ── Header ── */
.site-header {
    background: var(--header-bg);
    color: var(--header-text);
    padding: 0 max(var(--space-page-x), env(safe-area-inset-right, 0px))
        0 max(var(--space-page-x), env(safe-area-inset-left, 0px));
    min-height: 64px;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.site-header__brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.site-header__logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #3b82f6, #0d9488);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
}

.site-header__title {
    font-size: var(--text-md);
    font-weight: 600;
    line-height: 1.35;
    max-width: min(520px, 55vw);
}

.site-header__meta {
    font-size: var(--text-sm);
    color: rgba(255, 255, 255, 0.7);
    text-align: right;
}

.site-header__meta strong {
    display: block;
    color: #fff;
    font-weight: 500;
}

/* ── Tabs ── */
.site-tabs {
    background: var(--tabs-bg);
    padding: 0 max(var(--space-page-x), env(safe-area-inset-right, 0px))
        0 max(var(--space-page-x), env(safe-area-inset-left, 0px));
    display: flex;
    gap: 4px;
    align-items: flex-end;
    min-height: 44px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.site-tabs::-webkit-scrollbar {
    display: none;
}

.site-tabs__link {
    padding: 10px clamp(12px, 1.5vw, 18px);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--tabs-text);
    border-radius: 8px 8px 0 0;
    transition: background 0.15s, color 0.15s;
    margin-bottom: 0;
    white-space: nowrap;
    flex-shrink: 0;
}

.site-tabs__link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.site-tabs__link.is-active {
    background: var(--tabs-active-bg);
    color: var(--tabs-active-text);
}

/* ── Page ── */
.page {
    width: min(100%, 1800px);
    max-width: 1800px;
    margin: 0 auto;
    padding: var(--space-page-y) var(--space-page-x)
        max(clamp(24px, 4vw, 48px), env(safe-area-inset-bottom, 0px));
}

.page-title {
    font-size: var(--text-2xl);
    font-weight: 600;
    margin: 0 0 4px;
}

.page-subtitle {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin: 0 0 clamp(16px, 2.5vw, 24px);
}

/* ── KPI Cards ── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-grid);
    margin-bottom: clamp(16px, 2.5vw, 24px);
}

@media (max-width: 900px) {
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
}

.kpi-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: clamp(14px, 2vw, 20px) clamp(16px, 2.2vw, 22px);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.kpi-card__label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.kpi-card__value {
    font-size: var(--text-kpi);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.02em;
}

.kpi-card__hint {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin-top: 8px;
}

.kpi-card--blue .kpi-card__value { color: var(--accent); }
.kpi-card--teal .kpi-card__value { color: var(--accent-teal); }
.kpi-card--purple .kpi-card__value { color: var(--accent-purple); }
.kpi-card--green .kpi-card__value { color: var(--success); }

/* ── Layout grids ── */
.grid-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-grid);
    margin-bottom: var(--space-grid);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-grid);
    margin-bottom: var(--space-grid);
}

@media (max-width: 1024px) {
    .grid-2-1,
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

/* ── Cards ── */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.card__header {
    padding: clamp(12px, 1.8vw, 16px) clamp(14px, 2vw, 20px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.card__title {
    font-size: var(--text-lg);
    font-weight: 600;
    margin: 0;
}

.card__subtitle {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin: 2px 0 0;
}

.card__body {
    padding: clamp(12px, 1.8vw, 16px) clamp(14px, 2vw, 20px) clamp(16px, 2.2vw, 20px);
}

.card__body--flush {
    padding: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ── Analytics hub card previews ── */
.analytics-hub-card {
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.15s, transform 0.15s;
}

a.analytics-hub-card:hover {
    box-shadow: 0 4px 20px rgba(15, 45, 82, 0.12);
    transform: translateY(-1px);
}

.analytics-hub-card--soon {
    opacity: 0.72;
}

.analytics-hub-card__arrow {
    color: var(--accent);
    font-size: 20px;
    flex-shrink: 0;
}

.analytics-card-preview {
    position: relative;
    width: 100%;
    min-height: 224px;
    height: 224px;
    padding: 4px 12px 0;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
    pointer-events: none;
    overflow: hidden;
}
.analytics-card-preview--progress {
    padding: 2px 10px 0;
    display: flex;
    flex-direction: column;
}
.analytics-card-preview--progress .therapy-progress-panel {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
.analytics-card-preview--progress .therapy-progress-legend {
    display: none;
}
.analytics-card-preview--progress .therapy-progress-row td {
    padding: 2px 4px;
    vertical-align: middle;
}
.analytics-card-preview--progress .therapy-progress-row__head {
    font-size: 11px;
    line-height: 1.25;
}
.analytics-card-preview--progress .therapy-progress-row__meta {
    font-size: 9px;
    line-height: 1.3;
}
.analytics-card-preview--progress .therapy-progress-row__count {
    font-size: 10px;
    padding-right: 6px;
}
.analytics-card-preview--progress .therapy-progress-row__track {
    height: 14px;
    min-height: 14px;
}
.analytics-card-preview--progress .therapy-progress-seg {
    font-size: 9px;
    min-width: 0;
}
.analytics-card-preview--progress .therapy-progress-scale-block--scroll {
    max-height: 224px !important;
    overflow: hidden !important;
}
.analytics-card-preview--progress .therapy-progress-axis-row {
    display: none;
}
.analytics-card-preview--progress .therapy-progress-row__link {
    pointer-events: none;
    cursor: default;
}
.analytics-card-preview--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: repeating-linear-gradient(
        -45deg,
        #f8fafc,
        #f8fafc 8px,
        #f1f5f9 8px,
        #f1f5f9 16px
    );
}

.analytics-card-preview__label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

.analytics-hub-card__footer {
    padding-top: 12px;
    padding-bottom: 14px;
}

.analytics-hub-card__desc {
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.55;
}

/* ── Table ── */
.data-table {
    width: 100%;
    min-width: var(--tbl-min-width);
    border-collapse: collapse;
    font-size: var(--text-sm);
    table-layout: fixed;
}

.data-table th {
    text-align: left;
    padding: clamp(8px, 1vw, 10px) clamp(10px, 1.2vw, 16px);
    background: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: clamp(8px, 1vw, 11px) clamp(10px, 1.2vw, 16px);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    min-width: 0;
}

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

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

/* ── Status badges ── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: var(--text-xs);
    font-weight: 500;
    white-space: nowrap;
}

.badge--planned {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge--done {
    background: #d1fae5;
    color: #047857;
}

.badge--cancelled {
    background: #f1f5f9;
    color: #64748b;
}

.badge--other {
    background: #fef3c7;
    color: #b45309;
}

/* ── Placeholder pages ── */
.placeholder {
    text-align: center;
    padding: 64px 24px;
}

.placeholder__icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.placeholder__title {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 8px;
}

.placeholder__text {
    color: var(--text-secondary);
    font-size: 14px;
    max-width: 420px;
    margin: 0 auto 24px;
    line-height: 1.6;
}

.placeholder__links {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px clamp(14px, 2vw, 18px);
    border-radius: 8px;
    font-size: var(--text-sm);
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: opacity 0.15s;
    min-height: 36px;
}

.btn:hover {
    opacity: 0.9;
}

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

.btn--sm {
    padding: 5px 10px;
    font-size: var(--text-xs);
    min-height: 32px;
}

.btn--danger {
    border: 1px solid #dc2626;
    background: #fef2f2;
    color: #b91c1c;
}

.btn--danger:hover:not(:disabled) {
    background: #dc2626;
    color: #fff;
}

.btn--danger:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn--secondary {
    background: #f1f5f9;
    color: var(--text-primary);
}

/* ── Chart containers ── */
.chart-box {
    min-height: 280px;
}

.chart-box--tall {
    min-height: 320px;
}

.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ── Analytics page controls (existing) ── */
.controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.controls label {
    font-size: 13px;
    color: var(--text-secondary);
}

.controls select,
.controls button {
    padding: 8px 12px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    font-family: var(--font);
}

.controls button {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    cursor: pointer;
    font-weight: 500;
}

.controls-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.controls-actions #period-picker-mount,
.controls-actions .period-pickers {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.controls .controls-action-btn.btn--secondary,
.controls .controls-actions .period-picker__trigger.btn--secondary {
    background: #f8fafc;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: 8px;
    line-height: 1.2;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.controls .controls-action-btn.btn--secondary:hover,
.controls .controls-actions .period-picker__trigger.btn--secondary:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.08);
}

.meta {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 10px;
}

/* ── Journal ── */
.page--journal {
    max-width: 1600px;
}

.journal-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
    align-items: start;
}

@media (max-width: 1100px) {
    .journal-layout {
        grid-template-columns: 1fr;
    }
    .journal-sidebar {
        order: -1;
    }
}

.journal-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.journal-week-layout[hidden] {
    display: none !important;
}

.journal-week-layout {
    display: flex;
    align-items: center;
    gap: 8px;
}

.journal-week-layout__label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.journal-view-tabs--compact .journal-view-tab {
    padding: 6px 12px;
    font-size: 12px;
}

.journal-view-tabs {
    display: inline-flex;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px;
    gap: 2px;
}

.journal-view-tab {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    font-family: var(--font);
    transition: background 0.15s, color 0.15s;
}

.journal-view-tab:hover {
    color: var(--text-primary);
    background: #f8fafc;
}

.journal-view-tab.is-active {
    background: var(--accent);
    color: #fff;
}

.journal-total-badge {
    font-size: 13px;
    color: var(--text-secondary);
    background: #fff;
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 8px;
    margin-left: auto;
}

.journal-total-badge strong {
    color: var(--accent);
    font-weight: 600;
}

.journal-main {
    min-height: 520px;
}

.journal-sidebar .card {
    position: sticky;
    top: 16px;
}

/* Sidebar mini calendar */
.side-cal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.side-cal__title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
}

.side-cal__nav {
    display: flex;
    gap: 4px;
}

.side-cal__nav button {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.side-cal__nav button:hover {
    background: #f8fafc;
    color: var(--text-primary);
}

.side-cal__weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 4px;
}

.side-cal__weekdays span {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 4px 0;
}

.side-cal__grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.side-cal__day {
    aspect-ratio: 1;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-primary);
    font-family: var(--font);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2px;
}

.side-cal__day:hover:not(:disabled) {
    background: #eff6ff;
}

.side-cal__day.is-other {
    color: #cbd5e1;
}

.side-cal__day.is-today {
    font-weight: 700;
    color: var(--accent);
}

.side-cal__day.is-selected {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

.side-cal__day.is-selected .side-cal__dot {
    background: rgba(255, 255, 255, 0.9);
}

.side-cal__day:disabled {
    cursor: default;
    visibility: hidden;
}

.side-cal__dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent-teal);
    margin-top: 2px;
}

.side-cal__today-btn {
    width: 100%;
    margin-top: 12px;
    padding: 8px;
    border: 1px solid var(--border);
    background: #f8fafc;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    font-family: var(--font);
    color: var(--text-secondary);
}

.side-cal__today-btn:hover {
    background: #eff6ff;
    color: var(--accent);
}

/* Day view */
.journal-day-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.journal-day-header h2 {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 600;
}

.journal-day-header p {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
}

.journal-doctor-block {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}

.journal-doctor-block:last-child {
    border-bottom: none;
}

.journal-doctor-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.journal-doctor-count {
    font-size: 12px;
    font-weight: 500;
    background: #eff6ff;
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 999px;
}

.journal-patient-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.journal-patient-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 12px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
}

.journal-patient-item:last-child {
    border-bottom: none;
}

.journal-patient-name {
    font-weight: 500;
}

.journal-patient-id {
    font-size: 12px;
    color: var(--text-secondary);
}

.journal-patient-regimen {
    color: var(--text-secondary);
    font-size: 12px;
    text-align: right;
}

/* Week view */
.journal-week-grid.is-columns {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    padding: 12px;
    align-items: start;
}

@media (max-width: 900px) {
    .journal-week-grid.is-columns {
        grid-template-columns: 1fr;
    }
}

.journal-week-grid.is-rows {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
}

.journal-week-row {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.journal-week-row.is-today {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.journal-week-row-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}

.journal-week-row-header__date {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.journal-week-row-header__date strong {
    font-size: 15px;
    color: var(--text-primary);
}

.journal-week-row-header__date span {
    font-size: 14px;
    color: var(--text-secondary);
}

.journal-week-row-header__count {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
}

.journal-week-row-header.journal-week-day-link:hover {
    background: #eff6ff;
}

.journal-week-row.is-today .journal-week-row-header.journal-week-day-link:hover {
    background: #dbeafe;
}

.journal-week-row-body {
    padding: 0;
    overflow-x: auto;
}

.journal-week-doctors-horizontal {
    display: flex;
    gap: 20px;
    flex-wrap: nowrap;
    min-width: min-content;
}

.journal-week-doctor-col {
    min-width: 180px;
    max-width: 260px;
    flex-shrink: 0;
}

@media (max-width: 700px) {
    .journal-week-doctors-horizontal {
        flex-wrap: wrap;
    }
}

.journal-week-grid {
    /* legacy fallback */
}

.journal-week-col {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    min-height: 100px;
    min-width: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.journal-week-col.is-today {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.journal-week-col-header {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    background: #fff;
    border-radius: 10px 10px 0 0;
}

.journal-week-col-header strong {
    display: block;
    font-size: 13px;
}

.journal-week-col-header span {
    font-size: 11px;
    color: var(--text-secondary);
}

.journal-week-day-link {
    cursor: pointer;
    transition: background 0.15s;
}

.journal-week-day-link:hover {
    background: #eff6ff;
}

.journal-week-col.is-today .journal-week-day-link:hover {
    background: #dbeafe;
}

.journal-week-col-body {
    padding: 6px;
    flex: 1;
    overflow: visible;
    min-width: 0;
}

.week-col-empty {
    padding: 16px 8px !important;
    font-size: 11px !important;
    color: #cbd5e1;
}

.week-col-cards {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.week-col-card {
    background: #fff;
    border: 1px solid #eef2f7;
    border-radius: 6px;
    padding: 5px 7px;
    line-height: 1.25;
}

.week-col-card__name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.week-col-card__meta {
    display: flex;
    align-items: baseline;
    gap: 4px;
    font-size: 10px;
    color: var(--text-secondary);
    min-width: 0;
}

.week-col-card__regimen {
    color: #0369a1;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}

.week-col-card__dot {
    flex-shrink: 0;
    opacity: 0.5;
}

.week-col-card__doctor {
    flex-shrink: 0;
    font-weight: 500;
    color: #64748b;
}

.journal-week-col.is-today .week-col-card {
    background: #f8fbff;
    border-color: #dbeafe;
}

.journal-week-doctor {
    margin-bottom: 12px;
}

.journal-week-doctor-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 4px;
}

.journal-week-patient {
    font-size: 12px;
    padding: 3px 0;
    color: var(--text-primary);
}

/* Month / year period header */
.journal-period-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}

.journal-period-header--year {
    padding: 20px 24px;
}

.journal-period-header__left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.journal-period-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.journal-period-header--year h2 {
    font-size: 22px;
}

.journal-period-header__hint {
    margin: 0;
    margin-left: auto;
    font-size: 14px;
    color: var(--text-secondary);
    text-align: right;
}

.journal-period-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.journal-period-nav__btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font);
    flex-shrink: 0;
}

.journal-period-nav__btn:hover {
    background: #eff6ff;
    color: var(--accent);
    border-color: #dbeafe;
}

.journal-month-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}

.journal-month-weekdays span {
    text-align: center;
    padding: 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.journal-month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.journal-month-cell {
    min-height: 88px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 8px 10px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    position: relative;
}

.journal-month-cell.workload-tier-low { background: #ecfdf5; }
.journal-month-cell.workload-tier-normal { background: #eff6ff; }
.journal-month-cell.workload-tier-high { background: #fff7ed; }
.journal-month-cell.workload-tier-overload { background: #fef2f2; }
.journal-month-cell.workload-tier-none { background: #f8fafc; }

.journal-month-cell:nth-child(7n) {
    border-right: none;
}

.journal-month-cell:hover:not(.is-empty) {
    transform: scale(1.03);
    z-index: 1;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.1);
}

.journal-month-cell.is-empty {
    background: #fafbfc;
    cursor: default;
}

.journal-month-cell.is-selected {
    box-shadow: inset 0 0 0 2px var(--accent);
}

.journal-month-cell.is-today {
    outline: 2px solid #1d4ed8;
    outline-offset: -2px;
}

.journal-month-cell.is-today .journal-month-day-num {
    background: var(--accent);
    color: #fff;
}

.journal-month-day-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 500;
}

.journal-month-count {
    margin-top: 8px;
    font-size: 18px;
    font-weight: 700;
    color: #334155;
    line-height: 1.15;
}

.journal-month-count-label {
    font-size: 11px;
    color: #64748b;
    margin-top: 2px;
}

.journal-month-cell.is-zero .journal-month-count {
    color: #94a3b8;
    font-weight: 600;
    font-size: 16px;
}

.journal-month-cell.is-zero .journal-month-count-label {
    color: #cbd5e1;
}

.side-cal__dot--low { background: #86efac; }
.side-cal__dot--normal { background: #93c5fd; }
.side-cal__dot--high { background: #fdba74; }
.side-cal__dot--overload { background: #fca5a5; }

/* Year view */
.journal-year-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    padding: 20px;
}

.journal-year-card {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    text-align: center;
}

.journal-year-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
}

.journal-year-card h3 {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
}

.journal-year-card .count {
    font-size: 32px;
    font-weight: 700;
    color: var(--accent);
}

.journal-year-card .label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ── Schedule table (unified column grid) ── */
.schedule-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

.schedule-table {
    width: 100%;
    min-width: var(--tbl-min-width);
    border-collapse: collapse;
    font-size: var(--text-table);
    table-layout: fixed;
}

.schedule-table col.col-num,
.schedule-table .col-num { width: var(--tbl-col-num); }

.schedule-table col.col-id,
.schedule-table .col-id { width: var(--tbl-col-id); }

.schedule-table col.col-name,
.schedule-table .col-name { width: var(--tbl-col-name); }

.schedule-table col.col-regimen,
.schedule-table .col-regimen { width: var(--tbl-col-regimen); }

.schedule-table col.col-doctor,
.schedule-table .col-doctor { width: var(--tbl-col-doctor); }

.schedule-table col.col-status,
.schedule-table .col-status { width: var(--tbl-col-status); }

.schedule-table col.col-date,
.schedule-table .col-date { width: var(--tbl-col-date); }

.schedule-table col.col-notes,
.schedule-table .col-notes { width: var(--tbl-col-notes); }

.schedule-table col.col-visit-action,
.schedule-table .col-visit-action { width: var(--tbl-col-action); }

.schedule-table col.col-visits,
.schedule-table .col-visits { width: var(--tbl-col-visits); }

.schedule-table th {
    text-align: left;
    padding: clamp(6px, 1vw, 10px) clamp(8px, 1.2vw, 12px);
    background: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: var(--text-table-head);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    vertical-align: middle;
}

.schedule-table td {
    padding: clamp(6px, 1vw, 10px) clamp(8px, 1.2vw, 12px);
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    overflow: hidden;
    min-width: 0;
}

.schedule-table .col-num,
.schedule-table th.col-num,
.schedule-table td.col-num,
.schedule-table .col-visits,
.schedule-table th.col-visits,
.schedule-table td.col-visits,
.schedule-table .col-visit-action,
.schedule-table th.col-visit-action,
.schedule-table td.col-visit-action {
    text-align: center;
}

.schedule-table .col-num {
    color: var(--text-secondary);
    font-size: var(--text-xs);
}

.schedule-table .col-doctor,
.schedule-table th.col-doctor,
.schedule-table td.col-doctor {
    text-align: center;
}

.schedule-table .col-notes {
    color: var(--text-secondary);
}

.schedule-table .tag-regimen,
.schedule-table .tag-name,
.schedule-table .tag-id,
.schedule-table .tag-doctor,
.schedule-table .tag-notes,
.schedule-table .tag-date {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.schedule-table .tag-name,
.schedule-table .tag-regimen {
    display: block;
}

.schedule-table .col-visit-action {
    padding-left: 0;
    padding-right: 6px;
}

.schedule-table tbody tr:hover .visit-add-next-btn {
    opacity: 1;
}

.visit-add-next-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid #bae6fd;
    border-radius: 6px;
    background: #f0f9ff;
    color: #0369a1;
    font-size: 20px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, border-color 0.15s, color 0.15s;
}

.visit-add-next-btn:hover {
    background: #e0f2fe;
    border-color: #7dd3fc;
    color: #0284c7;
}

.visit-add-next-btn:focus-visible {
    opacity: 1;
    outline: 2px solid #7dd3fc;
    outline-offset: 1px;
}

.visit-add-next-btn:disabled {
    opacity: 0.55;
    cursor: wait;
}

.schedule-table--compact {
    font-size: var(--text-table-compact);
}

.schedule-table--compact th {
    font-size: var(--text-table-head);
}

.schedule-table--compact .col-num {
    font-size: var(--text-calendar-sm);
}

/* Home: no ID/date — give space to regimen & notes */
.schedule-table--layout-home col.col-name,
.schedule-table--layout-home .col-name { width: 21%; }

.schedule-table--layout-home col.col-regimen,
.schedule-table--layout-home .col-regimen { width: 28%; }

.schedule-table--layout-home col.col-notes,
.schedule-table--layout-home .col-notes { width: 16%; }

/* Patients registry */
.schedule-table--layout-patients col.col-name,
.schedule-table--layout-patients .col-name { width: 18%; }

.schedule-table--layout-patients col.col-regimen,
.schedule-table--layout-patients .col-regimen { width: 16%; }

.schedule-table--layout-patients col.col-status,
.schedule-table--layout-patients .col-status { width: 15%; }

.schedule-table--layout-patients .col-status {
    min-width: 0;
}

.schedule-table tbody tr:hover {
    background: #fafbfc;
}

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

/* Tags / pills */
.tag-id {
    display: inline-block;
    padding: 4px 8px;
    background: #f1f5f9;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.tag-date {
    display: inline-block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--accent);
}

.tag-name,
.tag-regimen {
    display: block;
    max-width: 100%;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tag-name {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #dbeafe;
}

button.patient-name-link.tag-name {
    cursor: pointer;
    font: inherit;
    text-align: left;
    width: 100%;
    transition: background 0.15s, border-color 0.15s;
}

button.patient-name-link.tag-name:hover,
button.patient-name-link.tag-name:focus-visible {
    background: #dbeafe;
    border-color: #93c5fd;
    outline: none;
}

.week-col-card__name .patient-name-link {
    display: block;
    width: 100%;
    padding: 0;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.week-col-card__name .patient-name-link:hover,
.week-col-card__name .patient-name-link:focus-visible {
    color: #2563eb;
    outline: none;
}

.tag-regimen {
    background: #f0f9ff;
    color: #0369a1;
    border: 1px solid #e0f2fe;
}

.tag-doctor {
    display: block;
    max-width: 100%;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: var(--text-sm);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tag-doctor--amirov {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #dbeafe;
}

.tag-doctor--dzhelyalova {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #d1fae5;
}

.tag-doctor--zolotukhina {
    background: #f5f3ff;
    color: #6d28d9;
    border: 1px solid #ede9fe;
}

.tag-doctor:not(.tag-doctor--amirov):not(.tag-doctor--dzhelyalova):not(.tag-doctor--zolotukhina) {
    background: #f8fafc;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.tag-notes {
    display: inline-block;
    padding: 3px 8px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.tag-notes--empty {
    background: transparent;
    border-color: transparent;
    color: #cbd5e1;
}

/* Week rows — aligned columns across day tables */
.schedule-table--week-rows {
    table-layout: fixed;
    width: 100%;
}

.schedule-table--week-rows col.col-num,
.schedule-table--week-rows .col-num { width: var(--tbl-col-num); }

.schedule-table--week-rows col.col-id,
.schedule-table--week-rows .col-id { width: var(--tbl-col-id); }

.schedule-table--week-rows col.col-name,
.schedule-table--week-rows .col-name { width: var(--tbl-col-name); }

.schedule-table--week-rows col.col-regimen,
.schedule-table--week-rows .col-regimen { width: var(--tbl-col-regimen); }

.schedule-table--week-rows col.col-doctor,
.schedule-table--week-rows .col-doctor { width: var(--tbl-col-doctor); }

.schedule-table--week-rows col.col-status,
.schedule-table--week-rows .col-status { width: var(--tbl-col-status); }

.schedule-table--week-rows td.col-regimen,
.schedule-table--week-rows td.col-name {
    overflow: hidden;
}

.schedule-table--week-rows .tag-regimen,
.schedule-table--week-rows .tag-name {
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.journal-week-col-body--table,
.journal-week-row-body--table {
    padding: 0;
    overflow-x: auto;
    max-height: none;
}

.journal-week-col-body--table .schedule-table-wrap,
.journal-week-row-body--table .schedule-table-wrap {
    border-radius: 0;
    width: 100%;
}

.journal-week-row-body--table {
    min-width: 0;
}

.journal-week-row.is-today .journal-week-row-body--table .schedule-table tbody tr:first-child td {
    /* subtle highlight optional */
}

/* ── Day view filters ── */
.day-filters {
    margin-bottom: 12px;
    padding: 16px 20px !important;
}

.day-filters__section {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.day-filters__section:last-child {
    margin-bottom: 0;
}

.day-filters__label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    min-width: 72px;
    padding-top: 7px;
    flex-shrink: 0;
}

.day-filters__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.day-filters__content {
    flex: 1;
    min-width: 0;
}

.day-filters__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.day-filter-chip--action {
    white-space: nowrap;
    font-weight: 500;
    color: var(--text-secondary);
    background: #f8fafc;
}

.day-filter-chip--action:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.day-filter-chip--action.is-on {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.day-filter-chip {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: var(--text-sm);
    font-family: var(--font);
    cursor: pointer;
    transition: opacity 0.15s, border-color 0.15s, background 0.15s;
    line-height: 1.3;
}

.day-filter-chip--letter {
    min-width: 36px;
    text-align: center;
    font-weight: 600;
    padding: 6px 10px;
}

.day-filter-chip--letter.is-active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.day-filter-chip--doctor.is-on {
    opacity: 1;
}

.day-filter-chip--doctor.is-off {
    opacity: 0.4;
    filter: grayscale(0.6);
    text-decoration: line-through;
}

.day-filter-chip.is-merge-mark {
    box-shadow: inset 0 0 0 2px var(--accent-purple);
    border-color: var(--accent-purple);
}

.day-filter-meta {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding: 0 4px;
}

.day-filter-meta strong {
    color: var(--accent);
    font-weight: 600;
}

/* ── Patients page ── */
.patients-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    margin-bottom: 12px;
}

.patients-toolbar__search {
    flex: 1;
    min-width: 0;
    max-width: 420px;
}

.patients-search-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: var(--font);
    background: #fff;
    color: var(--text-primary);
}

.patients-search-input:focus {
    outline: none;
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.patients-toolbar__badge {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.patients-toolbar__right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-required {
    color: var(--danger);
}

.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: var(--font);
    background: #fff;
    color: var(--text-primary);
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: none;
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-field textarea {
    resize: vertical;
    min-height: 84px;
}

.form-error {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    font-size: 13px;
}

.modal[hidden] {
    display: none;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 45, 82, 0.45);
}

.modal__dialog {
    position: relative;
    width: min(100%, 520px);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(15, 45, 82, 0.25);
    overflow: hidden;
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.modal__title {
    margin: 0;
    font-size: 18px;
}

.modal__close {
    width: 32px;
    height: 32px;
    border: none;
    background: #f1f5f9;
    border-radius: 8px;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal__body {
    padding: 20px;
}

.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.modal--nested {
    z-index: 1100;
}

#schedule-cycles-modal:not([hidden]) {
    display: flex;
}

.modal__dialog--schedule {
    width: min(100%, 420px);
}

.schedule-cycles-modal__hint {
    margin: 0 0 16px;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.45;
}

.schedule-cycles-modal__label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 500;
}

.schedule-cycles-modal__input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
}

.schedule-cycles-modal__input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
}

.schedule-cycles-modal__footer {
    margin-top: 0;
}

    margin-bottom: 12px;
}

.flow-status {
    display: inline-block;
    max-width: 100%;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: 1.35;
    white-space: normal;
}

.flow-status--primary {
    background: #dbeafe;
    color: #1e3a8a;
    border: 1px solid #bfdbfe;
}

.flow-status--therapy {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.flow-status--completed {
    background: #d1fae5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.flow-status--dropped {
    background: #f87171;
    color: #ffffff;
    border: 1px solid #ef4444;
}

.flow-status--unknown {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.schedule-table--patients .col-status {
    width: var(--tbl-col-status);
}

.patients-row {
    cursor: pointer;
}

.patients-row:hover {
    background: #f8fbff;
}

.patients-row:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: -2px;
}

.patients-row__cell {
    user-select: none;
}

.modal__dialog--wide {
    width: min(100%, 920px);
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
}

.modal__dialog--wide .modal__header {
    flex-shrink: 0;
}

.modal__dialog--wide .modal__body {
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    overscroll-behavior: contain;
}

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

.patient-card-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 20px;
    margin-bottom: 20px;
}

.patient-card-field__label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.patient-card-field__value {
    font-size: 14px;
    color: var(--text-primary);
}

.patient-card-regimen-cycles {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.patient-card-regimen-cycle {
    display: inline-block;
    width: auto;
}

.patient-card-therapy {
    margin: 18px 0 16px;
    padding-top: 16px;
    border-top: 1px solid #f1f5f9;
}
.patient-card-therapy[hidden] {
    display: none !important;
}
.patient-card-therapy__title {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
}
.patient-card-therapy__chart .therapy-progress-panel--compact {
    align-items: flex-start;
    gap: 14px;
}
.patient-card-therapy__chart .therapy-progress-scale-block,
.patient-card-therapy__chart .therapy-progress-legend {
    width: 100%;
    max-width: var(--therapy-track-width, 560px);
    margin-left: 0;
    margin-right: auto;
    box-sizing: border-box;
}
.patient-card-therapy__chart .therapy-progress-legend {
    justify-content: flex-start;
    margin-top: 2px;
    padding-top: 2px;
}
.patient-card-therapy__chart .therapy-progress-axis__scale {
    padding-bottom: 2px;
}
.patient-card-therapy__chart .therapy-progress-table {
    width: 100%;
    table-layout: fixed;
}
.patient-card-therapy__chart .therapy-progress-col-track {
    width: 100%;
}
.patient-card-therapy__chart .therapy-progress-row__track-scale {
    width: 100%;
    box-sizing: border-box;
}
.patient-card-therapy__chart .therapy-progress-row__track {
    min-width: 0;
}
.therapy-progress-panel--compact .therapy-progress-table {
    width: 100%;
    table-layout: fixed;
}
.therapy-progress-panel--compact .therapy-progress-col-track {
    width: 100%;
}
.therapy-progress-panel--compact .therapy-progress-row__track-scale {
    width: 100%;
}
.patient-card-notes {
    margin-bottom: 20px;
    padding: 14px 16px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.patient-card-notes__label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.patient-card-notes__text {
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.patient-card-notes__input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: #fff;
    resize: vertical;
    min-height: 72px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.patient-card-notes__input:hover {
    border-color: #cbd5e1;
}

.patient-card-notes__input:focus {
    outline: none;
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.patient-card-notes__input:disabled {
    opacity: 0.65;
    cursor: wait;
}

.patient-card-visits__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.patient-card-visits__header-left {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.patient-visits-bulk {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.patient-visits-bulk__label {
    font-size: 13px;
    color: var(--text-secondary);
}

.patient-visits-bulk__count-num {
    color: var(--text-primary, #0f172a);
}

.patient-card-visits__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.patient-card-visits__header .patient-card-visits__title {
    margin: 0;
}

.patient-schedule-btn {
    flex-shrink: 0;
    border: 1px solid var(--accent);
    background: var(--accent-soft, #eef4ff);
    color: var(--accent);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.patient-schedule-btn:hover:not(:disabled) {
    background: var(--accent);
    color: #fff;
}

.patient-schedule-btn--link {
    border-color: #7c3aed;
    background: #f5f3ff;
    color: #6d28d9;
}

.patient-schedule-btn--link:hover:not(:disabled) {
    background: #7c3aed;
    color: #fff;
}

.patient-schedule-btn--link.is-active {
    background: #7c3aed;
    color: #fff;
    border-color: #6d28d9;
}

.patient-schedule-btn--adapt:not(:disabled) {
    border-color: #0d9488;
    background: #ecfdf5;
    color: #0f766e;
}

.patient-schedule-btn--adapt:hover:not(:disabled) {
    background: #0d9488;
    color: #fff;
}

.patient-schedule-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.patient-schedule-btn:disabled,
.patient-schedule-btn--disabled {
    opacity: 0.45;
    cursor: not-allowed;
    border-color: var(--border);
    background: var(--surface-muted, #f3f4f6);
    color: var(--text-secondary);
}

.patient-card-visits__title {
    margin: 0 0 12px;
    font-size: 15px;
}

.patient-card-visits__notice {
    margin: 0 0 12px;
    padding: 10px 12px;
    font-size: 13px;
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
}

.patient-card-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 18px 12px !important;
}

@media (max-width: 640px) {
    .patient-card-grid {
        grid-template-columns: 1fr;
    }
}

.week-col-card__status {
    margin-top: 8px;
}

.week-col-card__status .journal-cell-editable {
    width: 100%;
}

/* ── Journal inline edit ── */
.journal-cell-editable {
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    cursor: pointer;
    font: inherit;
    text-align: left;
    width: 100%;
    display: block;
    border-radius: 6px;
}

.journal-cell-editable:hover,
.journal-cell-editable:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: 1px;
}

.patient-card-field__value .journal-cell-editable,
.schedule-table--compact .journal-cell-editable {
    width: auto;
    display: inline-block;
}

.patient-visit-new-row {
    background: #f8fafc;
}

.patient-visit-new-row td {
    vertical-align: middle;
}

.patient-visit-new-row__num {
    color: var(--text-secondary);
}

.visit-date-field {
    display: inline-block;
    box-sizing: border-box;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.35;
    font-variant-numeric: tabular-nums;
    font-family: inherit;
    color: #0369a1;
    background: #f0f9ff;
    border: 1px solid #e0f2fe;
    max-width: 148px;
    width: 100%;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.visit-date-field:hover {
    border-color: #7dd3fc;
}

.visit-date-field:focus {
    outline: none;
    border-color: #38bdf8;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

.visit-date-field:disabled {
    opacity: 0.65;
    cursor: wait;
}

.visit-date-field::-webkit-calendar-picker-indicator {
    opacity: 0.55;
    cursor: pointer;
    filter: hue-rotate(180deg);
}

.visit-date-field--draft {
    background: #fff;
    border-color: #bae6fd;
}

.schedule-table--compact .col-visit-select {
    width: 36px;
    padding-left: 8px;
    padding-right: 0;
    text-align: center;
    vertical-align: middle;
}

.schedule-table--compact .col-visit-select input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--accent);
}

.schedule-table--selectable tbody tr.patient-visit-row:has(.visit-select-checkbox:checked) {
    background: #fff7ed;
}

.schedule-table--compact .col-visit-action {
    width: 36px;
    padding-left: 0;
    padding-right: 4px;
    text-align: center;
}

.visit-delete-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #94a3b8;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
}

.schedule-table--compact tbody tr:hover .visit-delete-btn {
    opacity: 1;
}

.visit-delete-btn:hover {
    background: #fef2f2;
    color: #dc2626;
}

.visit-delete-btn:focus-visible {
    opacity: 1;
    outline: 2px solid #fca5a5;
    outline-offset: 1px;
}

.visit-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid #bae6fd;
    border-radius: 6px;
    background: #f0f9ff;
    color: #0369a1;
    font-size: 20px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.visit-add-btn:hover {
    background: #e0f2fe;
    border-color: #7dd3fc;
    color: #0284c7;
}

.visit-add-btn:focus-visible {
    outline: 2px solid #7dd3fc;
    outline-offset: 1px;
}

.visit-add-btn:disabled {
    opacity: 0.55;
    cursor: wait;
}

.journal-edit-popover {
    position: fixed;
    z-index: 2000;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow), 0 12px 40px rgba(15, 45, 82, 0.12);
    min-width: 220px;
    max-width: min(320px, calc(100vw - 24px));
    overflow: hidden;
}

.journal-edit-popover__title {
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}

.journal-edit-menu {
    padding: 6px;
    max-height: 280px;
    overflow-y: auto;
}

.journal-edit-menu__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font);
    text-align: left;
    transition: background 0.12s, opacity 0.12s;
}

.journal-edit-menu__item:hover,
.journal-edit-menu__item:focus-visible {
    background: #eff6ff;
    outline: none;
}

.journal-edit-menu__item.is-selected {
    background: #eff6ff;
}

.journal-edit-menu__item:disabled {
    cursor: default;
    opacity: 0.6;
}

.journal-edit-menu__item-content {
    min-width: 0;
    flex: 1;
}

.journal-edit-menu__item-content .badge,
.journal-edit-menu__item-content .tag-doctor,
.journal-edit-menu__item-content .tag-regimen {
    display: inline-block;
    max-width: 100%;
}

.journal-edit-menu__check {
    color: var(--accent);
    font-size: 14px;
    font-weight: 700;
    opacity: 0;
    flex-shrink: 0;
    line-height: 1;
}

.journal-edit-menu__item.is-selected .journal-edit-menu__check {
    opacity: 1;
}

.journal-edit-menu__default {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: #f1f5f9;
    border: 1px solid var(--border);
}

.active-cycles-chart,
.active-cycles-chart .plotly .cursor-crosshair {
    cursor: pointer;
}

tr.active-cycles-row--clickable {
    cursor: pointer;
}

tr.active-cycles-row--clickable:hover td {
    background: #f8fafc;
}

/* ── Analytics period pickers ── */
.controls-actions #period-picker-mount,
.controls-actions .period-pickers {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 10px;
    width: auto;
    flex: 0 0 auto;
}

.controls #period-picker-mount,
.controls .period-pickers {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 10px;
    width: auto;
    flex: 0 0 auto;
}

.period-pickers {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 10px;
    align-items: center;
}

.period-picker {
    position: relative;
    flex: 0 0 auto;
}

.controls .period-picker__trigger.btn--secondary {
    background: #f8fafc;
    color: var(--text-primary);
    border-color: #cbd5e1;
}

.controls .period-picker__trigger.btn--secondary:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.period-picker__popover {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 200;
    min-width: 0;
    padding: 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06);
    overflow: hidden;
}

.period-picker__popover--open {
    z-index: 1200;
}

.period-picker__popover--month {
    width: 284px;
    padding: 14px;
}

.period-picker__popover--quarter {
    width: 280px;
    padding: 14px;
}

.period-picker__popover--year {
    width: 156px;
    padding: 10px 8px 12px;
}

.period-picker__popover[hidden] {
    display: none !important;
}

/* Reset toolbar button styles inside popovers */
.controls .period-picker__popover button {
    background: transparent;
    color: inherit;
    border: none;
    font-weight: inherit;
    line-height: inherit;
}

.period-picker__panel-head {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 12px;
}

.period-picker__panel-head--compact {
    margin-bottom: 8px;
    padding: 0 6px;
}

.period-picker__panel-kicker {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #94a3b8;
}

.period-picker__panel-title {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
}

.period-picker__month-cal {
    min-width: 252px;
}

.period-picker__month-cal .side-cal__grid {
    min-height: 216px;
}

.period-picker__month-cal .side-cal__header {
    margin-bottom: 10px;
}

.period-picker__month-cal .side-cal__title {
    font-size: 16px;
}

.period-picker__month-cal .side-cal__nav button {
    width: 30px;
    height: 30px;
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 8px;
    color: #64748b;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.period-picker__month-cal .side-cal__nav button:hover {
    background: #f8fafc;
    color: #0f172a;
    border-color: #cbd5e1;
}

.period-picker__month-cal .side-cal__day {
    border-radius: 8px;
}

.period-picker__month-apply {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 10px 12px;
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.25);
}

.period-picker__month-apply:hover {
    filter: brightness(1.04);
}

.side-cal__day.workload-tier-low { background: #ecfdf5; }
.side-cal__day.workload-tier-normal { background: #eff6ff; }
.side-cal__day.workload-tier-high { background: #fff7ed; }
.side-cal__day.workload-tier-overload { background: #fef2f2; }
.side-cal__day.workload-tier-none { background: #f8fafc; color: #94a3b8; }

.period-picker__error {
    grid-column: 1 / -1;
    padding: 24px 8px;
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
}

.period-picker__year-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
    padding: 8px 10px;
    border-radius: 10px;
    background: #f8fafc;
}

.period-picker__year-nav button {
    width: 30px;
    height: 30px;
    border: 1px solid #e2e8f0 !important;
    background: #fff !important;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font);
}

.period-picker__year-nav button:hover {
    background: #eff6ff !important;
    color: #2563eb;
    border-color: #bfdbfe !important;
}

.period-picker__year-label {
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
}

.period-picker__quarters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.period-picker__quarter {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 72px;
    padding: 12px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    cursor: pointer;
    font-family: var(--font);
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}

.period-picker__quarter:hover {
    border-color: #93c5fd;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.1);
    background: #fff;
    transform: translateY(-1px);
}

.period-picker__quarter-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #eff6ff;
    font-size: 15px;
    font-weight: 700;
    color: #2563eb;
}

.period-picker__quarter-range {
    font-size: 11px;
    color: #64748b;
}

.period-picker__year-panel {
    width: 100%;
}

.period-picker__year-wheel-wrap {
    position: relative;
    border-radius: 12px;
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 50%, #f8fafc 100%);
    padding: 4px 0;
}

.period-picker__year-wheel-wrap::before,
.period-picker__year-wheel-wrap::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 28px;
    pointer-events: none;
    z-index: 1;
}

.period-picker__year-wheel-wrap::before {
    top: 0;
    background: linear-gradient(to bottom, #fff 10%, transparent);
    border-radius: 12px 12px 0 0;
}

.period-picker__year-wheel-wrap::after {
    bottom: 0;
    background: linear-gradient(to top, #fff 10%, transparent);
    border-radius: 0 0 12px 12px;
}

.period-picker__year-wheel {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 208px;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    padding: 16px 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.period-picker__year-wheel::-webkit-scrollbar {
    width: 4px;
}

.period-picker__year-wheel::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

.period-picker__year-item {
    flex-shrink: 0;
    scroll-snap-align: center;
    width: 100%;
    padding: 7px 10px;
    border: none;
    border-radius: 10px;
    background: transparent;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font);
    color: #94a3b8;
    text-align: center;
    transition: color 0.12s, font-size 0.12s, background 0.12s;
}

.period-picker__year-item:hover {
    color: #475569;
    background: rgba(148, 163, 184, 0.08);
}

.period-picker__year-item.is-selected {
    background: #eff6ff;
    color: #2563eb;
    font-size: 22px;
    font-weight: 700;
    box-shadow: inset 0 0 0 1px #bfdbfe;
}

/* ── Auth pages ── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(160deg, #0f2d52 0%, #1a4a7a 45%, #eef2f7 45%);
}

.auth-shell {
    width: 100%;
    max-width: 560px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    color: #fff;
    margin-bottom: 20px;
}

.auth-brand__logo {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b82f6, #0d9488);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
}

.auth-brand__title {
    font-size: 20px;
    font-weight: 700;
}

.auth-brand__subtitle {
    font-size: 13px;
    opacity: 0.85;
    margin-top: 2px;
}

.auth-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
}

.auth-card--wide {
    max-width: 640px;
}

.auth-card__title {
    margin: 0 0 8px;
    font-size: 24px;
}

.auth-card__hint {
    margin: 0 0 20px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

.auth-card__footer {
    margin: 20px 0 0;
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-card__footer a {
    color: var(--accent);
    font-weight: 500;
}

.auth-form__submit {
    width: 100%;
    margin-top: 4px;
}

.auth-form--grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
}

.auth-form__full {
    grid-column: 1 / -1;
}

.auth-alert {
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.45;
    margin-bottom: 16px;
}

.auth-alert--error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.auth-alert--success {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.auth-alert--info {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    word-break: break-all;
}

.site-header__user {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.site-header__user-name {
    color: #fff;
    font-size: var(--text-sm);
    font-weight: 500;
}

.site-header__logout {
    color: rgba(255, 255, 255, 0.75);
    font-size: var(--text-xs);
}

.site-header__logout:hover {
    color: #fff;
}

/* ── Admin ── */
.admin-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.admin-tabs__link {
    padding: 8px 14px;
    border-radius: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    font-size: 14px;
    font-weight: 500;
}

.admin-tabs__link.is-active {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.card__body--flush .data-table td {
    vertical-align: top;
}

.empty-cell {
    text-align: center;
    color: var(--text-secondary);
    padding: 24px !important;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.badge--success { background: #ecfdf5; color: #047857; }
.badge--warning { background: #fffbeb; color: #b45309; }
.badge--muted { background: #f1f5f9; color: #64748b; }

.admin-approve-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 180px;
}

.admin-role-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.admin-role-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.admin-user-details {
    margin-bottom: 8px;
}

.admin-user-details summary {
    list-style: none;
    cursor: pointer;
    display: inline-block;
}

.admin-user-details summary::-webkit-details-marker {
    display: none;
}

.admin-approve-form--edit {
    margin-top: 10px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
}

.admin-action-row {
    margin-top: 8px;
}

.admin-deactivate-form {
    margin-top: 4px;
}

.admin-muted-note {
    font-size: 12px;
}

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

.admin-matrix-wrap {
    overflow-x: auto;
}

.admin-matrix {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 720px;
}

.admin-matrix th,
.admin-matrix td {
    border: 1px solid var(--border);
    padding: 8px 10px;
}

.admin-matrix__section td {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-secondary);
}

.admin-matrix__cell {
    text-align: center;
}

.admin-matrix__toggle {
    min-width: 36px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    color: #94a3b8;
}

.admin-matrix__toggle.is-on {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #2563eb;
    font-weight: 700;
}

@media (max-width: 640px) {
    .auth-form--grid {
        grid-template-columns: 1fr;
    }
}

/* ── Therapy progress list (home + analytics) ── */
.therapy-progress-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.therapy-progress-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    align-items: center;
    font-size: 11px;
    color: #64748b;
}
.therapy-progress-legend__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.therapy-progress-legend__swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    flex-shrink: 0;
}
.therapy-progress-legend__state {
    width: 14px;
    height: 10px;
    border-radius: 2px;
    border: 1px solid #94a3b8;
    flex-shrink: 0;
}
.therapy-progress-legend__state--done {
    background: #2563eb;
    border-color: #1d4ed8;
}
.therapy-progress-legend__state--planned {
    background: #e2e8f0;
    border-color: #cbd5e1;
}
.therapy-progress-scale-block {
    width: 100%;
    overflow-x: auto;
}
.therapy-progress-legend--in-scroll {
    flex-shrink: 0;
}
.therapy-progress-table {
    width: auto;
    max-width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
.therapy-progress-col-info {
    width: var(--therapy-info-width, 300px);
}
.therapy-progress-col-count {
    width: 72px;
}
.therapy-progress-col-track {
    width: var(--therapy-track-width, 560px);
}
.therapy-progress-row td {
    padding: 10px 0;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
}
.therapy-progress-row--last td,
.therapy-progress-axis-row td {
    border-bottom: none;
}
.therapy-progress-row__info {
    padding-right: 16px;
    min-width: 0;
}
.therapy-progress-row__count {
    padding-right: 12px;
    text-align: right;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.therapy-progress-row__track-scale {
    border-left: 2px solid #94a3b8;
    padding-left: 0;
    width: var(--therapy-track-width, 560px);
}
.therapy-progress-row__track {
    display: flex;
    height: 28px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-left: none;
    border-radius: 0 6px 6px 0;
    background: #f8fafc;
    max-width: 100%;
    margin-right: auto;
}
.therapy-progress-row__track-scale--axis {
    padding-top: 2px;
    padding-bottom: 0;
}
.therapy-progress-row__head {
    display: block;
}
.therapy-progress-row__link {
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    cursor: pointer;
    text-align: left;
}
.therapy-progress-row__link:hover,
.therapy-progress-row__link:focus-visible {
    color: #2563eb;
    text-decoration: underline;
    outline: none;
}
.therapy-progress-row__name {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
}
.therapy-progress-row__progress {
    display: none;
}
.therapy-progress-row__meta {
    margin: 3px 0 0;
    font-size: 11px;
    line-height: 1.35;
    color: #64748b;
}
.therapy-progress-axis__scale {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-width: 0;
    padding: 0 1px;
    font-size: 10px;
    line-height: 1;
    color: #94a3b8;
    font-variant-numeric: tabular-nums;
    user-select: none;
}
.therapy-progress-axis__tick--mid {
    flex: 1;
    text-align: center;
}
.therapy-progress-seg {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 6px;
    height: 100%;
    box-sizing: border-box;
    border-right: 1px solid rgba(255, 255, 255, 0.55);
    font-size: 11px;
    font-weight: 700;
    color: #0f172a;
}
.therapy-progress-seg:last-child {
    border-right: none;
}
.therapy-progress-seg--planned {
    background-color: #e2e8f0;
    color: #475569;
}
.active-cycles-card__header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.therapy-view-toggle {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.is-hidden {
    display: none !important;
}

/* ── Responsive shell (phone / tablet / desktop) ── */
@media (max-width: 768px) {
    .site-header {
        flex-wrap: wrap;
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .site-header__brand {
        flex: 1 1 180px;
        min-width: 0;
    }

    .site-header__title {
        max-width: none;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .site-header__meta {
        flex-shrink: 0;
        font-size: var(--text-xs);
    }

    #header-updated {
        display: none;
    }

    .site-tabs__link {
        min-height: var(--touch-min);
        display: inline-flex;
        align-items: center;
    }

    .btn {
        min-height: var(--touch-min);
    }

    .card__header {
        align-items: flex-start;
    }

    .card__header > .btn {
        width: 100%;
        justify-content: center;
    }

    .home-section__header {
        flex-direction: column;
        align-items: stretch;
    }

    .home-calendar-nav {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .page-title {
        font-size: var(--text-xl);
    }

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

    .admin-tabs__link {
        font-size: var(--text-sm);
    }
}

@media (max-width: 480px) {
    .site-header__logo {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .site-header__user-name {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .kpi-card__value {
        font-size: clamp(24px, 8vw, 32px);
    }
}

@media (min-width: 1025px) and (min-height: 800px) {
    .page-title {
        font-size: var(--text-2xl);
    }
}

@media (max-width: 900px) {
    :root {
        --tbl-col-name: 21%;
        --tbl-col-regimen: 26%;
        --tbl-col-doctor: 10%;
        --tbl-col-status: 12%;
    }

    .schedule-table,
    .data-table {
        min-width: 580px;
    }
}

@media (max-width: 640px) {
    :root {
        --tbl-col-num: 4%;
        --tbl-col-id: 9%;
        --tbl-col-name: 23%;
        --tbl-col-regimen: 27%;
    }

    .schedule-table,
    .data-table {
        min-width: 520px;
    }

    .schedule-table--layout-home .col-notes,
    .schedule-table--layout-home th.col-notes,
    .schedule-table--layout-home td.col-notes {
        display: none;
    }

    .schedule-table--layout-patients .col-date,
    .schedule-table--layout-patients th.col-date,
    .schedule-table--layout-patients td.col-date {
        display: none;
    }
}

@media (pointer: coarse) {
    .site-tabs__link,
    .btn,
    .day-filter-chip,
    .journal-cell-editable {
        min-height: var(--touch-min);
    }
}
