:root {
    --bg: #f3f5f6;
    --panel: #ffffff;
    --ink: #26312e;
    --muted: #67736f;
    --line: #d8dee2;
    --brand: #217c71;
    --brand-dark: #14584f;
    --accent: #c06b3e;
    --soft: #e7f0ec;
    --danger: #af3f3f;
    --shadow: 0 8px 22px rgba(38, 49, 46, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

a {
    color: inherit;
}

.shell {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    width: 236px;
    height: 100vh;
    padding: 14px 12px;
    border-right: 1px solid var(--line);
    background: rgba(255, 253, 248, 0.96);
    backdrop-filter: blur(12px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    margin-bottom: 18px;
    font-weight: 800;
    letter-spacing: 0;
}

.brand-logo {
    display: block;
    width: min(100%, 190px);
    height: auto;
}

.nav {
    display: flex;
    align-items: center;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    flex-wrap: nowrap;
}

.nav a,
.button,
button {
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 12px;
    text-decoration: none;
    font-weight: 700;
    font-size: 13px;
}

.nav a {
    justify-content: flex-start;
    width: 100%;
}

.nav a.active,
.button.primary,
button.primary {
    border-color: var(--brand);
    background: var(--brand);
    color: white;
}

.button.ghost {
    background: transparent;
}

.button.danger {
    border-color: #e0b7b7;
    color: var(--danger);
}

.user-pill {
    color: var(--muted);
    font-size: 13px;
}

.sidebar-user {
    display: grid;
    gap: 10px;
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.sidebar-user form,
.sidebar-user button {
    width: 100%;
}

.page {
    width: min(1180px, calc(100vw - 236px - 48px));
    margin: 20px auto 38px;
    margin-left: calc(236px + max(24px, (100vw - 236px - 1180px) / 2));
}

.hero {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 14px;
    margin-bottom: 14px;
}

.hero h1 {
    margin: 0 0 3px;
    font-size: clamp(22px, 2.5vw, 30px);
    line-height: 1.12;
    letter-spacing: 0;
}

.hero p {
    margin: 0;
    color: var(--muted);
}

.panel {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.panel-body {
    padding: 14px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: end;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

input,
select,
textarea {
    min-height: 38px;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    padding: 8px 10px;
    font: inherit;
}

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

.field-small {
    width: 150px;
}

.field-medium {
    width: 220px;
}

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

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

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

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

tr:last-child td {
    border-bottom: 0;
}

.child-name {
    font-weight: 800;
}

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

.attendance-table select {
    min-width: 136px;
}

.attendance-table input[type="time"] {
    min-width: 112px;
}

.amount {
    font-weight: 900;
    color: var(--brand-dark);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.therapy-calendar-panel {
    margin-bottom: 14px;
}

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

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

.calendar-weekday {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.calendar-day {
    display: grid;
    align-content: start;
    gap: 4px;
    min-height: 78px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    padding: 8px;
    text-decoration: none;
}

.calendar-day:hover,
.calendar-day:focus {
    border-color: var(--brand);
    outline: none;
}

.calendar-day.selected {
    border-color: var(--brand);
    background: var(--soft);
}

.calendar-day.today .calendar-date {
    color: var(--brand-dark);
}

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

.calendar-date {
    font-size: 17px;
    font-weight: 900;
    line-height: 1;
}

.calendar-count,
.calendar-attended,
.calendar-empty {
    font-size: 12px;
    line-height: 1.2;
}

.calendar-count {
    font-weight: 800;
    color: var(--brand-dark);
}

.calendar-attended,
.calendar-empty {
    color: var(--muted);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: start center;
    overflow-y: auto;
    padding: 38px 18px;
    background: rgba(26, 34, 33, 0.42);
}

.modal-panel {
    width: min(620px, 100%);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 24px 60px rgba(24, 33, 31, 0.24);
}

.metric {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    padding: 11px;
}

.metric span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.metric strong {
    display: block;
    margin-top: 4px;
    font-size: 19px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 800;
}

.badge-present {
    background: #dcefe8;
    color: #176452;
}

.badge-absent {
    background: #f4dfdc;
    color: #8b342e;
}

.badge-sick {
    background: #f7e7c7;
    color: #805314;
}

.badge-excused {
    background: #dce8f2;
    color: #2b5977;
}

.flash {
    margin-bottom: 16px;
    border-radius: 8px;
    padding: 12px 14px;
    background: #dcefe8;
    color: #176452;
    font-weight: 700;
}

.flash.error {
    background: #f4dfdc;
    color: #8b342e;
}

.form-fieldset {
    border: 0;
    margin: 0;
    padding: 0;
    min-inline-size: 0;
}

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

.login-card {
    width: min(430px, 100%);
}

.login-title {
    padding: 24px 24px 0;
}

.login-title h1 {
    margin: 0;
    font-size: 28px;
}

.login-title p {
    margin: 8px 0 0;
    color: var(--muted);
}

.quick-login {
    display: grid;
    gap: 10px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.package-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(190px, 1fr));
    gap: 10px;
}

.package-card {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.package-card.recommended {
    border-color: var(--accent);
}

.package-ribbon {
    position: absolute;
    right: -34px;
    top: 18px;
    width: 130px;
    transform: rotate(38deg);
    background: #86c940;
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    line-height: 28px;
    text-align: center;
    text-transform: uppercase;
}

.package-head {
    display: grid;
    gap: 2px;
    min-height: 68px;
    padding: 14px 12px;
    background: #f4bd68;
    color: white;
    text-align: center;
}

.package-head strong {
    font-size: 15px;
    text-transform: uppercase;
}

.package-head span {
    font-size: 12px;
    font-weight: 700;
}

.package-body {
    display: grid;
    gap: 10px;
    padding: 12px;
}

.package-save {
    margin: 16px 0 0;
}

.two-col {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
    gap: 16px;
}

.therapy-settings-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.therapist-editor-panel {
    max-width: none;
}

.therapy-detail-grid {
    display: grid;
    grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.selected-row td {
    background: #eaf4f1;
}

.empty-state {
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 16px;
    color: var(--muted);
    background: #faf7f0;
}

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

.checkbox {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--ink);
}

.checkbox input {
    width: 18px;
    min-height: 18px;
}

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

@media (max-width: 820px) {
    .sidebar {
        position: sticky;
        width: 100%;
        height: auto;
        padding: 12px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .brand {
        margin-bottom: 12px;
    }

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

    .sidebar-user {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        margin-top: 12px;
        padding-top: 12px;
    }

    .sidebar-user form {
        width: auto;
    }

    .sidebar-user button {
        width: auto;
    }

    .hero {
        align-items: flex-start;
        flex-direction: column;
    }

    .page {
        width: min(100% - 20px, 1180px);
        margin: 16px auto 36px;
    }

    .summary-grid,
    .two-col,
    .therapy-detail-grid,
    .package-grid {
        grid-template-columns: 1fr;
    }

    .attendance-table table,
    .attendance-table thead,
    .attendance-table tbody,
    .attendance-table th,
    .attendance-table td,
    .attendance-table tr {
        display: block;
    }

    .attendance-table thead {
        display: none;
    }

    .attendance-table tr {
        border-bottom: 1px solid var(--line);
        padding: 12px 0;
    }

    .attendance-table td {
        border: 0;
        padding: 7px 0;
    }

    .attendance-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 4px;
        color: var(--muted);
        font-size: 12px;
        font-weight: 800;
        text-transform: uppercase;
    }
}

@media print {
    body {
        background: white;
    }

    .topbar,
    .sidebar,
    .hero form,
    button,
    .button {
        display: none !important;
    }

    .page {
        width: 100%;
        margin: 0;
    }

    .panel,
    .metric {
        box-shadow: none;
        break-inside: avoid;
    }
}
