:root {
    --color-bg: #F5F6F8;
    --color-surface: #FFFFFF;
    --color-primary: #2C3E66;
    --color-primary-dark: #1E2B47;
    --color-accent: #4C7A82;
    --color-danger: #C0392B;
    --color-text: #1E2430;
    --color-text-muted: #6B7280;
    --color-border: #E3E6EB;

    --font-body: "Noto Sans JP", "Hiragino Kaku Gothic ProN", sans-serif;
    --font-mono: "JetBrains Mono", "SF Mono", monospace;

    --radius-md: 10px;
    --radius-lg: 18px;
    --shadow-card: 0 1px 2px rgba(30, 36, 48, 0.04), 0 8px 24px rgba(30, 36, 48, 0.06);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
}

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

/* ---------- Header ---------- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 32px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.app-header__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--color-primary);
}

/* 半月モチーフ */
.crescent {
    display: inline-block;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-primary);
    box-shadow: 8px 0 0 -3px var(--color-bg) inset;
    position: relative;
    overflow: hidden;
}
.crescent::after {
    content: "";
    position: absolute;
    top: 0; left: 40%;
    width: 100%; height: 100%;
    border-radius: 50%;
    background: var(--color-bg);
}

.crescent--lg {
    width: 56px;
    height: 56px;
    margin-bottom: 20px;
}

/* ---------- Layout ---------- */
.app-main {
    max-width: 1080px;
    margin: 0 auto;
    padding: 64px 32px 96px;
}

.app-main--wide {
    max-width: 1320px;
}

/* ---------- Entry (top page) ---------- */
.entry {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 56px;
}

.entry__intro { max-width: 560px; }

.entry__title {
    font-size: clamp(1.8rem, 3vw, 2.4rem);
    font-weight: 900;
    line-height: 1.4;
    color: var(--color-primary-dark);
    margin: 0 0 16px;
}

.entry__lead {
    color: var(--color-text-muted);
    font-size: 1rem;
    line-height: 1.8;
    margin: 0;
}

.entry__cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    width: 100%;
    max-width: 920px;
}

@media (max-width: 860px) {
    .entry__cards { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
    .entry__cards { grid-template-columns: 1fr; }
}

.entry-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 28px 26px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    text-align: left;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.entry-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(30, 36, 48, 0.06), 0 16px 32px rgba(30, 36, 48, 0.08);
}

.entry-card__label {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-primary-dark);
}

.entry-card__desc {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    line-height: 1.6;
}

.entry-card__arrow {
    margin-top: 8px;
    font-family: var(--font-mono);
    color: var(--color-accent);
    font-weight: 600;
}

.entry-card--admin .entry-card__arrow { color: var(--color-primary); }
.entry-card--schedule .entry-card__arrow { color: var(--color-danger); }

/* ---------- Shared form elements (used by later screens) ---------- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 28px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    border: none;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.btn:hover { opacity: 0.88; }

.btn--primary { background: var(--color-primary); color: #fff; }
.btn--danger { background: var(--color-danger); color: #fff; }
.btn--ghost { background: transparent; color: var(--color-text-muted); border: 1px solid var(--color-border); }

.badge-shortage {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(192, 57, 43, 0.1);
    color: var(--color-danger);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
}


/* ---------- Header nav (for inner pages) ---------- */
.header-nav__link {
    font-size: 0.88rem;
    color: var(--color-text-muted);
    font-weight: 500;
}
.header-nav__link:hover { color: var(--color-primary); }

/* ---------- Generic inner page layout ---------- */
.page {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.page__head { max-width: 640px; }

.page__title {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--color-primary-dark);
    margin: 0 0 8px;
}

.page__lead {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    line-height: 1.7;
    margin: 0;
}

.card__title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-primary-dark);
    margin: 0 0 18px;
}

/* ---------- Add staff form ---------- */
.add-staff-form {
    display: flex;
    gap: 12px;
}

.text-input {
    flex: 1;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--color-text);
    background: var(--color-bg);
}

.text-input:focus {
    outline: none;
    border-color: var(--color-primary);
    background: var(--color-surface);
}

.form-error {
    margin: 12px 0 0;
    color: var(--color-danger);
    font-size: 0.85rem;
}

