*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-bg: #f4f5f7;
  --c-surface: #ffffff;
  --c-surface2: #f8f9fa;
  --c-border: #e2e4e9;
  --c-border2: #c8ccd6;
  --c-text: #1a1d23;
  --c-text2: #5a6072;
  --c-text3: #9aa0b0;
  --c-blue: #1a6cf8;
  --c-blue-bg: #eef3fe;
  --c-blue-dark: #1458d0;
  --c-green: #15a66a;
  --c-green-bg: #e6f7f1;
  --c-yellow: #d48a00;
  --c-yellow-bg: #fef7e0;
  --c-red: #d63b3b;
  --c-red-bg: #fdeaea;
  --c-purple: #6c47d8;
  --c-purple-bg: #f0ecfd;
  --sidebar-w: 220px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 4px rgba(0,0,0,.08);
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; color: var(--c-text); background: var(--c-bg); line-height: 1.5; }

/* ── Layout ── */
#app { display: flex; min-height: 100vh; }
#sidebar { width: var(--sidebar-w); flex-shrink: 0; background: var(--c-surface); border-right: 1px solid var(--c-border); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; }
#main { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; display: flex; flex-direction: column; }
#topbar { height: 56px; background: var(--c-surface); border-bottom: 1px solid var(--c-border); display: flex; align-items: center; padding: 0 24px; gap: 12px; position: sticky; top: 0; z-index: 50; }
#content { flex: 1; padding: 28px 28px; }

/* ── Sidebar ── */
.sidebar-logo { padding: 18px 20px 14px; font-weight: 700; font-size: 16px; color: var(--c-blue); letter-spacing: -.3px; border-bottom: 1px solid var(--c-border); }
.sidebar-logo span { font-weight: 400; color: var(--c-text2); font-size: 13px; }
.nav-section { padding: 12px 12px 4px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--c-text3); }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 8px 12px; border-radius: var(--radius); margin: 1px 8px; cursor: pointer; color: var(--c-text2); font-size: 13.5px; font-weight: 500; transition: background .15s, color .15s; }
.nav-item:hover { background: var(--c-bg); color: var(--c-text); }
.nav-item.active { background: var(--c-blue-bg); color: var(--c-blue); }
.nav-item svg { flex-shrink: 0; opacity: .7; }
.nav-item.active svg { opacity: 1; }
.sidebar-user { margin-top: auto; padding: 16px; border-top: 1px solid var(--c-border); display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--c-blue-bg); color: var(--c-blue); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; flex-shrink: 0; }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }

/* ── Topbar ── */
.topbar-title { font-weight: 600; font-size: 15px; flex: 1; }
.notif-btn { position: relative; width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--c-border); background: var(--c-surface); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.notif-badge { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--c-red); border: 2px solid var(--c-surface); }

/* ── Cards ── */
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: 20px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 24px; }
.kpi-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: 18px 20px; }
.kpi-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--c-text3); margin-bottom: 8px; }
.kpi-value { font-size: 28px; font-weight: 700; line-height: 1; margin-bottom: 4px; }
.kpi-sub { font-size: 12px; color: var(--c-text3); }
.kpi-card.danger .kpi-value { color: var(--c-red); }
.kpi-card.success .kpi-value { color: var(--c-green); }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th { text-align: left; padding: 10px 14px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--c-text3); border-bottom: 1px solid var(--c-border); }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--c-surface2); }
tbody tr { cursor: pointer; }

