/* Panel de la plataforma de inferencia.
   Sistema de diseno Tresipunt en modo oscuro: naranja corporativo como unico
   acento, teal como secundario, sin tarjetas y con secciones separadas por
   filetes. Todos los colores son variables. */

:root {
  --orange-50:  #FFF1ED;
  --orange-100: #FFDDD2;
  --orange-200: #FFBCA6;
  --orange-300: #FF9472;
  --orange-400: #FB6840;
  --orange-500: #F84015;
  --orange-600: #DA3208;
  --orange-700: #B12706;

  --teal-300: #54C9CF;
  --teal-400: #1FB3BB;
  --teal-500: #00A6B0;
  --teal-600: #008791;

  --neutral-400: #9A9A9E;
  --neutral-500: #6F6F73;

  --color-primary: var(--orange-500);
  --color-primary-hover: var(--orange-600);
  --color-primary-press: var(--orange-700);
  --color-primary-subtle: rgba(248, 64, 21, .14);
  --color-secondary: var(--teal-500);
  --color-secondary-subtle: rgba(0, 166, 176, .15);

  --surface-page: #121215;
  --surface-alt: #1B1B1F;
  --surface-card: #1B1B1F;
  --surface-sunken: #232328;
  --border-subtle: #26262B;
  --border-default: #33333A;
  --border-strong: #45454C;
  --divider: #232328;

  --text-strong: #FFFFFF;
  --text-body: #E6E6E8;
  --text-muted: #9A9A9E;
  --text-subtle: #75757A;

  --success-500: #3FD285;
  --success-subtle: rgba(63, 210, 133, .14);
  --warning-500: #F0B93F;
  --warning-subtle: rgba(240, 185, 63, .14);
  --danger-500: #E23B2E;
  --danger-text: #FF7A6B;
  --danger-subtle: rgba(226, 59, 46, .12);
  --danger-border: rgba(226, 59, 46, .32);

  --focus-ring: rgba(248, 64, 21, .45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .45);
  --shadow-brand: 0 8px 24px rgba(248, 64, 21, .28);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-standard: cubic-bezier(.4, 0, .2, 1);
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --transition-control:
    background-color var(--dur-fast) var(--ease-standard),
    color var(--dur-fast) var(--ease-standard),
    border-color var(--dur-fast) var(--ease-standard),
    box-shadow var(--dur-base) var(--ease-out);

  --font-heading: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-md: 10px;
  --sidebar-w: 236px;
  --sidebar-w-collapsed: 68px;
  --topbar-h: 68px;

  /* alias que usa app.js en estilos en linea */
  --border: var(--divider);
  --ok: var(--success-500);
  --warn: var(--warning-500);
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--surface-page);
  color: var(--text-body);
  font: 400 14px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--orange-300); text-decoration: none; }
a:hover { color: var(--orange-400); }
code { font-family: var(--mono); font-size: .92em; color: var(--text-body); }
strong { font-weight: 600; color: var(--text-body); }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: #3A3A41; border-radius: 99px; border: 3px solid var(--surface-page); }
::-webkit-scrollbar-thumb:hover { background: #4E4E56; }
::-webkit-scrollbar-track { background: transparent; }

:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }

/* ---------------------------------------------------------------- estructura */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface-card);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width var(--dur-base) var(--ease-out), flex-basis var(--dur-base) var(--ease-out);
  overflow: hidden;
}
.app.collapsed .sidebar { width: var(--sidebar-w-collapsed); flex-basis: var(--sidebar-w-collapsed); }

.brand {
  display: flex; align-items: center; gap: 11px;
  height: var(--topbar-h); flex: none; padding: 0 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.app.collapsed .brand { padding: 0; justify-content: center; }
.brand-mark {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: var(--radius-sm);
  background: var(--color-primary); color: #fff;
  display: grid; place-items: center;
  font-family: var(--font-heading); font-weight: 800; font-size: 12px; letter-spacing: -.02em;
}
.brand-text {
  font-family: var(--font-heading); font-weight: 700; font-size: 16.5px;
  letter-spacing: -.01em; color: var(--text-strong); white-space: nowrap;
}
.app.collapsed .brand-text { display: none; }

.nav {
  flex: 1; min-height: 0; padding: 20px 12px;
  display: flex; flex-direction: column; gap: 2px;
  overflow-y: auto; overflow-x: hidden;
}
.nav-label {
  padding: 22px 10px 9px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .11em; text-transform: uppercase;
  color: var(--text-subtle); white-space: nowrap;
}
.nav-label:first-child { padding-top: 0; }
.app.collapsed .nav-label { opacity: 0; height: 10px; padding: 8px 0 0; overflow: hidden; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; height: 38px; padding: 0 10px;
  border: 0; border-radius: var(--radius-sm); background: transparent;
  color: var(--text-body); font: inherit; font-size: 14px; font-weight: 500;
  text-align: left; white-space: nowrap; cursor: pointer;
  transition: var(--transition-control);
}
.nav-item:hover { background: var(--surface-sunken); color: var(--text-strong); }
.nav-item.active {
  background: var(--color-primary-subtle); color: var(--orange-300); font-weight: 600;
  box-shadow: inset 2px 0 0 var(--color-primary);
}
.nav-item .ico { width: 16px; flex: 0 0 16px; display: grid; place-items: center; }
.nav-item .dot { width: 7px; height: 7px; border-radius: 50%; margin-left: auto; flex: 0 0 7px; }
.app.collapsed .nav-item span.txt, .app.collapsed .nav-item .dot { display: none; }
.app.collapsed .nav-item {
  width: 40px; height: 40px; margin: 0 auto; padding: 0;
  justify-content: center; border-radius: var(--radius-md); box-shadow: none;
}

.sidebar-foot { flex: none; padding: 12px; border-top: 1px solid var(--border-subtle); }
#collapseIco { transition: transform var(--dur-base) var(--ease-out); }
.app.collapsed #collapseIco { transform: rotate(180deg); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  height: var(--topbar-h); flex: none; padding: 0 32px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(18, 18, 21, .86);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 {
  margin: 0; font-family: var(--font-heading); font-size: 20px; font-weight: 700;
  letter-spacing: -.02em; color: var(--text-strong); white-space: nowrap;
}
.topbar .sub { font-size: 13.5px; color: var(--text-muted); }
.topbar .badge.plain {
  background: none; padding: 0; height: auto;
  font-family: var(--mono); font-size: 12.5px; font-weight: 400;
  font-variant-numeric: tabular-nums; color: var(--text-subtle);
}
.spacer { flex: 1; }

