:root {
    color-scheme: light;
    --bg: #f3f7f6;
    --ink: #172126;
    --muted: #627176;
    --line: #dbe5e4;
    --panel: #ffffff;
    --panel-soft: #f8fbfa;
    --accent: #147c72;
    --accent-dark: #0d5f58;
    --accent-soft: #e5f4f1;
    --nav: #0c2428;
    --danger: #b42318;
    --warn-bg: #fff7dc;
    --shadow: 0 14px 36px rgba(16, 35, 38, .08);
    --shadow-soft: 0 8px 20px rgba(16, 35, 38, .06);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        linear-gradient(180deg, rgba(20, 124, 114, .08), transparent 320px),
        var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
}

.login-page {
    background:
        linear-gradient(135deg, #0c2428 0%, #12373a 56%, #0f2c30 100%);
}

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

.login-card {
    background: rgba(255, 255, 255, .98);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, .7);
    box-shadow: 0 26px 80px rgba(0, 0, 0, .34);
    max-width: 420px;
    padding: 30px;
    width: min(100%, 420px);
}

.login-card h1 {
    margin: 0;
    line-height: 1.05;
}

.login-note {
    color: var(--muted);
    line-height: 1.5;
    margin: 10px 0 20px;
}

.login-help {
    background: var(--accent-soft);
    border-radius: 8px;
    display: grid;
    gap: 6px;
    margin-top: 16px;
    padding: 14px;
}

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

