/* ContaWIN — interfaz contable compacta. Azul oscuro, grises suaves, densidad alta. */

:root {
  --azul: #19355e;
  --azul-osc: #0d1d37;
  --acento: #458ae5;
  --azul-claro: #2c5282;
  --acento: #3d6ea5;
  --fondo: #eef0f3;
  --panel: #ffffff;
  --borde: #d4d9e0;
  --borde-suave: #e5e8ed;
  --texto: #24292f;
  --texto-suave: #6a7380;
  --fila-hover: #f0f4f9;
  --fila-sel: #dbe7f4;
  --verde: #1a7f37;
  --rojo: #b42318;
  --naranja: #b54708;
  --radius: 3px;
}

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

html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.35;
  color: var(--texto);
  background: var(--fondo);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Barra superior ─────────────────────────────── */
#topbar {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  background: linear-gradient(180deg, var(--azul-osc), var(--azul));
  color: #fff;
  min-height: 40px;
  flex: none;
  box-shadow: 0 1px 6px rgba(10,20,45,.25);
}
.brand {
  display: flex; align-items: center;
  padding: 0 14px;
  font-size: 15px; font-weight: 700; letter-spacing: .3px;
  background: var(--azul-osc);
}
.brand span { font-weight: 300; opacity: .85; }
#modules { display: flex; flex-wrap: wrap; }
#modules button {
  border: none; background: none; color: #c7d3e2;
  font: inherit; font-size: 12px;
  padding: 0 9px; cursor: pointer;
  white-space: nowrap; height: 38px;
  border-bottom: 3px solid transparent;
  border-top: 3px solid transparent;
}
#modules button:hover { color: #fff; background: rgba(255,255,255,.06); }
#modules button.activo {
  color: var(--azul-osc); font-weight: 700;
  background: rgba(255,255,255,.93);
  border-radius: 14px;
  margin: 6px 2px;
  height: 26px;
  border-bottom-color: transparent;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.counter {
  background: var(--naranja); color: #fff;
  border-radius: 8px; padding: 0 5px; font-size: 10.5px; font-weight: 700;
  margin-left: 3px;
}
.topbar-right {
  margin-left: auto; display: flex; align-items: center; gap: 10px; padding: 0 12px;
  font-size: 12px; color: #c7d3e2; flex: none; white-space: nowrap;
}
.ej-label select {
  margin-left: 5px;
  background: var(--azul-osc); color: #fff;
  border: 1px solid var(--azul-claro); border-radius: var(--radius);
  font: inherit; padding: 2px 4px;
}
.salud { font-size: 11px; color: #4ade80; }
.salud.mal { color: #f87171; }
#btn-admin {
  background: none; border: 1px solid var(--azul-claro); color: #c7d3e2;
  border-radius: var(--radius); width: 24px; height: 24px; cursor: pointer;
  font-size: 13px; line-height: 1;
}
#btn-admin:hover { color: #fff; background: rgba(255,255,255,.08); }

/* ── Barra de herramientas (filtros) ────────────── */
#toolbar {
  flex: none;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--borde);
  padding: 6px 10px;
  min-height: 38px;
}
#toolbar:empty { display: none; }
#toolbar label {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; color: var(--texto-suave); white-space: nowrap;
}
#toolbar .sep { width: 1px; height: 20px; background: var(--borde); }
#toolbar .spacer { flex: 1; }

input, select, button, textarea { font: inherit; }
input[type=text], input[type=date], input[type=number], select, textarea {
  border: 1px solid var(--borde);
  border-radius: var(--radius);
  padding: 3px 6px;
  font-size: 12.5px;
  background: #fff;
  color: var(--texto);
  height: 25px;
}
textarea { height: auto; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--acento);
  box-shadow: 0 0 0 2px rgba(61,110,165,.18);
}
input.num { text-align: right; }
input[type=text].corto { width: 90px; }
input[type=date] { width: 130px; }

