:root {
    --rr-rose-700: #8f3f5d;
    --rr-rose-600: #b33050;
    --rr-rose-400: #d78287;
    --rr-blue-700: #245f82;
    --rr-blue-500: #4e91bd;
    --rr-green-600: #718471;
    --rr-mist-100: #eef8f8;
    --rr-mist-200: #d7eeee;
    --rr-surface: #fffafa;
    --rr-paper: #ffffff;
    --rr-ink: #213238;
    --rr-muted: #63737a;
    --rr-border: #d8e1e2;
    --rr-danger: #9f2541;
    --rr-success: #2f725f;
    --rr-shadow: 0 14px 36px rgba(31, 64, 74, 0.12);
}

* {
    box-sizing: border-box;
}

html {
    font-family: Arial, Helvetica, sans-serif;
    color: var(--rr-ink);
    background: var(--rr-mist-100);
}

body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
}

a {
    color: var(--rr-blue-700);
}

a:hover {
    color: var(--rr-rose-600);
}

.site-header {
    background: var(--rr-paper);
    border-bottom: 1px solid var(--rr-border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.header-inner {
    width: min(100%, 1120px);
    min-height: 70px;
    margin: 0 auto;
    padding: 0.1rem 0.85rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 48px;
    align-items: center;
    gap: 0.75rem;
}

.account-cluster {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    justify-self: start;
}

.brand {
    min-width: 0;
    justify-self: center;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    color: var(--rr-ink);
    text-decoration: none;
}

.brand-text {
    min-width: 0;
    display: grid;
    gap: 0.05rem;
}

.brand-logo {
    width: 96px;
    height: auto;
    object-fit: contain;
}

.brand-name {
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: clamp(1.12rem, 5vw, 1.35rem);
    font-weight: 600;
    color: var(--rr-rose-700);
}

.current-patient {
    min-height: 48px;
    min-width: 0;
    width: min(38vw, 17rem);
    padding: 0.42rem 0.7rem;
    display: grid;
    align-content: center;
    gap: 0.04rem;
    border: 1px solid rgba(143, 63, 93, 0.28);
    border-radius: 7px;
    background: #fff7f9;
    color: var(--rr-ink);
    box-shadow: 0 2px 8px rgba(31, 64, 74, 0.08);
    text-decoration: none;
}

.current-patient:hover {
    border-color: var(--rr-rose-600);
    background: #fff1f4;
    color: var(--rr-ink);
}

.current-patient:focus-visible {
    outline: 3px solid rgba(78, 145, 189, 0.32);
    outline-offset: 2px;
}

.current-patient-label {
    color: var(--rr-rose-700);
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    text-transform: uppercase;
}

.current-patient-name {
    min-width: 0;
    overflow: hidden;
    color: var(--rr-ink);
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 520px) {
    .header-inner {
        padding-inline: 0.55rem;
        gap: 0.5rem;
    }

    .account-cluster {
        gap: 0.45rem;
    }

    .brand {
        gap: 0;
    }

    .brand-logo {
        width: 76px;
    }

    .brand-name {
        display: none;
    }

    .current-patient {
        width: min(48vw, 12.5rem);
        padding-inline: 0.55rem;
    }

    .current-patient-label {
        font-size: 0.62rem;
    }

    .current-patient-name {
        font-size: 0.82rem;
    }
}

.account-menu,
.app-menu {
    position: relative;
    flex: 0 0 auto;
}

.app-menu {
    justify-self: end;
}

.menu-toggle {
    width: 48px;
    height: 48px;
    padding: 0;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border: 1px solid var(--rr-border);
    border-radius: 7px;
    background: var(--rr-paper);
    color: var(--rr-ink);
    cursor: pointer;
}

.menu-toggle:hover {
    background: var(--rr-mist-200);
    border-color: var(--rr-blue-500);
}

.menu-toggle:focus-visible {
    outline: 3px solid rgba(78, 145, 189, 0.32);
    outline-offset: 2px;
}

.hamburger-toggle {
    gap: 5px;
}

.hamburger-line {
    width: 22px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
}

.account-toggle {
    gap: 0;
    position: relative;
    overflow: hidden;
    background: #ffffff;
}

.account-toggle::after {
    content: none;
}

.avatar-icon {
    width: 38px;
    height: 38px;
    position: relative;
    display: block;
    border-radius: 50%;
    background:
        radial-gradient(circle at 34% 24%, rgba(255, 255, 255, 0.34) 0 16%, transparent 17%),
        linear-gradient(145deg, var(--rr-rose-400) 0%, var(--rr-rose-600) 46%, var(--rr-rose-700) 100%);
    box-shadow:
        inset 0 1px 1px rgba(255, 255, 255, 0.38),
        inset 0 -4px 7px rgba(66, 20, 38, 0.3),
        0 2px 4px rgba(33, 50, 56, 0.18),
        0 0 0 2px rgba(143, 63, 93, 0.14);
}

.avatar-face {
    width: 12px;
    height: 12px;
    position: absolute;
    top: 8px;
    left: 13px;
    border-radius: 50%;
    background: linear-gradient(180deg, #ffffff 0%, #f8eeee 100%);
    box-shadow: 0 1px 1px rgba(66, 20, 38, 0.16);
}

.avatar-body {
    width: 26px;
    height: 14px;
    position: absolute;
    left: 6px;
    bottom: 6px;
    border-radius: 999px 999px 5px 5px;
    background: linear-gradient(180deg, #ffffff 0%, #f7eded 100%);
    box-shadow: 0 1px 1px rgba(66, 20, 38, 0.16);
}

.avatar-spark {
    display: none;
}

.menu-panel {
    position: absolute;
    top: calc(100% + 0.55rem);
    right: 0;
    width: min(calc(100vw - 1.7rem), 23rem);
    max-height: calc(100vh - 5.75rem);
    max-height: calc(100dvh - 5.75rem);
    padding: 0.55rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--rr-border);
    border-radius: 8px;
    background: var(--rr-paper);
    box-shadow: var(--rr-shadow);
    -webkit-overflow-scrolling: touch;
}

.account-panel {
    right: auto;
    left: 0;
}

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

.menu-list a {
    min-height: 48px;
    padding: 0.78rem 0.85rem;
    display: flex;
    align-items: center;
    border-radius: 7px;
    color: var(--rr-ink);
    font-weight: 700;
    text-decoration: none;
}

.menu-list a:hover,
.menu-list a[aria-current="page"] {
    background: var(--rr-mist-200);
    color: var(--rr-blue-700);
}

.menu-separator {
    height: 1px;
    margin: 0.35rem 0.25rem;
    background: var(--rr-border);
}

.page-shell {
    width: min(100%, 1120px);
    margin: 0 auto;
    padding: 1.2rem 1rem 2rem;
    flex: 1;
}

.site-footer {
    padding: 1.4rem 1rem;
    color: var(--rr-muted);
    background: var(--rr-paper);
    border-top: 1px solid var(--rr-border);
    text-align: center;
    font-size: 0.92rem;
}

.site-footer p {
    margin: 0;
}

.page-header {
    margin: 0 0 1rem;
    display: grid;
    gap: 1rem;
}

.page-header h1 {
    margin: 0;
    font-size: 2rem;
    line-height: 1.12;
}

.eyebrow {
    margin: 0 0 0.2rem;
    color: var(--rr-rose-700);
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
}

.lede {
    max-width: 56rem;
    margin: 0.35rem 0 0;
    color: var(--rr-muted);
}

.about-logo {
    width: min(100%, 28rem);
    height: auto;
    margin: 0 auto 1.2rem;
    display: block;
}

.button,
button.button {
    min-height: 46px;
    width: fit-content;
    max-width: 100%;
    padding: 0.72rem 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--rr-rose-600);
    border-radius: 7px;
    background: var(--rr-rose-600);
    color: #ffffff;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.button:hover {
    background: var(--rr-rose-700);
    border-color: var(--rr-rose-700);
    color: #ffffff;
}

.button-secondary,
button.button-secondary {
    background: var(--rr-paper);
    color: var(--rr-blue-700);
    border-color: var(--rr-border);
}

.button-secondary:hover,
button.button-secondary:hover {
    background: var(--rr-mist-200);
    color: var(--rr-blue-700);
    border-color: var(--rr-blue-500);
}

.text-link {
    font-weight: 700;
}

.empty-state,
.list-panel,
.form-panel,
.detail-panel {
    padding: 1rem;
    border: 1px solid var(--rr-border);
    border-radius: 8px;
    background: var(--rr-paper);
    box-shadow: var(--rr-shadow);
}

.empty-state h2 {
    margin-top: 0;
}

.welcome-panel {
    min-height: min(58vh, 34rem);
    padding: 1.4rem;
    display: grid;
    align-content: center;
    gap: 1.3rem;
    border: 1px solid var(--rr-border);
    border-radius: 8px;
    background: var(--rr-paper);
    box-shadow: var(--rr-shadow);
}

.welcome-panel h1 {
    margin: 0;
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 2.2rem;
    line-height: 1.08;
    color: var(--rr-rose-700);
}

.welcome-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.list-panel {
    display: grid;
    gap: 0.55rem;
}

.medication-row {
    min-height: 64px;
    padding: 1rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    border: 1px solid var(--rr-border);
    border-radius: 7px;
    background: #ffffff;
    color: var(--rr-ink);
    text-decoration: none;
}

.patient-row {
    min-height: 64px;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: stretch;
    border: 1px solid var(--rr-border);
    border-radius: 7px;
    background: #ffffff;
    overflow: hidden;
}

.patient-row:hover {
    border-color: var(--rr-blue-500);
    background: var(--rr-mist-100);
}

.patient-row-main {
    min-width: 0;
    padding: 1rem;
    display: grid;
    align-content: center;
    color: var(--rr-ink);
    text-decoration: none;
}

.patient-row-main h2 {
    margin: 0;
    font-size: 1.12rem;
}

.patient-row-main:hover {
    color: var(--rr-ink);
}

.patient-row-actions {
    display: flex;
    align-items: stretch;
}

.patient-row-actions form {
    margin: 0;
    display: flex;
}

.patient-edit-button,
.patient-delete-button,
.patient-action-placeholder {
    width: 5.25rem;
    min-height: 100%;
    border-top: 0;
    border-right: 0;
    border-bottom: 0;
    border-radius: 0;
}

.patient-action-placeholder {
    display: block;
    border-left: 1px solid var(--rr-border);
}

.medication-row h2 {
    margin: 0;
    font-size: 1.12rem;
}

.medication-row:hover {
    border-color: var(--rr-blue-500);
    background: var(--rr-mist-100);
    color: var(--rr-ink);
}

.medication-row p {
    margin: 0.18rem 0 0;
}

.muted {
    color: var(--rr-muted);
}

.status {
    width: fit-content;
    min-height: 30px;
    padding: 0.25rem 0.6rem;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: var(--rr-mist-200);
    color: var(--rr-blue-700);
    font-size: 0.86rem;
    font-weight: 700;
}

.status-active {
    background: #e4f2ee;
    color: var(--rr-success);
}

.status-paused {
    background: #f8e7eb;
    color: var(--rr-rose-700);
}

.status-stopped {
    background: #eef0f0;
    color: var(--rr-muted);
}

.field {
    margin-bottom: 1rem;
}

.field-grid {
    display: grid;
    gap: 0;
}

label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 46px;
    padding: 0.72rem 0.78rem;
    border: 1px solid var(--rr-border);
    border-radius: 7px;
    background: #ffffff;
    color: var(--rr-ink);
    font: inherit;
}

.password-control {
    position: relative;
}

.password-control input {
    padding-right: 3.35rem;
}

.password-toggle {
    width: 46px;
    height: 46px;
    padding: 0;
    position: absolute;
    top: 0;
    right: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-left: 1px solid var(--rr-border);
    border-radius: 0 7px 7px 0;
    background: transparent;
    color: var(--rr-blue-700);
    cursor: pointer;
}

.password-toggle:hover {
    background: var(--rr-mist-200);
}

.password-toggle:focus-visible {
    outline: 3px solid rgba(78, 145, 189, 0.32);
    outline-offset: 2px;
}

.password-toggle svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
.button:focus-visible,
a:focus-visible {
    outline: 3px solid rgba(78, 145, 189, 0.32);
    outline-offset: 2px;
}

.field-error {
    margin: 0.35rem 0 0;
    color: var(--rr-danger);
    font-weight: 700;
}

.field-help {
    margin: 0.35rem 0 0;
    color: var(--rr-muted);
    font-size: 0.92rem;
}

.password-requirements {
    padding-left: 1.15rem;
}

.auth-panel,
.passkey-panel {
    margin-bottom: 1rem;
}

.auth-panel h2,
.passkey-panel h2 {
    margin-top: 0;
    font-size: 1.28rem;
}

.notice {
    margin-bottom: 1rem;
    padding: 0.8rem 1rem;
    border-radius: 7px;
    border: 1px solid;
    background: var(--rr-paper);
    font-weight: 700;
}

.notice-error {
    border-color: #efbac6;
    color: var(--rr-danger);
    background: #fff1f4;
}

.notice-success {
    border-color: #b9ddd2;
    color: var(--rr-success);
    background: #edf8f4;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
}

.detail-panel dl {
    margin: 0;
    display: grid;
    gap: 1rem;
}

.detail-panel div {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--rr-border);
}

