:root {
    --bg: #eef3f6;
    --surface: #ffffff;
    --surface-alt: #f6fafc;
    --ink: #17313a;
    --muted: #5f7580;
    --line: #d6e1e6;
    --accent: #0b5d7a;
    --accent-dark: #09475d;
    --warm: #d9853b;
    --success: #2f6b2f;
    --danger: #9f2f2f;
    --shadow: 0 16px 40px rgba(12, 43, 55, 0.08);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(11, 93, 122, 0.12), transparent 26%),
        linear-gradient(180deg, #f7fafb 0%, var(--bg) 100%);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

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

button,
input,
select,
textarea {
    font: inherit;
}

.container {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    overflow: visible;
    backdrop-filter: blur(18px);
    background: rgba(247, 250, 251, 0.92);
    border-bottom: 1px solid rgba(214, 225, 230, 0.9);
}

.topbar-inner,
.session-banner-inner,
.panel-grid,
.card-grid,
.two-column,
.toolbar,
.form-grid,
.summary-grid,
.rx-meta-grid,
.list-head {
    display: flex;
    gap: 16px;
}

.topbar-inner,
.session-banner-inner,
.toolbar,
.list-head {
    justify-content: space-between;
    align-items: center;
}

.topbar-inner {
    min-height: 78px;
    padding: 10px 0;
    overflow: visible;
}

.topbar-side {
    display: flex;
    align-items: center;
    gap: 18px;
}

.brand {
    display: inline-flex;
    gap: 16px;
    align-items: center;
}

.brand-mark {
    width: 132px;
    flex: 0 0 auto;
    display: block;
    margin-block: -14px;
}

.brand-mark img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

.brand-copy {
    display: grid;
    gap: 3px;
}

.brand strong,
.section-head h1,
.section-head h2,
.card strong,
.table-card h2,
.print-shell h1 {
    display: block;
}

.brand small,
.muted,
.section-note,
.card p,
.empty-state p,
.table-shell td small {
    color: var(--muted);
}

.brand strong {
    font-size: 1.22rem;
    line-height: 1.05;
}

.brand small {
    font-size: 0.93rem;
}

.nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.nav a {
    padding: 10px 14px;
    border-radius: 999px;
}

.nav a.active,
.nav a:hover {
    background: rgba(11, 93, 122, 0.1);
    color: var(--accent);
}

.nav-cta,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 0;
    cursor: pointer;
    border-radius: 12px;
    padding: 12px 16px;
    transition: 0.2s ease;
}