/* ---------- Data table ---------- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    color: var(--color-text-muted);
    font-weight: 500;
    font-size: 0.82rem;
    border-bottom: 1px solid var(--color-border);
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid var(--color-border);
}

.data-table tr:last-child td { border-bottom: none; }

.data-table__row--inactive { opacity: 0.55; }

.data-table__empty {
    text-align: center;
    color: var(--color-text-muted);
    padding: 24px 12px;
}

.data-table__actions { text-align: right; }

.mono { font-family: var(--font-mono); font-size: 0.85rem; color: var(--color-text-muted); }

.btn--sm { padding: 6px 14px; font-size: 0.82rem; }

.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.status-badge--active { background: rgba(76, 122, 130, 0.12); color: var(--color-accent); }
.status-badge--inactive { background: rgba(107, 114, 128, 0.12); color: var(--color-text-muted); }


/* ---------- Period creation form ---------- */
.period-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.select-input {
    flex: none;
    width: auto;
    min-width: 130px;
    cursor: pointer;
}


/* ---------- Requirements screen ---------- */
.requirements-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.requirements-head .card__title { margin: 0; }

.save-message {
    margin: 12px 0 0;
    font-size: 0.85rem;
    font-weight: 600;
}

.save-message--success { color: var(--color-accent); }
.save-message--error { color: var(--color-danger); }

.number-input {
    width: 90px;
    text-align: center;
    font-family: var(--font-mono);
}

.weekday--weekend {
    color: var(--color-danger);
    font-weight: 700;
}


/* ---------- Staff holiday request calendar ---------- */
.holiday-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 12px;
}

.holiday-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 16px 8px;
    min-height: 96px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    background: var(--color-bg);
    transition: background 0.15s ease, border-color 0.15s ease;
    text-align: center;
}