.content { width: 100%; max-width: 1240px; margin: 0 auto; padding: 30px 32px 96px; }

/* ---------------------------------------------------------------- primitivas */
.icon-btn {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
  background: var(--surface-card); color: var(--text-muted);
  cursor: pointer; padding: 0; transition: var(--transition-control);
}
.icon-btn:hover {
  background: var(--color-primary-subtle);
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.topbar .icon-btn { width: 32px; height: 32px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 20px;
  border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  background: var(--surface-card); color: var(--text-body);
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: var(--transition-control), transform var(--dur-fast) var(--ease-out);
}
.btn:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-sunken); color: var(--text-strong); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn.primary { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.btn.primary:hover:not(:disabled) {
  background: var(--color-primary-hover); border-color: var(--color-primary-hover); color: #fff;
  box-shadow: var(--shadow-brand);
}
.btn.primary:active:not(:disabled) { background: var(--color-primary-press); }
.btn.danger { color: var(--danger-text); border-color: var(--danger-border); background: var(--danger-subtle); }
.btn.danger:hover:not(:disabled) {
  background: var(--danger-500); border-color: var(--danger-500); color: #fff;
  box-shadow: 0 0 0 4px rgba(226, 59, 46, .12);
}
.btn.sm { height: 36px; padding: 0 14px; font-size: 13px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 20px; padding: 0 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: rgba(255, 255, 255, .06); color: var(--text-muted);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--success-subtle); color: var(--success-500); }
.badge.warn { background: var(--warning-subtle); color: var(--warning-500); }
.badge.danger { background: var(--danger-subtle); color: var(--danger-text); }
.badge.accent, .badge.prod { background: var(--color-primary-subtle); color: var(--orange-300); }
.badge.dev { background: var(--color-secondary-subtle); color: var(--teal-300); }

.msg {
  padding: 12px 16px; margin-bottom: 16px;
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  background: var(--surface-alt); color: var(--text-body);
  font-size: 13px; font-weight: 500; line-height: 1.6;
}
.msg.ok { background: var(--success-subtle); border-color: rgba(63, 210, 133, .3); color: var(--success-500); }
.msg.err { background: var(--danger-subtle); border-color: var(--danger-border); color: var(--danger-text); }
.msg.info { background: rgba(248, 64, 21, .1); border-color: rgba(248, 64, 21, .26); color: var(--text-body); }
.msg.info strong { color: var(--orange-300); }
.msg strong { color: inherit; }
.msg code { color: inherit; }
.msg .btn { margin-left: 8px; }

.toast {
  position: fixed; bottom: 26px; right: 26px; z-index: 50;
  display: flex; align-items: center; gap: 9px;
  height: 40px; padding: 0 16px; border-radius: var(--radius-md);
  background: #2A2A31; color: #fff; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg); pointer-events: none;
  opacity: 0; transform: translateY(6px);
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}
.toast.on { opacity: 1; transform: none; }
.toast svg { color: var(--orange-400); }

.empty {
  padding: 36px 24px; text-align: center;
  border: 1px dashed var(--border-default); border-radius: var(--radius);
  background: var(--surface-alt); color: var(--text-muted); font-size: 13.5px;
}

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text-body); }
.field label:has(.help) { display: flex; align-items: center; gap: 7px; }
.help {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px; flex: none; padding: 0;
  border: 0; border-radius: 50%; background: transparent;
  color: var(--text-subtle); cursor: pointer;
  transition: var(--transition-control);
}
.help:hover { background: var(--color-primary-subtle); color: var(--color-primary); }

