:root {
    color-scheme: light;
    --bg-top: #f4efe6;
    --bg-bottom: #d7e5f1;
    --card: rgba(255, 255, 255, 0.92);
    --card-strong: rgba(255, 255, 255, 0.96);
    --text: #1a2336;
    --muted: #5a667d;
    --primary: #0f5db5;
    --primary-strong: #0b4688;
    --border: rgba(22, 36, 62, 0.12);
    --info-bg: #e8f1ff;
    --info-text: #18487b;
    --panel-bg: rgba(247, 250, 255, 0.82);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    padding: 1.5rem;
    font-family: "Avenir Next", "Helvetica Neue", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.8), transparent 36%),
        linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
}

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

a:hover {
    color: var(--primary-strong);
}

.page-shell {
    min-height: calc(100vh - 3rem);
    display: grid;
    place-items: center;
}

.card {
    width: min(100%, 460px);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 28px;
    padding: 2rem;
    box-shadow: 0 24px 60px rgba(28, 40, 63, 0.14);
    backdrop-filter: blur(12px);
}

.wide-card {
    width: min(100%, 920px);
    background: var(--card-strong);
}

.hero {
    margin-bottom: 1.25rem;
}

.eyebrow {
    margin: 0 0 0.4rem;
    font-size: 0.75rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
}

h1,
h2,
p,
ul {
    margin-top: 0;
}

h1 {
    margin-bottom: 0.75rem;
    font-size: clamp(2rem, 4vw, 2.6rem);
}

h2 {
    margin-bottom: 0.9rem;
    font-size: 1.15rem;
}

.lead {
    color: var(--muted);
    line-height: 1.6;
    margin-bottom: 0;
}

.section-kicker,
.action-eyebrow {
    margin: 0 0 0.55rem;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--primary-strong);
}

.hero-title {
    margin-bottom: 0.75rem;
}

.small {
    max-width: 60ch;
}

.notice {
    margin: 1.25rem 0;
    padding: 0.95rem 1rem;
    border-radius: 16px;
    background: var(--info-bg);
    color: var(--info-text);
    font-size: 0.95rem;
    line-height: 1.5;
}

.flash {
    margin-bottom: 1rem;
    border-radius: 16px;
    padding: 0.95rem 1rem;
    border: 1px solid transparent;
}

.flash-success {
    background: #e7f7ec;
    color: #245935;
}

.flash-error {
    background: #fdecea;
    color: #8f2f25;
}

.form-grid {
    display: grid;
    gap: 1rem;
}

label {
    display: grid;
    gap: 0.45rem;
}

label span,
.detail-label {
    font-weight: 600;
}

input,
select,
button {
    font: inherit;
}

input {
    width: 100%;
    padding: 0.95rem 1rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.95);
}

select {
    width: 100%;
    padding: 0.95rem 1rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.95);
}

textarea {
    width: 100%;
    padding: 0.95rem 1rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.95);
    font: inherit;
    resize: vertical;
}

button {
    border: 0;
    border-radius: 999px;
    padding: 1rem 1.2rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: white;
    font-weight: 700;
    cursor: pointer;
}

.secondary-button {
    background: rgba(15, 93, 181, 0.1);
    color: var(--primary-strong);
    border: 1px solid rgba(15, 93, 181, 0.18);
    box-shadow: none;
}

.button-stack {
    display: grid;
    gap: 0.55rem;
}

.patient-selector-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.75rem;
    align-items: center;
}

.patient-detail-grid {
    display: grid;
    gap: 1rem;
    margin-bottom: 1rem;
}

.archived-note {
    margin: -0.25rem 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.footer-copy {
    margin: 1rem 0 0;
    font-size: 0.92rem;
    color: var(--muted);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.nav-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.hero-panel {
    margin-bottom: 1.25rem;
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 24px;
    background:
        radial-gradient(circle at top right, rgba(15, 93, 181, 0.12), transparent 34%),
        linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(241, 246, 255, 0.88));
}

.management-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.action-card {
    display: block;
    padding: 1.35rem;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(240, 246, 255, 0.84));
    box-shadow: 0 14px 34px rgba(28, 40, 63, 0.08);
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.action-card:hover {
    transform: translateY(-3px);
    border-color: rgba(15, 93, 181, 0.3);
    box-shadow: 0 18px 42px rgba(28, 40, 63, 0.12);
}

.action-card h2 {
    color: var(--text);
}

.action-card p:last-child {
    margin-bottom: 0;
    color: var(--muted);
    line-height: 1.6;
}

.panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.anchored-sections {
    margin-bottom: 0;
}

.panel {
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--panel-bg);
}

