/* ── Reset & Base ── */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: #f0f2f5; color: #1a1a2e; display: flex; min-height: 100vh; }

/* ── A11Y: Skip link ── */
.skip-link { position: absolute; top: -50px; left: 0; background: #3b82f6; color: #fff; padding: 10px 16px; z-index: 9999; font-size: 14px; font-weight: 600; text-decoration: none; border-radius: 0 0 8px 0; transition: top 0.2s; }
.skip-link:focus { top: 0; }

/* ── A11Y: Screen reader only ── */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ── A11Y: Focus indicators ── */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
[tabindex]:focus-visible { outline: 3px solid #3b82f6; outline-offset: 2px; }

/* ── Sidebar ── */
.sidebar { width: 260px; background: #1a1a2e; color: #fff; display: flex; flex-direction: column; position: fixed; height: 100vh; z-index: 100; }
.sidebar-header { padding: 24px 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-header h2 { font-size: 24px; font-weight: 700; letter-spacing: 2px; }
/* FIX: contrast 3.2:1 → 7.5:1 */
.sidebar-header .subtitle { font-size: 12px; color: rgba(255,255,255,0.8); text-transform: uppercase; letter-spacing: 3px; }
.nav-links { list-style: none; flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-links li a { display: flex; align-items: center; gap: 12px; padding: 12px 20px; color: rgba(255,255,255,0.7); text-decoration: none; transition: all 0.2s; font-size: 14px; }
.nav-links li a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-links li a.active { background: rgba(59,130,246,0.2); color: #60a5fa; border-right: 3px solid #3b82f6; }
/* FIX: contrast 2.5:1 → 5.2:1 */
.nav-section { padding: 20px 20px 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 2px; color: rgba(255,255,255,0.6); }
.icon { font-size: 18px; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.1); }
.user-info { margin-bottom: 8px; }
.user-info strong { display: block; font-size: 14px; }
/* FIX: contrast 3.2:1 → 7.5:1 */
.user-info small { color: rgba(255,255,255,0.8); font-size: 12px; }
/* FIX: contrast 3.8:1 → 5.7:1 */
.logout-btn { display: inline-block; padding: 8px 16px; background: rgba(239,68,68,0.2); color: #fca5a5; border-radius: 6px; text-decoration: none; font-size: 13px; transition: background 0.2s; }
.logout-btn:hover { background: rgba(239,68,68,0.3); }

/* ── Content ── */
.content { margin-left: 260px; flex: 1; padding: 32px; min-height: 100vh; }
.content-full { flex: 1; }

/* ── Login ── */
.login-container { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%); }
.login-box { background: #fff; padding: 48px 40px; border-radius: 16px; width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-box h1 { text-align: center; margin-bottom: 8px; font-size: 28px; color: #1a1a2e; }
.login-box .subtitle { text-align: center; color: #64748b; margin-bottom: 32px; font-size: 14px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: #475569; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 12px 16px; border: 2px solid #e2e8f0; border-radius: 10px; font-size: 15px; transition: border-color 0.2s; outline: none; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 12px 24px; border: none; border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer; transition: all 0.2s; text-decoration: none; }
.btn-primary { background: #3b82f6; color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-success { background: #10b981; color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-secondary { background: #64748b; color: #fff; }
.btn-secondary:hover { background: #475569; }
/* FIX: touch target — min 44x32 */
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 8px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Page Header ── */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.page-header h1 { font-size: 28px; font-weight: 700; color: #1a1a2e; }

/* ── Cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 32px; }
.stat-card { background: #fff; padding: 24px; border-radius: 14px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
.stat-card .label { font-size: 13px; color: #64748b; margin-bottom: 8px; }
.stat-card .value { font-size: 32px; font-weight: 700; color: #1a1a2e; }
.stat-card .value.blue { color: #3b82f6; }
.stat-card .value.green { color: #10b981; }
.stat-card .value.amber { color: #d97706; }
.stat-card .value.red { color: #dc2626; }

.card { background: #fff; border-radius: 14px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); margin-bottom: 24px; overflow: hidden; }
.card-header { padding: 20px 24px; border-bottom: 1px solid #f1f5f9; display: flex; justify-content: space-between; align-items: center; }
.card-header h2 { font-size: 18px; font-weight: 600; }
.card-body { padding: 24px; }

/* ── Tables ── */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid #f1f5f9; font-size: 14px; }
th { background: #f8fafc; font-weight: 600; color: #475569; position: sticky; top: 0; z-index: 10; white-space: nowrap; }
tr:hover { background: #f8fafc; }
td input.cell-input { width: 100%; padding: 6px 10px; border: 1px solid transparent; border-radius: 6px; font-size: 13px; background: transparent; transition: all 0.2s; }
td input.cell-input:hover { border-color: #e2e8f0; background: #fff; }
td input.cell-input:focus { border-color: #3b82f6; background: #fff; outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
td input.cell-input.readonly { color: #64748b; cursor: default; }
td input.cell-input.readonly:hover { border-color: transparent; background: transparent; }
td input.cell-input[disabled] { color: #94a3b8; cursor: not-allowed; background: #f8fafc; }

/* Department column headers */
.dept-header { text-align: center; font-weight: 700; padding: 10px; color: #fff; font-size: 13px; letter-spacing: 1px; }

/* ── Tasks ── */
.task-card { background: #fff; border-radius: 12px; padding: 20px; border-left: 4px solid #e2e8f0; margin-bottom: 12px; box-shadow: 0 1px 4px rgba(0,0,0,0.04); }
.task-card.status-pending { border-left-color: #f59e0b; }
.task-card.status-in_progress { border-left-color: #3b82f6; }
.task-card.status-completed { border-left-color: #10b981; }
.task-card h3 { font-size: 15px; margin-bottom: 8px; }
.task-meta { display: flex; gap: 16px; font-size: 13px; color: #64748b; flex-wrap: wrap; }
.task-meta .badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-in_progress { background: #dbeafe; color: #1e40af; }
.badge-completed { background: #d1fae5; color: #065f46; }
.badge-dept { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; color: #fff; }
.task-actions { margin-top: 12px; display: flex; gap: 8px; }

/* Status selector */
.status-select { padding: 6px 12px; border: 2px solid #e2e8f0; border-radius: 8px; font-size: 13px; cursor: pointer; background: #fff; }
.status-select:focus { border-color: #3b82f6; outline: none; }

/* ── Charts ── */
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(450px, 1fr)); gap: 24px; margin-bottom: 32px; }
.chart-container { background: #fff; border-radius: 14px; padding: 24px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
.chart-container h3 { font-size: 16px; margin-bottom: 16px; color: #1a1a2e; }

/* ── Completeness bars ── */
.completeness-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.completeness-bar .label { width: 120px; font-size: 13px; font-weight: 500; flex-shrink: 0; }
.completeness-bar .bar { flex: 1; height: 24px; background: #f1f5f9; border-radius: 12px; overflow: hidden; }
.completeness-bar .fill { height: 100%; border-radius: 12px; transition: width 0.5s ease; display: flex; align-items: center; justify-content: flex-end; padding-right: 8px; font-size: 11px; font-weight: 700; color: #fff; min-width: 30px; }

/* ── Complex cards ── */
.complex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.complex-card { background: #fff; border-radius: 14px; padding: 24px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); transition: transform 0.2s; }
.complex-card:hover { transform: translateY(-2px); box-shadow: 0 4px 20px rgba(0,0,0,0.1); }
.complex-card h3 { font-size: 18px; margin-bottom: 8px; }
.complex-card .info { font-size: 13px; color: #64748b; }
.complex-card .actions { margin-top: 16px; display: flex; gap: 8px; }

/* ── Flash ── */
.flash-messages { margin-bottom: 20px; }
.flash { padding: 14px 20px; border-radius: 10px; font-size: 14px; margin-bottom: 8px; }
.flash-success { background: #d1fae5; color: #065f46; }
.flash-error { background: #fee2e2; color: #991b1b; }

/* ── Form page ── */
.form-card { background: #fff; border-radius: 14px; padding: 32px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); max-width: 700px; }
.form-actions { margin-top: 24px; display: flex; gap: 12px; }

/* ── Building list in form ── */
.building-list { list-style: none; }
.building-list li { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.building-list li input { flex: 1; }
.add-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; background: #f1f5f9; border: 2px dashed #cbd5e1; border-radius: 8px; cursor: pointer; color: #64748b; font-size: 13px; transition: all 0.2s; }
.add-btn:hover { border-color: #3b82f6; color: #3b82f6; background: #eff6ff; }

/* ── Filter bar ── */
.filter-bar { display: flex; gap: 16px; align-items: center; margin-bottom: 24px; flex-wrap: wrap; }
.filter-bar select { padding: 10px 16px; border: 2px solid #e2e8f0; border-radius: 10px; font-size: 14px; background: #fff; min-width: 250px; }

/* ── Checkbox group ── */
.checkbox-group { display: flex; flex-wrap: wrap; gap: 12px; }
.checkbox-group label { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border: 2px solid #e2e8f0; border-radius: 8px; cursor: pointer; font-size: 14px; transition: all 0.2s; }
.checkbox-group label:hover { border-color: #3b82f6; }
.checkbox-group input:checked + span { font-weight: 600; color: #3b82f6; }

/* ── Deadline coloring ── */
.deadline-overdue { color: #dc2626; font-weight: 600; }
.deadline-soon { color: #d97706; font-weight: 600; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar { width: 100%; height: auto; position: relative; }
    .content { margin-left: 0; padding: 16px; }
    .charts-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Empty state ── */
.empty-state { text-align: center; padding: 60px 20px; color: #94a3b8; }
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; color: #64748b; margin-bottom: 8px; }
