:root {
    --ink: #edf0f7;
    --muted: #a3acc0;
    --line: #30384c;
    --soft: #111723;
    --rose: #e0527a;
    --rose-soft: #2b1722;
    --teal: #39b8ae;
    --green: #4fca83;
    --amber: #e1a738;
    --blue: #7ea3ff;
    --white: #20293a;
    --panel: #20293a;
    --panel-2: #263146;
    --field: #151d2b;
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.24);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--soft);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.app-shell {
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    background: #161e2d;
    border-right: 1px solid var(--line);
    padding: 18px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.brand img {
    width: 58px;
    height: 58px;
    object-fit: contain;
}

.brand strong {
    display: block;
    font-size: 15px;
}

.brand span {
    color: var(--muted);
    font-size: 12px;
}

.nav {
    display: grid;
    gap: 3px;
}

.nav a {
    border-radius: 8px;
    color: var(--muted);
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 8px 10px;
    font-size: 13px;
}

.nav a.active,
.nav a:hover {
    color: var(--ink);
    background: var(--rose-soft);
}

.nav-icon {
    align-items: center;
    background: #263146;
    border-radius: 7px;
    color: var(--rose);
    display: inline-flex;
    font-size: 11px;
    font-weight: 700;
    height: 26px;
    justify-content: center;
    width: 26px;
}

.nav a.active .nav-icon,
.nav a:hover .nav-icon {
    background: #303a50;
}

.nav-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-phase {
    background: #1f3156;
    border-radius: 999px;
    color: var(--blue);
    font-size: 10px;
    padding: 3px 7px;
    white-space: nowrap;
}

.content {
    padding: 24px;
}

.topbar {
    align-items: center;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.topbar h1 {
    font-size: 24px;
    line-height: 1.2;
    margin: 0;
}

.topbar p {
    margin: 6px 0 0;
    color: var(--muted);
}

.grid {
    display: grid;
    gap: 16px;
}

.grid.cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel,
.card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel {
    padding: 18px;
}

.metric {
    padding: 18px;
}

.metric span {
    color: var(--muted);
    display: block;
    font-size: 13px;
}

.metric strong {
    display: block;
    font-size: 28px;
    margin-top: 8px;
}

.metric small {
    color: var(--muted);
}

.section-title {
    align-items: center;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.section-title h2 {
    font-size: 17px;
    margin: 0;
}

.button,
button {
    align-items: center;
    background: var(--rose);
    border: 0;
    border-radius: 8px;
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-size: 14px;
    justify-content: center;
    min-height: 40px;
    padding: 9px 14px;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.button.secondary,
button.secondary {
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--ink);
}

.button.rose {
    background: var(--rose);
}

.button.small {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 12px;
}

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

.field {
    display: grid;
    gap: 7px;
}

.field.full {
    grid-column: 1 / -1;
}

label {
    color: var(--muted);
    font-size: 13px;
}

input,
select,
textarea {
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    font: inherit;
    min-height: 40px;
    padding: 9px 11px;
    width: 100%;
}

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

.table-wrap {
    overflow-x: auto;
}

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

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 11px 9px;
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.status {
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    padding: 4px 9px;
    text-transform: capitalize;
    white-space: nowrap;
}

.status.booked,
.status.checked_in {
    background: #1f3156;
    color: var(--blue);
}

.status.waiting,
.status.pending {
    background: #382b13;
    color: var(--amber);
}

.status.completed,
.status.vitals_done {
    background: #173523;
    color: var(--green);
}

.status.emergency,
.status.urgent {
    background: #381723;
    color: var(--rose);
}

.alert {
    background: #382b13;
    border: 1px solid #77591b;
    border-radius: 8px;
    color: #f2d18a;
    margin-bottom: 16px;
    padding: 12px 14px;
}

.success {
    background: #173523;
    border: 1px solid #36794e;
    border-radius: 8px;
    color: #a9ddb9;
    margin-bottom: 16px;
    padding: 12px 14px;
}

.login-page {
    align-items: center;
    display: grid;
    min-height: 100vh;
    padding: 24px;
}

.login-card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin: 0 auto;
    max-width: 420px;
    padding: 28px;
    width: 100%;
}

.login-card img {
    display: block;
    height: 110px;
    margin: 0 auto 18px;
    object-fit: contain;
}

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

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

.segmented {
    background: #151d2b;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: inline-flex;
    padding: 3px;
}

.segmented a {
    border-radius: 6px;
    color: var(--muted);
    font-size: 13px;
    padding: 8px 13px;
}

.segmented a.active {
    background: var(--panel-2);
    color: var(--ink);
    box-shadow: 0 2px 8px rgba(31, 33, 49, 0.08);
}

.timezone-note {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.calendar-toolbar {
    align-items: end;
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.date-jump {
    align-items: end;
    display: grid;
    grid-template-columns: 150px 170px auto;
    gap: 8px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(160px, 1fr));
    gap: 12px;
    overflow-x: auto;
}

.calendar-day-layout {
    align-items: start;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 16px;
}

.day-scheduler {
    max-height: calc(100vh - 180px);
    overflow: auto;
    padding: 0;
}

.day-scheduler-head {
    background: #263146;
    border-bottom: 1px solid var(--line);
    color: var(--blue);
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    padding: 8px 0;
    position: sticky;
    top: 0;
    z-index: 3;
}

.day-slot {
    background: #1b2333;
    border-bottom: 1px solid #30384c;
    color: var(--ink);
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    min-height: 34px;
}

.day-slot:hover,
.day-slot.selected {
    background: #2b1722;
}

.day-slot.past {
    background: #171c27;
    color: #777f92;
    cursor: not-allowed;
    opacity: 0.72;
}

.day-slot.past .day-time {
    background: #121824;
    color: #687184;
}

.day-slot.past .slot-empty {
    color: #9da0ad;
}

.day-slot.past .calendar-event {
    opacity: 0.75;
}

.day-slot.hour-slot {
    border-top: 1px solid #465169;
}

.day-time {
    background: #151d2b;
    border-right: 1px solid #30384c;
    color: var(--blue);
    font-size: 12px;
    font-weight: 700;
    padding: 7px 9px;
    text-align: right;
}

.slot-body {
    align-items: stretch;
    display: grid;
    gap: 6px;
    min-height: 34px;
    padding: 4px 7px;
}

.slot-empty {
    color: transparent;
    font-size: 12px;
    padding-top: 4px;
}

.day-slot:hover .slot-empty,
.day-slot.selected .slot-empty {
    color: var(--rose);
}

.calendar-event.compact {
    align-items: center;
    display: grid;
    grid-template-columns: 96px minmax(190px, 0.4fr) minmax(260px, 1fr);
    margin: 0;
    min-height: 30px;
    padding: 6px 8px;
}

.calendar-event.compact span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-booking-panel {
    position: sticky;
    top: 24px;
}

.week-calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(150px, 1fr));
    gap: 12px;
    overflow-x: auto;
}

.week-day,
.month-day {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    display: grid;
    align-content: start;
    gap: 7px;
    min-height: 230px;
    padding: 12px;
}

.week-day:hover,
.week-day.selected,
.month-day:hover,
.month-day.today {
    border-color: var(--rose);
    box-shadow: 0 0 0 2px var(--rose-soft);
}

.week-day-head {
    align-items: center;
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.week-day-head span,
.more-events {
    color: var(--muted);
    font-size: 12px;
}

.mini-event {
    background: #151d2b;
    border: 1px solid var(--line);
    border-left: 3px solid var(--rose);
    border-radius: 6px;
    display: grid;
    gap: 2px;
    padding: 6px 7px;
}

.mini-event strong {
    color: var(--rose);
    font-size: 11px;
}

.mini-event span {
    color: var(--muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.month-calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(140px, 1fr));
    gap: 10px;
    overflow-x: auto;
}

.month-day {
    min-height: 150px;
}

.month-day.outside {
    opacity: 0.45;
}

.month-day-number {
    color: var(--ink);
    font-weight: 700;
}

.calendar-day {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 8px;
    min-height: 260px;
    padding: 12px;
}

.calendar-day.selected {
    border-color: var(--rose);
    box-shadow: 0 0 0 2px var(--rose-soft);
}

.calendar-day-head {
    align-items: center;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.calendar-day-head span {
    color: var(--muted);
    font-size: 12px;
}

.calendar-event {
    border: 1px solid var(--line);
    border-left: 3px solid var(--rose);
    border-radius: 7px;
    display: grid;
    gap: 5px;
    margin-bottom: 8px;
    padding: 9px;
}

.calendar-event span {
    color: var(--muted);
    font-size: 12px;
}

.event-time {
    color: var(--rose);
    font-size: 12px;
    font-weight: 700;
}

.calendar-empty {
    font-size: 13px;
}

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

.feature-row {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 13px;
}

.feature-row p {
    color: var(--muted);
    margin: 5px 0 0;
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        height: auto;
        position: static;
    }

    .nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .calendar-toolbar,
    .date-jump {
        align-items: stretch;
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .calendar-grid {
        grid-template-columns: 1fr;
    }

    .week-calendar,
    .month-calendar {
        grid-template-columns: 1fr;
    }

    .calendar-day-layout {
        grid-template-columns: 1fr;
    }

    .calendar-event.compact,
    .day-slot,
    .day-scheduler-head {
        grid-template-columns: 74px minmax(0, 1fr);
    }

    .calendar-event.compact {
        align-items: start;
        grid-template-columns: 1fr;
    }

    .grid.cols-2,
    .grid.cols-3,
    .grid.cols-4,
    .form-grid {
        grid-template-columns: 1fr;
    }
}
