:root {
  --bg: #0f172a;
  --panel: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --accent: #b91c1c;
  --accent-soft: #fee2e2;
  --ok: #15803d;
  --border: #e2e8f0;
  --sidebar: #111827;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #f1f5f9; color: var(--ink);
}
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; background: var(--sidebar); color: #e5e7eb; padding: 20px 14px; flex-shrink: 0;
}
.sidebar h1 { font-size: 16px; color: #fff; margin: 0 0 4px; }
.sidebar .sub { font-size: 12px; color: #9ca3af; margin-bottom: 20px; }
.sidebar a { display: block; color: #d1d5db; text-decoration: none; padding: 8px 10px; border-radius: 6px; font-size: 14px; margin-bottom: 2px;}
.sidebar a:hover, .sidebar a.active { background: #1f2937; color: #fff; }
.sidebar .grupo { margin-top: 18px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #6b7280; padding: 0 10px; }
.main { flex: 1; padding: 24px 32px; max-width: 1300px; }
.topbar { display:flex; justify-content: space-between; align-items:center; margin-bottom: 20px; }
.topbar .user { font-size: 13px; color: var(--muted); }
h2 { margin-top: 0; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; margin-bottom: 18px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #f8fafc; font-weight: 600; color: #334155; position: sticky; top:0; }
tr:hover td { background: #fafafa; }
.badge { display:inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.alta { background: var(--accent-soft); color: var(--accent); }
.badge.media { background: #fef3c7; color: #92400e; }
.badge.baja { background: #e0f2fe; color: #0369a1; }
.btn { display: inline-block; background: var(--accent); color: #fff; border: none; padding: 8px 16px;
  border-radius: 6px; cursor: pointer; text-decoration: none; font-size: 14px; }
.btn.secondary { background: #334155; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
form .field { margin-bottom: 12px; }
label { display:block; font-size: 13px; margin-bottom: 4px; color: var(--muted); }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 14px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.stat .num { font-size: 26px; font-weight: 700; }
.stat .label { font-size: 12px; color: var(--muted); }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tabs a { padding: 8px 14px; text-decoration:none; color: var(--muted); font-size: 13px; border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.umbral-form { display:flex; align-items:center; gap: 10px; margin-bottom: 14px; font-size: 13px; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.alert.error { background: #fee2e2; color: #991b1b; }
.alert.ok { background: #dcfce7; color: #166534; }
.muted { color: var(--muted); font-size: 12px; }
.tag { display:inline-block; background:#eef2ff; color:#3730a3; border-radius:6px; padding:1px 6px; font-size:11px; margin-right:4px;}

/* --- Dashboards / mini rankings ------------------------------------- */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px,1fr)); gap: 14px; margin-bottom: 18px; }
.dash-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.dash-card h4 { margin: 0 0 10px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.dash-card ol { margin: 0; padding-left: 18px; font-size: 13px; }
.dash-card ol li { margin-bottom: 6px; display: flex; justify-content: space-between; gap: 8px; }
.dash-card .v { font-weight: 700; color: var(--accent); }
.dash-card.empty { color: var(--muted); font-size: 13px; }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { display:block; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px;
  text-decoration:none; color:inherit; transition: box-shadow .15s, transform .15s; position:relative; overflow:hidden; }
.stat-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); transform: translateY(-1px); }
.stat-card .icon { font-size: 22px; margin-bottom: 6px; display:block; }
.stat-card .num { font-size: 28px; font-weight: 800; line-height:1; }
.stat-card .label { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.stat-card.c-rojo { border-left: 5px solid #dc2626; }
.stat-card.c-naranja { border-left: 5px solid #ea580c; }
.stat-card.c-azul { border-left: 5px solid #2563eb; }
.stat-card.c-verde { border-left: 5px solid #16a34a; }
.stat-card.c-morado { border-left: 5px solid #7c3aed; }
.stat-card.c-gris { border-left: 5px solid #64748b; }
.stat-card.c-amarillo { border-left: 5px solid #eab308; }

.chart-box { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 18px; }
.chart-box h4 { margin: 0 0 10px; font-size: 13px; color: var(--muted); text-transform: uppercase; }
.chart-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px,1fr)); gap: 14px; }

/* --- Grupos por orden (acordeón) ------------------------------------- */
.grupo-orden { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; overflow: hidden; }
.grupo-orden > summary { cursor: pointer; padding: 12px 16px; display: flex; align-items: center; gap: 12px; list-style: none; font-size: 14px; }
.grupo-orden > summary::-webkit-details-marker { display: none; }
.grupo-orden > summary:before { content: "▸"; color: var(--muted); transition: transform .15s; }
.grupo-orden[open] > summary:before { transform: rotate(90deg); }
.grupo-orden .cab-orden { font-weight: 700; }
.grupo-orden .cab-meta { color: var(--muted); font-size: 12.5px; }
.grupo-orden .cuerpo { padding: 4px 16px 16px; border-top: 1px solid var(--border); }
.grupo-orden .nivel-badge { margin-left: auto; }
.grupo-orden.n-alta { border-left: 4px solid #dc2626; }
.grupo-orden.n-media { border-left: 4px solid #ea580c; }
.grupo-orden.n-baja { border-left: 4px solid #eab308; }

.orden-caliente { display:flex; align-items:center; gap:10px; padding: 8px 10px; border-radius: 8px; margin-bottom:6px; }
.orden-caliente .barra { width: 6px; align-self: stretch; border-radius: 4px; }
.orden-caliente.n-alta .barra { background: #dc2626; }
.orden-caliente.n-media .barra { background: #ea580c; }
.orden-caliente.n-baja .barra { background: #eab308; }
.orden-caliente .info { flex:1; font-size: 13px; }
.orden-caliente .num { font-weight: 800; font-size: 16px; }

.subseccion { margin: 14px 0 6px; font-size: 13.5px; font-weight: 700; color: var(--ink); }
.total-cuenta { font-size: 13px; margin-bottom: 6px; color: var(--ink); }
.pago-linea { display:inline-block; font-size:12px; background:#f1f5f9; border-radius:6px; padding:2px 8px; margin:2px 4px 2px 0; }
.impresion-paso { border-left: 3px solid var(--border); padding: 6px 0 6px 12px; margin-bottom: 6px; }
.impresion-paso.cambio { border-left-color: var(--accent); }
.filtro-centro { margin-bottom: 16px; }
.chart-wrap { position: relative; height: 260px; width: 100%; }
.chart-wrap.chart-wrap-sm { height: 170px; }

.legend-tipos { list-style: none; margin: 12px 0 0; padding: 0; font-size: 12.5px; }
.legend-tipos li { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid #f1f5f9; }
.legend-tipos li:last-child { border-bottom: none; }
.legend-tipos .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-tipos .lbl { flex: 1; color: var(--ink); }
.legend-tipos .v { font-weight: 700; color: var(--ink); }
.filtro-centro select { max-width: 320px; display:inline-block; width:auto; }

.btn-mini { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 5px 12px;
  font-size: 12.5px; cursor: pointer; color: var(--ink); }
.btn-mini:hover { background: #f8fafc; border-color: #cbd5e1; }

/* Checkboxes de "Tipos incluidos en el cruce" (Panel de alertas): antes
   iban en línea suelta con el resto del formulario y se veían amontonados
   contra el selector de umbral. Ahora cada tipo es un chip independiente
   con su propio borde, para que se puedan distinguir de un vistazo. */
.tipos-filtro { display: flex; flex-wrap: wrap; gap: 8px; }
.tipos-filtro label { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: normal;
  font-size: 12.5px; background: #f8fafc; border: 1px solid var(--border); border-radius: 999px;
  padding: 5px 12px 5px 8px; cursor: pointer; transition: background .1s, border-color .1s; }
.tipos-filtro label:hover { border-color: #94a3b8; }
.tipos-filtro input[type="checkbox"] { width: auto; accent-color: var(--accent); }
.tipos-filtro label:has(input:checked) { background: #eef2ff; border-color: #a5b4fc; color: #3730a3; font-weight: 600; }
