/* Telemetry (2TR8DE) — estilos. Temas claro/oscuro con variables CSS. */
:root {
  color-scheme: light;
  --page: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f9f9f7;
  --surface-3: #f1f1ec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --line: #e7e6e0;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.08);
  --accent: #0b7f72;
  --accent-ink: #ffffff;
  --accent-soft: #e2f3f0;
  --pos: #0b7a0b;          /* texto de ganancia */
  --neg: #c62f2f;          /* texto de pérdida  */
  --bar-pos: #0f9d8f;      /* barras: polaridad azul/rojo */
  --bar-neg: #e34948;
  --good: #0ca30c; --warn: #eda100; --bad: #d03b3b; --idle: #898781;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .05);
  --radius: 14px;
  --s1: #0f9d8f; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --heat-neg: #c62f2f; --heat-mid: #f0efec; --heat-pos: #0b7f72;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #202020;
  --surface-3: #262625;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --line: #2c2c2a;
  --grid: #2c2c2a;
  --axis: #383835;
  --ring: rgba(255, 255, 255, 0.10);
  --accent: #19c2ad;
  --accent-ink: #06201d;
  --accent-soft: #0f2a27;
  --pos: #34c034;
  --neg: #ef6b6b;
  --bar-pos: #19c2ad;
  --bar-neg: #e66767;
  --shadow: none;
  --s1: #19c2ad; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --heat-neg: #b8322f; --heat-mid: #383835; --heat-pos: #17a594;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--page); color: var(--ink); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
.num, table td.n, table th.n { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 20px 14px; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; font-weight: 700; font-size: 16px; }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; background: #0b0b0b; display: grid; place-items: center; flex: none; box-shadow: 0 0 0 1px var(--ring); }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; letter-spacing: .02em; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--ink-2);
  font-weight: 500; margin-bottom: 2px;
}
.nav a:hover { background: var(--surface-3); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: auto; display: grid; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--ink-2); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-weight: 600; color: var(--ink); }