select, input[type="text"], input[type="password"], input[type="time"], input[type="number"],
input[type="date"] {
  width: 100%; height: 42px; padding: 0 13px;
  border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  background: var(--surface-card); color: var(--text-body);
  font: inherit; font-size: 13.5px;
  transition: var(--transition-control);
}
input::placeholder { color: var(--text-subtle); }
input[type="time"], input[type="date"] { font-family: var(--mono); }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.65); cursor: pointer; }
select {
  appearance: none; padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239A9A9E' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
select:focus, input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--focus-ring); }
.card-head select { height: 36px; font-size: 13px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.day {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 13.5px; font-weight: 500; color: var(--text-body);
  cursor: pointer; user-select: none;
}
.day input { width: 16px; height: 16px; margin: 0; accent-color: var(--color-primary); cursor: pointer; }
.days { display: flex; gap: 7px; flex-wrap: wrap; }
.days .day {
  width: 38px; height: 34px; justify-content: center; gap: 0;
  border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  font-size: 12.5px; font-weight: 600; color: var(--text-muted);
  transition: var(--transition-control);
}
.days .day:hover { border-color: var(--border-strong); color: var(--text-body); }
.days .day input { position: absolute; width: 0; height: 0; opacity: 0; }
.days .day:has(input:checked) { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.days .day:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--focus-ring); }

/* ------------------------------------------------------------------ pestañas */
.tabs {
  display: flex; gap: 2px; flex-wrap: wrap;
  margin: 0 0 32px; border-bottom: 1px solid var(--border-default);
}
.tab {
  height: 44px; padding: 0 16px;
  border: 0; background: none; color: var(--text-muted);
  font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  box-shadow: inset 0 -2px 0 transparent;
  transition: var(--transition-control);
}
.tab:hover { color: var(--text-body); }
.tab.sel { color: var(--orange-300); font-weight: 600; box-shadow: inset 0 -2px 0 var(--color-primary); }

/* Con pestañas debajo, la fila de métricas no lleva su propio filete: el de la
   barra de pestañas ya separa, y dos líneas seguidas ensucian la cabecera. */
.grid.cols-4:has(+ .tabs) { border-bottom: 0; padding-bottom: 22px; margin-bottom: 12px; }
.tabpanel > .card:last-child { margin-bottom: 0; }

/* ------------------------------------------------------------------ secciones */
.card { background: none; border: 0; box-shadow: none; margin: 0 0 40px; }
.card-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 0; margin-bottom: 20px; border: 0;
}
.card-head h2 {
  margin: 0; font-family: var(--font-heading); font-size: 16.5px; font-weight: 700;
  letter-spacing: -.01em; color: var(--text-strong);
}
.card-head .hint { font-size: 13px; font-weight: 400; color: var(--text-muted); }
.card-body { padding: 0; }
.card-body.tight { padding: 0; }
.card-body.sep { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--divider); }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 0; }
@media (min-width: 900px) {
  .grid.cols-2 > .card:first-child { padding-right: 44px; }
  .grid.cols-2 > .card:last-child { padding-left: 44px; border-left: 1px solid var(--divider); }
}

