/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif; font-size: 14px; line-height: 1.6; color: #333; background: #f5f5f5; min-height: 100vh; display: flex; flex-direction: column; }
a { color: #2563eb; text-decoration: none; } a:hover { text-decoration: underline; }
.site-header { background: #fff; border-bottom: 1px solid #ddd; padding: 0 16px; position: sticky; top: 0; z-index: 100; }
.header-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; height: 52px; }
.site-title { font-size: 16px; font-weight: 700; color: #111; } .header-user { font-size: 13px; color: #666; }
.site-nav { background: #fff; border-bottom: 1px solid #e5e5e5; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.nav-inner { max-width: 1200px; margin: 0 auto; display: flex; padding: 0 16px; }
.nav-inner a { display: block; padding: 10px 16px; font-size: 13px; color: #555; white-space: nowrap; border-bottom: 2px solid transparent; transition: color .15s, border-color .15s; }
.nav-inner a:hover { color: #2563eb; text-decoration: none; } .nav-inner a.active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 600; }
.nav-inner a.nav-logout { margin-left: auto; color: #999; } .nav-inner a.nav-logout:hover { color: #e53e3e; }
.main-content { flex: 1; max-width: 1200px; width: 100%; margin: 0 auto; padding: 20px 16px; }
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 16px; color: #111; }
.section-title { font-size: 16px; font-weight: 700; margin: 24px 0 10px; color: #111; }
.site-footer { background: #fff; border-top: 1px solid #ddd; padding: 12px 16px; text-align: center; font-size: 12px; color: #999; }
.card { background: #fff; border: 1px solid #e5e5e5; border-radius: 6px; padding: 20px; margin-bottom: 16px; }
.login-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { background: #fff; border: 1px solid #ddd; border-radius: 8px; padding: 32px; width: 100%; max-width: 380px; }
.login-box h1 { font-size: 20px; margin-bottom: 24px; text-align: center; color: #111; }
.form-group { margin-bottom: 16px; } .form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: #444; }
.form-group input[type="text"], .form-group input[type="password"], .form-group input[type="date"],
.form-group input[type="datetime-local"], .form-group input[type="number"], .form-group textarea, .form-group select {
    width: 100%; padding: 8px 10px; font-size: 14px; border: 1px solid #ccc; border-radius: 4px; background: #fff; color: #333; transition: border-color .15s; }
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.15); }
.form-group textarea { min-height: 80px; resize: vertical; }
.form-group .checkbox-label { display: inline-flex; align-items: center; gap: 6px; font-weight: normal; cursor: pointer; }
.form-group .checkbox-label input[type="checkbox"] { width: auto; }
.required-mark { color: #e53e3e; margin-left: 2px; }
.btn { display: inline-block; padding: 8px 20px; font-size: 14px; font-weight: 600; border: none; border-radius: 4px; cursor: pointer; transition: background .15s; text-align: center; line-height: 1.4; }
.btn-primary { background: #2563eb; color: #fff; } .btn-primary:hover { background: #1d4ed8; text-decoration: none; }
.btn-secondary { background: #e5e7eb; color: #374151; } .btn-secondary:hover { background: #d1d5db; text-decoration: none; }
.btn-danger { background: #e53e3e; color: #fff; } .btn-danger:hover { background: #c53030; text-decoration: none; }
.btn-sm { padding: 4px 10px; font-size: 12px; } .btn-block { display: block; width: 100%; }
.error-message { background: #fef2f2; border: 1px solid #fca5a5; color: #b91c1c; padding: 10px 14px; border-radius: 4px; margin-bottom: 16px; font-size: 13px; }
.success-message { background: #f0fdf4; border: 1px solid #86efac; color: #166534; padding: 10px 14px; border-radius: 4px; margin-bottom: 16px; font-size: 13px; }
.info-message { background: #eff6ff; border: 1px solid #93c5fd; color: #1d4ed8; padding: 10px 14px; border-radius: 4px; margin-bottom: 16px; font-size: 13px; }
.warning-message { background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; padding: 10px 14px; border-radius: 4px; margin-bottom: 16px; font-size: 13px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid #e5e5e5; white-space: nowrap; }
.data-table th { background: #f9fafb; font-weight: 600; color: #555; font-size: 12px; position: sticky; top: 0; }
.data-table tbody tr:hover { background: #f8fafc; } .data-table .actions { display: flex; gap: 6px; }
.data-table .row-inactive td { color: #bbb; }
.count-badge { display: inline-block; background: #e5e7eb; color: #374151; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 10px; margin-left: 8px; vertical-align: middle; }
.attachment-badge { display: inline-block; font-size: 11px; color: #6b7280; margin-left: 4px; vertical-align: middle; }
.placeholder-box { text-align: center; padding: 60px 20px; color: #999; } .placeholder-box p { font-size: 15px; }
.text-muted { color: #999; font-size: 13px; }
.due-overdue { color: #e53e3e; font-weight: 600; } .due-soon { color: #d97706; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid .form-group.full-width { grid-column: 1 / -1; }
.form-actions { margin-top: 20px; display: flex; gap: 10px; align-items: center; }
.detail-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.detail-table th, .detail-table td { padding: 10px 12px; border-bottom: 1px solid #e5e5e5; vertical-align: top; }
.detail-table th { width: 140px; font-weight: 600; color: #555; background: #f9fafb; white-space: nowrap; }
.detail-table td.pre-wrap { white-space: pre-wrap; word-break: break-word; }
.detail-actions { display: flex; gap: 10px; margin-top: 20px; align-items: center; } .detail-actions .spacer { flex: 1; }
.delete-confirm { display: inline; }
.search-card { padding: 14px 16px; margin-bottom: 16px; }
.search-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px 12px; align-items: end; }
.search-field label { display: block; font-size: 11px; font-weight: 600; color: #666; margin-bottom: 2px; }
.search-field input[type="text"], .search-field select { width: 100%; padding: 6px 8px; font-size: 13px; border: 1px solid #ccc; border-radius: 4px; }
.search-field input:focus, .search-field select:focus { outline: none; border-color: #2563eb; }
.search-field-check { display: flex; align-items: center; padding-bottom: 4px; }
.search-field-check .checkbox-label { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: normal; cursor: pointer; }
.search-field-check .checkbox-label input { width: auto; }
.search-actions { margin-top: 10px; display: flex; gap: 8px; }

/* === Attachments === */
.attachment-list, .att-list { display: flex; flex-direction: column; gap: 10px; }
.attachment-item { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid #e5e5e5; border-radius: 6px; background: #fafafa; }
.attachment-preview { flex-shrink: 0; width: 64px; height: 64px; border-radius: 4px; overflow: hidden; background: #eee; display: flex; align-items: center; justify-content: center; }
.attachment-preview img { max-width: 100%; max-height: 100%; object-fit: cover; }
.attachment-icon { flex-shrink: 0; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; font-size: 28px; color: #9ca3af; }
.attachment-info { flex: 1; min-width: 0; }
.attachment-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-name a { color: #2563eb; }
.attachment-meta { font-size: 11px; color: #999; margin-top: 2px; }
.attachment-actions { flex-shrink: 0; display: flex; gap: 4px; align-items: center; }
.attachment-delete { flex-shrink: 0; }

/* === Drop Zone === */
.att-drop-area {
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    transition: border-color .2s, background .2s;
    margin-bottom: 12px;
    cursor: pointer;
    position: relative;
}
.att-drop-area:hover, .att-drop-active {
    border-color: #2563eb;
    background: #eff6ff;
}
.att-drop-text { font-size: 13px; color: #666; margin-bottom: 8px; }
.att-file-input { font-size: 13px; }
.upload-hint { font-size: 11px; color: #999; margin-top: 6px; }
.att-status { font-size: 12px; margin: 6px 0; min-height: 18px; }
.att-status-loading { color: #2563eb; }
.att-status-ok { color: #166534; }
.att-status-err { color: #b91c1c; }

/* === Pagination === */
.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 16px; flex-wrap: wrap; }
.page-link { display: inline-block; padding: 6px 12px; font-size: 13px; color: #2563eb; background: #fff; border: 1px solid #ddd; border-radius: 4px; text-decoration: none; }
.page-link:hover { background: #f0f4ff; text-decoration: none; }
.page-current { background: #2563eb; color: #fff; border-color: #2563eb; }
.page-ellipsis { padding: 6px 4px; font-size: 13px; color: #999; }
.page-info { font-size: 12px; color: #999; margin-left: 12px; }

/* === Calendar === */
.calendar-card { padding: 10px; overflow: hidden; }
.calendar-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; font-size: 12px; color: #555; }
.legend-item { display: inline-flex; align-items: center; gap: 4px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.fc { font-size: 13px; } .fc .fc-toolbar-title { font-size: 16px; font-weight: 700; } .fc .fc-button { font-size: 12px; padding: 4px 10px; }
.fc .fc-button-primary { background-color: #2563eb; border-color: #2563eb; }
.fc .fc-button-primary:not(:disabled).fc-button-active, .fc .fc-button-primary:not(:disabled):active { background-color: #1d4ed8; border-color: #1d4ed8; }
.fc .fc-daygrid-event { border-radius: 3px; padding: 1px 4px; font-size: 11px; cursor: pointer; }
.fc-theme-standard td, .fc-theme-standard th { border-color: #e5e5e5; }
.fc .fc-day-today { background: #eff6ff !important; }

/* === Settings === */
.settings-tabs { display: flex; gap: 0; margin-bottom: 16px; overflow-x: auto; }
.settings-tab { display: block; padding: 10px 18px; font-size: 13px; font-weight: 600; color: #555; background: #fff; border: 1px solid #e5e5e5; border-bottom: none; border-radius: 6px 6px 0 0; margin-right: -1px; white-space: nowrap; text-decoration: none; }
.settings-tab:hover { color: #2563eb; text-decoration: none; }
.settings-tab.active { color: #2563eb; border-bottom: 2px solid #fff; position: relative; z-index: 1; }
.settings-form-area { margin-top: 24px; padding-top: 16px; border-top: 1px solid #e5e5e5; }

/* === Responsive === */
@media (max-width: 640px) {
    .header-inner { height: 48px; } .site-title { font-size: 14px; }
    .nav-inner a { padding: 8px 12px; font-size: 12px; }
    .main-content { padding: 14px 12px; } .page-title { font-size: 17px; }
    .form-grid { grid-template-columns: 1fr; } .login-box { padding: 24px 20px; } .card { padding: 14px; }
    .detail-table th { width: 100px; font-size: 12px; } .detail-actions { flex-wrap: wrap; }
    .search-grid { grid-template-columns: 1fr 1fr; }
    .attachment-item { flex-wrap: wrap; } .attachment-preview { width: 48px; height: 48px; }
    .fc .fc-toolbar { flex-direction: column; gap: 6px; } .calendar-card { padding: 6px; }
    .settings-tab { padding: 8px 12px; font-size: 12px; }
    .att-drop-area { padding: 14px; }
}
