:root {
    --page: #f4f8f7;
    --surface: #ffffff;
    --surface-soft: #edf6f4;
    --surface-muted: #f6f9f9;
    --text: #102a35;
    --muted: #60747c;
    --line: #d7e3e5;
    --line-strong: #bfd2d5;
    --primary: #087f78;
    --primary-dark: #075f5b;
    --primary-soft: #d9f1ed;
    --navy: #0d3441;
    --blue: #2563eb;
    --violet: #6d4aff;
    --success: #198754;
    --success-soft: #e0f5e9;
    --warning: #a65b00;
    --warning-soft: #fff0d5;
    --danger: #b42318;
    --danger-soft: #ffebe8;
    --shadow-sm: 0 8px 24px rgba(22, 60, 72, 0.07);
    --shadow: 0 18px 48px rgba(22, 60, 72, 0.1);
    --radius-sm: 12px;
    --radius: 18px;
    --radius-lg: 24px;
    --header-height: 76px;
    --sidebar-width: 244px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--page);
    color-scheme: light;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at 82% 6%, rgba(55, 181, 165, 0.1), transparent 24rem),
        radial-gradient(circle at 25% 100%, rgba(37, 99, 235, 0.05), transparent 28rem),
        var(--page);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.55;
    text-rendering: optimizeLegibility;
}

a {
    color: var(--primary-dark);
    text-underline-offset: 3px;
}

a:hover {
    color: var(--primary);
}

a:focus-visible,
button:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(8, 127, 120, 0.38);
    outline-offset: 3px;
}

button,
input,
select,
textarea {
    min-width: 0;
    font: inherit;
}

button,
summary,
select {
    cursor: pointer;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1,
h2,
h3,
strong {
    color: var(--text);
}

h1 {
    margin-bottom: 8px;
    font-size: clamp(2rem, 4vw, 2.75rem);
    line-height: 1.08;
    letter-spacing: -0.045em;
}

h2 {
    margin-bottom: 14px;
    font-size: clamp(1.3rem, 2.5vw, 1.65rem);
    line-height: 1.2;
    letter-spacing: -0.025em;
}

h3 {
    margin-bottom: 10px;
    font-size: 1.05rem;
}

code {
    padding: 2px 6px;
    border-radius: 6px;
    background: #e7eeee;
    font-size: 0.88em;
}

.top-header {
    position: sticky;
    z-index: 100;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 32px;
    border-bottom: 1px solid rgba(191, 210, 213, 0.78);
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 4px 18px rgba(22, 60, 72, 0.035);
    backdrop-filter: blur(18px);
}

.brand {
    display: inline-flex;
    gap: 12px;
    align-items: center;
    color: var(--navy);
    text-decoration: none;
}

.brand:hover {
    color: var(--navy);
}

.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    overflow: hidden;
    border-radius: 14px;
    box-shadow: 0 9px 20px rgba(8, 127, 120, 0.22);
}

.brand-mark img {
    display: block;
    width: 100%;
    height: 100%;
}

.brand-copy {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.brand-copy strong {
    font-size: 1.08rem;
    letter-spacing: -0.02em;
}

.brand-copy small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.71rem;
    font-weight: 650;
    letter-spacing: 0.02em;
}

.user-menu {
    display: flex;
    gap: 20px;
    align-items: center;
}

.user-menu form {
    margin: 0;
}

.user-name {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 650;
}

.link-button {
    padding: 8px 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--primary-dark);
    font-weight: 750;
}

.link-button:hover {
    background: var(--primary-soft);
}

.desktop-nav {
    position: fixed;
    z-index: 80;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    display: flex;
    width: var(--sidebar-width);
    flex-direction: column;
    gap: 6px;
    padding: 30px 20px 24px;
    border-right: 1px solid var(--line);
    background: rgba(238, 246, 245, 0.9);
    backdrop-filter: blur(12px);
}

.nav-caption {
    margin: 0 12px 8px;
    color: #789097;
    font-size: 0.68rem;
    font-weight: 850;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.desktop-nav > a {
    display: flex;
    gap: 12px;
    align-items: center;
    min-height: 48px;
    padding: 9px 12px;
    border-radius: 14px;
    color: #304d57;
    font-size: 0.94rem;
    font-weight: 720;
    text-decoration: none;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.desktop-nav > a:hover {
    background: rgba(255, 255, 255, 0.8);
    color: var(--primary-dark);
    transform: translateX(2px);
}

.desktop-nav > a.is-active {
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    color: var(--primary-dark);
}

.nav-icon {
    display: grid;
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.66);
    color: var(--primary-dark);
    font-size: 0.94rem;
}

.is-active .nav-icon {
    border-color: transparent;
    background: var(--primary-soft);
}

.nav-support {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: auto;
    padding: 15px;
    border: 1px solid #cfe5e2;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.66);
}

.nav-support strong {
    color: var(--primary-dark);
    font-size: 0.76rem;
}

.nav-support span {
    color: var(--muted);
    font-size: 0.72rem;
    line-height: 1.45;
}

.page-shell {
    width: min(100%, 1240px);
    margin: 0 auto;
    padding: 38px 32px 64px;
}

.has-navigation .page-shell {
    width: min(calc(100% - var(--sidebar-width)), 1240px);
    margin-left: max(var(--sidebar-width), calc((100% - 996px) / 2));
}

.auth-layout .page-shell {
    display: grid;
    min-height: calc(100vh - var(--header-height));
    place-items: center;
    padding-top: 48px;
    padding-bottom: 72px;
}

.card {
    margin-bottom: 24px;
    padding: clamp(22px, 3vw, 30px);
    border: 1px solid rgba(205, 221, 223, 0.9);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.93);
    box-shadow: var(--shadow-sm);
}