.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0; margin-bottom: 36px;
  padding-bottom: 30px; border-bottom: 1px solid var(--divider);
}
.stat { padding: 0 26px; border: 0; border-radius: 0; background: none; }
.grid.cols-4 > .stat + .stat { border-left: 1px solid var(--divider); }
.grid.cols-4 > .stat:first-child { padding-left: 0; }
.grid.cols-4 > .stat:last-child { padding-right: 0; }
@media (min-width: 981px) {
  .grid.cols-4.tres { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.stat .k { font-size: 10.5px; font-weight: 600; letter-spacing: .11em; text-transform: uppercase; color: var(--text-subtle); }
.stat .v {
  margin: 10px 0 5px; font-family: var(--font-heading); font-size: 30px; font-weight: 700;
  letter-spacing: -.025em; color: var(--text-strong); font-variant-numeric: tabular-nums;
}
.stat .v.sm { font-size: 22px; letter-spacing: -.02em; }
.stat .s { font-size: 12.5px; color: var(--text-muted); }
.stat.accent .v { color: var(--text-strong); }
.stat.ok .v { color: var(--success-500); }
.stat.warn .v { color: var(--warning-500); }
.stat.danger .v { color: var(--danger-text); }

@media (max-width: 980px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 0; }
  .grid.cols-4 > .stat:nth-child(odd) { padding-left: 0; border-left: 0; }
  .grid.cols-4 > .stat:nth-child(even) { padding-right: 0; }
}
@media (max-width: 560px) {
  .grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .grid.cols-4 > .stat { padding: 0; border-left: 0; }
}

/* --------------------------------------------------------------------- tablas */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  padding: 0 12px 10px; text-align: left; white-space: nowrap;
  font-size: 10.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-subtle); border-bottom: 1px solid var(--border-default);
}
td { padding: 12px; border-bottom: 1px solid var(--divider); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
tbody tr:hover { background: var(--surface-alt); }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { padding-top: 16px; border-bottom: 0; }
tfoot td:first-child { font-family: var(--font-heading); color: var(--text-strong); }
tfoot td.num { font-family: var(--font-heading); color: var(--orange-400); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* Una tabla con muchas columnas numericas no se puede plegar sin mentir: en
   pantalla estrecha se desplaza en horizontal, ella sola, sin llevarse la
   pagina entera. */
.tabla-ancha { overflow-x: auto; }
.tabla-ancha table { min-width: 780px; }

th.sortable { padding: 0 0 10px; }
th.sortable:first-child .th-b { padding-left: 0; }
th.sortable:last-child .th-b { padding-right: 0; }
th.sortable .th-b {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 0 12px; border: 0; background: none; cursor: pointer;
  font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit;
  transition: var(--transition-control);
}
th.sortable .th-b:hover { color: var(--text-body); }
th.sortable.on .th-b { color: var(--orange-300); }
th.sortable .ind { font-size: 8.5px; }
th.num.sortable .th-b { justify-content: flex-end; width: 100%; }

/* -------------------------------------------------------------- gasto por pod */
.bill-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.bill-bar input[type="text"] { flex: 1; min-width: 200px; }
.bill-bar select { width: auto; }
.bill-bar .day { white-space: nowrap; }
.bill-fechas { display: flex; align-items: center; gap: 8px; }
.bill-fechas input { width: 152px; }

.seg { display: flex; border: 1px solid var(--border-default); border-radius: var(--radius-sm); overflow: hidden; }
.seg-b {
  height: 42px; padding: 0 13px; border: 0; border-right: 1px solid var(--border-subtle);
  background: var(--surface-card); color: var(--text-muted);
  font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap;
  transition: var(--transition-control);
}
.seg-b:last-child { border-right: 0; }
.seg-b:hover { background: var(--surface-sunken); color: var(--text-body); }
.seg-b.sel { background: var(--color-primary-subtle); color: var(--orange-300); font-weight: 600; }

.bill-kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0 22px; margin-bottom: 22px;
}
.bill-kpi + .bill-kpi { padding-left: 22px; border-left: 1px solid var(--divider); }
.bill-kpi .k {
  font-size: 10.5px; font-weight: 600; letter-spacing: .11em; text-transform: uppercase;
  color: var(--text-subtle);
}
.bill-kpi .v {
  font-family: var(--font-heading); font-size: 22px; font-weight: 600;
  letter-spacing: -.02em; color: var(--text-strong);
}
.bill-kpi .s { font-size: 12.5px; color: var(--text-muted); }

/* Una barra por dia. Marcas finas, remate redondeado arriba y linea de base
   solida: el hueco entre barras lo hace el `gap`, no un borde dibujado. */
.bill-dias { margin-bottom: 24px; }
.bill-dias-plot {
  display: flex; align-items: flex-end; justify-content: center; gap: 2px;
  height: 76px; padding-bottom: 0; border-bottom: 1px solid var(--border-default);
}
.bill-dia {
  flex: 1 1 0; max-width: 24px; min-width: 3px; min-height: 0;
  border-radius: 4px 4px 0 0; background: var(--color-primary);
}
.bill-dia:hover { background: var(--orange-300); }
.bill-dias-eje {
  display: flex; justify-content: space-between; gap: 12px; padding-top: 7px;
  font-size: 12px; color: var(--text-muted);
}
.bill-dias-eje .bill-pico { color: var(--text-body); }

.bill-pod { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; color: var(--text-strong); }
.bill-share { height: 3px; margin-top: 6px; border-radius: 2px; background: var(--surface-sunken); }
.bill-share > span { display: block; height: 100%; border-radius: 2px; background: var(--color-primary); }
.bill-nota { margin-top: 16px; font-size: 12.5px; line-height: 1.6; }

/* Al reconsultar se atenua lo que ya hay en vez de vaciarlo: sin salto de
   maquetacion y sin perder de vista la cifra anterior. */
#ovBilling.cargando { opacity: .55; transition: opacity var(--dur-base) var(--ease-out); }

@media (max-width: 760px) {
  .bill-kpi + .bill-kpi { padding-left: 0; border-left: 0; }
  .bill-bar input[type="text"] { min-width: 0; }
}

/* ---------------------------------------------------- entornos y credenciales */
.envtabs { display: flex; gap: 10px; margin-bottom: 30px; flex-wrap: wrap; }
.envtab {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 11px 18px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
  background: var(--surface-card); color: var(--text-strong);
  font: inherit; text-align: left; cursor: pointer; transition: var(--transition-control);
}
.envtab:hover { border-color: var(--border-strong); background: var(--surface-sunken); }
.envtab-name { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.envtab-name::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--neutral-500); }
.envtab.prod .envtab-name::before { background: var(--color-primary); }
.envtab.dev .envtab-name::before { background: var(--color-secondary); }
.envtab-pod { font-family: var(--mono); font-size: 11.5px; color: var(--text-muted); }
.envtab.sel.prod {
  border-color: var(--color-primary); background: rgba(248, 64, 21, .12);
  box-shadow: inset 0 -2px 0 var(--color-primary);
}
.envtab.sel.dev {
  border-color: var(--color-secondary); background: rgba(0, 166, 176, .14);
  box-shadow: inset 0 -2px 0 var(--color-secondary);
}