.btn-primary,
.nav-cta {
    color: #fff;
    background: linear-gradient(135deg, var(--accent) 0%, #0f748f 100%);
}

.btn-primary:hover,
.nav-cta:hover {
    background: linear-gradient(135deg, var(--accent-dark) 0%, var(--accent) 100%);
}

.btn-secondary {
    background: #eff6f9;
    color: var(--accent);
}

.btn-secondary:hover {
    background: #dcecf2;
}

.btn-light {
    background: #fff;
    border: 1px solid var(--line);
}

.page-shell {
    padding: 18px 0 120px;
}

.session-banner {
    padding: 10px 0 0;
}

.session-banner-inner {
    padding: 12px 18px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid var(--line);
}

.flash-stack {
    margin-top: 16px;
    display: grid;
    gap: 10px;
}

.flash {
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fff;
}

.flash-success {
    border-color: rgba(47, 107, 47, 0.25);
    color: var(--success);
}

.flash-error {
    border-color: rgba(159, 47, 47, 0.25);
    color: var(--danger);
}

.flash-warning {
    border-color: rgba(217, 133, 59, 0.35);
    color: #8b541f;
}

.section {
    padding: 22px 0;
}

.section-head {
    margin-bottom: 18px;
}

.eyebrow {
    display: inline-block;
    margin-bottom: 8px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 12px;
    font-weight: 700;
}

.panel-grid,
.card-grid,
.summary-grid,
.rx-meta-grid {
    flex-wrap: wrap;
}

.card-grid > *,
.summary-grid > *,
.rx-meta-grid > * {
    flex: 1 1 220px;
}

.card,
.table-card,
.auth-card,
.hero-card,
.print-shell {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card,
.table-card,
.auth-card,
.hero-card {
    padding: 22px;
}

.hero-card {
    margin-top: 28px;
    padding: 28px;
    display: grid;
    gap: 20px;
    background:
        linear-gradient(140deg, rgba(255, 255, 255, 0.98) 0%, rgba(245, 251, 253, 0.94) 100%);
}

.hero-actions,
.inline-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.metric-value {
    font-size: 34px;
    font-weight: 700;
}

.form-grid {
    flex-wrap: wrap;
}

.form-grid label,
.stack-form label {
    display: grid;
    gap: 8px;
    flex: 1 1 220px;
}

.stack-form,
.rx-lines,
.patient-list,
.prescription-list {
    display: grid;
    gap: 14px;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(11, 93, 122, 0.45);
    box-shadow: 0 0 0 4px rgba(11, 93, 122, 0.12);
}

input[list] {
    background-image:
        linear-gradient(45deg, transparent 50%, rgba(79, 115, 134, 0.9) 50%),
        linear-gradient(135deg, rgba(79, 115, 134, 0.9) 50%, transparent 50%);
    background-position:
        calc(100% - 18px) calc(50% - 2px),
        calc(100% - 12px) calc(50% - 2px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    padding-right: 34px;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

.table-shell {
    width: 100%;
    border-collapse: collapse;
}

.table-shell th,
.table-shell td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 999px;
    background: #eef6fa;
    color: var(--accent);
    font-size: 13px;
}

.patient-card,
.prescription-card,
.line-card {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface-alt);
}

.prescription-list-compact {
    max-height: min(72vh, 980px);
    overflow-y: auto;
    padding-right: 8px;
    scrollbar-gutter: stable;
}

.auth-shell {
    min-height: calc(100vh - 90px);
    display: grid;
    place-items: center;
}

.auth-card {
    width: min(520px, calc(100% - 32px));
}

.table-card {
    overflow: hidden;
}

.line-card .form-grid > * {
    min-width: 150px;
}

.line-card .wide {
    flex-basis: 100%;
}

.rx-form-toolbar {
    align-items: flex-end;
}

.rx-form-heading {
    margin-bottom: 0;
}

.rx-form-shell {
    gap: 18px;
}

.rx-form-card {
    position: relative;
    overflow: visible;
}

.rx-form-card::before {
    content: "";
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, rgba(11, 93, 122, 0.2), rgba(11, 93, 122, 0));
}

.rx-form-card-patient {
    background:
        radial-gradient(circle at top right, rgba(157, 200, 224, 0.2), transparent 34%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 251, 253, 0.96));
}

.rx-form-card-head {
    margin-bottom: 16px;
}

.rx-form-card-head .section-note,
.rx-form-card-notes .section-note {
    margin: 6px 0 0;
    max-width: 720px;
}

.rx-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(214, 225, 230, 0.95);
    background: rgba(247, 251, 253, 0.95);
    cursor: pointer;
    user-select: none;
    line-height: 1;
}

.rx-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
}

.rx-toggle-ui {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: #d4e0e6;
    transition: background-color 0.18s ease;
    flex: 0 0 auto;
    vertical-align: middle;
}

.rx-toggle-ui::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(12, 43, 55, 0.24);
    transition: transform 0.18s ease;
}

.rx-toggle input:checked + .rx-toggle-ui {
    background: rgba(11, 93, 122, 0.8);
}

.rx-toggle input:checked + .rx-toggle-ui::after {
    transform: translateX(18px);
}

.rx-form-grid {
    gap: 14px;
}

