:root {
    font-family:
        system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", sans-serif;
    color-scheme: light;
    background: #eef2f7;
    color: #172033;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.card {
    width: min(100%, 440px);
    padding: 32px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 36px rgb(15 23 42 / 12%);
}

h1 {
    margin: 0 0 10px;
    font-size: 1.7rem;
}

p {
    line-height: 1.7;
}

label {
    display: block;
    margin-top: 18px;
    font-weight: 700;
}

input {
    width: 100%;
    margin-top: 7px;
    padding: 12px;
    border: 1px solid #aab4c3;
    border-radius: 8px;
    font: inherit;
}

button {
    width: 100%;
    margin-top: 24px;
    padding: 12px;
    border: 0;
    border-radius: 8px;
    background: #174ea6;
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

button:hover {
    filter: brightness(.92);
}

.error {
    padding: 12px;
    border-radius: 8px;
    background: #fee2e2;
    color: #991b1b;
}

.notice {
    padding: 12px;
    border-radius: 8px;
    background: #dbeafe;
    color: #1e3a8a;
}

.meta {
    color: #536176;
    font-size: .92rem;
}

.logout button {
    background: #374151;
}


select {
    width: 100%;
    margin-top: 7px;
    padding: 12px;
    border: 1px solid #aab4c3;
    border-radius: 8px;
    background: #fff;
    font: inherit;
}

.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.error-list {
    margin: 8px 0 0;
    padding-left: 22px;
}

@media (max-width: 560px) {
    .field-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .card {
        padding: 24px 20px;
    }
}

.admin-section {
    margin-top: 30px;
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 14px;
}

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

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

.table-actions form {
    margin: 0;
}

.table-actions button {
    margin: 0;
    padding: 8px 12px;
}

.status-ok {
    font-weight: 700;
}

.status-pending {
    font-weight: 700;
}

button.secondary {
    background: #58677d;
}

button.danger {
    background: #9f2f2f;
}

/* メール通知先管理画面 */
.card.card-wide {
    width: min(100%, 1100px);
}

.card-wide .table-scroll {
    width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
}

.card-wide .data-table {
    width: 100%;
    min-width: 820px;
    table-layout: auto;
}

.card-wide .data-table th,
.card-wide .data-table td {
    word-break: normal;
    overflow-wrap: normal;
}

.card-wide .data-table th:nth-child(1),
.card-wide .data-table td:nth-child(1) {
    min-width: 110px;
}

.card-wide .data-table th:nth-child(2),
.card-wide .data-table td:nth-child(2) {
    min-width: 280px;
    white-space: nowrap;
}

.card-wide .data-table th:nth-child(3),
.card-wide .data-table td:nth-child(3) {
    min-width: 170px;
}

.card-wide .data-table th:nth-child(4),
.card-wide .data-table td:nth-child(4) {
    min-width: 145px;
    white-space: nowrap;
}

.card-wide .data-table th:nth-child(5),
.card-wide .data-table td:nth-child(5) {
    min-width: 130px;
}

.card-wide .table-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
}

.card-wide .table-actions form {
    width: auto;
    margin: 0;
}

.card-wide .table-actions button {
    width: auto;
    min-width: 56px;
    white-space: nowrap;
}

@media (max-width: 700px) {
    body {
        padding: 12px;
        place-items: start center;
    }

    .card.card-wide {
        padding: 20px;
    }
}

/* ワイド管理画面の最大幅制限を上書き */
.card.card-wide {
    width: calc(100vw - 48px);
    max-width: 1100px;
    min-width: 0;
}

@media (max-width: 700px) {
    .card.card-wide {
        width: calc(100vw - 24px);
        max-width: none;
    }
}

/*
 * メール通知先管理画面をワイド表示する。
 * card-wideが付いていない場合にも適用される。
 */
body:has(> main.card .admin-section) > main.card {
    width: calc(100vw - 48px);
    max-width: 1100px;
    min-width: 0;
}

body:has(> main.card .admin-section) .table-scroll {
    width: 100%;
    overflow-x: auto;
}

body:has(> main.card .admin-section) .data-table {
    width: 100%;
    min-width: 820px;
}

@media (max-width: 700px) {
    body:has(> main.card .admin-section) > main.card {
        width: calc(100vw - 24px);
        max-width: none;
    }
}

.member-dashboard .current-attendance {
    padding: 14px;
    border-radius: 8px;
    background: #eef5ff;
}

.member-dashboard select,
.member-dashboard textarea {
    width: 100%;
}

.member-dashboard textarea {
    resize: vertical;
}

.member-dashboard .attendance-list {
    margin-top: 30px;
}