.cred { display: flex; flex-direction: column; gap: 10px; max-width: 920px; }
.cred-row { display: flex; align-items: center; gap: 12px; }
.cred-k {
  flex: 0 0 160px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-subtle);
}
.cred-v {
  flex: 1; min-width: 0; height: 40px; display: flex; align-items: center;
  padding: 0 13px; border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
  background: var(--surface-alt); color: var(--text-body);
  font-family: var(--mono); font-size: 12.5px;
  overflow-x: auto; white-space: nowrap; user-select: all;
}

/* ------------------------------------------------------- enlaces y catalogos */
.links { display: flex; flex-wrap: wrap; gap: 10px; }
.link-card {
  display: flex; align-items: center; gap: 9px; height: 42px; padding: 0 16px;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
  background: var(--surface-card); color: var(--text-body);
  font-size: 13.5px; font-weight: 500; text-decoration: none;
  transition: var(--transition-control);
}
.link-card:hover { border-color: var(--color-primary); background: var(--color-primary-subtle); color: var(--orange-300); }
.link-card .ext { display: flex; color: var(--text-subtle); opacity: .6; }
.link-card:hover .ext { color: inherit; opacity: 1; }

.gpu-list { max-height: 340px; overflow: auto; }
.gpu-row {
  display: flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 8px 12px;
  border-bottom: 1px solid var(--divider); cursor: pointer;
}
.gpu-row:last-child { border-bottom: 0; }
.gpu-row:hover { background: var(--surface-alt); }
.gpu-row.disabled { opacity: .42; cursor: not-allowed; }
.gpu-row input[type="radio"] { accent-color: var(--color-primary); }
.gpu-row .name { min-width: 132px; font-weight: 600; color: var(--text-strong); }
.gpu-row .meta { font-size: 12.5px; color: var(--text-muted); }

.logbox {
  padding: 20px 22px; min-height: 96px; max-height: 520px; overflow: auto;
  border: 1px solid var(--border-subtle); border-radius: var(--radius);
  background: #0D0D10; color: var(--neutral-400);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
}
.logbox .err { color: #FF8F80; }
.logbox .warnline { color: var(--warning-500); }

/* ------------------------------------------------- fase del pod y servidores */
.bar { height: 5px; margin-top: 10px; border-radius: 3px; background: var(--surface-sunken); overflow: hidden; }
.bar > span { display: block; width: 0; height: 100%; background: var(--color-primary); transition: width .4s var(--ease-out); }
.srv { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 12.5px; }
.srv .badge { min-width: 82px; justify-content: center; }

/* ------------------------------------------------------ apartado configuracion */
.cfg-bar { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.cfg-bar input[type="text"] { flex: 1; }
.cfg-bar .day { white-space: nowrap; }

.cfg-nota { margin-bottom: 20px; font-size: 12.5px; line-height: 1.6; }
.cfg-nota code { font-size: 12px; }

.cfg-sec { margin-bottom: 30px; }
.cfg-sec-head {
  display: flex; align-items: center; gap: 9px;
  padding-bottom: 9px; margin-bottom: 4px;
  border-bottom: 1px solid var(--border-default);
  font-family: var(--font-heading); font-size: 13px; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted);
}
.cfg-sec-head .n {
  min-width: 20px; height: 18px; padding: 0 6px;
  display: grid; place-items: center; border-radius: 999px;
  background: var(--surface-sunken);
  font-family: var(--mono); font-size: 10.5px; font-weight: 400; color: var(--text-subtle);
}

/* Dos columnas: identidad a la izquierda, valor a la derecha. En pantallas
   estrechas se apilan, que es mejor que partir el valor en trocitos. */
.cfg-row {
  display: grid; grid-template-columns: minmax(240px, 1fr) minmax(0, 1.25fr);
  gap: 14px 20px; align-items: baseline;
  padding: 11px 0; border-bottom: 1px solid var(--divider);
}
.cfg-row:last-child { border-bottom: 0; }
.cfg-row:hover { background: var(--surface-alt); }

.cfg-title { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--text-body); }
.cfg-var {
  display: inline-block; margin-top: 3px;
  font-family: var(--mono); font-size: 11.5px; color: var(--text-subtle);
  background: none; padding: 0;
}
.cfg-v { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; min-width: 0; }
.cfg-val {
  font-family: var(--mono); font-size: 12.5px; color: var(--text-strong);
  word-break: break-all;
}
.cfg-val.oculto { color: var(--text-subtle); letter-spacing: 1px; }
.cfg-val.revelado {
  padding: 1px 7px; border-radius: 5px;
  background: var(--warning-subtle); color: var(--warning-500);
}
.cfg-v .badge { align-self: center; }

/* El dialogo de la contrasena es una tercera capa, mucho mas pequena. */
.modal.tiny { width: min(430px, 92vw); height: auto; max-height: 90vh; }
.modal-cuerpo { padding: 22px 24px 20px; overflow-y: auto; }
.modal-cuerpo p { font-size: 13.5px; line-height: 1.6; }
.modal-cuerpo .msg { margin: 0 0 14px; }
.modal-cuerpo .row { gap: 8px; margin-top: 4px; }