.rx-form-grid-patient label:first-child,
.rx-form-grid-patient label.patient-age-field {
    flex: 1 1 160px;
}

.rx-form-grid-patient label.patient-name-field,
.rx-form-grid-patient label.diagnosis-combobox {
    flex: 2 1 260px;
}

.patient-alert {
    margin-top: 14px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid rgba(217, 133, 59, 0.3);
    background: rgba(255, 247, 236, 0.96);
    color: #8b541f;
    font-weight: 600;
}

.diagnosis-combobox {
    position: relative;
}

.diagnosis-suggestions {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 20;
    display: grid;
    gap: 2px;
    max-height: 280px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid rgba(214, 225, 230, 0.98);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 18px 40px rgba(12, 43, 55, 0.12);
}

.diagnosis-suggestions[hidden] {
    display: none;
}

.diagnosis-suggestion {
    width: 100%;
    border: 0;
    border-radius: 12px;
    background: transparent;
    padding: 10px 12px;
    text-align: left;
    cursor: pointer;
    display: grid;
    gap: 4px;
}

.diagnosis-suggestion strong {
    color: var(--accent);
    font-size: 13px;
}

.diagnosis-suggestion span {
    color: #244452;
    font-size: 13px;
    line-height: 1.4;
}

.diagnosis-suggestion:hover,
.diagnosis-suggestion.is-active {
    background: rgba(11, 93, 122, 0.08);
}

.rx-lines-premium {
    gap: 16px;
}

.rx-line-editor {
    display: grid;
    gap: 14px;
}

.rx-line-toolbar {
    justify-content: center;
    margin-top: 4px;
}

.rx-line-editor-actions {
    justify-content: center;
}

.rx-line-error {
    margin: 0;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(161, 32, 32, 0.08);
    color: #8f1d1d;
    font-size: 14px;
    font-weight: 600;
}

.rx-line-card {
    display: grid;
    gap: 14px;
    padding: 18px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(242, 248, 251, 0.98));
    border: 1px solid rgba(214, 225, 230, 0.9);
    box-shadow: 0 10px 24px rgba(12, 43, 55, 0.05);
}

.rx-line-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.rx-line-card-head > div {
    display: grid;
    gap: 4px;
}

.rx-line-index {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 11px;
    font-weight: 700;
}

.rx-line-index::before {
    content: "";
    width: 24px;
    height: 1px;
    background: rgba(11, 93, 122, 0.35);
}

.rx-line-title {
    font-size: 18px;
    font-weight: 650;
    color: #244452;
}

.rx-form-grid-line {
    gap: 12px 14px;
}

.rx-form-grid-line-core label {
    min-width: 180px;
}

.rx-line-summary {
    margin-top: 18px;
}

.rx-line-summary-card {
    gap: 12px;
}

.rx-line-summary-actions {
    align-items: center;
}

.rx-line-prescription-preview {
    padding: 16px 18px;
    border-style: dashed;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 251, 253, 0.98));
}

.rx-line-preview {
    display: grid;
    gap: 6px;
}

.rx-line-preview-main {
    color: #244452;
    font-size: 17px;
    font-weight: 650;
    line-height: 1.35;
}

.rx-line-preview-detail {
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.rx-line-preview-instructions {
    color: #244452;
    font-size: 14px;
    line-height: 1.5;
}

.rx-line-summary-actions .btn {
    padding: 7px 10px;
    min-height: auto;
}

.rx-line-empty {
    margin-top: 18px;
}

.rx-inline-notes-toggle {
    margin-top: 18px;
}

.rx-general-notes-card {
    gap: 10px;
}

.rx-form-actions {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    z-index: 40;
    justify-content: center;
    padding: 14px 16px;
    border: 1px solid rgba(214, 225, 230, 0.95);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
    box-shadow: 0 14px 30px rgba(12, 43, 55, 0.08);
}

.empty-state {
    padding: 30px;
    text-align: center;
}

.panel-snapshot-card {
    background:
        radial-gradient(circle at top right, rgba(157, 200, 224, 0.18), transparent 34%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 251, 253, 0.96));
}

