:root {
    color-scheme: light;
    --bg: #f6f7f3;
    --panel: #ffffff;
    --ink: #1d2522;
    --muted: #63706a;
    --line: #dfe5df;
    --primary: #176d5b;
    --primary-dark: #105143;
    --warn: #8c3d19;
    --ok: #16633e;
}

* {
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
}

.app-shell {
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
}

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

.topbar {
    align-items: center;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 24px;
    justify-content: space-between;
    padding: 14px 28px;
}

.brand {
    color: var(--ink);
    font-size: 19px;
    font-weight: 700;
    text-decoration: none;
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

nav a {
    color: var(--muted);
    font-weight: 700;
    text-decoration: none;
}

.nav-toggle {
    display: none;
}

.pagination {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 16px;
}

.notice-alerts {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.notice-alert {
    background: #fde8e8;
    border: 1px solid #e9a9a9;
    border-left: 6px solid #c94040;
    border-radius: 8px;
    color: #6f1d1d;
    display: block;
    font-weight: 700;
    padding: 13px 15px;
    text-decoration: none;
}

.notice-alert:hover {
    background: #fbdada;
    color: #5c1717;
}

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

.health-item {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    padding: 10px 12px;
}

.preset-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.inline-form {
    display: inline-block;
    margin: 8px 0 0;
}

.schedule-month {
    margin-bottom: 22px;
}

.schedule-month-head {
    align-items: baseline;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
}

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

.schedule-weekday,
.schedule-day {
    background: #f8faf8;
    border: 1px solid var(--line);
    min-width: 118px;
}

.schedule-weekday {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    padding: 8px;
    text-align: center;
}

.schedule-day {
    min-height: 128px;
    padding: 8px;
}

.schedule-day.empty {
    background: #eef3ef;
}

.schedule-day.today {
    border-color: var(--primary);
    box-shadow: inset 0 0 0 1px var(--primary);
}

.schedule-day-number {
    font-weight: 700;
    margin-bottom: 6px;
}

.schedule-chip {
    background: #e9f4ef;
    border-left: 3px solid var(--primary);
    border-radius: 5px;
    font-size: 12px;
    margin-top: 5px;
    overflow-wrap: anywhere;
    padding: 5px 6px;
}

.schedule-chip strong,
.schedule-chip span {
    display: block;
}

.schedule-more {
    color: var(--muted);
    font-size: 12px;
    margin-top: 5px;
}

.page {
    margin: 0 auto;
    max-width: 1120px;
    padding: 28px;
    width: 100%;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
}

.grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.form-grid {
    display: grid;
    gap: 0 16px;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.compact-form {
    margin-bottom: 22px;
}

.compact-form textarea {
    min-height: 110px;
}

.large-textarea {
    min-height: 420px;
}

.care-plan-readonly,
.audit-text {
    background: #f8faf8;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 14px;
    white-space: normal;
}

.audit-card h3 {
    font-size: 16px;
    margin: 16px 0 8px;
}

.audit-card summary {
    cursor: pointer;
    font-weight: 700;
}

.section-head {
    margin: 24px 0 12px;
}

.actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
    margin-bottom: 18px;
}

h1, h2 {
    line-height: 1.15;
    margin: 0 0 16px;
}

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

label {
    display: block;
    font-weight: 700;
    margin: 14px 0 6px;
}

input, select, textarea {
    border: 1px solid var(--line);
    border-radius: 6px;
    font: inherit;
    padding: 10px 12px;
    width: 100%;
}

.check-row {
    align-items: center;
    display: grid;
    gap: 8px;
    grid-template-columns: auto 18px;
    justify-content: start;
    margin: 18px 0 8px;
}

.check-row input[type="checkbox"] {
    align-self: center;
    height: 18px;
    margin: 0;
    padding: 0;
    width: 18px;
}

.check-row label {
    line-height: 1.25;
    margin: 0;
}

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

button, .button {
    background: var(--primary);
    border: 0;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    display: inline-block;
    font: inherit;
    font-weight: 700;
    padding: 10px 14px;
    text-decoration: none;
}

button:hover, .button:hover {
    background: var(--primary-dark);
}

.button.danger, button.danger {
    background: #9d2f2f;
}

.button.danger:hover, button.danger:hover {
    background: #742222;
}

.button.secondary, button.secondary {
    background: #e9eee9;
    color: var(--ink);
}

table {
    background: var(--panel);
    border-collapse: collapse;
    border: 1px solid var(--line);
    width: 100%;
}

.table-wrap {
    max-width: 100%;
    overflow-x: auto;
}

.passkey-table {
    font-size: 13px;
    table-layout: fixed;
}

.passkey-table th,
.passkey-table td {
    overflow-wrap: anywhere;
    padding: 8px;
}

.passkey-table th:last-child,
.passkey-table td:last-child {
    width: 86px;
}

.passkey-table form {
    margin: 0;
}

.passkey-table button {
    font-size: 12px;
    padding: 8px 6px;
    width: 100%;
}

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

th {
    background: #eef3ef;
    font-size: 14px;
}

.status {
    border-radius: 999px;
    display: inline-block;
    font-size: 13px;
    font-weight: 700;
    padding: 3px 8px;
}

.status.submitted {
    background: #fff0d7;
    color: var(--warn);
}

.status.approved {
    background: #dff4e7;
    color: var(--ok);
}

.status.rejected {
    background: #f9dddd;
    color: #8b1e24;
}

.flash {
    background: #dff4e7;
    border: 1px solid #b9dec9;
    border-radius: 8px;
    margin-bottom: 18px;
    padding: 12px 14px;
}

.error {
    background: #f9dddd;
    border: 1px solid #e6b6b9;
    border-radius: 8px;
    margin-bottom: 18px;
    padding: 12px 14px;
}

.qr {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    height: 260px;
    padding: 8px;
    width: 260px;
}

.qr svg {
    display: block;
    height: 100%;
    width: 100%;
}

.secret {
    background: #eef3ef;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-family: Consolas, Monaco, monospace;
    overflow-wrap: anywhere;
    padding: 10px 12px;
}

.footer {
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 14px;
    width: 100%;
}

.footer-inner {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin: 0 auto;
    max-width: 1120px;
    padding: 18px 28px 28px;
}

.footer-version {
    white-space: nowrap;
}

@media (max-width: 720px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .nav-toggle {
        display: inline-block;
    }

    nav {
        display: none;
        flex-direction: column;
        width: 100%;
    }

    nav.open {
        display: flex;
    }

    .page {
        padding: 18px;
    }

    .footer-inner {
        flex-direction: column;
        gap: 4px;
        padding: 16px 18px 24px;
    }

    table {
        display: block;
        overflow-x: auto;
    }
}