/* Un unico tooltip que se mueve: con 154 filas, uno por fila seria absurdo. */
.tip {
  position: fixed; z-index: 60; pointer-events: none;
  padding: 10px 13px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: #26262C;
  box-shadow: var(--shadow-lg);
  font-size: 12.5px; line-height: 1.55; color: var(--text-body);
  opacity: 0; transform: translateY(3px);
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.tip.on { opacity: 1; transform: none; }

@media (max-width: 720px) {
  .cfg-row { grid-template-columns: 1fr; gap: 6px; }
  .cfg-bar { flex-wrap: wrap; }
}

/* ----------------------------------------------------------------- guia (modal)
   Ventana de ayuda: 80 % del ancho y 90 % del alto, con indice de capitulos a la
   izquierda y el texto a la derecha. El contenido vive en ui/guia.js; aqui solo
   esta la caja y la tipografia del texto largo. */
.modal-overlay {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center; padding: 16px;
  background: rgba(8, 8, 10, .74);
  backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
}
.modal-overlay.on { opacity: 1; pointer-events: auto; }

.modal {
  width: 80vw; height: 90vh;
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface-page);
  border: 1px solid var(--border-default); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); overflow: hidden;
  transform: translateY(10px) scale(.995);
  transition: transform var(--dur-base) var(--ease-out);
}
.modal-overlay.on .modal { transform: none; }
/* Recibe el foco al abrir para que Esc funcione; no necesita anillo propio. */
.modal:focus { outline: none; box-shadow: var(--shadow-lg); }
/* La ayuda de un solo tema no necesita 80 % de ancho: sin indice, un texto
   tan largo se lee peor cuanto mas se estira. */
.modal.narrow { width: min(760px, 92vw); height: min(88vh, 900px); }

.modal-head {
  display: flex; align-items: center; gap: 14px;
  height: 64px; flex: none; padding: 0 20px 0 26px;
  border-bottom: 1px solid var(--border-subtle); background: var(--surface-card);
}
.modal-head h2 {
  margin: 0; font-family: var(--font-heading); font-size: 17px; font-weight: 700;
  letter-spacing: -.01em; color: var(--text-strong); white-space: nowrap;
}
.modal-head .sub { font-size: 13px; color: var(--text-muted); }

/* --------------------------------------------------------------- indice */
.guide { flex: 1; min-height: 0; display: flex; }

.guide-nav {
  width: 268px; flex: 0 0 268px; min-height: 0;
  padding: 18px 12px; overflow-y: auto; overflow-x: hidden;
  border-right: 1px solid var(--border-subtle); background: var(--surface-card);
}
.guide-nav .nav-label { padding: 18px 10px 8px; }
.guide-nav .nav-label:first-child { padding-top: 0; }

.gnav {
  display: flex; align-items: flex-start; gap: 11px;
  width: 100%; padding: 9px 10px; margin-bottom: 2px;
  border: 0; border-radius: var(--radius-sm); background: transparent;
  color: var(--text-muted); font: inherit; font-size: 13.5px; font-weight: 500;
  text-align: left; cursor: pointer; transition: var(--transition-control);
}
.gnav:hover { background: var(--surface-sunken); color: var(--text-body); }
.gnav.sel {
  background: var(--color-primary-subtle); color: var(--orange-300); font-weight: 600;
  box-shadow: inset 2px 0 0 var(--color-primary);
}
.gnav .n {
  flex: 0 0 20px; height: 20px; display: grid; place-items: center;
  border-radius: 5px; background: var(--surface-sunken);
  font-family: var(--mono); font-size: 11px; color: var(--text-subtle);
}
.gnav.sel .n { background: var(--color-primary); color: #fff; }
.gnav .ttl { line-height: 1.35; }

/* -------------------------------------------------------------- contenido */
.guide-content { flex: 1; min-width: 0; min-height: 0; overflow-y: auto; }
/* Centrado en el hueco que deja el indice, no pegado al filete. */
.guide-content > .inner { max-width: 820px; margin: 0 auto; padding: 32px 40px 56px; }

.guide-content h3 {
  margin: 0 0 6px; font-family: var(--font-heading);
  font-size: 23px; font-weight: 700; letter-spacing: -.02em; color: var(--text-strong);
}
.guide-content h4 {
  margin: 34px 0 10px; font-family: var(--font-heading);
  font-size: 15px; font-weight: 600; color: var(--text-strong);
}
.guide-content .lead { margin: 0 0 26px; font-size: 14.5px; color: var(--text-muted); }
.guide-content p { margin: 0 0 12px; font-size: 14px; line-height: 1.68; }
.guide-content ul, .guide-content ol { margin: 0 0 12px; padding-left: 20px; }
.guide-content li { margin-bottom: 7px; font-size: 14px; line-height: 1.62; }
.guide-content li::marker { color: var(--text-subtle); }
.guide-content table { margin: 6px 0 18px; }
.guide-content td { font-size: 13px; line-height: 1.55; vertical-align: top; }
.guide-content code {
  padding: 1px 5px; border-radius: 4px;
  background: var(--surface-sunken); color: var(--orange-300); font-size: 12.5px;
}
.guide-content hr { height: 0; margin: 30px 0; border: 0; border-top: 1px solid var(--divider); }

/* Aviso destacado. `tip` explica, `warn` avisa de un pie del que no se sale
   solo, `key` es la respuesta corta a la pregunta del capitulo. */
.note {
  margin: 0 0 18px; padding: 14px 16px;
  border: 1px solid var(--border-default); border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface-alt);
}
.note > :last-child { margin-bottom: 0; }
.note .t {
  display: block; margin-bottom: 5px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-subtle);
}
.note.key { border-left-color: var(--color-primary); background: var(--color-primary-subtle); }
.note.key .t { color: var(--orange-300); }
.note.warn { border-left-color: var(--warning-500); background: var(--warning-subtle); }
.note.warn .t { color: var(--warning-500); }
.note.tip { border-left-color: var(--color-secondary); background: var(--color-secondary-subtle); }
.note.tip .t { color: var(--teal-300); }