.topbar {
    align-items: center;
    background:
        linear-gradient(135deg, var(--nav), #11383b);
    color: #fff;
    display: flex;
    justify-content: space-between;
    padding: 24px 48px;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 12px 34px rgba(12, 36, 40, .18);
}

.topbar h1,
.panel h2 {
    margin: 0;
}

.topbar nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.topbar a {
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 6px;
    color: #fff;
    padding: 10px 13px;
    text-decoration: none;
    transition: background .16s ease, border-color .16s ease, transform .16s ease;
}

.topbar a:hover {
    background: rgba(255, 255, 255, .14);
    border-color: rgba(255, 255, 255, .34);
    transform: translateY(-1px);
}

.button-link {
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    display: inline-flex;
    font-weight: 700;
    justify-content: center;
    min-height: 40px;
    padding: 8px 12px;
    text-decoration: none;
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.button-link:hover {
    border-color: rgba(20, 124, 114, .35);
    box-shadow: var(--shadow-soft);
    transform: translateY(-1px);
}

main {
    margin: 0 auto;
    max-width: 1280px;
    padding: 24px;
}

.userbar {
    align-items: center;
    background: rgba(255, 255, 255, .9);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 14px 16px;
    box-shadow: var(--shadow-soft);
}

.yearbar {
    align-items: center;
    background: rgba(255, 255, 255, .9);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 14px 16px;
    box-shadow: var(--shadow-soft);
}

.year-picker {
    align-items: end;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(240px, 320px) auto;
}

.yearbar div {
    display: grid;
    gap: 4px;
    text-align: right;
}

.yearbar span,
.muted {
    color: var(--muted);
}

.userbar div,
.user-list article,
.user-card {
    display: grid;
    gap: 4px;
}

.userbar span,
.userbar small,
.user-list span,
.user-list small {
    color: var(--muted);
}

.eyebrow {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    margin: 0 0 6px;
    text-transform: uppercase;
}

.topbar .eyebrow {
    color: #9eb3b6;
}

.stats {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 16px;
}

.stats div,
.panel,
.warning,
.alert {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.stats div {
    background: linear-gradient(180deg, #ffffff, #f9fcfb);
    box-shadow: var(--shadow-soft);
    position: relative;
    padding: 18px;
}

.stats div::before {
    background: var(--accent);
    border-radius: 999px;
    content: "";
    height: 4px;
    left: 18px;
    position: absolute;
    right: 18px;
    top: 0;
}

.stats span {
    display: block;
    font-size: 28px;
    font-weight: 700;
}

.stats p {
    color: var(--muted);
    margin: 4px 0 0;
}

.panel {
    margin-bottom: 18px;
    padding: 20px;
    box-shadow: var(--shadow);
}

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

.section-note {
    color: var(--muted);
    margin: 6px 0 0;
}

.filters,
.grid-form,
.stack {
    display: grid;
    gap: 10px;
}

.filters {
    align-items: center;
    grid-template-columns: 180px 260px auto auto;
}

.moving-filter {
    align-items: end;
    display: grid;
    gap: 10px;
    grid-template-columns: 150px auto;
}

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

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

input,
select,
button {
    border: 1px solid var(--line);
    border-radius: 6px;
    font: inherit;
    min-height: 40px;
    padding: 8px 10px;
}

input,
select {
    background: #fff;
    color: var(--ink);
    transition: border-color .16s ease, box-shadow .16s ease;
}

input:focus,
select:focus {
    border-color: rgba(20, 124, 114, .65);
    box-shadow: 0 0 0 3px rgba(20, 124, 114, .14);
    outline: none;
}

.password-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 72px;
}

.password-field input {
    border-radius: 6px 0 0 6px;
    min-width: 0;
}

.password-field .eye-toggle {
    border-radius: 0 6px 6px 0;
    min-height: 40px;
    padding: 8px;
}

button {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    cursor: pointer;
    font-weight: 700;
    transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

button:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
    box-shadow: 0 8px 18px rgba(20, 124, 114, .18);
    transform: translateY(-1px);
}

button:disabled {
    background: #a8b8b7;
    border-color: #a8b8b7;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.ghost {
    background: #fff;
    border-color: #f1b5af;
    color: var(--danger);
}

.ghost:hover {
    background: #fff6f5;
    border-color: #e47f75;
    color: var(--danger);
}

.ghost.neutral {
    border-color: var(--line);
    color: var(--ink);
}

.ghost.neutral:hover {
    background: var(--panel-soft);
    border-color: rgba(20, 124, 114, .3);
}

.small {
    min-height: 34px;
    padding: 6px 10px;
}

.schedule-wrap {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: auto;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .75);
}

.schedule-table {
    border-collapse: collapse;
    min-width: 1120px;
    width: 100%;
}

.schedule-table th,
.schedule-table td {
    border: 1px solid #e1e9e8;
    height: 86px;
    padding: 8px;
    text-align: left;
    vertical-align: top;
}

.schedule-table thead th {
    background: #eaf3f2;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 2;
}

.schedule-table th:first-child {
    background: #eaf3f2;
    width: 92px;
}

.schedule-table tbody tr:nth-child(even) td {
    background: #fbfdfd;
}

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

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

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

.table-scroll {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: auto;
    background: #fff;
}

.compact-scroll {
    max-height: 520px;
}

.list-scroll {
    max-height: 420px;
}

.year-list {
    margin-top: 16px;
    max-height: 280px;
}

.time-row {
    align-items: center;
    display: grid;
    gap: 8px;
    grid-template-columns: 90px 1fr 1fr auto;
}

.time-row + form {
    margin-top: 8px;
}

.data-table {
    border-collapse: collapse;
    min-width: 860px;
    width: 100%;
}

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

.data-table thead th {
    background: #eaf3f2;
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table tbody tr:nth-child(even) {
    background: #fbfdfd;
}

.data-table tbody tr:hover {
    background: var(--accent-soft);
}

.moving-scroll {
    max-height: 560px;
}

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

.moving-table th:first-child,
.moving-table td:first-child {
    background: #eaf3f2;
    font-weight: 700;
}

.moving-table td {
    min-width: 82px;
    vertical-align: top;
}

.moving-table td strong,
.moving-table td span,
.moving-table td small {
    display: block;
}

.moving-table td strong {
    color: var(--accent-dark);
}

.moving-table td small {
    color: var(--muted);
}

.row {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    padding: 12px;
    background: #fff;
    transition: border-color .16s ease, box-shadow .16s ease;
}

.row:hover {
    border-color: rgba(20, 124, 114, .28);
    box-shadow: var(--shadow-soft);
}

.swap-box {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 14px;
    margin-top: 18px;
    padding: 16px;
}

.swap-box h3 {
    margin: 0;
}

.schedule-summary-row td {
    padding: 8px;
}

.schedule-edit-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.schedule-edit-card summary {
    align-items: center;
    cursor: pointer;
    display: grid;
    gap: 8px;
    grid-template-columns: 130px minmax(160px, 1fr) minmax(180px, 1fr) 130px;
    list-style-position: inside;
}

.schedule-edit-card summary span {
    color: var(--muted);
}

.schedule-edit-form {
    margin: 14px 0 10px;
}

.row p,
.empty {
    color: var(--muted);
    margin: 4px 0 0;
}

.master-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.compact-master-list {
    max-height: 520px;
    overflow: auto;
    padding-right: 4px;
}

.master-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 10px;
    padding: 12px;
    background: #fff;
    transition: border-color .16s ease, box-shadow .16s ease;
}

.master-card:hover,
.user-card:hover,
.user-list article:hover,
.import-box:hover {
    border-color: rgba(20, 124, 114, .28);
    box-shadow: var(--shadow-soft);
}

.master-card summary {
    cursor: pointer;
    display: grid;
    gap: 4px;
    list-style-position: inside;
}

.master-card summary span {
    color: var(--muted);
}

.master-card form:first-of-type {
    margin-top: 10px;
}

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

.import-box {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: #fff;
    transition: border-color .16s ease, box-shadow .16s ease;
}

.import-box h3 {
    margin: 0;
}

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

.user-list {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 18px;
}

.user-list article,
.user-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fff;
    transition: border-color .16s ease, box-shadow .16s ease;
}

.user-card {
    align-content: start;
}

.user-card summary {
    cursor: pointer;
    display: grid;
    gap: 4px;
    list-style-position: inside;
}

.user-card form:first-of-type {
    margin-top: 12px;
}

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

.pagination a,
.pagination span,
.pagination strong {
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    min-width: 40px;
    padding: 8px 11px;
    text-align: center;
    text-decoration: none;
}

.pagination a:hover {
    border-color: rgba(20, 124, 114, .35);
    background: var(--accent-soft);
}

.print-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    margin: -4px 0 16px;
}

