/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
    font-size: 14px;
    color: #1e293b;
    background: #f0f4f8;
    line-height: 1.6;
}

/* ===== Header ===== */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #1e40af, #2563eb);
    color: #fff;
    padding: 16px 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.site-header h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: .05em;
}
.header-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}
.btn-logout {
    color: #fff;
    background: rgba(255,255,255,.2);
    padding: 4px 14px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 13px;
}
.btn-logout:hover { background: rgba(255,255,255,.35); }

/* ===== Login ===== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f0f4f8;
}
.login-card {
    background: #fff;
    padding: 36px 32px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,.1);
    width: 360px;
    text-align: center;
}
.login-card h1 {
    font-size: 18px;
    color: #1e40af;
    margin-bottom: 24px;
}
.login-card .form-group { text-align: left; margin-bottom: 16px; }
.login-btn { width: 100%; padding: 10px; font-size: 15px; }
.login-error {
    color: #dc2626;
    font-size: 13px;
    margin-bottom: 12px;
}

/* ===== Main ===== */
.site-main { padding: 20px 24px; }

/* ===== Toolbar ===== */
.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    background: #fff;
    padding: 12px 16px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
}
.toolbar label { font-weight: 600; color: #334155; }

/* ===== Form Controls ===== */
.form-control {
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: #1e293b;
}
.form-control:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37,99,235,.2);
}

/* ===== Table ===== */
.table-wrap {
    background: #fff;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    overflow-x: auto;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

#data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 960px;
}

#data-table thead th {
    background: #2563eb;
    color: #fff;
    padding: 10px 12px;
    font-weight: 600;
    font-size: 13px;
    text-align: left;
    border-bottom: 2px solid #1e40af;
    white-space: nowrap;
}

.th-month   { width: 56px; }
.th-workers { width: 220px; }
.th-inv-in  { width: 180px; }
.th-inv-out { width: 180px; }
.th-reports { width: 210px; }
.th-notes   { min-width: 160px; }

#data-table tbody td {
    padding: 8px 10px;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: top;
}

#data-table tbody tr:nth-child(even) { background: #f8fafc; }
#data-table tbody tr:hover { background: #eff6ff; }

.row-total td {
    padding: 10px 12px;
    background: #1e40af;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    border-top: 2px solid #1d4ed8;
}

.col-month {
    font-weight: 600;
    color: #1e40af;
    text-align: center;
    white-space: nowrap;
}

/* ===== Tags / Items ===== */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    margin: 2px 0;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.4;
}

.tag-link {
    color: #1e40af;
    text-decoration: none;
    cursor: pointer;
}
.tag-link:hover { text-decoration: underline; }

.tag-remove {
    background: none;
    border: none;
    color: #dc2626;
    font-size: 15px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    font-weight: bold;
}
.tag-remove:hover { color: #991b1b; }

/* ===== Cell Buttons ===== */
.btn-add, .btn-upload {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 10px;
    font-size: 12px;
    border-radius: 4px;
    border: 1px solid;
    cursor: pointer;
    font-family: inherit;
}

.btn-add {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1e40af;
}
.btn-add:hover { background: #bfdbfe; }

.btn-upload {
    background: #f0fdf4;
    border-color: #86efac;
    color: #166534;
}
.btn-upload:hover { background: #dcfce7; }

/* ===== Notes ===== */
.note-display {
    min-height: 24px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    white-space: pre-wrap;
    word-break: break-word;
    color: #475569;
    font-size: 13px;
}
.note-display:hover { background: #f1f5f9; }

.note-display:empty::after {
    content: "クリックして入力";
    color: #94a3b8;
    font-style: italic;
}

.note-textarea {
    width: 100%;
    min-height: 60px;
    padding: 4px 6px;
    border: 1px solid #2563eb;
    border-radius: 4px;
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
}

/* ===== Buttons ===== */
.btn {
    padding: 8px 18px;
    border-radius: 4px;
    border: 1px solid transparent;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    font-weight: 500;
}
.btn-primary {
    background: #2563eb;
    color: #fff;
    border-color: #1d4ed8;
}
.btn-primary:hover { background: #1d4ed8; }

.btn-secondary {
    background: #f1f5f9;
    color: #475569;
    border-color: #cbd5e1;
}
.btn-secondary:hover { background: #e2e8f0; }

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal.active { display: flex; }

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .45);
}

.modal-dialog {
    position: relative;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
    width: 420px;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}
.modal-lg { width: 780px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 8px 8px 0 0;
}
.modal-header h3 { font-size: 15px; color: #1e293b; }

.modal-header-actions { display: flex; align-items: center; gap: 8px; }

.btn-close {
    background: none;
    border: none;
    font-size: 22px;
    color: #64748b;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.btn-close:hover { color: #1e293b; }

.modal-body {
    padding: 18px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 0 0 8px 8px;
}

/* ===== Form Group ===== */
.form-group {
    margin-bottom: 14px;
}
.form-group label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: #334155;
    margin-bottom: 4px;
}
.form-group .form-control { width: 100%; }

/* ===== File viewer ===== */
#file-modal-body iframe {
    width: 100%;
    height: 70vh;
    border: none;
}
#file-modal-body img {
    max-width: 100%;
    max-height: 70vh;
    display: block;
    margin: 0 auto;
}