/* Formula o ejemplo numerico: monoespaciado y sin ruido. */
.calc {
  margin: 0 0 18px; padding: 14px 16px;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.75;
  color: var(--text-body); white-space: pre; overflow-x: auto;
}
.calc b { color: var(--orange-300); font-weight: 600; }

.guide-foot {
  display: flex; align-items: center; gap: 10px;
  margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--divider);
}
.guide-foot .spacer { flex: 1; }

@media (max-width: 960px) {
  .modal { width: 96vw; height: 94vh; }
  .guide { flex-direction: column; }
  .guide-nav {
    width: auto; flex: none; max-height: 132px;
    border-right: 0; border-bottom: 1px solid var(--border-subtle);
  }
  .guide-content > .inner { padding: 24px 20px 40px; }
  .modal-head .sub { display: none; }
}

/* Con la guia abierta, la pagina de detras no se desplaza con la rueda. */
body.modal-open { overflow: hidden; }

.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.nowrap { white-space: nowrap; }

@media (max-width: 820px) {
  .sidebar { position: fixed; z-index: 20; box-shadow: var(--shadow-lg); }
  .app.collapsed .sidebar { width: 0; flex-basis: 0; border: 0; }
  .topbar { padding: 0 18px; }
  .content { padding: 22px 18px 72px; }
}

/* ------------------------------------------------------------------ acceso
   Pantalla de identificacion (ui/login.html). Sustituye al dialogo de Basic
   Auth del navegador, asi que reutiliza las mismas primitivas que el panel
   —.field, .btn, .msg— y no introduce colores propios. */
.login {
  min-height: 100vh;
  display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(760px 420px at 50% -8%, rgba(248, 64, 21, .13), transparent 68%),
    radial-gradient(560px 340px at 88% 106%, rgba(0, 166, 176, .10), transparent 70%);
}

.login-caja {
  width: min(384px, 100%);
  padding: 32px 32px 24px;
  border: 1px solid var(--border-subtle); border-radius: var(--radius);
  background: var(--surface-card); box-shadow: var(--shadow-lg);
  animation: login-entrada var(--dur-base) var(--ease-out) both;
}
@keyframes login-entrada { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .login-caja { animation: none; } }

.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 28px; }

.login h1 {
  margin: 0 0 6px;
  font-family: var(--font-heading); font-size: 21px; font-weight: 700;
  letter-spacing: -.02em; color: var(--text-strong);
}
.login-sub { margin: 0 0 24px; font-size: 13.5px; color: var(--text-muted); }

.login .field { margin-bottom: 14px; }
.login .msg { margin: 2px 0 12px; }
.login-btn { width: 100%; justify-content: center; margin-top: 8px; }

.login-pie {
  margin: 22px 0 0; padding-top: 16px; border-top: 1px solid var(--divider);
  font-size: 12px; line-height: 1.6; color: var(--text-subtle);
}
.login-pie code { font-size: 11.5px; color: var(--text-muted); }

/* ------------------------------------------------- guia de la configuracion
   Fichas de variable dentro de la guia. La tabla del apartado Configuracion
   tiene su propio estilo compacto (.cfg-row): esto es la version larga, con la
   explicacion completa, y vive dentro de .guide-content.

   Los botones se OCULTAN cuando no llevan a ninguna parte: el de la guia en las
   vistas que no tienen una, y el «Ver la guía completa» de la ayuda del contexto
   cuando el proyecto no tiene guía. Las dos clases declaran `display` propio
   —`grid` e `inline-flex`—, que gana al `display: none` del atributo `hidden`:
   sin estas reglas los botones seguirían viéndose. */
.icon-btn[hidden], .btn[hidden] { display: none; }

.gvar {
  margin: 0 0 14px; padding: 16px 18px;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
  background: var(--surface-card);
  scroll-margin-top: 20px;
}
/* Destello al llegar desde un "Va con". Se quita solo: lo que hace falta es ver
   donde has aterrizado, no dejar la ficha marcada. */