.detail-label {
    margin-bottom: 0.25rem;
    color: var(--muted);
}

.detail-value {
    margin-bottom: 1rem;
    font-size: 1.05rem;
}

.diary-toolbar {
    display: grid;
    gap: 1rem;
    margin-bottom: 1rem;
}

.timeline-controls {
    margin-bottom: 1rem;
}

.diary-range-switcher,
.diary-navigation,
.slot-switcher {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
}

.diary-range-switcher {
    justify-content: flex-start;
}

.range-chip,
.nav-button,
.slot-chip {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.7rem 1rem;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    font-weight: 600;
}

.range-chip.is-active {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: white;
    border-color: transparent;
}

.slot-chip.is-active {
    background: rgba(15, 93, 181, 0.12);
    border-color: rgba(15, 93, 181, 0.35);
    color: var(--primary-strong);
}

.diary-period {
    margin: 0;
    min-width: 120px;
    text-align: center;
    font-weight: 700;
    color: var(--text);
}

.diary-preview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.85rem;
    margin-top: 1rem;
}

.timeline-panel {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.72);
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

.timeline-note {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.timeline-grid {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 0.85rem;
}

.time-column {
    display: grid;
    gap: 0.6rem;
    color: var(--muted);
    font-weight: 600;
}

.time-column p {
    margin: 0;
    min-height: 58px;
    display: flex;
    align-items: center;
}

.schedule-column {
    display: grid;
    gap: 0.6rem;
}

.timeline-slot {
    min-height: 58px;
    border-radius: 16px;
    border: 1px dashed rgba(22, 36, 62, 0.14);
    background: rgba(255, 255, 255, 0.4);
    width: 100%;
    text-align: left;
}

.booking-card {
    padding: 0.85rem 1rem;
    border-style: solid;
    border-color: rgba(15, 93, 181, 0.2);
    background: linear-gradient(145deg, rgba(226, 239, 255, 0.95), rgba(244, 249, 255, 0.9));
}

.booking-card.subtle {
    background: linear-gradient(145deg, rgba(237, 245, 255, 0.9), rgba(255, 255, 255, 0.9));
}

.appointment-trigger {
    cursor: pointer;
}

.empty-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.56);
}

.empty-slot span {
    font-weight: 600;
}

.timeline-slot .detail-value {
    margin-bottom: 0;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(16, 24, 38, 0.42);
}

.modal-card {
    width: min(100%, 560px);
    max-height: 90vh;
    overflow: auto;
    padding: 1.5rem;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 30px 70px rgba(16, 24, 38, 0.22);
}

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

.modal-close {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.7rem 1rem;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    font-weight: 600;
}

.modal-body {
    display: grid;
    gap: 1rem;
}

.appointment-meta {
    margin: 0;
    display: grid;
    gap: 0.9rem;
}

.appointment-meta div {
    display: grid;
    gap: 0.35rem;
}

.appointment-meta dt {
    font-weight: 700;
    color: var(--muted);
}

.appointment-meta dd {
    margin: 0;
}

.appointment-form textarea {
    width: 100%;
    padding: 0.95rem 1rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.95);
    font: inherit;
    resize: vertical;
}

.detail-list {
    margin: 0;
    padding-left: 1.1rem;
    color: var(--muted);
    line-height: 1.6;
}

.list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.6rem;
}

.list-copy {
    display: grid;
    gap: 0.2rem;
}

.list-copy span {
    color: var(--muted);
    font-size: 0.92rem;
}

@media (max-width: 640px) {
    body {
        padding: 1rem;
    }

    .page-shell {
        min-height: calc(100vh - 2rem);
    }

    .card {
        padding: 1.35rem;
        border-radius: 22px;
    }

    .topbar {
        flex-direction: column;
    }

    .timeline-header,
    .timeline-grid {
        grid-template-columns: 1fr;
    }

    .timeline-header {
        display: grid;
    }

    .time-column p {
        min-height: auto;
    }

    .modal-header {
        flex-direction: column;
    }

    .patient-selector-row {
        grid-template-columns: 1fr;
    }
}
