* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #f8f8f8;
    color: #1f2937;
    font-family: Sarabun, "Noto Sans Thai", Arial, sans-serif;
    font-size: 18px;
    line-height: 1.4;
}

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

.text-link {
    color: #991b1b;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 250px 1fr;
}

.sidebar {
    background: #ffffff;
    border-right: 1px solid #ead7d7;
    color: #7f1d1d;
    padding: 24px 20px;
}

.sidebar-backdrop,
.menu-toggle {
    display: none;
}

.brand-mark {
    width: 68px;
    height: 68px;
    background: #fff;
    border: 2px solid #b91c1c;
    border-radius: 50%;
    display: grid;
    place-items: center;
    margin-bottom: 12px;
    overflow: hidden;
}

.brand-mark img {
    display: block;
    height: 100%;
    object-fit: contain;
    width: 100%;
}

.brand-title {
    font-size: 24px;
    font-weight: 700;
}

.brand-subtitle {
    color: #7f1d1d;
    font-size: 17px;
}

.nav {
    display: grid;
    gap: 8px;
    margin-top: 32px;
}

.nav-section {
    color: #991b1b;
    font-size: 16px;
    font-weight: 700;
    margin-top: 12px;
    padding: 0 4px;
}

.nav a,
.nav button {
    background: #fff7f7;
    border: 1px solid #f3d0d0;
    border-radius: 6px;
    color: #7f1d1d;
    cursor: pointer;
    display: block;
    font: inherit;
    padding: 10px 12px;
    text-align: left;
    width: 100%;
}

.content {
    min-width: 0;
    padding: 28px;
}

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

.menu-toggle {
    align-items: center;
    background: #fff;
    border: 1px solid #f3d0d0;
    border-radius: 6px;
    color: #7f1d1d;
    cursor: pointer;
    font: inherit;
    font-size: 24px;
    height: 42px;
    justify-content: center;
    line-height: 1;
    width: 46px;
}

.language-switch {
    display: flex;
    gap: 8px;
}

.button,
button.button {
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #1f2937;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    padding: 8px 14px;
}

.language-switch a {
    align-items: center;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    display: inline-flex;
    font-size: 24px;
    height: 40px;
    justify-content: center;
    line-height: 1;
    width: 46px;
}

.language-switch a[aria-current="true"] {
    border-color: #b91c1c;
    box-shadow: 0 0 0 2px rgba(185, 28, 28, .16);
}

.button.primary {
    background: #b91c1c;
    border-color: #b91c1c;
    color: #fff;
}

.button.small {
    font-size: 16px;
    padding: 5px 10px;
}

.button.danger {
    border-color: #fecaca;
    color: #991b1b;
}