.gvar.destacada { animation: gvar-destello 1.6s var(--ease-out); }
@keyframes gvar-destello {
  0%   { border-color: var(--color-primary); background: var(--color-primary-subtle); }
  100% { border-color: var(--border-subtle); background: var(--surface-card); }
}

.gvar-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.gvar-n {
  padding: 2px 7px; border-radius: 4px;
  background: var(--surface-sunken); color: var(--orange-300);
  font-family: var(--mono); font-size: 12.5px; font-weight: 600;
}
.gvar-val {
  min-width: 0; max-width: 100%;
  font-family: var(--mono); font-size: 12.5px; color: var(--text-body);
  overflow-wrap: anywhere;
}
.gvar-val.oculto { color: var(--text-subtle); letter-spacing: 1px; }

.gvar-t {
  margin-bottom: 4px;
  font-family: var(--font-heading); font-size: 14px; font-weight: 600; color: var(--text-strong);
}
.guide-content .gvar-d { margin: 0; font-size: 13.5px; color: var(--text-muted); }
.gvar-def { margin-top: 6px; font-size: 12.5px; color: var(--text-subtle); }

/* Lo que la plantilla no dice: efecto, acoplamiento, aviso y cuando se aplica.
   Separado del comentario por un filete para que se vea de un vistazo que son
   dos cosas distintas y de dos sitios distintos. */
.gvar-nota {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--divider);
}
.guide-content .gvar-nota p { margin: 0 0 8px; font-size: 13.5px; line-height: 1.6; }
.guide-content .gvar-nota p:last-child { margin-bottom: 0; }
.gvar-nota .t {
  display: block; margin-bottom: 2px;
  font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-subtle);
}
.gvar-nota .ojo .t { color: var(--warning-500); }
.gvar-nota .cuando .t { color: var(--teal-300); }

/* Nombre de una variable acoplada: lleva a su ficha. Es un boton y no un enlace
   porque no hay URL a la que ir, la guia vive dentro de la modal. */
.gvar-ir {
  display: inline-block; margin: 2px 4px 2px 0; padding: 2px 7px;
  border: 1px solid var(--border-default); border-radius: 4px;
  background: var(--surface-sunken); color: var(--text-body);
  font-family: var(--mono); font-size: 12px; cursor: pointer;
  transition: var(--transition-control);
}
.gvar-ir:hover {
  border-color: var(--color-primary); background: var(--color-primary-subtle);
  color: var(--orange-300);
}

@media (max-width: 720px) {
  .gvar { padding: 13px 14px; }
}

.tk-acciones { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.tk-acciones .btn { white-space: nowrap; }
#tab-tokens td { vertical-align: top; }
#tokOverlay .cred-v { word-break: break-all; }

[hidden] { display: none !important; }

textarea {
  width: 100%; padding: 10px 13px;
  border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  background: var(--surface-card); color: var(--text-body);
  font: inherit; font-size: 13.5px; line-height: 1.5;
  resize: vertical; transition: var(--transition-control);
}
textarea::placeholder { color: var(--text-subtle); }
textarea:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--focus-ring); }
textarea:disabled, select:disabled, input:disabled { opacity: .55; cursor: not-allowed; }

#tab-harness .card-body, #tab-cuenta .card-body, #usLista { overflow-x: auto; }
#hzSecciones { display: flex; flex-wrap: wrap; }
.hz-sub { font-size: 13.5px; font-weight: 600; color: var(--text-strong); margin: 24px 0 10px; }
.hz-filas { width: 100%; }
.hz-filas td { padding: 6px 8px 6px 0; vertical-align: middle; }
.hz-filas input, .hz-filas select { height: 36px; }
.hz-pre { white-space: pre-wrap; word-break: break-word; max-height: 420px; overflow: auto; margin: 0; }
.hz-diff .add { color: var(--success-500); }
.hz-diff .del { color: var(--danger-text); }
.hz-lista { margin: 6px 0 0; padding-left: 18px; }

/* -------------------------------------------------------------- calidad */
.cal-texto {
  white-space: pre-wrap; word-break: break-word; max-height: 420px; overflow: auto;
  background: var(--surface-sunken); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13.5px; color: var(--text-body);
}
.cal-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-size: 12.5px; color: var(--text-muted); margin-bottom: 14px; }
.cal-paso { border-top: 1px solid var(--divider); padding: 10px 0; }
.cal-paso details { margin-top: 6px; }
.cal-paso .tabla-ancha table { min-width: 560px; }
.modal.ancha { width: min(1500px, 94vw); height: 92vh; }
.enlace {
  padding: 0; border: 0; background: none; cursor: pointer;
  font: inherit; color: var(--text-muted); text-decoration: underline dotted;
}
.enlace:hover { color: var(--orange-300); }
.modal.ancha .cal-texto { max-height: 46vh; }
.cal-columnas { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 32px; align-items: start; }
.cal-columnas .hz-sub.cal-primero { margin-top: 0; }
.cal-intento + .cal-intento { border-top: 1px solid var(--divider); margin-top: 24px; }
@media (max-width: 1100px) {
  .cal-columnas { grid-template-columns: minmax(0, 1fr); }
  .cal-columnas .hz-sub.cal-primero { margin-top: 24px; }
}