.holiday-day__input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.holiday-day__weekday {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

.holiday-day__date {
    font-family: var(--font-mono);
    font-weight: 800;
    font-size: 1.35rem;
    color: var(--color-text);
    line-height: 1.1;
}

.holiday-day__status {
    font-size: 0.72rem;
    font-weight: 700;
    color: transparent;
    height: 1em;
}

.holiday-day:hover {
    border-color: var(--color-accent);
}

.holiday-day--checked {
    background: var(--color-danger);
    border-color: var(--color-danger);
}

.holiday-day--checked .holiday-day__weekday,
.holiday-day--checked .holiday-day__date {
    color: #fff;
}

.holiday-day--checked .holiday-day__status {
    color: #fff;
}

/* ---------- Shift schedule table ---------- */
.schedule-note {
    font-size: 0.85rem;
    margin: 0 0 4px;
}

.schedule-table-wrap {
    overflow-x: auto;
    margin-top: 12px;
}

.schedule-table {
    min-width: 100%;
    white-space: nowrap;
    font-size: 0.82rem;
    border-collapse: collapse;
    table-layout: fixed;
}

.schedule-table__staff-col {
    position: sticky;
    left: 0;
    background: var(--color-surface);
    text-align: left;
    font-weight: 600;
    width: 92px;
    min-width: 92px;
    max-width: 92px;
    padding: 6px 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 1;
}

.schedule-table__day-col {
    text-align: center;
    width: 34px;
    min-width: 34px;
    max-width: 34px;
    font-weight: 500;
    padding: 4px 2px;
    font-size: 0.76rem;
    line-height: 1.3;
    overflow: hidden;
}

.schedule-table__cell {
    text-align: center;
    padding: 5px 2px;
}

.shift-mark {
    color: var(--color-accent);
    font-weight: 700;
    font-size: 0.95rem;
}

.schedule-table__shortfall-row td {
    border-top: 2px solid var(--color-border);
    font-weight: 700;
}

.schedule-table__shortfall-row .schedule-table__staff-col {
    color: var(--color-danger);
}

.shortfall-value {
    font-family: var(--font-mono);
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

.shortfall-value--alert {
    color: var(--color-danger);
}


/* ---------- Header: admin name & logout ---------- */
.app-header__right {
    display: flex;
    align-items: center;
    gap: 18px;
}

.header-admin-name {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.header-logout-form { margin: 0; }

.header-logout-btn {
    background: none;
    border: none;
    padding: 0;
    font-family: var(--font-body);
    font-size: 0.88rem;
    cursor: pointer;
}

/* ---------- Login page ---------- */
.login-page {
    display: flex;
    justify-content: center;
    padding-top: 40px;
}

.login-card {
    max-width: 360px;
    width: 100%;
}

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

.login-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.login-submit { margin-top: 4px; }

.login-error {
    margin: 12px 0 0;
}

/* ---------- Confirmed badges ---------- */
.page__head-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.confirmed-badge {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 999px;
    background: var(--color-primary);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
}

.confirmed-badge-sm {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    background: rgba(44, 62, 102, 0.1);
    color: var(--color-primary);
    font-size: 0.72rem;
    font-weight: 700;
    margin-left: 6px;
}

/* ---------- Schedule actions / editable cells ---------- */
.schedule-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.schedule-table__cell--editable {
    cursor: pointer;
}

.schedule-table__cell--editable:hover {
    background: rgba(44, 62, 102, 0.06);
}

/* ---------- Change log table ---------- */
.log-action {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.log-action--add {
    background: rgba(76, 122, 130, 0.12);
    color: var(--color-accent);
}

.log-action--remove {
    background: rgba(192, 57, 43, 0.1);
    color: var(--color-danger);
}

.bulk-create-row {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.bulk-create-note {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin: 0;
}

/* ---------- PIN entry ---------- */
.pin-note {
    font-size: 0.85rem;
    margin: 0 0 14px;
}

.pin-form {
    display: flex;
    gap: 12px;
}

.pin-input {
    flex: none;
    width: 140px;
    letter-spacing: 0.4em;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 1.1rem;
}


/* ---------- Holiday cell (×) & today highlight ---------- */
.schedule-table__cell--holiday {
    cursor: not-allowed;
    background: rgba(107, 114, 128, 0.06);
}

.shift-mark--holiday {
    color: var(--color-text-muted);
    font-weight: 700;
}

.schedule-table__day-col--today {
    background: rgba(44, 62, 102, 0.1);
    border-radius: 6px 6px 0 0;
}

.schedule-table__cell--today {
    background: rgba(44, 62, 102, 0.06);
}

.schedule-table__cell--editable.schedule-table__cell--today:hover {
    background: rgba(44, 62, 102, 0.14);
}

/* ---------- Mobile responsive adjustments ---------- */
@media (max-width: 640px) {
    .app-header {
        flex-wrap: wrap;
        gap: 10px;
        padding: 16px 18px;
    }

    .app-header__right {
        gap: 12px;
        flex-wrap: wrap;
    }

    .app-main {
        padding: 32px 16px 64px;
    }

    .app-main--wide {
        max-width: 100%;
    }

    .period-form,
    .add-staff-form,
    .pin-form {
        flex-direction: column;
        align-items: stretch;
    }

    .select-input {
        min-width: 0;
        width: 100%;
    }

    .requirements-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .schedule-actions {
        width: 100%;
    }

    .schedule-actions .btn {
        flex: 1 1 auto;
    }

    .data-table__actions {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        justify-content: flex-end;
    }

    .bulk-create-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .login-page {
        padding-top: 12px;
    }

    .page__title {
        font-size: 1.35rem;
    }

    .schedule-table__day-col {
        width: 46px;
        min-width: 46px;
        max-width: 46px;
        font-size: 0.82rem;
        padding: 6px 3px;
    }

    .schedule-table__cell {
        padding: 8px 3px;
    }

    .schedule-table__total-col {
        width: 52px;
        min-width: 52px;
        max-width: 52px;
        font-size: 0.78rem;
    }
}

.schedule-table__total-col {
    text-align: center;
    width: 44px;
    min-width: 44px;
    max-width: 44px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-text-muted);
    border-left: 2px solid var(--color-border);
}

.schedule-table__required-row td {
    border-top: 2px solid var(--color-border);
    font-weight: 700;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.schedule-table__required-row .schedule-table__staff-col {
    color: var(--color-primary);
    font-family: var(--font-body);
}

.schedule-table__note-row td {
    border-top: 1px solid var(--color-border);
}

.schedule-table__note-row .schedule-table__staff-col {
    color: var(--color-text-muted);
    font-weight: 600;
}

.schedule-table__note-cell {
    vertical-align: top;
    padding: 4px 2px;
}

.note-stack {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.note-input {
    width: 100%;
    min-width: 30px;
    border: none;
    border-bottom: 1px solid var(--color-border);
    background: transparent;
    text-align: center;
    font-size: 0.68rem;
    line-height: 1.4;
    padding: 2px 1px;
    color: var(--color-text);
    font-family: var(--font-body);
}

.note-input:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: -2px;
    background: var(--color-surface);
    border-radius: 4px;
}

.note-readonly-stack {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.note-readonly-line {
    font-size: 0.68rem;
    line-height: 1.4;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
}