@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

:root {
  --primary: #1a5276;
  --primary-dark: #154360;
  --primary-light: #2e86c1;
  --accent: #2980b9;
  --success: #1e8449;
  --danger: #c0392b;
  --warning: #d68910;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #dde1e7;
  --text: #1c2833;
  --text-muted: #717d7e;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.12);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; font-family: inherit;
  border: none; cursor: pointer; transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #ecf0f1; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #dde1e7; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #196f3d; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a93226; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-icon { padding: 6px 8px; }

/* FORMS */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; color: var(--text); }
.form-control {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; font-family: inherit; color: var(--text);
  background: var(--surface); transition: border-color 0.2s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,82,118,0.1); }
textarea.form-control { resize: vertical; min-height: 80px; }

/* CARDS */
.card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 15px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
}
.card-body { padding: 20px; }

/* TABLES */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  background: var(--primary); color: white;
  padding: 10px 14px; text-align: left; font-weight: 500; font-size: 13px;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.15s; }
tbody tr:hover { background: #f0f4f8; }
tbody td { padding: 10px 14px; }

/* TOPBAR */
.topbar {
  background: var(--primary); color: white;
  padding: 0 24px; height: 58px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow-lg);
}
.topbar-brand { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
.topbar-brand span { font-weight: 300; opacity: 0.8; }
.topbar-user { display: flex; align-items: center; gap: 12px; font-size: 14px; }

/* SIDEBAR LAYOUT */
.layout { display: flex; min-height: calc(100vh - 58px); }
.sidebar {
  width: 220px; min-width: 220px; background: var(--surface);
  border-right: 1px solid var(--border); padding: 16px 0;
}
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: var(--text);
  font-size: 14px; font-weight: 500; transition: all 0.2s;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  background: #ebf5fb; color: var(--primary);
  border-left-color: var(--primary); text-decoration: none;
}
.main-content { flex: 1; padding: 28px; overflow-y: auto; }

/* STAT CARDS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 20px;
  text-align: center; box-shadow: var(--shadow);
}
.stat-card .stat-num { font-size: 36px; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* GROUP CARDS */
.grupos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.grupo-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  padding: 20px; display: flex; flex-direction: column; gap: 12px;
  transition: box-shadow 0.2s;
}
.grupo-card:hover { box-shadow: var(--shadow-lg); }
.grupo-card h3 { font-size: 16px; font-weight: 600; color: var(--primary); }
.grupo-card .grupo-meta { font-size: 13px; color: var(--text-muted); }

/* BADGE */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600;
}
.badge-success { background: #d5f5e3; color: var(--success); }
.badge-warning { background: #fef9e7; color: var(--warning); }
.badge-danger { background: #fdedec; color: var(--danger); }

/* MODAL */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.45); z-index: 1000;
  align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius);
  width: 100%; max-width: 480px; box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.btn-close { background: none; border: none; cursor: pointer; font-size: 20px; color: var(--text-muted); padding: 0 4px; }

/* ALERTS */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.alert-error { background: #fdedec; color: var(--danger); border: 1px solid #f5b7b1; }
.alert-success { background: #d5f5e3; color: var(--success); border: 1px solid #a9dfbf; }
.alert-info { background: #ebf5fb; color: var(--primary); border: 1px solid #aed6f1; }

/* INFORME PAGE */
.informe-section {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.informe-section-header {
  padding: 12px 20px; background: #ebf5fb;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 14px; color: var(--primary);
  cursor: pointer; display: flex; justify-content: space-between;
}
.informe-section-body { padding: 16px 20px; }

.checkbox-list { display: flex; flex-direction: column; gap: 8px; }
.checkbox-list label {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 14px; cursor: pointer; line-height: 1.5;
}
.checkbox-list input[type="checkbox"] { margin-top: 3px; min-width: 16px; accent-color: var(--primary); }

.notas-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.notas-table td { padding: 6px 8px; }
.notas-table td:first-child { width: 60%; }
.notas-table td:last-child { width: 30%; }
.notas-table input { width: 100%; }
.notas-table .btn-danger { padding: 4px 8px; }

#texto-final-container { position: relative; }
#texto-final {
  width: 100%; min-height: 200px; font-family: inherit; font-size: 14px;
  line-height: 1.7; padding: 16px; border: 1px solid var(--border);
  border-radius: var(--radius); resize: vertical;
}

/* LOGIN PAGE */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, #154360 100%);
}
.login-box { width: 100%; max-width: 420px; padding: 16px; }
.login-card { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; }
.login-logo {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  padding: 28px 20px; text-align: center; color: white;
}
.login-logo h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-logo p { font-size: 13px; opacity: 0.8; }
.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tab-btn {
  flex: 1; padding: 12px; text-align: center; font-size: 14px; font-weight: 500;
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  border-bottom: 2px solid transparent; transition: all 0.2s;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; padding: 24px; }
.tab-content.active { display: block; }

/* PRINT STYLES */
@media print {
  .topbar, .sidebar, .btn, .informe-section-header,
  #btn-generar, #btn-copiar, #btn-guardar, #btn-imprimir,
  .no-print { display: none !important; }
  body { background: white; font-size: 13pt; }
  .main-content { padding: 0; }
  #texto-final { border: none; font-size: 13pt; line-height: 1.8; }
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); padding: 8px 0; }
  .sidebar-nav { display: flex; overflow-x: auto; }
  .sidebar-nav a { white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; }
  .main-content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

.page-title { font-size: 20px; font-weight: 700; color: var(--primary); margin-bottom: 20px; }
.section-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 12px; }
.text-muted { color: var(--text-muted); font-size: 13px; }
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-8 { margin-bottom: 8px; }
.mt-8 { margin-top: 8px; }
.w-full { width: 100%; }
