* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-texto);
  color: var(--tinta-texto);
  background: var(--fondo-app);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-titulares); margin: 0; }
button { font-family: var(--font-texto); }
a { color: var(--azul-institucional); }

#appRoot {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--azul-serin);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}
.sidebar__brand img { width: 100%; max-width: 168px; height: auto; display: block; }
.sidebar__nav { padding: 18px 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius);
  color: #cdd9e6;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  border-left: 3px solid transparent;
  background: transparent;
}
.sidebar__link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar__link.active { background: rgba(55,177,228,0.14); color: #fff; border-left-color: var(--cian-tecnico); }
.sidebar__link svg { width: 18px; height: 18px; flex: 0 0 auto; }
.sidebar__footer {
  padding: 14px 18px 18px;
  font-size: 10.5px;
  color: #7b8fa3;
  line-height: 1.6;
  border-top: 1px solid rgba(255,255,255,0.12);
}

/* ---------- Main ---------- */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: #fff;
  border-bottom: 1px solid var(--linea-suave);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 {
  font-size: 19px;
  letter-spacing: 0.03em;
  color: var(--azul-serin);
  text-transform: uppercase;
}
.topbar__actions { display: flex; gap: 10px; align-items: center; }
.content { padding: 24px 28px 60px; flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-texto);
  font-weight: 700;
  font-size: 13px;
  border-radius: var(--radius);
  padding: 9px 16px;
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.btn-primary { background: var(--azul-serin); color: #fff; }
.btn-primary:hover { background: #002a6e; }
.btn-accent { background: var(--cian-tecnico); color: #00243f; }
.btn-accent:hover { background: #29a0d4; }
.btn-outline { background: #fff; color: var(--azul-serin); border-color: var(--gris-medio); }
.btn-outline:hover { background: var(--gris-claro); }
.btn-ghost { background: transparent; color: var(--texto-secundario); border-color: transparent; }
.btn-ghost:hover { background: var(--gris-claro); color: var(--tinta-texto); }
.btn-danger { background: #fff; color: var(--peligro); border-color: #f0c4bd; }
.btn-danger:hover { background: #fdecea; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ---------- Cards / list ---------- */
.card {
  background: #fff;
  border: 1px solid var(--linea-suave);
  border-radius: 6px;
}
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.input, select.input, textarea.input {
  font-family: var(--font-texto);
  font-size: 13.5px;
  padding: 9px 11px;
  border: 1px solid var(--gris-medio);
  border-radius: var(--radius);
  background: #fff;
  color: var(--tinta-texto);
}
.input:focus, select.input:focus, textarea.input:focus {
  outline: none;
  border-color: var(--cian-tecnico);
  box-shadow: 0 0 0 3px rgba(55,177,228,0.18);
}
.search-box { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.search-box .input { width: 100%; padding-left: 32px; }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--texto-secundario); }

table.list-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.list-table th {
  text-align: left;
  font-family: var(--font-titulares);
  font-weight: 600;
  letter-spacing: 0.07em;
  font-size: 11px;
  color: var(--texto-secundario);
  background: var(--gris-claro);
  padding: 10px 14px;
  border-bottom: 1px solid var(--linea-suave);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
table.list-table th .sort-arrow { margin-left: 4px; opacity: 0.6; font-size: 10px; }
table.list-table td { padding: 12px 14px; border-bottom: 1px solid #eef2f6; vertical-align: middle; }
table.list-table tbody tr { cursor: pointer; }
table.list-table tbody tr:hover { background: #f7fafc; }
.badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--gris-claro);
  color: var(--azul-institucional);
}
.badge-v { background: #eaf6fc; color: #0c6ea3; }
.empty-state { padding: 60px 20px; text-align: center; color: var(--texto-secundario); }
.empty-state svg { width: 46px; height: 46px; color: var(--gris-medio); margin-bottom: 10px; }

/* ---------- Inicio ---------- */
.content.home-bg {
  background:
    linear-gradient(rgba(243,246,249,0.86), rgba(243,246,249,0.86)),
    url('../assets/inicio-bg.png') center top / cover no-repeat;
}
.home-hero { text-align: center; padding: 28px 16px 8px; max-width: 640px; margin: 0 auto; }
.home-hero__logo { width: 220px; height: auto; margin-bottom: 18px; }
.home-hero__title {
  font-size: 22px; letter-spacing: 0.02em; color: var(--azul-serin); text-transform: uppercase;
}
.home-hero__subtitle { margin-top: 10px; font-size: 14px; color: var(--texto-secundario); line-height: 1.6; }

.home-cards {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
  max-width: 780px; margin: 32px auto 0;
}
.home-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  background: #fff; border: 1px solid var(--linea-suave); border-radius: 8px;
  padding: 24px; text-align: left; cursor: pointer; font-family: var(--font-texto);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.home-card:hover {
  border-color: var(--cian-tecnico); box-shadow: 0 8px 20px rgba(0,26,75,0.08); transform: translateY(-2px);
}
.home-card__icon {
  width: 42px; height: 42px; border-radius: 50%; background: var(--azul-serin); color: #fff;
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.home-card__icon svg { width: 20px; height: 20px; }
.home-card__title { font-family: var(--font-titulares); font-size: 16px; font-weight: 600; letter-spacing: 0.02em; color: var(--azul-serin); }
.home-card__text { font-size: 13px; color: var(--texto-secundario); line-height: 1.55; }

.home-stat {
  max-width: 780px; margin: 28px auto 0; text-align: center; font-size: 13px; color: var(--texto-secundario);
}
.home-stat strong { color: var(--azul-serin); font-size: 15px; }

@media (max-width: 720px) {
  .home-cards { grid-template-columns: 1fr; }
}

/* ---------- Toast ---------- */
#toastHost { position: fixed; bottom: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--azul-serin);
  color: #fff;
  padding: 11px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
  animation: toast-in .18s ease;
}
.toast.error { background: var(--peligro); }
@keyframes toast-in { from { opacity:0; transform: translateY(6px);} to {opacity:1; transform:none;} }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10,25,45,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 500; padding: 20px;
}
.modal {
  background: #fff; border-radius: 8px; max-width: 640px; width: 100%;
  max-height: 86vh; overflow: auto; padding: 22px 24px;
}
.modal h3 { font-size: 16px; color: var(--azul-serin); letter-spacing: 0.03em; margin-bottom: 12px; }
.modal__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.sidebar__overlay { display: none; }
#menuToggle { display: none; }

@media (max-width: 900px) {
  .sidebar { position: fixed; z-index: 101; top: 0; left: 0; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar__overlay.open {
    display: block; position: fixed; inset: 0; background: rgba(10,25,45,0.4); z-index: 100;
  }
  .main { width: 100%; }
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  #menuToggle { display: inline-flex; }
}

@media print {
  .sidebar, .topbar, .noprint { display: none !important; }
  .content { padding: 0 !important; }
  #appRoot { display: block !important; }
  html, body { background: #fff !important; }
}