.narrow-card,
.auth-card {
    width: min(100%, 620px);
}

.auth-card {
    padding: clamp(28px, 5vw, 42px);
    box-shadow: var(--shadow);
}

.auth-card h1 {
    font-size: clamp(2rem, 6vw, 2.65rem);
}

.auth-link {
    margin: 24px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
    overflow-wrap: anywhere;
    text-align: center;
}

.eyebrow {
    margin-bottom: 8px;
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 850;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.muted,
.page-heading p,
.date-heading p {
    color: var(--muted);
}

.page-heading,
.section-heading,
.date-heading {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: space-between;
}

.page-heading {
    margin-bottom: 28px;
}

.page-heading p,
.date-heading p {
    margin-bottom: 0;
}

.section-heading {
    margin-bottom: 18px;
}

.section-heading h2,
.section-heading h3,
.date-heading h1 {
    margin-bottom: 0;
}

.date-heading {
    width: min(100%, 620px);
    margin: 0 auto 28px;
    text-align: center;
}

.date-heading h1 {
    font-variant-numeric: tabular-nums;
}

.date-heading .eyebrow {
    margin-bottom: 4px;
}

.date-heading a:not(.date-arrow) {
    color: var(--muted);
    font-size: 0.8rem;
}

.date-arrow,
.month-switch a {
    display: grid;
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    color: var(--primary-dark);
    font-size: 1.65rem;
    line-height: 1;
    text-decoration: none;
}

.date-arrow:hover,
.month-switch a:hover {
    border-color: #93c8c2;
    background: var(--primary-soft);
}

.month-switch {
    display: flex;
    gap: 10px;
    align-items: center;
}

.month-switch strong {
    min-width: 74px;
    text-align: center;
}

.stack-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form-grid {
    display: grid;
    gap: 16px;
}

.form-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.span-2 {
    grid-column: span 2;
}

.span-3 {
    grid-column: span 3;
}

label {
    display: flex;
    flex-direction: column;
    gap: 7px;
    color: #294852;
    font-size: 0.82rem;
    font-weight: 750;
}

input,
select,
textarea {
    width: 100%;
    min-height: 48px;
    padding: 11px 13px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    outline: none;
    background: #fff;
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 520;
    transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

textarea {
    min-height: 82px;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: #94a5aa;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #53aaa2;
    box-shadow: 0 0 0 4px rgba(8, 127, 120, 0.11);
}

input[type="checkbox"],
input[type="radio"] {
    width: 20px;
    min-height: 20px;
    padding: 0;
    accent-color: var(--primary);
}

.readonly-field {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 48px;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
    color: var(--text);
    font-weight: 720;
}

.field-hint {
    margin: -8px 0 0;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 520;
}

.button {
    display: inline-flex;
    width: fit-content;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    padding: 11px 18px;
    border: 1px solid transparent;
    border-radius: 13px;
    font-size: 0.9rem;
    font-weight: 800;
    text-decoration: none;
    transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button-primary {
    background: linear-gradient(145deg, #0a9389, #08736d);
    box-shadow: 0 10px 22px rgba(8, 127, 120, 0.19);
    color: #fff;
}

.button-primary:hover {
    box-shadow: 0 13px 26px rgba(8, 127, 120, 0.25);
    color: #fff;
}

.button-secondary {
    border-color: #b8d7d3;
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.button-secondary:hover {
    background: #c9ebe6;
}

.button-quiet {
    border-color: var(--line);
    background: var(--surface);
    color: var(--primary-dark);
}

.button-quiet:hover {
    border-color: #b8d7d3;
    background: var(--surface-soft);
}

.button-small {
    min-height: 38px;
    padding: 8px 13px;
    font-size: 0.78rem;
    white-space: nowrap;
}

.icon-button {
    display: grid;
    width: 44px;
    min-width: 44px;
    height: 44px;
    place-items: center;
    border: 1px solid #efcbc6;
    border-radius: 12px;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 1.25rem;
}

.alert,
.notice,
.safety-strip {
    margin-bottom: 20px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    color: #38545d;
    font-size: 0.88rem;
}

.alert-success {
    border-color: #bde4cd;
    background: var(--success-soft);
    color: #136b43;
}

.alert-danger,
.alert-error {
    border-color: #f3c5bf;
    background: var(--danger-soft);
    color: var(--danger);
}

.notice {
    border-color: #cfe4e2;
    background: #eff8f6;
}

.notice.notice-warning {
    border-color: #efd09a;
    background: var(--warning-soft);
    color: #74420a;
}

.safety-strip {
    display: flex;
    gap: 8px;
    align-items: center;
    border-color: #f0d5a6;
    background: var(--warning-soft);
    color: #714313;
}

.safety-strip a {
    color: #714313;
    font-weight: 850;
}

.badge,
.status,
.time-pill {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    white-space: nowrap;
    font-size: 0.72rem;
    font-weight: 850;
}

.badge {
    padding: 6px 10px;
}

.badge-primary {
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.badge-warning {
    margin-left: 4px;
    background: var(--warning-soft);
    color: var(--warning);
}

.status {
    padding: 6px 10px;
    background: #e9eff0;
    color: #526970;
}

.status-completed {
    background: var(--success-soft);
    color: #157044;
}

.status-skipped,
.status-cancelled,
.status-interrupted {
    background: var(--warning-soft);
    color: var(--warning);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.metric-card {
    position: relative;
    min-height: 118px;
    overflow: hidden;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-sm);
}

.metric-card::after {
    position: absolute;
    right: -20px;
    bottom: -30px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--primary-soft);
    content: "";
    opacity: 0.6;
}

.metric-card span {
    display: block;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 750;
}

.metric-card strong {
    position: relative;
    z-index: 1;
    font-size: clamp(1.28rem, 2.2vw, 1.65rem);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
}

details.card {
    padding: 0;
    overflow: hidden;
}

details.card > summary {
    display: flex;
    min-height: 68px;
    align-items: center;
    padding: 20px 26px;
    list-style: none;
    color: var(--text);
    font-weight: 800;
}

details.card > summary::-webkit-details-marker {
    display: none;
}

details.card > summary::before {
    margin-right: 12px;
    color: var(--primary);
    content: "›";
    font-size: 1.45rem;
    line-height: 1;
    transition: transform 150ms ease;
}

details.card[open] > summary {
    border-bottom: 1px solid var(--line);
}

details.card[open] > summary::before {
    transform: rotate(90deg);
}

details.card > form,
details.card > .notice {
    margin: 24px 26px 26px;
}

.top-space {
    margin-top: 18px;
}

.planned-exchanges-section {
    margin-bottom: 32px;
}

.timeline {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.exchange-card {
    margin-bottom: 0;
}

.exchange-card > summary {
    display: grid !important;
    grid-template-columns: auto auto 1fr auto;
    gap: 14px;
}

.exchange-card > summary::before {
    align-self: center;
    margin-right: 0 !important;
}

.time-pill {
    min-width: 66px;
    padding: 7px 11px;
    background: var(--navy);
    color: #fff;
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

.exchange-summary {
    display: flex;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
}

.exchange-summary strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.exchange-summary small {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 620;
}

.exchange-form {
    padding-top: 2px;
}

.entry-delete-form {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.compact-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.compact-list > div {
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    padding: 13px 0;
    border-bottom: 1px solid var(--line);
}

.compact-list > div:last-child {
    border-bottom: 0;
}

.compact-list span {
    color: var(--muted);
}

.compact-entry-copy {
    display: flex;
    min-width: 0;
    gap: 16px;
    align-items: center;
}

.empty-state {
    padding: 44px 30px;
    text-align: center;
}

.empty-state .button {
    margin: 8px auto 0;
}

.lab-chart-card {
    overflow: hidden;
}

.chart-heading {
    align-items: flex-start;
}

.button-compact {
    min-height: 42px;
    padding: 9px 15px;
}

.chart-filter-form {
    display: grid;
    grid-template-columns: minmax(220px, 1.7fr) repeat(2, minmax(145px, 0.75fr));
    gap: 12px;
    align-items: end;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface-muted);
}

.chart-filter-footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin: 10px 2px 22px;
    color: var(--muted);
    font-size: 0.78rem;
}

.chart-range-links {
    display: flex;
    gap: 14px;
}

.chart-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.chart-summary > div {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
    padding: 12px 14px;
    border: 1px solid #d5e8e5;
    border-radius: 14px;
    background: var(--surface-soft);
}

.chart-summary span {
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 750;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.chart-summary strong {
    overflow: hidden;
    font-size: 1rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chart-summary small {
    color: var(--muted);
    font-size: 0.72em;
    font-weight: 700;
}

.chart-canvas-wrap {
    position: relative;
    height: 380px;
    padding: 18px 8px 4px 0;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
}

.chart-note {
    margin: 12px 2px 0;
    color: var(--muted);
    font-size: 0.78rem;
}

.chart-alert {
    margin-top: 18px;
}

.chart-empty-state {
    margin-top: 18px;
    border: 1px dashed var(--line-strong);
    border-radius: 16px;
    background: var(--surface-muted);
}

.chart-empty-state p {
    margin: 5px 0 0;
    color: var(--muted);
}

.report-export-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(150px, 1fr));
    gap: 14px;
    align-items: end;
    margin-top: 20px;
}

.report-series-fieldset {
    min-width: 0;
    margin: 0;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface-muted);
}

.report-series-fieldset legend {
    padding: 0 8px;
    color: var(--text);
    font-weight: 800;
}

.report-series-fieldset h3 {
    margin: 18px 0 9px;
    color: var(--muted);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.report-series-fieldset h3:first-of-type {
    margin-top: 0;
}

.report-series-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.report-series-option {
    display: flex;
    min-width: 0;
    flex-direction: row;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    font-size: 0.82rem;
}

.report-series-option input {
    flex: 0 0 auto;
}

.report-series-option span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.report-builder-form > .button {
    align-self: flex-start;
}

.report-scope-note {
    margin: 18px 0 0;
}

.settings-action-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.settings-action-card .button {
    margin-top: auto;
}

.report-print-layout {
    min-width: 320px;
    background: #e8efef;
}

.report-print-layout .page-shell {
    width: min(100%, 1040px);
    margin: 0 auto;
    padding: 28px 24px 56px;
}

.report-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-bottom: 18px;
}

.report-document {
    padding: 42px 46px 34px;
    border: 1px solid #d5e1e2;
    border-radius: 18px;
    background: #fff;
    box-shadow: var(--shadow);
}

.report-document-header,
.report-section-heading,
.report-document-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.report-document-header {
    padding-bottom: 22px;
    border-bottom: 2px solid var(--primary);
}

.report-brand {
    display: flex;
    gap: 12px;
    align-items: center;
}

.report-brand > span {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    overflow: hidden;
    border-radius: 13px;
}

.report-brand > span img {
    display: block;
    width: 100%;
    height: 100%;
}

.report-brand div,
.report-generated,
.report-patient-grid > div {
    display: flex;
    flex-direction: column;
}

.report-brand small,
.report-generated span,
.report-patient-grid span {
    color: var(--muted);
    font-size: 0.7rem;
}

.report-generated {
    align-items: flex-end;
}

.report-title-block {
    padding: 30px 0 22px;
}

.report-title-block h1 {
    font-size: 2.25rem;
}

.report-title-block p:last-child {
    margin-bottom: 0;
    color: var(--muted);
}

.report-patient-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 30px;
}

.report-patient-grid > div {
    min-width: 0;
    gap: 3px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-muted);
}

.report-patient-grid strong {
    overflow-wrap: anywhere;
    font-size: 0.88rem;
}

.report-section {
    margin-top: 26px;
}

.report-section-heading {
    align-items: flex-end;
    margin-bottom: 12px;
}

.report-section-heading span {
    color: var(--primary);
    font-size: 0.68rem;
    font-weight: 850;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.report-section-heading h2 {
    margin: 2px 0 0;
    font-size: 1.3rem;
}

.report-section-heading > strong {
    color: var(--muted);
    font-size: 0.78rem;
}

.report-chart-canvas {
    height: 190px;
}

.report-message {
    padding: 18px;
    border: 1px dashed var(--line-strong);
    border-radius: 12px;
    background: var(--surface-muted);
    color: var(--muted);
    font-size: 0.86rem;
}

.report-chart-caption {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 0.72rem;
}

.report-document-footer {
    align-items: flex-end;
    margin-top: 32px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.7rem;
}

.report-document-footer p {
    max-width: 76%;
    margin-bottom: 0;
}

.report-document-footer span {
    font-weight: 800;
}

.plan-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.plan-row {
    display: grid;
    grid-template-columns: 120px minmax(180px, 1fr) minmax(160px, 0.7fr) 44px;
    gap: 12px;
    align-items: end;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface-muted);
}

.two-column {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
}

.two-column > .card {
    height: fit-content;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 15px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: 0.88rem;
}

th,
td {
    padding: 14px 15px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    background: var(--surface-muted);
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 850;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr:hover td {
    background: #fbfdfd;
}

.ocr-row {
    display: grid;
    grid-template-columns: 70px 145px minmax(180px, 1.25fr) minmax(120px, 1fr) minmax(120px, 1fr) minmax(120px, 1fr) 90px;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: var(--surface-muted);
    transition: opacity 0.2s ease;
}

.ocr-row.is-excluded {
    opacity: 0.48;
}

.scan-import-list {
    display: grid;
    gap: 12px;
}

.scan-import-row {
    display: grid;
    grid-template-columns: 70px 145px 120px 145px minmax(190px, 1fr) minmax(150px, auto);
    gap: 12px;
    align-items: end;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fbfdfd;
}

.scan-import-row.is-excluded {
    background: #f7f9f9;
}

.scan-include,
.scan-plan-match,
.scan-row-status {
    display: grid;
    gap: 6px;
}

.scan-include input {
    width: 22px;
    height: 22px;
}

.scan-plan-match span,
.scan-row-status small {
    color: var(--muted);
    font-size: 0.78rem;
}

.scan-warnings {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 12px;
    background: var(--warning-soft);
}

.scan-warnings ul {
    margin-bottom: 0;
}

.ocr-include input {
    margin-top: 8px;
}

.settings-grid {
    display: grid;
    grid-template-columns: minmax(280px, 0.85fr) minmax(360px, 1.15fr);
    gap: 22px;
    align-items: start;
}

.setup-steps {
    display: grid;
    gap: 11px;
    margin: 18px 0;
}

.setup-steps > div {
    display: grid;
    grid-template-columns: 34px 1fr;
    gap: 11px;
    align-items: start;
}

.setup-steps span {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 0.78rem;
    font-weight: 850;
}

.setup-steps p {
    margin: 5px 0 0;
}

.credential-delete-form {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.consent-row {
    display: grid;
    grid-template-columns: 22px 1fr;
    gap: 10px;
    align-items: start;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--surface-muted);
    font-weight: 600;
    line-height: 1.45;
}

.consent-row input {
    margin-top: 1px;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.file-upload-control {
    cursor: pointer;
}

.file-upload-surface {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    min-height: 64px;
    padding: 8px;
    border: 1px dashed #8fc8c2;
    border-radius: 15px;
    background: linear-gradient(135deg, #f6fbfa, #eef8f6);
    transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.file-upload-control:hover .file-upload-surface,
.file-upload-control:focus-within .file-upload-surface {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: 0 0 0 4px rgba(8, 127, 120, 0.09);
}

.file-upload-button {
    display: inline-flex;
    min-height: 46px;
    align-items: center;
    gap: 7px;
    padding: 10px 15px;
    border-radius: 11px;
    background: var(--primary);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 820;
    white-space: nowrap;
}

.file-upload-button > span {
    font-size: 1.15rem;
    line-height: 1;
}

.file-upload-summary {
    min-width: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 620;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ocr-processing {
    display: grid;
    grid-template-columns: 34px 1fr;
    gap: 12px;
    align-items: center;
    padding: 15px;
    border: 1px solid #b8d7d3;
    border-radius: 14px;
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.ocr-processing[hidden] {
    display: none;
}

.ocr-processing div {
    display: grid;
    gap: 3px;
}

.ocr-processing small {
    color: var(--muted);
    line-height: 1.4;
}

.processing-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(8, 127, 120, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: processing-spin 0.8s linear infinite;
}

@keyframes processing-spin {
    to { transform: rotate(360deg); }
}

button:disabled {
    cursor: wait;
    opacity: 0.72;
    transform: none;
}

.lab-result-list {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

.lab-result-item {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: var(--surface);
}

.lab-result-item > summary {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(150px, auto) auto;
    gap: 16px;
    align-items: center;
    padding: 15px 17px;
    cursor: pointer;
    list-style: none;
}

.lab-result-item > summary::-webkit-details-marker {
    display: none;
}

.lab-result-item > summary > span:first-child {
    display: grid;
    gap: 3px;
}

.lab-result-item > summary small {
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 600;
}

.lab-result-value {
    color: var(--text);
    text-align: right;
}

.lab-edit-label {
    color: var(--primary-dark);
    font-size: 0.75rem;
    font-weight: 800;
}

.lab-result-item[open] .lab-edit-label::after {
    content: ' ↑';
}

.lab-result-editor {
    display: grid;
    gap: 14px;
    padding: 18px;
    border-top: 1px solid var(--line);
    background: var(--surface-muted);
}

.lab-delete-form {
    padding-top: 13px;
    border-top: 1px solid var(--line);
}

.button-danger {
    border-color: #efcbc6;
    background: var(--danger-soft);
    color: var(--danger);
}

.button-danger:hover {
    background: #f8deda;
}

.calendar-card {
    overflow: hidden;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 9px;
}

.calendar-labels {
    margin-bottom: 10px;
}

.calendar-labels span {
    padding: 5px;
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 850;
    text-align: center;
    text-transform: uppercase;
}

.calendar-empty {
    min-height: 112px;
}

.calendar-day {
    display: flex;
    min-width: 0;
    min-height: 112px;
    flex-direction: column;
    gap: 5px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: #fff;
    color: var(--text);
    text-decoration: none;
    transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.calendar-day:hover {
    z-index: 2;
    border-color: #8fc5c0;
    box-shadow: var(--shadow-sm);
    color: var(--text);
    transform: translateY(-2px);
}

.calendar-day > strong {
    font-size: 1.02rem;
    font-variant-numeric: tabular-nums;
}

.calendar-plan-name {
    display: -webkit-box;
    max-width: 100%;
    overflow: hidden;
    color: var(--primary-dark);
    font-size: 0.68rem;
    font-weight: 780;
    line-height: 1.25;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.day-no_plan .calendar-plan-name {
    color: var(--muted);
}

.calendar-day.day-complete {
    background: #e5f6ec;
}

.calendar-day.day-partial {
    background: #fff4df;
}

.calendar-day.day-planned {
    background: #f0f5f5;
}

.calendar-day.is-today {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.calendar-day.has-plan-change {
    border: 2px solid var(--violet);
}

.calendar-day.has-lab-results {
    box-shadow: inset 0 -4px var(--blue);
}

.calendar-markers {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
    margin-top: auto;
    max-width: 100%;
}

.lab-result-marker {
    display: inline-flex;
    width: max-content;
    max-width: 100%;
    gap: 4px;
    overflow: hidden;
    padding: 3px 7px;
    border-radius: 999px;
    font-size: 0.62rem;
    font-weight: 850;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lab-result-marker {
    background: #e3edff;
    color: #1e4daf;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 20px;
    color: var(--muted);
    font-size: 0.74rem;
}

.legend span {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    background: #fff;
}

.legend-dot.day-complete {
    background: #bce7ce;
}

.legend-dot.day-partial {
    background: #ffdda1;
}

.legend-dot.day-planned {
    background: #dce7e8;
}

.legend-dot.plan-change-dot {
    border: 2px solid var(--violet);
    background: #eee9ff;
}

.legend-dot.lab-results-dot {
    border-color: var(--blue);
    background: #c9dcff;
}

.plan-version-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.plan-version-list a {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 16px;
    align-items: center;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-muted);
    color: var(--text);
    text-decoration: none;
}

.plan-version-list a:hover {
    border-color: #b2cecc;
    background: var(--primary-soft);
}

.plan-version-list time {
    color: #5636c4;
    font-weight: 850;
}

.plan-version-list span {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.plan-version-list small {
    color: var(--muted);
}

.plan-summary-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.plan-history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.plan-history-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 16px;
    align-items: center;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-muted);
}

.plan-history-row > div {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
}

.plan-history-row small {
    color: var(--muted);
}

.plan-name-form {
    width: min(100%, 620px);
}

.danger-zone {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 0.7fr);
    gap: 24px;
    margin-top: 26px;
    padding: 22px;
    border: 1px solid #efcbc6;
    border-radius: var(--radius-md);
    background: #fff8f7;
}

.danger-zone h3 {
    margin-bottom: 8px;
    color: var(--danger);
}

.danger-zone p:last-child {
    margin: 0;
    color: #72514e;
}

.danger-zone .stack-form {
    align-self: center;
    gap: 14px;
}

.medication-list {
    display: grid;
    gap: 10px;
}

.medication-item {
    display: grid;
    grid-template-columns: minmax(180px, 0.8fr) minmax(240px, 1.6fr);
    gap: 20px;
    align-items: center;
    padding: 15px 17px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #f8fbfb;
}

.medication-item strong {
    color: var(--ink);
}

.medication-item span {
    color: var(--muted);
    line-height: 1.5;
}

.medication-date-field {
    max-width: 320px;
}

.section-heading-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
}

.medication-items-heading {
    margin: 4px 0 0;
}

.medication-items-heading h3 {
    margin: 0;
}

.medication-form-list {
    display: grid;
    gap: 12px;
}

.medication-form-row {
    display: grid;
    grid-template-columns: minmax(180px, 0.8fr) minmax(260px, 1.4fr) auto;
    gap: 12px;
    align-items: end;
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: #f8fbfb;
}

.medication-remove {
    min-height: 48px;
}

.medication-empty-hint {
    margin: 0;
    padding: 14px 16px;
    border: 1px dashed #b9d2d2;
    border-radius: 14px;
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.medication-history-list {
    display: grid;
    gap: 10px;
}

.medication-history-item {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: #fff;
}

.medication-history-item > summary {
    display: flex;
    cursor: pointer;
    justify-content: space-between;
    padding: 16px 18px;
    color: var(--ink);
    font-weight: 800;
}

.medication-history-item > summary small {
    color: var(--muted);
    font-weight: 700;
}

.medication-history-item > .medication-list,
.medication-history-item > p {
    margin: 0 16px 16px;
}

.medication-history-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    margin: 0 16px 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.medication-list-compact .medication-item {
    padding: 12px 14px;
}

.mobile-nav {
    display: none;
}

@media (max-width: 1100px) {
    .chart-filter-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .form-grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .span-3 {
        grid-column: span 2;
    }

    .ocr-row {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .scan-import-row {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    :root {
        --header-height: 68px;
    }

    body.has-navigation {
        padding-bottom: 78px;
    }

    .top-header {
        padding: 0 20px;
    }

    .desktop-nav {
        display: none;
    }

    .has-navigation .page-shell,
    .page-shell {
        width: 100%;
        margin: 0;
        padding: 28px 20px 44px;
    }

    .mobile-nav {
        position: fixed;
        z-index: 120;
        right: 12px;
        bottom: 12px;
        left: 12px;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        padding: 7px;
        border: 1px solid rgba(191, 210, 213, 0.8);
        border-radius: 20px;
        background: rgba(255, 255, 255, 0.94);
        box-shadow: 0 18px 45px rgba(22, 60, 72, 0.17);
        backdrop-filter: blur(18px);
    }

    .mobile-nav.mobile-nav-compact {
        right: 12px;
        left: auto;
        width: min(220px, calc(100vw - 24px));
        grid-template-columns: 1fr;
    }

    .mobile-nav > a,
    .mobile-more > summary {
        display: flex;
        min-width: 0;
        flex-direction: column;
        gap: 2px;
        align-items: center;
        padding: 7px 2px;
        border-radius: 13px;
        color: var(--muted);
        font-size: 0.62rem;
        font-weight: 760;
        text-decoration: none;
        list-style: none;
    }

    .mobile-more > summary::-webkit-details-marker {
        display: none;
    }

    .mobile-nav > a > span,
    .mobile-more > summary > span {
        font-size: 1rem;
        line-height: 1.2;
    }

    .mobile-nav > a.is-active,
    .mobile-more > summary.is-active,
    .mobile-more[open] > summary {
        background: var(--primary-soft);
        color: var(--primary-dark);
    }

    .mobile-more {
        min-width: 0;
    }

    .mobile-more-menu {
        position: absolute;
        right: 0;
        bottom: calc(100% + 10px);
        display: grid;
        width: min(310px, calc(100vw - 24px));
        gap: 7px;
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 18px;
        background: rgba(255, 255, 255, 0.98);
        box-shadow: 0 18px 45px rgba(22, 60, 72, 0.22);
    }

    .mobile-more-menu > strong {
        padding: 3px 7px 7px;
        color: var(--muted);
        font-size: 0.72rem;
        letter-spacing: 0.08em;
        text-transform: uppercase;
    }

    .mobile-more-menu a {
        display: grid;
        grid-template-columns: 38px 1fr;
        gap: 10px;
        align-items: center;
        padding: 9px 10px;
        border-radius: 13px;
        color: #304d57;
        font-size: 0.9rem;
        font-weight: 760;
        text-decoration: none;
    }

    .mobile-more-menu a.is-active {
        background: var(--primary-soft);
        color: var(--primary-dark);
    }

    .mobile-more-menu .nav-icon {
        width: 34px;
        height: 34px;
    }

    .two-column,
    .settings-grid {
        grid-template-columns: 1fr;
    }

    .report-export-form {
        grid-template-columns: 1fr 1fr;
    }

}

@media (max-width: 700px) {
    .brand-copy small,
    .user-name {
        display: none;
    }

    .top-header {
        padding: 0 14px;
    }

    .brand-mark {
        width: 38px;
        height: 38px;
        border-radius: 12px 12px 12px 5px;
    }

    .page-shell,
    .has-navigation .page-shell {
        padding: 24px 14px 36px;
    }

    .card {
        margin-bottom: 18px;
        padding: 20px 18px;
        border-radius: 19px;
    }

    .auth-card {
        width: 100%;
        max-width: calc(100vw - 28px);
        padding: 28px 22px;
    }

    .page-heading {
        align-items: flex-start;
    }

    .page-heading,
    .section-heading {
        gap: 12px;
    }

    .metrics-grid {
        gap: 10px;
    }

    .metric-card {
        min-height: 102px;
        padding: 16px;
    }

    .form-grid-2,
    .form-grid-3,
    .ocr-row {
        grid-template-columns: 1fr;
    }

    .scan-import-row {
        grid-template-columns: 1fr;
    }

    .chart-filter-form {
        grid-template-columns: 1fr 1fr;
        padding: 14px;
    }

    .chart-filter-form label:first-of-type {
        grid-column: 1 / -1;
    }

    .chart-filter-footer {
        align-items: flex-start;
    }

    .chart-summary {
        grid-template-columns: 1fr 1fr;
    }

    .chart-summary > div:first-child {
        grid-column: 1 / -1;
    }

    .chart-canvas-wrap {
        height: 320px;
        margin-right: -8px;
        margin-left: -8px;
        border-right: 0;
        border-left: 0;
        border-radius: 0;
    }

    .report-print-layout .page-shell {
        padding: 14px 8px 32px;
    }

    .report-toolbar {
        display: grid;
        grid-template-columns: 1fr;
    }

    .report-toolbar .button {
        width: 100%;
    }

    .report-document {
        padding: 26px 20px;
        border-radius: 14px;
    }

    .report-patient-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .report-series-grid {
        grid-template-columns: 1fr;
    }

    .file-upload-surface {
        grid-template-columns: 1fr;
    }

    .file-upload-button {
        justify-content: center;
    }

    .file-upload-summary {
        padding: 2px 8px 5px;
        text-align: center;
    }

    .lab-result-item > summary {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px 12px;
    }

    .lab-result-value {
        grid-column: 1 / -1;
        grid-row: 2;
        text-align: left;
    }

    .lab-edit-label {
        grid-column: 2;
        grid-row: 1;
    }

    .span-2,
    .span-3 {
        grid-column: span 1;
    }

    .plan-row {
        grid-template-columns: 1fr 1fr;
    }

    .exchange-card > summary {
        grid-template-columns: auto auto 1fr !important;
    }

    .exchange-card .status {
        grid-column: 2 / -1;
        justify-self: start;
    }

    details.card > summary {
        padding: 18px;
    }

    details.card > form,
    details.card > .notice {
        margin: 20px 18px;
    }

    .calendar-card {
        padding: 16px 10px 18px;
    }

    .calendar-grid {
        gap: 4px;
    }

    .calendar-labels {
        margin-bottom: 6px;
    }

    .calendar-labels span {
        padding: 3px 0;
        font-size: 0.62rem;
    }

    .calendar-empty,
    .calendar-day {
        min-height: 76px;
    }

    .calendar-day {
        align-items: center;
        justify-content: space-between;
        gap: 2px;
        padding: 6px 2px 5px;
        border-radius: 10px;
    }

    .calendar-day > strong {
        font-size: 0.9rem;
        line-height: 1.2;
    }

    .calendar-plan-name {
        width: 100%;
        font-size: 0.48rem;
        line-height: 1.08;
        overflow-wrap: anywhere;
        text-align: center;
    }

    .calendar-markers {
        min-height: 13px;
        width: 100%;
        flex-direction: row;
        gap: 3px;
        align-items: center;
        justify-content: center;
        margin-top: 0;
    }

    .lab-result-marker {
        display: inline-flex;
        width: auto;
        height: auto;
        padding: 1px 3px;
        font-size: 0.42rem;
        line-height: 1.25;
    }

    .legend {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px 12px;
        margin-top: 16px;
        font-size: 0.67rem;
    }

    .plan-items-heading {
        flex-wrap: wrap;
    }

    .plan-items-heading .button {
        flex: 1 1 auto;
    }

    .plan-summary-heading {
        align-items: flex-start;
    }

    .plan-summary-actions {
        flex-direction: column;
        align-items: flex-end;
    }

    .plan-history-row {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 9px 12px;
        padding: 13px;
    }

    .plan-history-row > .muted {
        justify-self: end;
        font-size: 0.72rem;
    }

    .plan-history-row > .button {
        grid-column: 1 / -1;
        width: 100%;
    }

    .medication-item,
    .medication-form-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .medication-item {
        align-items: start;
        padding: 14px;
    }

    .medication-form-row {
        padding: 14px;
    }

    .medication-remove {
        width: 100%;
        min-height: 44px;
    }

    .medication-items-heading {
        align-items: center;
    }

    .medication-items-heading .button {
        flex: 0 0 auto;
    }

    .medication-history-item > summary {
        gap: 12px;
        padding: 14px;
    }

    .section-heading-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .section-heading-actions .button {
        width: 100%;
    }

    .medication-history-actions,
    .medication-history-actions form,
    .medication-history-actions .button {
        width: 100%;
    }

    .danger-zone {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 440px) {
    .compact-entry-copy {
        flex-direction: column;
        gap: 2px;
        align-items: flex-start;
    }

    .danger-zone {
        padding: 17px;
    }

    .danger-zone .button {
        width: 100%;
    }

    .brand-copy strong {
        font-size: 0.94rem;
    }

    .user-menu {
        gap: 4px;
    }

    .link-button {
        padding: 7px;
        font-size: 0.78rem;
    }

    .metrics-grid {
        grid-template-columns: 1fr 1fr;
    }

    .metric-card strong {
        font-size: 1.15rem;
    }

    .date-arrow,
    .month-switch a {
        width: 38px;
        height: 38px;
    }

    .month-switch {
        gap: 4px;
    }

    .page-heading {
        flex-direction: column;
    }

    .chart-heading {
        flex-direction: column;
    }

    .chart-heading .button {
        width: 100%;
    }

    .chart-filter-form {
        grid-template-columns: 1fr;
    }

    .chart-filter-form label,
    .chart-filter-form label:first-of-type {
        grid-column: 1;
    }

    .chart-filter-footer {
        flex-direction: column;
        gap: 4px;
    }

    .chart-range-links {
        flex-direction: column;
        gap: 4px;
    }

    .chart-canvas-wrap {
        height: 285px;
    }

    .report-export-form {
        grid-template-columns: 1fr;
    }

    .report-builder-form > .button {
        width: 100%;
    }

    .report-document-header {
        align-items: flex-start;
    }

    .report-generated {
        text-align: right;
    }

    .report-title-block h1 {
        font-size: 1.75rem;
    }

    .report-patient-grid {
        grid-template-columns: 1fr;
    }

    .report-document-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .report-document-footer p {
        max-width: none;
    }

    .calendar-heading {
        gap: 16px;
    }

    .calendar-heading .month-switch {
        width: 100%;
        justify-content: space-between;
    }

    .calendar-empty,
    .calendar-day {
        min-height: 72px;
    }

    .plan-row {
        position: relative;
        grid-template-columns: 1fr;
        padding: 16px 64px 16px 14px;
    }

    .plan-row .icon-button {
        position: absolute;
        top: 16px;
        right: 12px;
    }

    .plan-items-heading {
        align-items: stretch;
    }

    .plan-items-heading .button,
    .stack-form > .button-primary {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.access-invite-form {
    max-width: 620px;
}

.access-privacy-hint {
    margin: 16px 0 0;
}

.access-list,
.readonly-data-list {
    display: grid;
    gap: 12px;
}

.access-row {
    display: flex;
    gap: 18px;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface-soft);
}

.access-row > div:first-child,
.readonly-data-row {
    display: grid;
    gap: 4px;
}

.access-row span,
.access-row small,
.readonly-data-row small {
    color: var(--muted);
}

.access-row-link {
    color: inherit;
    text-decoration: none;
}

.access-row-link:hover {
    border-color: var(--primary);
}

.access-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.doctor-patient-heading {
    align-items: center;
}

.readonly-date-heading {
    margin-top: 24px;
}

.readonly-section {
    margin-top: 18px;
}

.readonly-data-row {
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.readonly-data-row:last-child {
    border-bottom: 0;
}

.readonly-key-values {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.readonly-key-values > div {
    display: grid;
    gap: 4px;
    padding: 14px;
    border-radius: 14px;
    background: var(--surface-soft);
}

.readonly-key-values span {
    color: var(--muted);
    font-size: .85rem;
}

@media (max-width: 720px) {
    .access-row,
    .doctor-patient-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .access-actions {
        width: 100%;
    }

    .access-actions form,
    .access-actions .button {
        flex: 1;
    }
}

.report-print-layout.report-print-preparing {
    min-width: 190mm;
}

.report-print-layout.report-print-preparing .page-shell,
.report-print-layout.report-print-preparing .report-document {
    width: 190mm;
    max-width: none;
    margin: 0;
    padding: 0;
}

.report-print-layout.report-print-preparing .report-chart-canvas {
    height: 190px;
    margin-right: 0;
    margin-left: 0;
}

.report-print-layout.report-print-preparing .report-toolbar {
    display: none;
}

@media print {
    @page {
        size: A4;
        margin: 10mm;
    }

    html,
    body.report-print-layout {
        min-width: 0;
        background: #fff;
    }

    body.report-print-layout {
        color: #102a35;
        font-size: 10pt;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .report-print-layout .page-shell {
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .report-toolbar {
        display: none !important;
    }

    .report-document {
        padding: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .report-title-block {
        padding: 18px 0 14px;
    }

    .report-title-block h1 {
        font-size: 22pt;
    }

    .report-patient-grid {
        margin-bottom: 18px;
    }

    .report-section {
        margin-top: 18px;
    }

    .report-chart-sheet,
    .report-chart-page,
    .report-message,
    .report-patient-grid > div {
        break-inside: avoid;
    }

    .report-chart-sheet:not(.is-first) {
        break-before: page;
    }

    .report-chart-canvas {
        height: 190px;
        margin-right: 0;
        margin-left: 0;
    }

    .report-document-footer {
        margin-top: 20px;
    }
}