.actions {
    align-items: center;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

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

.schedule-filter {
    align-items: end;
}

.filter-grid {
    align-items: end;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.filter-grid .form-actions {
    flex-wrap: wrap;
    margin-top: 0;
}

.activity-details summary {
    color: #991b1b;
    cursor: pointer;
    font-weight: 700;
}

.activity-details pre {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 14px;
    line-height: 1.45;
    margin: 8px 0 0;
    max-width: 760px;
    overflow-x: auto;
    padding: 10px 12px;
}

.schedule-filter .form-actions {
    align-items: end;
    flex-wrap: wrap;
    margin-top: 0;
}

.schedule-card h2 {
    margin-top: 0;
}

.schedule-table {
    min-width: 1180px;
}

.schedule-table th:first-child {
    min-width: 112px;
    width: 112px;
}

.schedule-table th span,
.schedule-table td span,
.schedule-table th .muted {
    display: block;
}

.schedule-table td {
    min-width: 145px;
}

.schedule-block {
    border-radius: 6px;
    font-size: 16px;
    margin-bottom: 6px;
    padding: 7px 8px;
}

.schedule-block.fixed {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #7c2d12;
}

.schedule-block.reservation {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #7f1d1d;
}

.schedule-action {
    background: #fff;
    border: 1px solid #fed7aa;
    border-radius: 6px;
    color: #7c2d12;
    display: inline-flex;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    margin-top: 6px;
    padding: 5px 8px;
}

.schedule-available {
    border: 1px dashed #d1d5db;
    border-radius: 6px;
    color: #6b7280;
    display: block;
    min-height: 64px;
    padding: 7px 8px;
}

.schedule-available strong {
    color: #991b1b;
    display: block;
    font-size: 16px;
    font-weight: 700;
    margin-top: 3px;
}

.schedule-available:hover,
.schedule-available:focus-visible {
    background: #fff7f7;
    border-color: #b91c1c;
    outline: none;
}

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

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

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

.card {
    background: #fff;
    border: 1px solid #ead7d7;
    border-radius: 8px;
    padding: 18px;
}

.card h2,
.card h3,
.page-title {
    margin: 0 0 12px;
}

.card h2 {
    font-size: 24px;
    line-height: 1.25;
}

.card h3 {
    font-size: 21px;
    line-height: 1.25;
}

.page-title {
    font-size: 30px;
    line-height: 1.2;
}

.section-title {
    color: #7f1d1d;
    font-size: 23px;
    line-height: 1.2;
    margin: 22px 0 12px;
}

.app-launcher {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    margin-bottom: 18px;
}

.app-tile {
    align-items: center;
    background: #fff;
    border: 1px solid #ead7d7;
    border-radius: 8px;
    color: #1f2937;
    display: flex;
    gap: 14px;
    min-height: 108px;
    padding: 18px;
}

.app-tile:hover {
    border-color: #b91c1c;
    box-shadow: 0 10px 24px rgba(127, 29, 29, 0.08);
}

.app-icon {
    border-radius: 8px;
    flex: 0 0 52px;
    height: 52px;
    object-fit: contain;
    width: 52px;
}

.app-tile strong,
.app-tile small {
    display: block;
}

.app-tile strong {
    color: #7f1d1d;
    font-size: 23px;
    line-height: 1.2;
}

.app-tile small {
    color: #6b7280;
    font-size: 16px;
    line-height: 1.35;
    margin-top: 5px;
}

.metric {
    font-size: 34px;
    font-weight: 700;
    line-height: 1.15;
}

.dashboard-list {
    display: grid;
    gap: 8px;
}

.dashboard-list a {
    align-items: center;
    background: #fff7f7;
    border: 1px solid #f3d0d0;
    border-radius: 6px;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 9px 12px;
}

.student-history-item {
    background: #fff7f7;
    border: 1px solid #f3d0d0;
    border-radius: 6px;
    padding: 9px 12px;
}

.dashboard-list strong {
    color: #7f1d1d;
    font-size: 20px;
    white-space: nowrap;
}

.muted {
    color: #6b7280;
}

.status {
    background: #fef2f2;
    border-radius: 999px;
    color: #991b1b;
    display: inline-block;
    font-size: 16px;
    padding: 3px 10px;
}

.status.cancelled {
    background: #f3f4f6;
    color: #4b5563;
}

.notice {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    color: #9a3412;
    margin-bottom: 16px;
    padding: 10px 12px;
}

.errors {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #991b1b;
    margin-bottom: 16px;
    padding: 10px 12px;
}

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

th,
td {
    border-bottom: 1px solid #e5e7eb;
    padding: 10px;
    text-align: left;
    vertical-align: top;
}

th {
    color: #374151;
    font-weight: 700;
}

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

.field-label {
    font-weight: 700;
    margin-bottom: 6px;
}

.checkbox-list {
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    display: grid;
    gap: 8px;
    padding: 10px;
}

.inline-check {
    align-items: center;
    display: flex;
    font-weight: 400;
    gap: 8px;
    margin-bottom: 0;
}

.inline-check input {
    width: auto;
}

input,
select,
textarea {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font: inherit;
    padding: 8px 10px;
    width: 100%;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

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

.login-card {
    margin: 0 auto;
    max-width: 460px;
    width: 100%;
}

.registration-card {
    margin: 0 auto;
    max-width: 860px;
    width: 100%;
}

.login-divider {
    align-items: center;
    color: #6b7280;
    display: flex;
    gap: 12px;
    margin: 18px 0;
}

.login-divider::before,
.login-divider::after {
    background: #e5e7eb;
    content: "";
    flex: 1;
    height: 1px;
}

.line-login {
    align-items: center;
    background: #06c755;
    border-color: #06c755;
    color: #fff;
    gap: 10px;
    justify-content: center;
    width: 100%;
}

.line-mark {
    border-right: 1px solid rgba(255, 255, 255, .45);
    font-family: Arial, sans-serif;
    font-size: 14px;
    font-weight: 700;
    padding-right: 10px;
}

.login-note {
    font-size: 16px;
    margin-top: 10px;
    text-align: center;
}

.registration-heading {
    align-items: center;
    display: flex;
    gap: 14px;
}

.line-avatar {
    border: 1px solid #d1d5db;
    border-radius: 50%;
    height: 64px;
    object-fit: cover;
    width: 64px;
}

.status-card {
    display: grid;
    gap: 16px;
}

.status.pending {
    background: #fff7ed;
    color: #9a3412;
}

.nav-count {
    background: #b91c1c;
    border-radius: 999px;
    color: #fff;
    float: right;
    font-size: 14px;
    line-height: 1;
    min-width: 22px;
    padding: 4px 6px;
    text-align: center;
}

@media (max-width: 1023px) {
    body.menu-open {
        overflow: hidden;
    }

    .shell {
        display: block;
        grid-template-columns: 1fr;
    }

    .sidebar {
        bottom: 0;
        left: 0;
        max-width: 86vw;
        overflow-y: auto;
        position: fixed;
        top: 0;
        transform: translateX(-100%);
        transition: transform .18s ease;
        width: 290px;
        z-index: 40;
    }

    body.menu-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        background: rgba(17, 24, 39, .42);
        border: 0;
        bottom: 0;
        cursor: pointer;
        display: block;
        left: 0;
        opacity: 0;
        pointer-events: none;
        position: fixed;
        right: 0;
        top: 0;
        transition: opacity .18s ease;
        z-index: 30;
    }

    body.menu-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .brand-mark {
        margin-bottom: 12px;
    }

    .nav {
        gap: 6px;
        margin-top: 18px;
    }

    .nav a,
    .nav button {
        min-height: 44px;
        padding: 9px 11px;
    }

    .content {
        padding: 18px;
    }

    .menu-toggle {
        display: inline-flex;
    }

    .grid.two,
    .grid.three,
    .filter-grid {
        grid-template-columns: 1fr;
    }
}