button.btn {
  border: 1px solid var(--borde);
  background: #f6f7f9; color: var(--texto);
  border-radius: var(--radius);
  padding: 3px 11px; height: 25px;
  cursor: pointer; font-size: 12.5px;
}
button.btn:hover { background: #eceef2; }
button.btn.primario {
  background: linear-gradient(180deg, #234a80, var(--azul));
  border-color: var(--azul); color: #fff; font-weight: 600;
  box-shadow: 0 1px 3px rgba(15,30,60,.25);
}
button.btn.primario:hover { background: var(--azul-claro); }
button.btn.peligro { color: var(--rojo); }
button.btn.peligro:hover { background: #fdf1f0; border-color: #e5b5b0; }
button.btn.ok { color: var(--verde); }
button.btn.ok:hover { background: #f0f9f2; border-color: #b3d9be; }

/* ── Contenido y tablas ─────────────────────────── */
#content {
  flex: 1; overflow: auto;
  padding: 8px 10px;
}
.panel {
  background: var(--panel);
  border: 1px solid rgba(0,0,0,.06);
  border-radius: 9px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(15,30,60,.07);
}
.panel + .panel { margin-top: 8px; }
.panel-cab {
  padding: 7px 12px;
  font-size: 10.5px; font-weight: 700; color: var(--azul);
  letter-spacing: .07em; text-transform: uppercase;
  background: rgba(25,53,94,.045);
  border-bottom: 1px solid var(--borde-suave);
  display: flex; align-items: center; gap: 12px;
}
.panel-cab::before {
  content: ""; width: 3px; height: 13px; border-radius: 2px;
  background: var(--acento);
}
.panel-cab .suave { text-transform: none; letter-spacing: 0; font-size: 11.5px; }
.panel-cab .suave { font-weight: 400; color: var(--texto-suave); }

table.grid { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.grid th {
  position: sticky; top: 0; z-index: 2;
  background: #f4f6f9;
  color: #414b58;
  text-align: left; font-weight: 600; font-size: 11.5px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--borde);
  white-space: nowrap;
  user-select: none;
}
table.grid td {
  padding: 2px 8px;
  border-bottom: 1px solid var(--borde-suave);
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
table.grid td.wrap { white-space: normal; }
table.grid tbody tr { cursor: default; }
table.grid tbody tr.clicable { cursor: pointer; }
table.grid tbody tr:nth-child(even) { background: #fafbfd; }
table.grid tbody tr:hover { background: var(--fila-hover); }
table.grid tbody tr.sel { background: var(--fila-sel); }
th.num, td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
td.neg { color: var(--rojo); }
table.grid tfoot td {
  position: sticky; bottom: 0;
  background: #eef2f7;
  border-top: 2px solid var(--azul);
  font-weight: 700; padding: 4px 8px;
  font-variant-numeric: tabular-nums;
}
.tabla-scroll { overflow: auto; max-height: 100%; }

/* estados */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 700;
  padding: 1px 8px; border-radius: 9px; line-height: 15px;
  border: .5px solid currentColor;
}
.badge::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: currentColor;
}
.badge.b-contabilizado { background: #e3f2e7; color: var(--verde); }
.badge.b-borrador { background: #fdf0e3; color: var(--naranja); }
.badge.b-anulado { background: #ececee; color: var(--texto-suave); text-decoration: line-through; }
.badge.b-pendiente { background: #fdf0e3; color: var(--naranja); }
.badge.b-contabilizada { background: #e3f2e7; color: var(--verde); }
.badge.b-cobrada, .badge.b-pagada { background: #e2ecf7; color: var(--azul-claro); }
.badge.b-claude { background: #ede7f8; color: #5b3fa8; }
.badge.b-manual, .badge.b-importacion { background: #ececee; color: var(--texto-suave); }
.badge.b-activo { background: #e3f2e7; color: var(--verde); }
.badge.b-baja_pendiente { background: #fdf0e3; color: var(--naranja); }
.badge.b-baja { background: #ececee; color: var(--texto-suave); text-decoration: line-through; }

/* ── Ficha de inmovilizado ──────────────────────── */
.mono { font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: 12px; }
input.mono[readonly] { background: #f4f6f9; color: var(--azul); font-weight: 700; }
.enlace-suave { font-size: 11px; color: var(--azul-claro); text-decoration: none; }
.enlace-suave:hover { text-decoration: underline; }
.fila-ubicacion { align-items: flex-end; gap: 8px; }
.fila-ubicacion input[readonly] { background: #f4f6f9; }
.ficha-seccion {
  display: flex; align-items: center; gap: 8px;
  margin: 14px 0 8px; font-size: 10.5px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--azul-claro);
}
.ficha-seccion span {
  font-weight: 400; text-transform: none; letter-spacing: 0;
  font-size: 11px; color: var(--texto-suave);
}
.ficha-seccion::after {
  content: ""; flex: 1; height: 1px; background: #e2e6ee;
}
.fiscal-pte { background: #fdf0e3; color: var(--naranja); border-radius: 3px;
  padding: 1px 6px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.aviso-bloqueo { background: #fdf6e3; border: 1px solid #e8d9a8; border-radius: 6px;
  padding: 8px 12px; margin-bottom: 12px; font-size: 12.5px; color: #7a5c12; }
.ficha-resumen { margin: 10px 0 6px; padding: 8px 12px; background: #f4f6f9;
  border-radius: 6px; font-size: 12.5px; }
.fila-fiscal { align-items: center; }
.zona-baja { align-items: flex-end; margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed #d4d9e2; }

/* galería de fotos del activo */
.galeria-fotos { display: flex; gap: 10px; align-items: stretch; min-height: 88px; }
.foto-tile { position: relative; width: 116px; height: 88px; border-radius: 6px;
  overflow: hidden; border: 1px solid #dbe0e9; background: #f4f6f9; }
.foto-tile img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.foto-quitar { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px;
  border: none; border-radius: 50%; background: rgba(20, 28, 45, .65); color: #fff;
  font-size: 11px; line-height: 20px; cursor: pointer; padding: 0; }
.foto-quitar:hover { background: var(--rojo); }
.foto-add { display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; border-style: dashed; cursor: pointer; font-size: 20px; }
.foto-add .suave { font-size: 11px; }
.foto-add:hover { border-color: var(--azul-claro); background: #eef3fa; }

.ok-texto { color: var(--verde); font-weight: 700; }
.mal-texto { color: var(--rojo); font-weight: 700; }
.aviso-texto { color: var(--naranja); }

/* ── Barra de estado ────────────────────────────── */
#statusbar {
  flex: none;
  display: flex; justify-content: space-between; align-items: center;
  background: var(--panel);
  border-top: 1px solid var(--borde);
  padding: 3px 10px;
  font-size: 11.5px; color: var(--texto-suave);
  height: 24px;
}
#status-left b { color: var(--texto); }

/* ── Modal ──────────────────────────────────────── */
#modal-bg {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20,30,45,.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 6vh;
}
#modal-bg.hidden, .hidden { display: none !important; }
#modal {
  background: var(--panel);
  border-radius: 4px;
  /* REGLA: ningún modal sale de los límites de la ventana */
  min-width: min(560px, calc(100vw - 24px));
  max-width: min(900px, calc(100vw - 24px));
  max-height: calc(100vh - 10vh);
  display: flex; flex-direction: column;
  box-shadow: 0 12px 40px rgba(10,20,35,.35);
}
#modal > header {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--azul); color: #fff;
  padding: 6px 12px; font-weight: 600; font-size: 13px;
  border-radius: 4px 4px 0 0;
}
#modal-close { background: none; border: none; color: #cbd6e4; cursor: pointer; font-size: 13px; }
#modal-close:hover { color: #fff; }
#modal-body { padding: 12px; overflow: auto; }

.form-fila { display: flex; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.form-fila label { display: flex; flex-direction: column; gap: 2px; font-size: 11.5px; color: var(--texto-suave); }
.errores {
  background: #fdf1f0; border: 1px solid #e5b5b0; color: var(--rojo);
  border-radius: var(--radius); padding: 6px 10px; margin: 8px 0; font-size: 12px;
}
.avisos {
  background: #fdf6ec; border: 1px solid #e8cfa8; color: var(--naranja);
  border-radius: var(--radius); padding: 6px 10px; margin: 8px 0; font-size: 12px;
}
.errores ul, .avisos ul { margin-left: 16px; }

/* pie pegado: los botones de acción siempre visibles aunque el cuerpo
   del modal tenga scroll */
.modal-pie {
  display: flex; justify-content: flex-end; gap: 8px;
  position: sticky; bottom: -12px;
  margin: 10px -12px -12px; padding: 10px 12px 12px;
  background: var(--panel); border-top: 1px solid #e2e6ee;
}

/* entrada de asientos: cuadrícula */
table.entrada { width: 100%; border-collapse: collapse; margin-top: 6px; }
table.entrada th { font-size: 11px; color: var(--texto-suave); text-align: left; padding: 2px 4px; }
table.entrada td { padding: 1px 2px; }
table.entrada input { width: 100%; }
table.entrada .c-cuenta { width: 110px; }
table.entrada .c-importe { width: 110px; }
.cuadre { font-size: 12.5px; font-variant-numeric: tabular-nums; padding: 6px 4px; }

.dos-col { display: flex; gap: 8px; align-items: flex-start; }
.dos-col > .panel { flex: 1; }

kbd {
  background: #f1f3f5; border: 1px solid var(--borde); border-radius: 3px;
  padding: 0 4px; font-size: 10.5px; font-family: inherit;
}
.detalle-meta { font-size: 12px; color: var(--texto-suave); margin-bottom: 8px; line-height: 1.6; }
.detalle-meta b { color: var(--texto); }

/* estados financieros */
table.ef td { padding-top: 3px; padding-bottom: 3px; }
tr.ef-seccion td {
  background: #eef2f7; color: var(--azul);
  font-weight: 700; font-size: 12px;
  border-top: 1px solid var(--borde);
}
tr.ef-total td {
  font-weight: 700; font-size: 12.5px;
  border-top: 2px solid var(--azul);
  background: #f7f9fc;
}
tr.ef-linea td:first-child { color: var(--texto); }

tr.ef-cuenta td {
  font-size: 11.5px; color: #555e69;
  background: #fbfcfd;
}
td.pct { color: var(--texto-suave); font-size: 11.5px; }

tr.vencido td { background: #fdf6ec; }

/* plan de amortización */
.fila-anio { cursor: pointer; }
.fila-anio.anio-actual td { background: #f2f7fd; }
.fila-familia td { font-size: 11.5px; background: #fafbfd; }

/* ── Acceso (login) ─────────────────────────────────── */
#login {
  position: fixed; inset: 0; z-index: 100;
  display: flex;
}
#login-marca {
  flex: 0 0 min(38%, 430px);
  background: linear-gradient(135deg, #0d1d37, #19355e);
  background-image:
    radial-gradient(rgba(255,255,255,.06) 1px, transparent 1.6px),
    linear-gradient(135deg, #0d1d37, #19355e);
  background-size: 26px 26px, cover;
  color: #fff;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 44px;
}
#login-logo {
  width: 66px; height: 66px; border-radius: 17px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  background: linear-gradient(135deg, #458ae5, #2c527f);
  box-shadow: 0 6px 22px rgba(69,138,229,.45);
}
#login-marca h1 { font-size: 32px; margin: 18px 0 2px; font-weight: 800; }
.login-tagline { font-size: 14px; color: rgba(255,255,255,.85); margin: 0; }
#login-rasgos { list-style: none; padding: 0; margin: 34px 0 0; }
#login-rasgos li { display: flex; flex-direction: column; margin-bottom: 15px; }
#login-rasgos b { font-size: 12.5px; }
#login-rasgos span { font-size: 11px; color: rgba(255,255,255,.55); }
#login-pie { font-size: 10.5px; color: rgba(255,255,255,.4); }
#login-zona {
  flex: 1; background: var(--fondo, #f2f4f8);
  display: flex; align-items: center; justify-content: center;
}
#login-card {
  width: 340px; background: #fff; border-radius: 14px;
  border: 1px solid rgba(0,0,0,.08);
  box-shadow: 0 24px 48px rgba(10,20,35,.12);
  padding: 30px; display: flex; flex-direction: column; gap: 14px;
}
#login-card h2 { margin: 0; font-size: 21px; color: var(--azul); }
#login-card .suave { margin: -10px 0 4px; font-size: 12px; }
.login-campo {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 9.5px; font-weight: 600; letter-spacing: .05em;
  color: var(--texto-suave);
}
.login-campo input {
  font-size: 13px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid rgba(0,0,0,.12); background: var(--fondo, #f2f4f8);
}
.login-campo input:focus { outline: 2px solid var(--azul-claro); }
#login-error { color: var(--rojo); font-size: 12px; min-height: 14px; }
#login-entrar { padding: 9px; font-size: 13.5px; font-weight: 600; }

/* ── Banners de aviso (bajo la barra de herramientas) ── */
#avisos { padding: 0 14px; }
.banner {
  display: flex; align-items: center; gap: 10px;
  margin: 8px 0 0; padding: 8px 12px;
  border-radius: 7px; border: 1px solid;
  font-size: 12.5px; line-height: 1.35;
  animation: banner-entra .18s ease-out;
}
@keyframes banner-entra { from { opacity: 0; transform: translateY(-4px); } }
.banner-fuera { opacity: 0; transition: opacity .3s; }
.banner-icono { font-size: 13px; font-weight: 700; }
.banner-texto { flex: 1; }
.banner-accion { flex-shrink: 0; }
.banner-cerrar {
  flex-shrink: 0; border: none; background: none; cursor: pointer;
  color: inherit; opacity: .55; font-size: 11px; padding: 2px 4px;
}
.banner-cerrar:hover { opacity: 1; }
.banner-info  { background: #eef3fa; border-color: #c9d9ef; color: #23446e; }
.banner-exito { background: #e9f5ec; border-color: #bfe0c8; color: #1e6234; }
.banner-aviso { background: #fdf6e3; border-color: #ecd9a0; color: #7a5c12; }
.banner-error { background: #fdecec; border-color: #f0c4c4; color: #8c2626; }
.banner-info .banner-icono { color: var(--azul-claro); }

/* pestañas de segundo nivel (navegación de informes) */
.tabs { display: flex; gap: 16px; align-items: flex-end; align-self: stretch; }
button.tab {
  background: none; border: none; cursor: pointer;
  text-align: left; padding: 5px 10px 7px;
  border-bottom: 3px solid transparent;
  border-radius: 6px 6px 0 0;
}
button.tab .t {
  display: block; font-size: 12.5px; font-weight: 600; color: #4a5462;
}
button.tab .d {
  display: block; font-size: 9.5px; color: var(--texto-suave); margin-top: 1px;
}
button.tab:hover .t { color: var(--azul); }
button.tab.activa {
  background: rgba(69,138,229,.08);
  border-bottom-color: var(--azul);
}
button.tab.activa .t { color: var(--azul); }
button.tab.activa .d { color: rgba(25,53,94,.6); }
.zona-sep { width: 1px; height: 26px; background: var(--borde); margin: 0 4px; align-self: center; }