.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: 14px 28px; background: color-mix(in srgb, var(--page) 85%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid transparent;
}
.topbar h1 { font-size: 20px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
.topbar .sub { color: var(--muted); font-size: 12.5px; }
.topbar .spacer { flex: 1; }
.content { padding: 8px 28px 48px; max-width: 1440px; }
.btn.menu-btn { display: none; }

/* ---------- controles ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 550;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--neg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.icon { width: 36px; padding: 0; }
.btn svg { width: 16px; height: 16px; }
.btn[disabled] { opacity: .55; cursor: default; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: 10px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--ink-2); font-weight: 550; font-size: 13px; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--ring); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 550; font-size: 13px; }
.field .hint { color: var(--muted); font-size: 12px; }
.input {
  height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2);
  outline: none; width: 100%;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.copy { display: flex; gap: 6px; }
.copy code { flex: 1; display: flex; align-items: center; padding: 0 12px; height: 38px; border-radius: 10px; background: var(--surface-3); overflow: auto; white-space: nowrap; font-size: 13px; }

/* ---------- tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 18px 20px; }
.card-h { display: flex; align-items: center; gap: 10px; padding: 16px 20px 0; flex-wrap: wrap; }
.card-h h3 { margin: 0; font-size: 14.5px; font-weight: 650; }
.card-h .spacer { flex: 1; }
.card-b { padding: 12px 20px 18px; }
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.g-kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.g-2 { grid-template-columns: 1.6fr 1fr; }
.g-2e { grid-template-columns: 1fr 1fr; }
.section { margin-top: 18px; }
.section-title { font-size: 13px; font-weight: 650; color: var(--ink-2); margin: 26px 0 10px; text-transform: uppercase; letter-spacing: .05em; }

.kpi { padding: 16px 18px; }
.kpi .lbl { color: var(--ink-2); font-size: 12.5px; font-weight: 550; display: flex; align-items: center; gap: 6px; }
.kpi .val { font-size: 25px; font-weight: 680; letter-spacing: -.02em; margin-top: 6px; }
.kpi .val.sm { font-size: 20px; }
.kpi .val .cur, .acct .cur { font-size: 13px; color: var(--muted); font-weight: 550; margin-left: 4px; letter-spacing: 0; }
.kpi .foot { color: var(--muted); font-size: 12px; margin-top: 4px; }
.pos { color: var(--pos); } .neg { color: var(--neg); }

.mini { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.mini > div { padding: 14px 18px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.mini .lbl { color: var(--muted); font-size: 12px; }
.mini .v { font-weight: 650; font-size: 16px; margin-top: 2px; }

/* tarjetas de cuenta */
.accounts { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.acct { cursor: pointer; transition: transform .12s, box-shadow .12s, border-color .12s; overflow: hidden; }
.acct:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.acct .top { display: flex; align-items: flex-start; gap: 10px; padding: 16px 18px 0; }
.acct .name { font-weight: 650; font-size: 15px; }
.acct .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.acct .eq { padding: 10px 18px 0; font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.acct .eq small { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.acct .spark { height: 64px; margin: 4px 6px 0; }
.acct .stats { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); }
.acct .stats > div { padding: 10px 12px; text-align: center; }
.acct .stats > div + div { border-left: 1px solid var(--line); }
.acct .stats .lbl { font-size: 11px; color: var(--muted); }
.acct .stats .v { font-weight: 650; font-size: 13.5px; margin-top: 2px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--idle); }
.pill.online .dot { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 25%, transparent); }
.pill.delayed .dot { background: var(--warn); }
.pill.offline .dot { background: var(--bad); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; background: var(--surface-3); color: var(--ink-2); }
.badge.real { background: color-mix(in srgb, var(--s2) 16%, transparent); color: var(--s2); }
.badge.demo { background: var(--accent-soft); color: var(--accent); }

/* ---------- tablas ---------- */
.tbl-wrap { overflow: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl .n { text-align: right; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.toolbar .input { height: 36px; max-width: 240px; }
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding: 12px 20px; color: var(--muted); font-size: 12.5px; }

.heat { width: 100%; border-collapse: separate; border-spacing: 3px; font-size: 12px; }
.heat th { color: var(--muted); font-weight: 600; padding: 4px; }
.heat td { text-align: center; padding: 7px 1px; border-radius: 6px; font-weight: 600; min-width: 32px; font-size: 11px; }
.heat td.y { text-align: left; color: var(--ink-2); padding-left: 2px; }
.heat td.empty { background: transparent; color: var(--muted); font-weight: 400; }

.chart { width: 100%; height: 300px; }
.chart.sm { height: 220px; }

/* ---------- estados ---------- */
.empty { text-align: center; padding: 56px 20px; }
.empty .ico { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 14px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.empty h2 { margin: 0 0 6px; font-size: 18px; }
.empty p { color: var(--ink-2); max-width: 460px; margin: 0 auto 18px; }
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; background: color-mix(in srgb, var(--warn) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); margin-bottom: 16px; }
.banner.info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.skeleton { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 10px; }
@keyframes sk { from { background-position: 200% 0 } to { background-position: -200% 0 } }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 400px; padding: 30px 28px; }
.auth h1 { font-size: 22px; margin: 14px 0 4px; }
.auth p.sub { color: var(--ink-2); margin: 0 0 22px; }
.err { color: var(--neg); font-size: 13px; min-height: 18px; margin-bottom: 8px; }

/* ---------- modal y toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: 100%; max-width: 620px; max-height: calc(100vh - 32px); overflow: auto; }
.modal .mh { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal .mh h2 { margin: 0; font-size: 17px; flex: 1; }
.modal .mb { padding: 20px 22px; }
.modal .mf { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; gap: 12px; }
.steps li::before { content: counter(s); width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.steps b { font-weight: 650; }
.kbd { font-family: inherit; font-size: 12px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); background: var(--surface-2); }
.toast-wrap { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 60; }
.toast { padding: 11px 14px; border-radius: 12px; background: var(--ink); color: var(--page); box-shadow: 0 8px 24px rgba(0,0,0,.18); font-weight: 550; max-width: 360px; }
.dropdown { position: relative; }
.dropdown .menu { position: absolute; right: 0; top: 40px; min-width: 210px; padding: 6px; z-index: 20; }
.dropdown .menu button { display: flex; width: 100%; text-align: left; border: 0; background: transparent; padding: 9px 10px; border-radius: 8px; cursor: pointer; gap: 8px; }
.dropdown .menu button:hover { background: var(--surface-3); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .g-2, .g-2e { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; left: 0; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .g-kpi { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi .foot { display: none; }
  .topbar .sub { display: none; }
  .btn.menu-btn { display: inline-flex; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .accounts { grid-template-columns: 1fr; }
  .kpi .val { font-size: 21px; }
}

/* ---------- extras MVC ---------- */
.flash { margin-bottom: 16px; }
.flash.ok { background: color-mix(in srgb, var(--good) 12%, var(--surface)); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.flash.err { background: color-mix(in srgb, var(--bad) 12%, var(--surface)); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
form.inline { display: inline; margin: 0; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.acct-link { color: inherit; display: block; }
.install { max-width: 760px; }
.status-box { display: flex; gap: 12px; align-items: center; }
.done-ico { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.seg a { padding: 6px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 550; font-size: 13px; }
.seg a.on { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--ring); }
.seg button.on, .seg a.on { cursor: default; }
/* pantallas de acceso: nada puede desbordar la tarjeta */
.auth .card { overflow-wrap: anywhere; }
.auth .banner { margin: 0 0 18px; }
code.path { display: block; margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--surface-3); font-size: 12px; word-break: break-all; white-space: normal; }

/* Administración: Cells */
.cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.cell-card { padding: 14px 16px; color: var(--ink); text-decoration: none; transition: border-color .12s, transform .12s; }
.cell-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.cell-card.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cell-card.none .nm { color: var(--muted); }
.cell-card .nm { font-weight: 650; font-size: 14px; margin-bottom: 4px; }
.cell-card .ct { color: var(--muted); font-size: 12px; margin-top: 4px; }
.tbl tr.grp td { background: var(--surface-2); font-weight: 650; font-size: 12.5px; color: var(--ink); padding-top: 8px; padding-bottom: 8px; }
.tbl tr.grp td span { color: var(--muted); font-weight: 500; }
.tbl tbody tr.grp:hover td { background: var(--surface-2); }

/* Marca 2TR8DE */
.brand-logo { display: flex; justify-content: center; margin: 2px 0 22px; }
.brand-logo img { display: block; width: 200px; height: auto; }
.brand-logo .for-dark { display: none; }
[data-theme="dark"] .brand-logo .for-light { display: none; }
[data-theme="dark"] .brand-logo .for-dark { display: block; }
.brand .by { color: var(--muted); font-weight: 600; font-size: 10.5px; letter-spacing: .08em; }

/* Ver / ocultar contraseña */
.pw-wrap { position: relative; }
.pw-wrap .input { width: 100%; padding-right: 42px; }
.pw-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; display: grid; place-items: center;
  border: 0; background: transparent; color: var(--muted); border-radius: 8px; cursor: pointer; }
.pw-eye:hover { color: var(--ink); background: var(--surface-3); }