.patient-glance-list {
    gap: 12px;
}

.patient-glance-card {
    display: grid;
    gap: 10px;
}

.print-page {
    position: relative;
    isolation: isolate;
    padding: 5mm 0 0;
    background: linear-gradient(180deg, #f6fbfe 0%, #e8f1f8 50%, #f8fbfd 100%);
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto;
    overflow: hidden;
}

.print-decor {
    display: block;
    position: absolute;
    z-index: 0;
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    height: 65.52mm;
    top: auto;
    bottom: 0;
    pointer-events: none;
    opacity: 0.42;
    overflow: hidden;
}

.print-decor img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    max-width: none;
}

.print-decor-left {
    left: -5mm;
    bottom: -12mm;
    width: 86mm;
}

.print-decor-right {
    justify-content: flex-end;
    width: 56mm;
    right: -3mm;
    bottom: -2mm;
}

.print-decor-left img {
    object-position: left bottom;
}

.print-decor-right img {
    object-position: right bottom;
}

.rx-sheet {
    position: relative;
    --fit-scale: 1;
    width: min(210mm, 100vw);
    height: 143.5mm;
    margin: 0 auto;
    padding: calc(5.8mm * var(--fit-scale)) calc(6.2mm * var(--fit-scale)) calc(6mm * var(--fit-scale));
    color: #465f76;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    page-break-inside: avoid;
}

.rx-sheet::before,
.rx-sheet::after {
    content: "";
    position: absolute;
    pointer-events: none;
    opacity: 0.42;
}

.rx-sheet::before {
    top: calc(30mm * var(--fit-scale));
    bottom: calc(7mm * var(--fit-scale));
    left: calc(50% - 0.15mm);
    width: 0.3mm;
    background: rgba(187, 198, 208, 0.9);
}

.rx-sheet::after {
    inset: 0;
    background: linear-gradient(transparent 0, transparent 92%, rgba(233, 239, 244, 0.56) 100%);
}

.rx-sheet-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0 calc(2.8mm * var(--fit-scale));
    flex: 0 0 auto;
    min-height: calc(28mm * var(--fit-scale));
}

.rx-sheet-logo {
    position: absolute;
    left: 8%;
    top: 43%;
    width: calc(72mm * var(--fit-scale));
    height: calc(72mm * var(--fit-scale));
    transform: translate(-50%, -50%);
    opacity: 1;
    z-index: 0;
    pointer-events: none;
}

.rx-sheet-logo img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

.rx-sheet-logo-core {
    width: calc(13.8mm * var(--fit-scale));
    height: calc(13.8mm * var(--fit-scale));
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: calc(3.8mm * var(--fit-scale));
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #4f82a9;
    border: 0.24mm solid rgba(88, 132, 164, 0.18);
    background: rgba(255, 255, 255, 0.74);
}

.rx-sheet-heading {
    position: relative;
    z-index: 1;
    text-align: center;
}

.rx-sheet-heading h1 {
    margin: 0 0 calc(0.7mm * var(--fit-scale));
    font-family: Georgia, "Times New Roman", serif;
    font-size: calc(6.3mm * var(--fit-scale));
    line-height: 1.1;
    font-weight: 500;
    color: #3a5672;
}

.rx-sheet-evelyn .rx-sheet-heading h1 {
    font-family: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
    font-style: italic;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.rx-sheet-license-row,
.rx-sheet-specialty {
    display: flex;
    justify-content: center;
    gap: 3mm;
    color: #5e7388;
}

.rx-sheet-license-row {
    font-size: calc(3.6mm * var(--fit-scale));
    letter-spacing: 0.03em;
}

.rx-sheet-specialty {
    margin-top: calc(0.8mm * var(--fit-scale));
    font-size: calc(3.75mm * var(--fit-scale));
    letter-spacing: 0.07em;
}

.rx-sheet-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    margin-top: calc(1.2mm * var(--fit-scale));
    flex: 1 1 auto;
    min-height: 0;
}