/* ── Badges / Pills ── */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge.pendiente { background: var(--c-border); color: var(--c-text2); }
.badge.en_proceso, .badge.activo { background: var(--c-blue-bg); color: var(--c-blue); }
.badge.detenido { background: var(--c-yellow-bg); color: var(--c-yellow); }
.badge.completado, .badge.cerrado { background: var(--c-green-bg); color: var(--c-green); }
.badge.cancelado, .badge.critica { background: var(--c-red-bg); color: var(--c-red); }
.badge.alta { background: var(--c-yellow-bg); color: var(--c-yellow); }
.badge.media { background: var(--c-blue-bg); color: var(--c-blue); }
.badge.baja { background: var(--c-border); color: var(--c-text3); }
.badge.borrador { background: var(--c-purple-bg); color: var(--c-purple); }
.badge.directivo { background: var(--c-purple-bg); color: var(--c-purple); }
.badge.gerente { background: var(--c-blue-bg); color: var(--c-blue); }

/* ── Progress bar ── */
.progress-wrap { background: var(--c-border); border-radius: 4px; height: 6px; overflow: hidden; }
.progress-bar  { height: 100%; border-radius: 4px; transition: width .4s; }
.progress-bar.low  { background: var(--c-red); }
.progress-bar.mid  { background: var(--c-yellow); }
.progress-bar.high { background: var(--c-green); }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); border: 1px solid var(--c-border2); background: var(--c-surface); cursor: pointer; font-size: 13.5px; font-weight: 500; color: var(--c-text); transition: background .15s; }
.btn:hover { background: var(--c-surface2); }
.btn.primary { background: var(--c-blue); color: #fff; border-color: var(--c-blue-dark); }
.btn.primary:hover { background: var(--c-blue-dark); }
.btn.danger { background: var(--c-red-bg); color: var(--c-red); border-color: var(--c-red); }
.btn.sm { padding: 5px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
label.fl { display: block; font-size: 12.5px; font-weight: 600; color: var(--c-text2); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--c-border2); border-radius: var(--radius);
  font-size: 13.5px; color: var(--c-text); background: var(--c-surface); outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--c-blue); }
textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--c-surface); border-radius: var(--radius-lg); width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-header { padding: 20px 24px 16px; border-bottom: 1px solid var(--c-border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--c-border); display: flex; justify-content: flex-end; gap: 10px; }
.close-btn { width: 28px; height: 28px; border-radius: 6px; border: none; background: none; cursor: pointer; font-size: 18px; color: var(--c-text3); display: flex; align-items: center; justify-content: center; }
.close-btn:hover { background: var(--c-bg); }

/* ── Misc ── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.page-header h2 { font-size: 20px; font-weight: 700; }
.section-title { font-size: 13px; font-weight: 600; color: var(--c-text2); margin-bottom: 12px; text-transform: uppercase; letter-spacing: .05em; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--c-text3); font-size: 12px; }
.text-danger { color: var(--c-red); }
.text-success { color: var(--c-green); }
.flex { display: flex; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--c-text3); }
.empty-state p { margin-top: 8px; font-size: 13px; }
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--c-border); border-top-color: var(--c-blue); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Login ── */
#login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--c-bg); }
.login-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: 40px 36px; width: 100%; max-width: 400px; box-shadow: var(--shadow); }
.login-logo { font-size: 22px; font-weight: 800; color: var(--c-blue); margin-bottom: 4px; }
.login-sub { font-size: 13px; color: var(--c-text3); margin-bottom: 30px; }
.error-msg { background: var(--c-red-bg); color: var(--c-red); padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; }

/* ── Task detail ── */
.update-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--c-border); }
.update-item:last-child { border-bottom: none; }
.update-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-blue); margin-top: 6px; flex-shrink: 0; }
.comment-item { display: flex; gap: 10px; padding: 10px 0; }
.notif-panel { position: absolute; top: 52px; right: 24px; width: 360px; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg); box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 200; max-height: 440px; overflow-y: auto; }
.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--c-border); cursor: pointer; }
.notif-item:hover { background: var(--c-surface2); }
.notif-item.unread { background: var(--c-blue-bg); }
.notif-item:last-child { border-bottom: none; }

@media(max-width:768px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .two-col, .three-col, .form-row { grid-template-columns: 1fr; }
  #sidebar { transform: translateX(-100%); }
  #main { margin-left: 0; }
}
