/* ============ Vértice Fit - estilos ============ */
:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #1b2233;
  --muted: #667085;
  --line: #e3e7ef;
  --brand: #e8541e;
  --brand-dark: #c4410f;
  --side: #141a29;
  --side-ink: #c9d0de;
  --ok: #138a52;
  --ok-bg: #e5f6ed;
  --warn: #b26b00;
  --warn-bg: #fff3dc;
  --bad: #c62828;
  --bad-bg: #fde8e8;
  --info: #2457c5;
  --info-bg: #e7eefc;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14.5px;
  display: flex;
}
@media (min-width: 761px) {
  /* el fondo oscuro del menú cubre toda la altura aunque la página sea larga */
  body { background: linear-gradient(to right, var(--side) 250px, var(--bg) 250px); }
}

/* ---------- Menú lateral ---------- */
.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--side);
  color: var(--side-ink);
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  padding: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 18px;
}
.brand b { color: #fff; font-size: 16px; display: block; }
.brand small { color: #8b94a8; font-size: 12px; }
.nav-group { margin-top: 14px; }
.nav-group-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: #6f7890; padding: 6px 10px;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  color: var(--side-ink); text-decoration: none;
  padding: 9px 10px; border-radius: 8px; margin: 1px 0;
}
.nav a:hover { background: #1f2738; color: #fff; }
.nav a.active { background: var(--brand); color: #fff; }
.nav a .ico { width: 20px; text-align: center; }
.nav a.fin { border: 1px dashed #3a4560; }
.nav a.fin.active { border-color: transparent; }

.btn.menu-btn { display: none; }

/* ---------- Contenido ---------- */
.main { flex: 1; min-width: 0; padding: 26px 32px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 24px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.tag {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px; background: var(--info-bg); color: var(--info);
}

/* Formulario arriba (campos en columnas) y lista a todo el ancho debajo */
.grid { display: grid; grid-template-columns: 1fr; gap: 20px; align-items: start; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; margin-bottom: 20px; }
.grid > *, .grid2 > * { min-width: 0; }
.grid .form { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); align-items: start; }
.form > .btn-row, .form > button, .form > .hint, .form > #resumen, .form > #detalleMem, .form > .row2 { grid-column: 1 / -1; }
.form > button { justify-self: start; min-width: 200px; }
.grid2 .form > button { justify-self: stretch; }
.grid2 .tx-console { margin-top: 0; min-height: 260px; }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.card h2 { margin: 0 0 14px; font-size: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 10px; }
.card-head h2 { margin: 0; }

/* ---------- Formularios ---------- */
.form { display: grid; gap: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: #344054; }
.field label .req { color: var(--brand); }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; font: inherit; color: var(--ink);
  border: 1px solid #cfd5e1; border-radius: 8px; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { min-height: 70px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(232, 84, 30, .15);
}
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 8px; padding: 10px 16px; font: inherit; font-weight: 600;
  cursor: pointer; background: var(--brand); color: #fff; transition: background .15s, transform .05s;
}
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.ghost { background: #eef1f6; color: var(--ink); }
.btn.ghost:hover { background: #e2e7ef; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.danger { background: var(--bad-bg); color: var(--bad); }
.btn.danger:hover { background: #f9d2d2; }
.btn-row { display: flex; gap: 8px; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); }
th, td.num, td .badge, td .btn-row { white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f8f9fc; }
tbody tr:hover { background: #fafbfd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; background: #f8f9fc; }
.empty { text-align: center; color: var(--muted); padding: 30px; }
.search { padding: 8px 11px; border: 1px solid #cfd5e1; border-radius: 8px; font: inherit; min-width: 200px; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-bad { background: var(--bad-bg); color: var(--bad); }
.b-info { background: var(--info-bg); color: var(--info); }
.b-muted { background: #eef1f6; color: var(--muted); }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi span { color: var(--muted); font-size: 12.5px; }
.kpi b { display: block; font-size: 24px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi.accent { border-left: 4px solid var(--brand); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.tile { display: block; text-decoration: none; color: inherit; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.tile:hover { border-color: var(--brand); }
.tile b { display: block; margin-bottom: 4px; }
.tile small { color: var(--muted); }

/* ---------- Barras (reportes) ---------- */
.bars { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 170px 1fr 120px; gap: 12px; align-items: center; }
.bar-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: #eef1f6; border-radius: 6px; height: 22px; position: relative; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: var(--brand); }
.bar-fill.back { position: absolute; inset: 0 auto 0 0; background: #f6c3ad; }
.bar-fill.front { position: absolute; inset: 0 auto 0 0; }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -2px; }

/* ---------- Consola de transacción ---------- */
.tx-console {
  background: #0f1422; color: #cfd6e6; border-radius: 10px; padding: 14px 16px;
  font-family: Consolas, "Cascadia Code", monospace; font-size: 13px; line-height: 1.7;
  min-height: 150px; margin-top: 14px; white-space: pre-wrap;
}
.tx-console .k { color: #7aa2ff; }
.tx-console .ok { color: #4ade80; font-weight: 700; }
.tx-console .bad { color: #f87171; font-weight: 700; }
.tx-console .dim { color: #6b7590; }
.tx-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.tx-summary div { background: #f8f9fc; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.tx-summary span { font-size: 12px; color: var(--muted); display: block; }
.tx-summary b { font-size: 16px; }

/* ---------- Avisos ---------- */
.toast-box { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 50; }
.toast {
  padding: 12px 16px; border-radius: 10px; color: #fff; box-shadow: var(--shadow);
  max-width: 380px; animation: slide .2s ease-out;
}
.toast.ok { background: var(--ok); }
.toast.bad { background: var(--bad); }
@keyframes slide { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

.setup { max-width: 640px; }
.setup code { background: #eef1f6; padding: 2px 6px; border-radius: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  body { display: block; }
  .sidebar { position: fixed; z-index: 40; left: -260px; transition: left .2s; }
  .sidebar.open { left: 0; }
  .btn.menu-btn { display: inline-flex; position: fixed; top: 12px; left: 12px; z-index: 45; }
  .main { padding: 64px 16px 40px; }
  .bar-row { grid-template-columns: 110px 1fr 90px; }
  .tx-summary { grid-template-columns: 1fr; }
}