.rx-sheet-column {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
}

.rx-sheet-column:first-child {
    padding-right: calc(2.6mm * var(--fit-scale));
}

.rx-sheet-column-right {
    padding-left: calc(2.6mm * var(--fit-scale));
}

.rx-section-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: calc(2mm * var(--fit-scale));
    min-height: calc(6mm * var(--fit-scale));
    border-radius: 999px;
    color: #58748d;
    background: linear-gradient(90deg, rgba(213, 230, 241, 0.25) 0%, rgba(205, 221, 234, 0.82) 48%, rgba(213, 230, 241, 0.25) 100%);
    text-transform: uppercase;
    letter-spacing: 0.13em;
    font-size: calc(3.15mm * var(--fit-scale));
    font-weight: 600;
    flex: 0 0 auto;
}

.rx-section-icon {
    width: calc(4.8mm * var(--fit-scale));
    height: calc(4.8mm * var(--fit-scale));
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    color: var(--print-accent, #4a8cac);
    font-weight: 700;
    font-size: calc(2.6mm * var(--fit-scale));
}

.rx-field-row,
.rx-date-row {
    display: flex;
    align-items: flex-end;
    gap: calc(1.5mm * var(--fit-scale));
    margin-top: calc(1.8mm * var(--fit-scale));
    font-size: calc(2.85mm * var(--fit-scale));
    flex: 0 0 auto;
}

.rx-field-label {
    white-space: nowrap;
    color: #556f86;
}

.rx-field-value {
    flex: 1;
    min-height: calc(3.4mm * var(--fit-scale));
    padding-bottom: calc(0.35mm * var(--fit-scale));
    border-bottom: 0.32mm dotted #cfd9e1;
    color: #1d2329;
}

.rx-inline-row {
    display: grid;
    grid-template-columns: 0.92fr 1.08fr;
    gap: calc(1.8mm * var(--fit-scale));
    align-items: end;
    flex: 0 0 auto;
}

.rx-inline-row-triple {
    grid-template-columns: 0.62fr 0.9fr 1.08fr;
}

.rx-date-value {
    display: inline-flex;
    align-items: flex-end;
    justify-content: center;
    min-width: calc(6.5mm * var(--fit-scale));
    min-height: calc(3.4mm * var(--fit-scale));
    padding-bottom: calc(0.35mm * var(--fit-scale));
    border-bottom: 0.32mm dotted #cfd9e1;
    color: #1d2329;
}

.rx-date-year {
    min-width: calc(11.5mm * var(--fit-scale));
}

.rx-date-sep {
    color: #7b8d9b;
}

.rx-rp-label {
    margin-top: calc(2.2mm * var(--fit-scale));
    font-size: calc(3.1mm * var(--fit-scale));
    color: #536d84;
    flex: 0 0 auto;
}

.rx-ruled-box {
    --content-scale: 1;
    --content-row-height: calc(4.45mm * var(--fit-scale) * var(--content-scale));
    margin-top: calc(0.7mm * var(--fit-scale));
    min-height: 0;
    flex: 1 1 auto;
    background-image: linear-gradient(to bottom, rgba(203, 213, 222, 0.88) 0.22mm, transparent 0.22mm);
    background-size: 100% var(--content-row-height);
    background-position: top left;
    overflow: hidden;
}

.rx-ruled-box-indications {
    margin-top: calc(1.8mm * var(--fit-scale));
    --indication-row-step: calc(4.4mm * var(--fit-scale) * var(--content-scale));
}

.rx-ruled-box-prescription {
    margin-right: calc(-0.35mm * var(--fit-scale));
}

.rx-stamp {
    margin-top: auto;
    width: calc(58mm * var(--fit-scale));
    max-width: 100%;
    align-self: center;
    padding-top: calc(7mm * var(--fit-scale));
    text-align: center;
    color: #111;
    line-height: 1.08;
    transform: translateY(calc(6mm * var(--fit-scale)));
}

.rx-stamp-line {
    width: 100%;
    margin: 0 auto calc(1.35mm * var(--fit-scale));
    border-top: 0.42mm solid #111;
}

.rx-stamp-name {
    font-size: calc(2.8mm * var(--fit-scale));
    font-weight: 700;
    letter-spacing: 0.045em;
    text-transform: uppercase;
}

.rx-stamp-role {
    margin-top: calc(0.55mm * var(--fit-scale));
    font-size: calc(2.08mm * var(--fit-scale));
    letter-spacing: 0.055em;
}

.rx-stamp-license {
    margin-top: calc(0.55mm * var(--fit-scale));
    font-size: calc(2mm * var(--fit-scale));
    letter-spacing: 0.05em;
}

.rx-ruled-line {
    min-height: var(--content-row-height);
    padding: calc(0.55mm * var(--fit-scale) * var(--content-scale)) calc(0.7mm * var(--fit-scale)) 0;
    font-size: calc(2.7mm * var(--fit-scale) * var(--content-scale));
    line-height: 1.18;
    color: #1d2329;
}

.rx-ruled-line-prescription {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: calc(0.75mm * var(--fit-scale) * var(--content-scale));
    width: 100%;
    padding-right: 0;
}

.rx-ruled-line-indication {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: calc(0.55mm * var(--fit-scale) * var(--content-scale));
    width: 100%;
    min-height: auto;
    padding-top: calc(0.55mm * var(--fit-scale) * var(--content-scale));
    padding-bottom: calc(0.1mm * var(--fit-scale) * var(--content-scale));
}

.rx-line-number {
    flex: 0 0 auto;
    color: #52697c;
}

.rx-line-number-prescription {
    justify-self: end;
    text-align: right;
    margin-right: calc(-0.2mm * var(--fit-scale) * var(--content-scale));
}

.rx-line-content {
    min-width: 0;
    display: block;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.34;
    padding-top: calc(0.2mm * var(--fit-scale) * var(--content-scale));
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent calc(var(--indication-row-step) - 0.24mm),
        rgba(203, 213, 222, 0.88) calc(var(--indication-row-step) - 0.24mm),
        rgba(203, 213, 222, 0.88) var(--indication-row-step)
    );
    background-size: 100% var(--indication-row-step);
    background-repeat: repeat-y;
}

