:root {
  --primary:   #1A2E4A;
  --accent:    #8B1A2E;
  --light:     #D6E4F0;
  --lighter:   #EEF5FB;
  --text:      #1c2b3a;
  --muted:     #5a7a96;
  --border:    #b0cde3;
  --white:     #ffffff;
  --radius:    8px;
  --shadow:    0 2px 12px rgba(26,46,74,.12);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: #f0f5fb; color: var(--text); min-height: 100vh; }

/* NAV */
nav {
  background: var(--primary);
  padding: 0 1.5rem;
  display: flex; align-items: center; gap: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  flex-wrap: wrap;
}
.nav-brand {
  color: var(--white); font-size: .85rem; font-weight: 700;
  padding: .9rem 0; letter-spacing: .5px; margin-right: auto;
  text-decoration: none; line-height: 1.3;
}
.nav-brand span { color: #8fc8f0; font-size: .7rem; font-weight: 400; display: block; }
nav a {
  color: #a8cce8; text-decoration: none; font-size: .82rem;
  padding: .9rem .6rem; border-bottom: 3px solid transparent;
  transition: color .2s, border-color .2s;
}
nav a:hover, nav a.active { color: var(--white); border-bottom-color: var(--accent); }
.nav-portal {
  margin-left: auto; padding: 4px 12px;
  border: 1px solid #c9a84c; border-radius: 4px;
  color: #c9a84c !important; text-decoration: none;
  font-size: .9em; border-bottom: none !important;
  white-space: nowrap;
}
.nav-portal:hover { background: rgba(201,168,76,.12); border-bottom: none !important; }

/* HERO */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, #2a4a72 100%);
  color: var(--white); padding: 2.5rem 2rem; text-align: center;
  border-bottom: 4px solid var(--accent);
}
.hero h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: .5px; }
.hero p  { margin-top: .5rem; color: #8fc8f0; font-size: .9rem; }
.hero p.sub2 { margin-top: .3rem; color: #a8cce8; font-size: .82rem; }

/* STAT GRID */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem; padding: 1.5rem 2rem;
}
.stat-card {
  background: var(--white); border-radius: var(--radius); padding: 1.2rem 1rem;
  text-align: center; box-shadow: var(--shadow);
  border-top: 4px solid var(--accent); transition: transform .2s;
}
.stat-card:hover { transform: translateY(-3px); }
.stat-card .num { font-size: 2rem; font-weight: 800; color: var(--primary); }
.stat-card .lbl { font-size: .75rem; color: var(--muted); margin-top: .2rem; text-transform: uppercase; letter-spacing: .5px; }

/* CONTAINER */
.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem 2rem; }

/* SECTION CARD */
.section-card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.5rem; margin-bottom: 1.5rem;
}
.section-card h2 {
  font-size: 1rem; font-weight: 700; color: var(--primary);
  border-left: 4px solid var(--accent); padding-left: .75rem;
  margin-bottom: 1rem;
}

/* GRID */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media(max-width:720px){ .grid-2 { grid-template-columns: 1fr; } }

/* TABLE */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
thead th {
  background: var(--primary); color: var(--white);
  padding: .6rem .8rem; text-align: left; font-weight: 600;
  position: sticky; top: 0;
}
tbody tr:nth-child(even) { background: var(--lighter); }
tbody tr:hover { background: var(--light); }
tbody td { padding: .55rem .8rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.badge {
  display: inline-block; background: var(--light); color: var(--primary);
  font-size: .7rem; font-weight: 700; padding: .15rem .5rem;
  border-radius: 20px; white-space: nowrap;
}
.badge-red { background: #fde8ec; color: var(--accent); }

/* FORM */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .8rem; }
label { font-size: .78rem; font-weight: 600; color: var(--muted); display: block; margin-bottom: .3rem; }
input, select {
  width: 100%; padding: .5rem .7rem; border: 1.5px solid var(--border);
  border-radius: 6px; font-size: .85rem; outline: none; transition: border-color .2s;
}
input:focus, select:focus { border-color: var(--primary); }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1.1rem; border-radius: 6px; font-size: .82rem;
  font-weight: 600; cursor: pointer; border: none; text-decoration: none;
  transition: filter .2s, transform .2s;
}
.btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: var(--white); }
.btn-accent  { background: var(--accent);  color: var(--white); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-sm { padding: .3rem .7rem; font-size: .75rem; }

/* BAR CHART */
.bar-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem; font-size: .78rem; }
.bar-label { min-width: 160px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.bar-track { flex: 1; background: var(--lighter); border-radius: 4px; height: 18px; overflow: hidden; }
.bar-fill   { height: 100%; background: linear-gradient(90deg, var(--primary), #2a6aad); border-radius: 4px; }
.bar-fill-b { height: 100%; background: linear-gradient(90deg, var(--accent), #c0394f); border-radius: 4px; }
.bar-val { min-width: 30px; text-align: right; font-weight: 700; color: var(--primary); }

/* LINKS */
a.row-link { color: var(--primary); text-decoration: none; font-weight: 600; }
a.row-link:hover { color: var(--accent); text-decoration: underline; }

/* PAGINATION */
.pager { display: flex; gap: .4rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.pager button {
  padding: .35rem .8rem; border-radius: 6px; border: 1.5px solid var(--border);
  background: var(--white); color: var(--primary); font-size: .8rem; cursor: pointer;
  transition: background .2s;
}
.pager button:hover, .pager button.active { background: var(--primary); color: var(--white); border-color: var(--primary); }
.pager button:disabled { opacity: .4; cursor: default; }

/* DETAIL */
.dl-grid { display: grid; grid-template-columns: 200px 1fr; gap: .5rem 1rem; font-size: .85rem; }
.dl-grid dt { font-weight: 600; color: var(--muted); }
.dl-grid dd { color: var(--text); }
@media(max-width:600px){ .dl-grid { grid-template-columns: 1fr; } }

/* AUTOCOMPLETE */
.ac-wrap { position: relative; }
.ac-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 99;
  background: var(--white); border: 1.5px solid var(--border);
  border-radius: 6px; box-shadow: var(--shadow); max-height: 220px; overflow-y: auto;
  list-style: none;
}
.ac-list li {
  padding: .5rem .8rem; cursor: pointer; font-size: .82rem;
  display: flex; justify-content: space-between; align-items: center;
}
.ac-list li:hover { background: var(--lighter); }
.ac-list li span { color: var(--muted); font-size: .72rem; }

/* ALERTS */
.alert { padding: .8rem 1rem; border-radius: var(--radius); font-size: .85rem; margin-bottom: 1rem; }
.alert-info { background: var(--light); color: var(--primary); border-left: 4px solid var(--primary); }

/* MINI BARS (estadísticas) */
.mini-bar-row { display:flex; align-items:center; gap:.5rem; margin-bottom:.35rem; font-size:.76rem; }
.mini-label { min-width:140px; max-width:200px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.mini-track { flex:1; background:var(--lighter); border-radius:3px; height:14px; }
.mini-fill-a { height:100%; background:linear-gradient(90deg,var(--primary),#3a7abf); border-radius:3px; }
.mini-fill-b { height:100%; background:linear-gradient(90deg,var(--accent),#c0394f); border-radius:3px; }
.mini-val { min-width:28px; text-align:right; font-weight:700; color:var(--primary); }

footer {
  text-align: center; padding: 1.5rem; font-size: .75rem; color: var(--muted);
  border-top: 1px solid var(--border); margin-top: 2rem;
}
