:root {
    color-scheme: light dark;
    --bg: #f7f7fa;
    --fg: #1b1b1f;
    --muted: #666;
    --border: #ddd;
    --accent: #2f6fed;
    --danger: #d63333;
    --ok: #1f9d55;
    --today: #fff6d8;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--fg);
}

.site-header {
    background: #16181d;
    color: #fff;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 12px 16px;
}

.site-header a {
    color: inherit;
    text-decoration: none;
}

.topnav {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #20232a;
    padding: 0 12px;
}

.topnav a, .topnav summary {
    display: flex;
    align-items: center;
    color: #ddd;
    text-decoration: none;
    padding: 12px 14px;
    font-size: 14px;
    flex: none;
    cursor: pointer;
}

.topnav a:hover, .topnav summary:hover { color: #fff; background: #2c2f38; }
.topnav a.active { color: #fff; background: var(--accent); }
.topnav a.nav-right { margin-left: auto; }

.nav-dropdown {
    position: relative;
}

.nav-dropdown summary {
    list-style: none;
}

.nav-dropdown summary::-webkit-details-marker { display: none; }
.nav-dropdown summary::marker { content: ''; }
.topnav summary.active { color: #fff; background: var(--accent); }

.nav-caret {
    margin-left: 6px;
    font-size: 12px;
}

.dropdown-menu {
    position: absolute;
    left: 0;
    top: 100%;
    background: #20232a;
    border: 1px solid #2c2f38;
    border-radius: 0 0 6px 6px;
    display: flex;
    flex-direction: column;
    min-width: 170px;
    z-index: 10;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.dropdown-menu a {
    padding: 12px 14px;
    white-space: nowrap;
}

.nav-icon {
    font-size: 20px;
    line-height: 1;
}

.nav-label {
    margin-left: 10px;
    font-size: 14px;
}

@media (max-width: 640px) {
    .topnav > a .nav-label,
    .nav-dropdown summary .nav-label { display: none; }
}

.login-main {
    max-width: 320px;
    margin: 80px auto 0;
    padding: 0 16px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 16px 60px;
}

h1 { font-size: 22px; margin-bottom: 16px; }

.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0;
}

input[type="text"], select, button {
    font-size: 14px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
    color: var(--fg);
}

button {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    cursor: pointer;
}

button:hover { opacity: 0.9; }
button.danger { background: var(--danger); border-color: var(--danger); }
button:disabled { opacity: 0.5; cursor: default; }

.data-table {
    border-collapse: collapse;
    width: 100%;
    margin-top: 16px;
    background: #fff;
}

.data-table th, .data-table td {
    border: 1px solid var(--border);
    padding: 8px;
    text-align: left;
    font-size: 14px;
}

.data-table th { background: #eef0f4; }

.error {
    color: var(--danger);
    font-weight: 600;
}

.save-status {
    min-height: 1.4em;
    font-size: 13px;
    font-weight: 600;
}

.save-status.ok { color: var(--ok); }
.save-status.error { color: var(--danger); }

.grid-scroll {
    overflow-x: auto;
}

table.grid-table {
    width: auto;
    table-layout: fixed;
}

.grid-table th, .grid-table td {
    text-align: center;
    white-space: nowrap;
    width: 136px;
}

.grid-table .sticky-col {
    position: sticky;
    left: 0;
    background: #eef0f4;
    text-align: left;
    z-index: 1;
    width: 130px;
}

.grid-table td.sticky-col { background: #fff; }

.grid-table th.today { background: var(--today); }

.day-cell {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
}

.grid-table select.day-select {
    min-width: 0;
    width: 100%;
}

.grid-table select.day-select:disabled {
    background: #eee;
    color: #888;
}

.day-participated {
    width: 16px;
    height: 16px;
    flex: none;
}

.participated-mark {
    color: var(--ok);
    font-weight: 700;
    font-size: 16px;
    flex: none;
}

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

.booked-mark {
    color: var(--accent);
    font-size: 18px;
    line-height: 1;
}

.class-tag {
    color: var(--muted);
    font-size: 12px;
    margin-left: 4px;
}

.week-title {
    margin: 24px 0 4px;
    font-size: 16px;
}

.week-title:first-of-type {
    margin-top: 12px;
}

.mobile-cards {
    display: none;
}

.day-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px 14px;
    margin-bottom: 14px;
}

.day-card.today {
    border-color: #e6cf6b;
    background: var(--today);
}

.day-card-title {
    margin: 10px 0;
    font-size: 16px;
}

.student-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-top: 1px solid var(--border);
}

.day-card.today .student-row {
    border-top-color: rgba(0, 0, 0, 0.1);
}

.student-label {
    flex: 0 0 90px;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.student-row .day-cell {
    flex: 1;
    justify-content: flex-start;
}

.student-row .day-select {
    flex: 1;
    min-width: 0;
    font-size: 16px;
    padding: 8px;
}

.student-row .day-participated {
    width: 22px;
    height: 22px;
}

@media (max-width: 640px) {
    .desktop-table {
        display: none;
    }

    .mobile-cards {
        display: block;
    }
}

.reorder-cell .inline-form {
    margin: 0 2px 0 0;
}