.detail-panel div:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.detail-panel dt {
    margin-bottom: 0.2rem;
    color: var(--rr-muted);
    font-weight: 700;
}

.detail-panel dd {
    margin: 0;
}

@media (min-width: 680px) {
    .header-inner {
        min-height: 92px;
        padding-inline: 1.5rem;
        padding-block: 0.1rem;
        gap: 1rem;
    }

    .brand-logo {
        width: 128px;
        height: auto;
    }

    .brand-name {
        font-size: 1.65rem;
    }

    .menu-panel {
        width: 18rem;
        max-height: calc(100vh - 7rem);
        max-height: calc(100dvh - 7rem);
        padding: 0.45rem;
    }

    .menu-list a {
        min-height: 44px;
        padding: 0.65rem 0.75rem;
        font-weight: 500;
    }

    .page-shell {
        padding: 2rem 1.5rem 3rem;
    }

    .page-header {
        grid-template-columns: 1fr auto;
        align-items: end;
    }

    .page-header h1 {
        font-size: 2.55rem;
    }

    .empty-state,
    .list-panel,
    .form-panel,
    .detail-panel,
    .welcome-panel {
        padding: 1.4rem;
    }

    .welcome-panel {
        min-height: min(62vh, 38rem);
        padding: 2rem;
    }

    .welcome-panel h1 {
        font-size: 3.1rem;
    }

    .field-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }

    .medication-row {
        grid-template-columns: 1fr auto;
        align-items: center;
    }
}
