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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1);
  --shadow-md: 0 4px 6px rgba(0,0,0,.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.5;
  min-height: 100vh;
}

/* NAVBAR */
.navbar {
  background: var(--gray-900);
  color: white;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand a { color: white; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.nav-links { display: flex; align-items: center; gap: .5rem; }
.nav-link { color: var(--gray-300); text-decoration: none; padding: .5rem .75rem; border-radius: var(--radius); font-size: .9rem; }
.nav-link:hover { background: rgba(255,255,255,.1); color: white; }
.nav-right { display: flex; align-items: center; gap: .75rem; margin-left: .5rem; }
.nav-user { color: var(--gray-300); font-size: .85rem; }
.menu-toggle { display: none; background: none; border: none; color: white; font-size: 1.5rem; cursor: pointer; padding: .25rem; }

.notif-btn { background: none; border: none; color: white; font-size: 1.2rem; cursor: pointer; position: relative; }
.notif-badge { position: absolute; top: -6px; right: -8px; background: var(--danger); color: white; font-size: .65rem; border-radius: 50%; width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; }
.notif-panel { position: fixed; top: 56px; right: 0; width: 320px; max-height: 400px; background: white; box-shadow: var(--shadow-md); border-radius: 0 0 0 var(--radius); overflow-y: auto; z-index: 101; }
.notif-item { padding: .75rem 1rem; border-bottom: 1px solid var(--gray-200); font-size: .85rem; }
.notif-item.unread { background: #eff6ff; }
.notif-item .notif-time { color: var(--gray-500); font-size: .75rem; }
.notif-empty { padding: 2rem; text-align: center; color: var(--gray-500); }

/* CONTAINER */
.container { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem; }

/* CARDS */
.card { background: white; border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card h3 { margin-bottom: .75rem; font-size: 1rem; }

/* STATS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat-card { background: white; border-radius: var(--radius); padding: 1rem; text-align: center; box-shadow: var(--shadow); border-left: 4px solid var(--primary); }
.stat-card.stat-warning { border-left-color: var(--warning); }
.stat-card.stat-info { border-left-color: var(--info); }
.stat-card.stat-success { border-left-color: var(--success); }
.stat-card.stat-danger { border-left-color: var(--danger); }
.stat-number { font-size: 1.75rem; font-weight: 700; }
.stat-label { font-size: .8rem; color: var(--gray-500); margin-top: .25rem; }

/* CHARTS */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.charts-grid-equal { align-items: stretch; }
.chart-card-equal { display: flex; flex-direction: column; }
.chart-card-equal h3 { flex-shrink: 0; }
.gauge-container { flex: 1; display: flex; align-items: center; justify-content: center; max-height: 280px; }

/* FORMS */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .3rem; color: var(--gray-700); }
.form-control { width: 100%; padding: .6rem .75rem; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: .9rem; transition: border-color .2s; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-control-sm { padding: .35rem .5rem; font-size: .8rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; gap: .75rem; margin-top: 1rem; }
.filter-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.filter-form .form-control { width: auto; min-width: 140px; }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: .6rem 1.25rem; border-radius: var(--radius); font-size: .9rem; font-weight: 500; border: none; cursor: pointer; text-decoration: none; transition: all .2s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-outline { background: none; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-100); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-block { width: 100%; }

/* BADGES */
.badge { display: inline-block; padding: .2rem .6rem; border-radius: 12px; font-size: .75rem; font-weight: 500; background: var(--gray-200); }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }

/* TABLES */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.table th, .table td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--gray-200); }
.table th { background: var(--gray-50); font-weight: 600; color: var(--gray-700); position: sticky; top: 0; }

/* PROGRESS BAR */
.progress-bar { height: 8px; background: var(--gray-200); border-radius: 4px; overflow: hidden; width: 100px; display: inline-block; vertical-align: middle; margin-right: .5rem; }
.progress-fill { height: 100%; background: var(--success); border-radius: 4px; transition: width .3s; }

/* TASK LIST */
.task-list { display: flex; flex-direction: column; gap: .5rem; }
.task-card { background: white; border-radius: var(--radius); padding: .75rem 1rem; box-shadow: var(--shadow); border-left: 3px solid var(--gray-300); }
.task-card.task-overdue { border-left-color: var(--danger); background: #fef2f2; }
.task-header { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.task-title { font-weight: 600; color: var(--gray-900); text-decoration: none; font-size: .9rem; }
.task-title:hover { color: var(--primary); }
.task-meta { display: flex; flex-wrap: wrap; gap: .5rem; font-size: .8rem; color: var(--gray-500); align-items: center; }
.task-actions { flex-shrink: 0; }

/* PAGE HEADER */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.page-header h2 { font-size: 1.25rem; }

/* ALERTS */
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .9rem; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* LOGIN */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1e3a5f 0%, #111827 100%); }
.login-card { background: white; padding: 2rem; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.2); width: 100%; max-width: 380px; margin: 1rem; }
.login-title { text-align: center; font-size: 1.5rem; color: var(--gray-900); }
.login-subtitle { text-align: center; color: var(--gray-500); margin-bottom: 1.5rem; font-size: .9rem; }

/* TASK DESC */
.task-desc { font-size: .82rem; color: var(--gray-500); margin: .25rem 0 .4rem; line-height: 1.4; }

/* PERIODO SELECTOR */
.periodo-selector { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* MODAL */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5); z-index: 200;
  display: none !important; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-overlay.modal-visible {
  display: flex !important;
}
.modal-card {
  background: white; border-radius: 12px; padding: 1.5rem;
  width: 100%; max-width: 440px; box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.modal-card h3 { margin-bottom: .25rem; }

/* PAGINATION */
.pagination { display: flex; gap: .35rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; align-items: center; }

/* AUDIT */
.audit-detail { max-width: 300px; font-size: .8rem; word-break: break-word; }

/* UTILITIES */
.mt-3 { margin-top: 1rem; }
.text-muted { color: var(--gray-500); }
.text-danger { color: var(--danger); font-weight: 600; }
hr { border: none; border-top: 1px solid var(--gray-200); margin: 1.25rem 0; }
h2 { font-size: 1.25rem; color: var(--gray-900); }
h3 { font-size: 1rem; }

/* =========== MOBILE =========== */
@media (max-width: 768px) {
  .menu-toggle { display: block; }
  .nav-links {
    display: none;
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--gray-900);
    flex-direction: column;
    padding: .5rem;
    z-index: 99;
  }
  .nav-links.open { display: flex; }
  .nav-right { flex-direction: column; width: 100%; gap: .5rem; margin-left: 0; margin-top: .5rem; padding-top: .5rem; border-top: 1px solid rgba(255,255,255,.1); }
  .nav-link { width: 100%; padding: .75rem; }
  .nav-user { display: none; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; gap: .5rem; }
  .filter-form { flex-direction: column; }
  .filter-form .form-control { width: 100%; min-width: 0; }
  .page-header { flex-direction: column; align-items: flex-start; gap: .5rem; }

  .task-header { flex-direction: column; align-items: flex-start; }
  .task-actions { width: 100%; }
  .task-actions .form-control { width: 100%; }

  .notif-panel { width: 100%; border-radius: 0; }

  .table th, .table td { padding: .5rem; font-size: .8rem; }
  .container { padding: 1rem .75rem; }

  .stat-number { font-size: 1.4rem; }
  .stat-label { font-size: .7rem; }
  .stat-card { padding: .75rem .5rem; }
}

@media (max-width: 380px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: .5rem; }
  .login-card { padding: 1.5rem; margin: .5rem; }
}