.rx-line-content-prescription {
    padding-top: 0;
    background: none;
    line-height: 1.18;
}

.rx-line-name {
    display: inline;
    min-width: 0;
    font-weight: 600;
}

.rx-line-detail {
    display: inline;
}

.rx-line-name + .rx-line-detail::before {
    content: " ";
}

.rx-ruled-line-note .rx-line-name {
    color: #425768;
}

.rx-field-row-date {
    margin-top: calc(1.8mm * var(--fit-scale));
}

.rx-cut-mark {
    position: absolute;
    left: 50%;
    bottom: calc(1.2mm * var(--fit-scale));
    transform: translateX(-50%);
    color: #6f8799;
    font-size: calc(4.4mm * var(--fit-scale));
    line-height: 1;
}

.print-shell {
    width: min(860px, calc(100% - 32px));
    margin: 0 auto;
    padding: 34px;
    background: #fff;
}

.print-header {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 18px;
    border-bottom: 3px solid var(--print-accent, var(--accent));
}

.print-header-brand {
    max-width: 70%;
}

.print-title {
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--print-accent, var(--accent));
    font-size: 13px;
    font-weight: 700;
}

.print-meta,
.patient-summary,
.print-footer {
    display: grid;
    gap: 10px;
}

.patient-summary,
.print-lines {
    margin-top: 20px;
}

