:root {
    --color-yes: #2e7d32;
    --color-yes-bg: #e8f5e9;
    --color-no: #c62828;
    --color-no-bg: #ffebee;
    --color-none-bg: #fafafa;
    --color-primary: #1a5276;
    --color-border: #ddd;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
    background: #f5f6f8;
    color: #222;
}

.app-header {
    background: var(--color-primary);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.app-header h1 { font-size: 1.1rem; margin: 0; }
.app-header nav { display: flex; gap: 12px; align-items: center; font-size: 0.9rem; }
.app-header nav a { color: #fff; text-decoration: underline; }
.app-header nav a.admin-btn {
    background: #ef6c00;
    color: #fff;
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.85rem;
}
.app-header nav a.admin-btn:hover { background: #f57c00; }

.month-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 10px;
    background: #fff;
    border-bottom: 1px solid var(--color-border);
}
.month-nav a { color: var(--color-primary); text-decoration: none; font-weight: bold; }

.legend {
    text-align: center;
    padding: 8px;
    font-size: 0.85rem;
    color: #555;
}
.site-tabs { display: flex; justify-content: center; gap: 8px; padding: 0 0 8px; flex-wrap: wrap; }
.site-tabs a {
    display: inline-block; padding: 6px 16px; border-radius: 16px;
    background: #eef3f7; color: var(--color-primary); text-decoration: none; font-size: 0.85rem;
}
.site-tabs a.active { background: var(--color-primary); color: #fff; font-weight: bold; }

.notice-box {
    max-width: 1500px; margin: 0 auto 12px; padding: 12px 24px;
    background: #fff8e1; border: 1px solid #ffe0b2; border-radius: 8px;
}
.notice-site-cutoff { font-weight: bold; color: var(--color-primary); margin: 0 0 8px; text-align: center; }
.notice-columns { display: flex; gap: 20px; flex-wrap: wrap; }
.notice-columns > div { flex: 1; min-width: 220px; }
.notice-box .notice-title { font-weight: bold; margin: 4px 0; color: #ef6c00; font-size: 0.9rem; }
.notice-box ul { margin: 0; padding-left: 20px; font-size: 0.9rem; }
.notice-vi { border-left: 1px dashed #ffcc80; padding-left: 20px; }
.notice-vi li, .notice-vi .notice-title { color: #1a5276; }
@media (max-width: 600px) {
    .notice-vi { border-left: none; padding-left: 0; border-top: 1px dashed #ffcc80; padding-top: 8px; }
}
.legend .cell {
    display: inline-block;
    width: 22px;
    height: 22px;
    line-height: 22px;
    text-align: center;
    border-radius: 4px;
    margin: 0 4px;
    font-weight: bold;
}

.grid-wrapper {
    overflow: auto;
    max-height: 75vh;
    margin: 0 8px 16px;
    border: 1px solid var(--color-border);
    background: #fff;
}

table.bento-grid {
    border-collapse: collapse;
    width: max-content;
    min-width: 100%;
}

.bento-grid th, .bento-grid td {
    border: 1px solid var(--color-border);
    padding: 0;
    text-align: center;
    font-size: 0.85rem;
    white-space: nowrap;
}

.bento-grid thead th {
    position: sticky;
    top: 0;
    background: var(--color-primary);
    color: #fff;
    padding: 6px 4px;
    z-index: 2;
    font-weight: normal;
    font-size: 0.75rem;
    line-height: 1.3;
}
.bento-grid thead th a { color: #fff; text-decoration: none; }

.name-col {
    position: sticky;
    left: 0;
    background: #eef3f7;
    z-index: 1;
    padding: 6px 12px !important;
    font-weight: bold;
    min-width: 110px;
    text-align: left !important;
    white-space: nowrap;
}
thead .name-col { z-index: 3; background: var(--color-primary); color: #fff; }

.date-col-head { min-width: 46px; }
.date-col-head.sunday, .date-col-head.saturday { background: #7a2020; }
.date-col-head.today-col { box-shadow: inset 3px 0 0 #ffb300, inset -3px 0 0 #ffb300, inset 0 3px 0 #ffb300; }
.date-col-head.locked-col { background: #9e9e9e; }
.date-col-head.locked-col a { color: #e0e0e0; }

.emp-col { min-width: 60px; padding: 6px 4px !important; }

td.cell {
    width: 44px;
    height: 38px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
    user-select: none;
}
td.cell.today-col { box-shadow: inset 3px 0 0 #ffb300, inset -3px 0 0 #ffb300; }
td.cell.yes { background: var(--color-yes-bg); color: var(--color-yes); }
td.cell.no { background: var(--color-no-bg); color: var(--color-no); }
td.cell.none { background: var(--color-none-bg); color: #bbb; }
td.cell.loading { opacity: 0.4; }
td.cell:focus { outline: 2px solid var(--color-primary); outline-offset: -2px; }

/* 締切済み列(9時を過ぎた当日・過去日): 一般ユーザーには編集不可としてグレー表示 */
td.cell.locked-col { background: #e0e0e0 !important; color: #9e9e9e !important; cursor: not-allowed; }
td.cell.locked-col.yes, td.cell.locked-col.no { color: #757575 !important; }
tfoot .total-cell.locked-col { background: #e0e0e0 !important; color: #9e9e9e !important; }

.total-col-head {
    position: sticky; right: 0; background: var(--color-primary) !important;
    min-width: 54px;
}
.total-col {
    position: sticky; right: 0; background: #fff8e1; z-index: 1;
    font-weight: bold; color: var(--color-primary); min-width: 54px;
}

tfoot .name-col {
    position: sticky; left: 0; bottom: 0; background: #eef3f7; z-index: 2;
}
tfoot .total-row td {
    position: sticky; bottom: 0;
    background: #fff8e1;
    font-weight: bold;
    color: var(--color-primary);
    border-top: 2px solid var(--color-primary);
}
tfoot .total-cell.today-col { box-shadow: inset 3px 0 0 #ffb300, inset -3px 0 0 #ffb300; }
tfoot .grand-total { z-index: 3; }


.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box {
    background: #fff;
    padding: 32px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    width: 90%;
    max-width: 360px;
}
.login-box h1 { text-align: center; font-size: 1.2rem; color: var(--color-primary); }
.login-box label { display: block; margin-top: 14px; font-size: 0.9rem; }
.login-box input {
    width: 100%; padding: 10px; margin-top: 4px;
    border: 1px solid var(--color-border); border-radius: 4px; font-size: 1rem;
}
.login-box button {
    width: 100%; margin-top: 20px; padding: 12px;
    background: var(--color-primary); color: #fff; border: none; border-radius: 4px;
    font-size: 1rem; cursor: pointer;
}
.error { color: var(--color-no); font-size: 0.9rem; }
.success { color: var(--color-yes); font-size: 0.9rem; }

.pin-desc { text-align: center; font-size: 0.85rem; color: #666; }
.pin-input {
    text-align: center; letter-spacing: 0.5em; font-size: 1.5rem !important;
}
.pin-back { text-align: center; margin-top: 16px; font-size: 0.85rem; }
.pin-back a { color: var(--color-primary); }

.summary-cards { display: flex; gap: 10px; padding: 10px 16px; flex-wrap: wrap; }
.summary-cards .card {
    flex: 1; min-width: 120px; padding: 14px; border-radius: 6px; text-align: center;
    font-weight: bold; background: #fff; border: 1px solid var(--color-border);
}
.summary-cards .card.yes { color: var(--color-yes); border-color: var(--color-yes); }
.summary-cards .card.no { color: var(--color-no); border-color: var(--color-no); }
.summary-cards .card.none { color: #888; }

section { padding: 8px 16px; }
section h2 { font-size: 1rem; color: var(--color-primary); border-bottom: 2px solid var(--color-primary); padding-bottom: 4px; }
.name-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.name-list li { background: #fff; border: 1px solid var(--color-border); padding: 6px 12px; border-radius: 16px; font-size: 0.9rem; }
.name-list.warn li { background: #fff3e0; border-color: #ef6c00; color: #ef6c00; font-weight: bold; }
.empty { color: #888; font-size: 0.9rem; }

.import-section { padding: 16px; background: #fff; margin: 16px; border-radius: 8px; }
.warn-box { background: #fff3e0; border: 1px solid #ef6c00; padding: 12px; border-radius: 6px; margin: 12px 0; }
.simple-table { border-collapse: collapse; width: 100%; margin-top: 8px; }
.simple-table th, .simple-table td { border: 1px solid var(--color-border); padding: 6px 10px; text-align: left; font-size: 0.9rem; }

.admin-menu { padding: 20px 16px; }
.admin-menu h2 { color: var(--color-primary); }
.admin-menu-grid { display: flex; flex-wrap: wrap; gap: 14px; }
.admin-card {
    display: flex; flex-direction: column; gap: 6px;
    background: #fff; border: 1px solid var(--color-border); border-radius: 8px;
    padding: 18px; min-width: 200px; flex: 1;
    text-decoration: none; color: #222;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.admin-card:hover { border-color: var(--color-primary); }
.admin-card.disabled { opacity: 0.5; cursor: not-allowed; }
.admin-card-title { font-weight: bold; color: var(--color-primary); font-size: 1rem; }
.admin-card-desc { font-size: 0.85rem; color: #666; }

.site-select { padding: 40px 16px; max-width: 560px; margin: 0 auto; }
.site-select h2 { text-align: center; color: var(--color-primary); font-size: 1.3rem; }
.site-select-buttons { display: flex; flex-direction: column; gap: 22px; margin-top: 32px; }
.site-btn {
    display: block; text-align: center; padding: 40px;
    background: #fff; border: 3px solid var(--color-primary); border-radius: 16px;
    color: var(--color-primary); font-size: 1.8rem; font-weight: bold;
    text-decoration: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    transition: transform 0.1s ease, background 0.15s ease, color 0.15s ease;
}
.site-btn:hover { background: var(--color-primary); color: #fff; }
.site-btn:active { transform: scale(0.97); }

.register-form { max-width: 360px; }
.register-form label { display: block; margin-top: 14px; font-size: 0.9rem; }
.register-form input[type="text"] {
    width: 100%; padding: 10px; margin-top: 4px;
    border: 1px solid var(--color-border); border-radius: 4px; font-size: 1rem;
}
.register-form select {
    width: 100%; padding: 10px; margin-top: 4px;
    border: 1px solid var(--color-border); border-radius: 4px; font-size: 1rem;
    background: #fff;
}
.register-form .checkbox-label { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.register-form .checkbox-label input { width: auto; }
.register-form button {
    margin-top: 20px; padding: 10px 24px;
    background: var(--color-primary); color: #fff; border: none; border-radius: 4px;
    font-size: 1rem; cursor: pointer;
}

.employee-table { width: 100%; }
.employee-table th { background: #eef3f7; }
.employee-table .muted-row { color: #999; }
.inline-form { display: inline; }
.danger-btn {
    background: #fff; border: 1px solid var(--color-no); color: var(--color-no);
    padding: 5px 14px; border-radius: 4px; cursor: pointer; font-size: 0.85rem;
}
.danger-btn:hover { background: var(--color-no); color: #fff; }
.secondary-btn {
    background: #fff; border: 1px solid var(--color-primary); color: var(--color-primary);
    padding: 5px 14px; border-radius: 4px; cursor: pointer; font-size: 0.85rem;
}
.secondary-btn:hover { background: var(--color-primary); color: #fff; }
.section-gap { margin-top: 32px; }

.app-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999; padding: 16px;
}
.app-modal-box {
    background: #fff; border-radius: 10px; padding: 28px;
    max-width: 400px; width: 100%;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    text-align: center;
}
.app-modal-message { font-size: 1rem; color: #222; white-space: pre-wrap; margin: 0 0 20px; line-height: 1.6; }
.app-modal-actions { display: flex; justify-content: center; gap: 12px; }
.app-modal-btn {
    padding: 10px 24px; border-radius: 6px; font-size: 0.95rem; cursor: pointer; border: none;
}
.app-modal-btn.app-modal-ok { background: var(--color-primary); color: #fff; }
.app-modal-btn.app-modal-cancel { background: #eee; color: #333; }

.edit-row td { background: #f5f8fa; padding: 14px; }
.edit-form { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.edit-form label { font-size: 0.85rem; display: flex; flex-direction: column; gap: 4px; }
.edit-form input[type="text"], .edit-form input[type="time"], .edit-form select {
    padding: 8px; border: 1px solid var(--color-border); border-radius: 4px; font-size: 0.9rem;
}

.force-cutoff-box { margin-top: 20px; padding: 16px; background: #fff3e0; border-radius: 6px; }

.fax-settings-form { background: #fff; border: 1px solid var(--color-border); border-radius: 8px; padding: 16px; margin-bottom: 20px; }
.fax-settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 12px; }
.fax-settings-grid label { font-size: 0.85rem; display: flex; flex-direction: column; gap: 4px; }
.fax-settings-grid input[type="text"] {
    padding: 8px; border: 1px solid var(--color-border); border-radius: 4px; font-size: 0.9rem;
}
