/* ===========================
   Base
=========================== */

* {
    box-sizing: border-box;
}

html {
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "Hiragino Kaku Gothic ProN",
        "Hiragino Sans",
        "Yu Gothic",
        Meiryo,
        sans-serif;
}

body {
    margin: 0;
    color: #333333;
    background: #F5F6F8;
}


/* ===========================
   Header
=========================== */

.app-header {
    background: #10264F;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: min(1180px, calc(100% - 48px));
    margin: 0 auto;
    padding: 16px 0;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 54px;
    width: 54px;
    height: 54px;
    border-radius: 12px;
    color: #10264F;
    background: #E9A4BF;
    font-size: 24px;
}

.header-label {
    margin: 0 0 3px;
    color: #E9A4BF;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.12em;
}

.app-header h1 {
    margin: 0;
    color: #FFFFFF;
    font-size: 24px;
    line-height: 1.4;
}


/* ===========================
   Navigation
=========================== */

.app-top {
    position: sticky;
    top: 0;
    z-index: 10;
}

.app-nav {
    background: #183563;
    box-shadow: 0 2px 5px rgb(16 38 79 / 15%);
}

.nav-inner {
    display: flex;
    gap: 4px;
    width: min(1180px, calc(100% - 48px));
    margin: 0 auto;
    overflow-x: auto;
}

.nav-button {
    display: flex;
    align-items: center;
    gap: 9px;
    flex: 0 0 auto;
    min-height: 52px;
    padding: 0 20px;
    border: 0;
    border-bottom: 4px solid transparent;
    color: #FFFFFF;
    text-decoration: none;
    background: transparent;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.nav-button i {
    width: 18px;
    font-size: 16px;
    text-align: center;
}

.nav-button:hover {
    background: #23477F;
}

.nav-button.active {
    background: #23477F;
    border-bottom-color: #E9A4BF;
}


/* ===========================
   Main / Page Heading
=========================== */

.app-main {
    width: min(1180px, calc(100% - 48px));
    margin: 0 auto;
    padding: 32px 0 80px;
}

.page-heading {
    margin-bottom: 24px;
}

.page-heading-main {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.page-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    margin-top: 2px;
    border-radius: 10px;
    color: #10264F;
    background: #F8D8E5;
    font-size: 20px;
}

.page-label {
    margin: 0 0 4px;
    color: #183563;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.1em;
}

.page-heading h2 {
    margin: 0;
    color: #10264F;
    font-size: 26px;
}

.page-back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
    color: #23477F;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

.page-back-link:hover {
    text-decoration: underline;
}


/* ===========================
   Cards
=========================== */

.content-card {
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid #D7DEE8;
    border-radius: 10px;
    background: #FFFFFF;
    box-shadow: 0 2px 6px rgb(16 38 79 / 5%);
}

.content-card h3 {
    margin: 0 0 16px;
    display: flex;
    align-items: center;
    gap: 9px;
    color: #10264F;
    font-size: 18px;
}

.content-card h3 i {
    color: #E9A4BF;
}


/* ===========================
   Table
=========================== */

.table-scroll {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #E4E8EE;
}

table {
    border-collapse: collapse;
    width: 100%;
    min-width: 480px;
    font-size: 0.92rem;
    background: #FFFFFF;
}

th, td {
    padding: 11px 14px;
    border-bottom: 1px solid #E4E8EE;
    text-align: left;
    white-space: nowrap;
}

th {
    color: #10264F;
    background: #F5F6F8;
    font-size: 0.85rem;
    font-weight: 800;
}

tbody tr:hover td {
    background: #FAFBFC;
}

tr.row-past td {
    background: #F5F6F8;
    color: #98A2B3;
}

tr.row-past a {
    color: #98A2B3;
}

a.employee-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #23477F;
    font-weight: 700;
    text-decoration: none;
}

a.employee-link:hover {
    text-decoration: underline;
}

.matrix-table {
    width: auto;
    min-width: 0;
    table-layout: fixed;
}

.matrix-table th,
.matrix-table td {
    width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.matrix-scroll {
    max-height: 70vh;
    overflow-y: auto;
}

.matrix-table th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.matrix-table th:first-child,
.matrix-table td:first-child {
    position: sticky;
    left: 0;
    width: 220px;
    background: #F5F6F8;
    z-index: 1;
}

.matrix-table th:first-child {
    z-index: 3;
}


/* ===========================
   Status badges
=========================== */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 800;
    white-space: nowrap;
    text-decoration: none;
}

a.status-badge:hover {
    filter: brightness(0.95);
}