.patient-summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.print-lines table {
    width: 100%;
    border-collapse: collapse;
}

.print-lines th,
.print-lines td {
    padding: 10px 8px;
    border-bottom: 1px solid #dde6ea;
    text-align: left;
    vertical-align: top;
}

.signature-box {
    margin-top: 34px;
    display: grid;
    justify-items: end;
}

.signature-line {
    width: 260px;
    border-top: 1px solid #50646d;
    padding-top: 10px;
    text-align: center;
}

.print-actions {
    width: min(860px, calc(100% - 32px));
    margin: 0 auto 18px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

@media (max-width: 800px) {
    .topbar-inner,
    .toolbar,
    .list-head,
    .print-header,
    .patient-summary-grid {
        display: grid;
    }

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

    .nav {
        justify-content: flex-start;
    }

    .rx-line-card-head {
        display: grid;
    }

    .rx-form-actions {
        width: calc(100vw - 24px);
        max-width: 520px;
        bottom: 12px;
    }

    .prescription-list-compact {
        max-height: 62vh;
    }

    .print-shell {
        padding: 24px;
    }

    .rx-sheet {
        width: min(100%, calc(100vw - 20px));
        height: auto;
        min-height: 0;
        padding: 20px;
    }

    .rx-sheet-columns {
        grid-template-columns: 1fr;
        gap: 28px;
    }

    .rx-sheet-column-right {
        padding-left: 0;
    }

    .rx-inline-row {
        grid-template-columns: 1fr;
    }

    .rx-inline-row-triple {
        grid-template-columns: 1fr;
    }

    .rx-cut-mark {
        display: none;
    }
}

@media print {
    @page {
        size: A4 portrait;
        margin: 0;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    html,
    body {
        background: #fff;
        margin: 0;
        padding: 0;
        width: 210mm;
        height: 297mm;
        overflow: hidden;
    }

    body.print-page {
        padding: 0 !important;
    }

    .print-page {
        width: 210mm;
        min-height: 297mm;
        padding-inline: 0 !important;
        background:
            linear-gradient(180deg, #f6fbfe 0%, #e8f1f8 55%, #f8fbfd 100%) top center / 100% 148.5mm no-repeat,
            #fff !important;
    }

    .topbar,
    .session-banner,
    .flash-stack,
    .print-actions {
        display: none !important;
    }

    .rx-sheet {
        --fit-scale: 0.93;
        width: 100%;
        max-width: 184mm;
        height: 143.5mm;
        margin: 0 auto;
        padding-left: calc(8.8mm * var(--fit-scale));
        padding-right: calc(8.8mm * var(--fit-scale));
        background: transparent;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        page-break-after: avoid;
        position: relative;
        z-index: 1;
    }

    .print-decor {
        display: flex !important;
        opacity: 0.36;
        bottom: 148.5mm;
    }

    .print-decor-left {
        bottom: 136mm;
    }

    .print-decor-right {
        bottom: 148.5mm;
    }

    .rx-sheet-column:first-child {
        padding-right: calc(3.2mm * var(--fit-scale));
    }

    .rx-sheet-column-right {
        padding-left: calc(3.2mm * var(--fit-scale));
    }

    .rx-sheet::after {
        display: none;
    }

    .rx-sheet-columns {
        grid-template-columns: 1fr 1fr;
        gap: calc(5.2mm * var(--fit-scale));
    }

    .rx-sheet-column-right {
        padding-left: calc(1.8mm * var(--fit-scale));
    }

    .rx-inline-row {
        grid-template-columns: 0.92fr 1.08fr;
    }

    .rx-inline-row-triple {
        grid-template-columns: 0.56fr 0.88fr 1.12fr;
    }

    .rx-cut-mark {
        display: block;
    }

    .print-shell {
        width: auto;
        margin: 0;
        padding: 0;
        border: 0;
        box-shadow: none;
        border-radius: 0;
    }
}
