:root {
  --bg: #0b0f17; --panel: #131a26; --panel2: #1a2333; --borde: #263248;
  --texto: #e6ebf5; --suave: #94a3b8; --acento: #6366f1; --acento2: #818cf8;
  --ok: #34d399; --warn: #fbbf24; --err: #f87171;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--texto); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { margin: 0 0 .6rem; }
.topbar { padding: 14px 22px; border-bottom: 1px solid var(--borde); background: var(--panel); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.topbar h1 { font-size: 1.15rem; margin: 0; }
.dataset-info { color: var(--suave); font-size: .85rem; background: var(--panel2); border: 1px solid var(--borde); border-radius: 999px; padding: 4px 12px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 53px); }
.sidebar { background: var(--panel); border-right: 1px solid var(--borde); padding: 18px 14px; display: flex; flex-direction: column; gap: 6px; }
.sidebar .grupo { color: var(--suave); font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; margin: 14px 8px 4px; }
.nav { background: transparent; color: var(--texto); border: 0; text-align: left; padding: 10px 12px; border-radius: 8px; cursor: pointer; font: inherit; }
.nav:hover { background: var(--panel2); }
.nav:focus-visible, .btn:focus-visible { outline: 2px solid var(--acento2); outline-offset: 2px; }
.nav.activo { background: var(--acento); color: #fff; }
.nav.salir { margin-top: auto; background: var(--panel2); }
.content { padding: 26px; max-width: 1100px; width: 100%; }
.card { background: var(--panel); border: 1px solid var(--borde); border-radius: 12px; padding: 18px; margin-bottom: 18px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 160px; }
label { display: block; font-size: .85rem; color: var(--suave); margin-bottom: 4px; }
input, select, textarea { width: 100%; background: var(--panel2); color: var(--texto); border: 1px solid var(--borde); border-radius: 8px; padding: 9px 11px; font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--acento2); outline-offset: 1px; }
textarea { min-height: 80px; resize: vertical; }
.btn { background: var(--acento); color: #fff; border: 0; border-radius: 8px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; flex: 0 0 auto; }
.btn:hover { background: var(--acento2); }
.btn.sec { background: var(--panel2); border: 1px solid var(--borde); }
.btn.peligro { background: #7f1d1d; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.drop { border: 2px dashed var(--borde); border-radius: 12px; padding: 28px; text-align: center; color: var(--suave); cursor: pointer; transition: .15s; }
.drop.over, .drop:hover { border-color: var(--acento2); color: var(--texto); }
.drop input { display: none; }
pre.salida { background: var(--panel2); border: 1px solid var(--borde); border-radius: 8px; padding: 12px; white-space: pre-wrap; margin: 0; min-height: 60px; font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace; }
.tabla-wrap { overflow: auto; max-height: 380px; border: 1px solid var(--borde); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: .85rem; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--borde); text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; background: var(--panel2); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.msg { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--panel2); }
.msg.ok { border-left: 4px solid var(--ok); } .msg.err { border-left: 4px solid var(--err); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--borde); border-radius: 12px; padding: 14px; }
.kpi b { display: block; font-size: 1.6rem; }
.kpi span { color: var(--suave); font-size: .85rem; }
.oculto { display: none !important; }
.chart-box { position: relative; height: 360px; }
.acciones { display: flex; gap: 10px; flex-wrap: wrap; }
.paginacion { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.paginacion .hint { margin: 0; text-align: center; }
th.ordenable { cursor: pointer; user-select: none; }
th.ordenable:hover { color: var(--acento2); }
td.vacio { color: var(--warn); opacity: .7; }
tbody tr:hover td, table tr:hover td { background: rgba(99,102,241,.06); }
.campo { margin-top: 12px; }
.historial { margin: 0; padding-left: 22px; }
.historial li { padding: 2px 0; }
.toast { position: fixed; right: 20px; bottom: 20px; max-width: min(420px, calc(100vw - 40px)); background: var(--panel2); border: 1px solid var(--borde); border-left: 4px solid var(--acento); border-radius: 8px; padding: 10px 14px; box-shadow: 0 8px 24px rgba(0,0,0,.4); z-index: 10; }
.msg.oculto { display: none; }
.trampa { position: absolute; left: -9999px; }
.centro { text-align: center; padding: 70px 20px; }
.hint { color: var(--suave); font-size: .85rem; }
.login { max-width: 380px; margin: 80px auto; }
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--borde); }
  .sidebar .grupo { display: none; }
  .nav.salir { margin-top: 0; }
  .content { padding: 16px; }
  .nav { padding: 8px 10px; }
}