.print-page {
    background: #edf3f2;
}

.print-shell {
    max-width: 1180px;
}

.print-toolbar {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-bottom: 16px;
}

.print-sheet {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
    padding: 22px;
}

.print-head {
    align-items: end;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 16px;
}

.print-head h1,
.print-head p {
    margin: 0;
}

.print-head p {
    color: var(--muted);
    margin-top: 6px;
}

.print-head div:last-child {
    background: var(--accent-soft);
    border: 1px solid #cce7e3;
    border-radius: 8px;
    display: grid;
    min-width: 120px;
    padding: 12px;
    text-align: center;
}

.print-head div:last-child span {
    font-size: 28px;
    font-weight: 700;
}

.print-table {
    min-width: 0;
}

.print-table th,
.print-table td {
    height: 70px;
}

.print-list-table {
    min-width: 0;
}

.print-list-table th,
.print-list-table td {
    padding: 8px 10px;
}

.pagination strong {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

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

.password-update {
    border-top: 1px solid var(--line);
    margin-top: 12px;
    padding-top: 12px;
}

.warning,
.alert {
    margin-bottom: 16px;
    padding: 14px 16px;
    box-shadow: var(--shadow-soft);
}

.warning {
    background: var(--warn-bg);
}

.conflict-list {
    margin: 10px 0 0;
    padding-left: 18px;
}

.alert.success {
    border-color: #9bd6bd;
    background: #f2fbf7;
}

.alert.error {
    border-color: #f1b5af;
    background: #fff7f6;
    color: var(--danger);
}

@media (max-width: 900px) {
    .topbar,
    .section-title,
    .userbar,
    .yearbar {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar {
        padding: 20px 16px;
        position: static;
    }

    .topbar nav {
        justify-content: flex-start;
    }

    .stats,
    .grid-form,
    .master-grid,
    .master-list,
    .filters,
    .moving-filter,
    .import-grid,
    .user-list {
        grid-template-columns: 1fr;
    }

    .year-picker {
        grid-template-columns: 1fr;
    }

    .time-row {
        grid-template-columns: 1fr;
    }

    .schedule-edit-card summary {
        align-items: start;
        grid-template-columns: 1fr;
    }

    .yearbar div {
        text-align: left;
    }

    main {
        padding: 14px;
    }

    .login-card {
        padding: 24px;
    }
}

@media print {
    @page {
        margin: 10mm;
        size: landscape;
    }

    body,
    .print-page {
        background: #fff;
    }

    .print-shell {
        max-width: none;
        padding: 0;
    }

    .print-toolbar {
        display: none;
    }

    .print-sheet {
        border: 0;
        box-shadow: none;
        break-after: page;
        margin: 0;
        padding: 0;
        page-break-after: always;
    }

    .print-sheet:last-child {
        break-after: auto;
        page-break-after: auto;
    }

    .print-head {
        margin-bottom: 10px;
    }

    .print-head h1 {
        font-size: 22px;
    }

    .print-head div:last-child {
        background: #fff;
        min-width: 90px;
        padding: 8px;
    }

    .schedule-table {
        font-size: 11px;
    }

    .schedule-table th,
    .schedule-table td {
        height: 48px;
        padding: 5px;
    }

    .schedule-table thead th {
        position: static;
    }

    .print-list-table {
        font-size: 11px;
    }

    .print-list-table thead th {
        position: static;
    }

    .print-list-table th,
    .print-list-table td {
        padding: 5px 6px;
    }

    .eyebrow {
        font-size: 10px;
    }
}