body:has(> main.card .member-dashboard) > main.card {
    width: calc(100vw - 48px);
    max-width: 850px;
    min-width: 0;
}

@media (max-width: 700px) {
    body:has(> main.card .member-dashboard) > main.card {
        width: calc(100vw - 24px);
        max-width: none;
    }
}

body:has(> main.card .admin-roster-page) > main.card,
body:has(> main.card .admin-attendance-page) > main.card {
    width: calc(100vw - 48px);
    max-width: 1200px;
    min-width: 0;
}

.roster-table {
    min-width: 1050px;
}

.button-link {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 7px;
    text-decoration: none;
    background: #315ea8;
    color: white;
    white-space: nowrap;
}

.danger-link {
    background: #9f2f2f;
}

@media (max-width: 700px) {
    body:has(> main.card .admin-roster-page) > main.card,
    body:has(> main.card .admin-attendance-page) > main.card {
        width: calc(100vw - 24px);
        max-width: none;
    }
}

/* ===== 日別出欠一覧：スマートフォン表示 ===== */

@media (max-width: 700px) {
    .admin-attendance-page .table-scroll {
        width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
    }

    .admin-attendance-page .data-table {
        width: 760px;
        min-width: 760px;
        table-layout: auto;
    }

    .admin-attendance-page .data-table th,
    .admin-attendance-page .data-table td {
        padding: 10px 12px;
        vertical-align: top;
    }

    .admin-attendance-page .data-table th:nth-child(1),
    .admin-attendance-page .data-table td:nth-child(1) {
        min-width: 95px;
        white-space: nowrap;
    }

    .admin-attendance-page .data-table th:nth-child(2),
    .admin-attendance-page .data-table td:nth-child(2) {
        min-width: 110px;
        white-space: nowrap;
    }

    .admin-attendance-page .data-table th:nth-child(3),
    .admin-attendance-page .data-table td:nth-child(3) {
        min-width: 75px;
        white-space: nowrap;
    }

    .admin-attendance-page .data-table th:nth-child(4),
    .admin-attendance-page .data-table td:nth-child(4) {
        min-width: 65px;
        white-space: nowrap;
    }

    .admin-attendance-page .data-table th:nth-child(5),
    .admin-attendance-page .data-table td:nth-child(5) {
        min-width: 150px;
        overflow-wrap: anywhere;
    }

    .admin-attendance-page .data-table th:nth-child(6),
    .admin-attendance-page .data-table td:nth-child(6) {
        min-width: 145px;
        white-space: nowrap;
    }

    .admin-attendance-page form button {
        width: 100%;
    }
}

/* ===== 出欠状態の色分け ===== */

.attendance-status-text {
    font-weight: 700;
}

.attendance-status-text.status-absent {
    color: #c62828;
}

.attendance-status-text.status-late {
    color: #d97706;
}

.attendance-status-text.status-present {
    color: #18864b;
}

.attendance-status-text.status-other {
    color: #475569;
}


/* PCでは通常の表だけを表示 */

.attendance-mobile-list {
    display: none;
}


/* ===== 日別出欠一覧：スマートフォンカード表示 ===== */

@media (max-width: 700px) {
    .admin-attendance-page .attendance-desktop-table {
        display: none;
    }

    .admin-attendance-page .attendance-mobile-list {
        display: grid;
        gap: 12px;
        margin-top: 14px;
    }

    .attendance-mobile-card {
        overflow: hidden;
        border: 1px solid #d7deea;
        border-radius: 12px;
        background: #ffffff;
        box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
    }

    /*
     * 1段目：
     * 氏名、学籍番号、入学年度、更新日時
     */
    .attendance-mobile-name-row {
        padding: 14px 15px 12px;
    }

    .attendance-mobile-name {
        display: block;
        font-size: 1.05rem;
        line-height: 1.45;
        overflow-wrap: anywhere;
    }

    .attendance-mobile-meta {
        margin-top: 4px;
        color: #64748b;
        font-size: 0.78rem;
        line-height: 1.55;
    }

    /*
     * 2段目：
     * 状態 / 理由
     */
    .attendance-mobile-detail-row {
        display: grid;
        grid-template-columns: 72px minmax(0, 1fr);
        gap: 10px;
        align-items: start;

        padding: 12px 15px;

        border-top: 1px solid #e2e8f0;
        background: #f8fafc;
    }

    .attendance-mobile-detail-row
    .attendance-status-text {
        font-size: 1rem;
        white-space: nowrap;
    }

    .attendance-mobile-reason {
        min-width: 0;
        color: #334155;
        line-height: 1.55;
        overflow-wrap: anywhere;
        word-break: normal;
    }
}