.status-held { color: #176B45; background: #E8F6EF; }
.status-planned { color: #1c5fa8; background: #E7F1FF; }
.status-not_applicable { color: #667085; background: #EAECF0; }
.status-checking { color: #956000; background: #FFF4D4; }
.status-revoked { color: #B42318; background: #FEECEB; }
.status-none { color: #98A2B3; background: #F5F6F8; }

/* 有効期限に基づく区分（heldレコードのみ。lifecycle_statusとは別軸） */
.status-no_expiry { color: #176B45; background: #E8F6EF; }
.status-valid { color: #176B45; background: #E8F6EF; }
.status-due_90 { color: #956000; background: #FFF4D4; }
.status-due_30 { color: #B45309; background: #FFEDD5; }
.status-expired { color: #B42318; background: #FEECEB; }


/* ===========================
   Buttons
=========================== */

.btn-primary,
.btn-secondary,
.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    padding: 0 16px;
    border-radius: 7px;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.btn-primary {
    border: 1px solid #E9A4BF;
    color: #10264F;
    background: #E9A4BF;
}

.btn-primary:hover {
    background: #E394B3;
    border-color: #E394B3;
}

.btn-secondary {
    border: 1px solid #D7DEE8;
    color: #183563;
    background: #FFFFFF;
}

.btn-secondary:hover {
    background: #F5F6F8;
}

.btn-danger {
    border: 1px solid #e9a6b8;
    color: #c45b76;
    background: #FFFFFF;
}

.btn-danger:hover {
    background: #fff4f7;
    border-color: #dc829b;
    color: #ad405e;
}

.action-form {
    display: inline-block;
}


/* ===========================
   Forms
=========================== */

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 18px;
    max-width: 480px;
}

.form-group label {
    color: #333333;
    font-size: 14px;
    font-weight: 700;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    min-height: 44px;
    padding: 9px 12px;
    border: 1px solid #C9D2DF;
    border-radius: 7px;
    outline: none;
    color: #333333;
    background: #FFFFFF;
    font: inherit;
    font-size: 15px;
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #23477F;
    box-shadow: 0 0 0 3px rgb(35 71 127 / 10%);
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
    color: #333333;
}

.form-checkbox input {
    width: 18px;
    height: 18px;
    accent-color: #E9A4BF;
}

.form-error {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    margin-bottom: 18px;
    border: 1px solid #f3b7c2;
    border-radius: 7px;
    color: #B42318;
    background: #FEECEB;
    font-size: 14px;
    font-weight: 700;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #E4E8EE;
}


/* ===========================
   Pagination
=========================== */

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

.pagination .btn-secondary {
    min-height: 36px;
    padding: 0 14px;
}

.pagination-disabled {
    opacity: 0.4;
    pointer-events: none;
}

.pagination-info {
    color: #667085;
    font-size: 14px;
    font-weight: 700;
}


/* ===========================
   Empty state
=========================== */

.empty-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 32px;
    color: #667085;
    text-align: center;
}


/* ===========================
   Responsive
=========================== */

@media (max-width: 700px) {
    .header-inner,
    .nav-inner,
    .app-main {
        width: min(100% - 24px, 1180px);
    }

    .header-icon {
        flex-basis: 44px;
        width: 44px;
        height: 44px;
        font-size: 19px;
    }

    .app-header h1 {
        font-size: 19px;
    }

    .page-heading h2 {
        font-size: 21px;
    }

    .content-card {
        padding: 16px;
    }

    table {
        font-size: 0.82rem;
    }

    th, td {
        padding: 8px 10px;
    }
}


/* ===========================
   Upload dropzone
=========================== */

.upload-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    max-width: 360px;
    padding: 28px 20px;
    border: 2px dashed #C9D2DF;
    border-radius: 10px;
    background: #FAFBFC;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
    border-color: #E9A4BF;
    background: #FFF8FB;
}

.upload-dropzone.has-file {
    border-color: #2f9e44;
    background: #F3FBF6;
}

.upload-dropzone input[type="file"] {
    display: none;
}

.upload-dropzone-content i {
    font-size: 26px;
    color: #E9A4BF;
}

.upload-dropzone-content p {
    margin: 4px 0 0;
    color: #667085;
    font-size: 13px;
}

.upload-filename {
    font-weight: 700;
    color: #10264F;
}

.certificate-preview {
    max-width: 280px;
    max-height: 200px;
    border-radius: 8px;
    border: 1px solid #E4E8EE;
    object-fit: contain;
    background: #fff;
    display: block;
}
