/* ============================================================
   Design tokens — azul/turquesa metálico como color primario.
   Paleta de estado (good/warning/serious/critical) y superficies
   siguen los valores validados del design system de referencia.
   ============================================================ */

:root {
  color-scheme: light;
  --brand-1: #0e7490; /* turquesa/acero */
  --brand-2: #22d3ee; /* brillo/acento */
  --brand-3: #155e75;
  --brand-ink: #083344;

  --surface-page: #f4f6f7;
  --surface-1: #ffffff;
  --surface-2: #ffffff;
  --surface-sunken: #f1f4f5;
  --text-primary: #0b0f10;
  --text-secondary: #52585a;
  --text-muted: #868f92;
  --gridline: #e4e9ea;
  --border: rgba(11, 15, 16, 0.09);

  --good: #0ca30c;
  --warning: #c07c00;
  --serious: #c2551f;
  --critical: #c72f2f;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --shadow-card: 0 1px 2px rgba(8, 51, 68, 0.06), 0 10px 28px -16px rgba(14, 116, 144, 0.28);
  --shadow-pop: 0 12px 32px -8px rgba(8, 51, 68, 0.28);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --brand-1: #22d3ee;
    --brand-2: #67e8f9;
    --brand-3: #0e7490;
    --surface-page: #0b1214;
    --surface-1: #121b1e;
    --surface-2: #162024;
    --surface-sunken: #0e1618;
    --text-primary: #f3f6f7;
    --text-secondary: #b9c2c4;
    --text-muted: #7c8688;
    --gridline: #223032;
    --border: rgba(255, 255, 255, 0.09);
    --good: #2fbf4f;
    --warning: #f0ad2e;
    --serious: #ef8a5c;
    --critical: #ef5a5a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand-1: #22d3ee;
  --brand-2: #67e8f9;
  --brand-3: #0e7490;
  --surface-page: #0b1214;
  --surface-1: #121b1e;
  --surface-2: #162024;
  --surface-sunken: #0e1618;
  --text-primary: #f3f6f7;
  --text-secondary: #b9c2c4;
  --text-muted: #7c8688;
  --gridline: #223032;
  --border: rgba(255, 255, 255, 0.09);
  --good: #2fbf4f;
  --warning: #f0ad2e;
  --serious: #ef8a5c;
  --critical: #ef5a5a;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--surface-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* Red de seguridad: [hidden] SIEMPRE gana, sin importar qué otra regla
   de layout tenga el elemento (esto es lo que estaba roto antes: una
   regla de autor con display:flex le ganaba al atributo hidden). */
[hidden] { display: none !important; }

.eyebrow {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-1);
}

h1, h2, h3, h4 { margin: 0; }

/* ============================================================
   Screens — únicas dos raíces de nivel superior. La visibilidad se
   controla agregando/quitando .is-visible, nunca con [hidden] acá,
   para no repetir el bug de especificidad de la versión anterior.
   ============================================================ */

.screen { display: none; width: 100%; height: 100vh; overflow: auto; }
.screen.is-visible { display: flex; }

/* ---------------- Login ---------------- */

.login-screen { background: var(--surface-page); }

.login-split { display: flex; width: 100%; min-height: 100%; }

.login-brand {
  flex: 1 1 46%;
  min-width: 340px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: 64px;
  color: #eafcff;
  background:
    radial-gradient(900px 500px at 100% 0%, rgba(103, 232, 249, 0.35), transparent),
    radial-gradient(700px 500px at 0% 100%, rgba(8, 51, 68, 0.6), transparent),
    linear-gradient(160deg, var(--brand-ink), var(--brand-3) 55%, var(--brand-1));
}
.login-brand h1 { font-size: 34px; line-height: 1.15; font-weight: 700; }
.login-brand p { max-width: 420px; color: rgba(234, 252, 255, 0.82); font-size: 15px; line-height: 1.5; }
.login-brand .brand-mark {
  width: 52px; height: 52px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
}
.brand-points { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.brand-points li { font-size: 13.5px; color: rgba(234, 252, 255, 0.85); padding-left: 22px; position: relative; }
.brand-points li::before {
  content: ""; position: absolute; left: 0; top: 6px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand-2); box-shadow: 0 0 0 3px rgba(103, 232, 249, 0.25);
}

.login-form-col { flex: 1 1 54%; display: flex; align-items: center; justify-content: center; padding: 40px; }

.login-card {
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h2 { font-size: 24px; margin-bottom: 6px; }

/* El de registro tiene más campos: se ensancha para poder acomodarlos en
   fila (ver .field-flow) en vez de apilar todo verticalmente. */
.login-card.registro-card { width: min(640px, 100%); }

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.login-card input,
.login-card select {
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
}
.login-card input:focus,
.login-card select:focus {
  outline: none;
  border-color: var(--brand-1);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-1) 18%, transparent);
}

/* Campos del alta de cuenta en fila: cada label ocupa como mínimo 220px y
   se reparte el espacio disponible; cuando no entran más uno al lado del
   otro, el que sigue baja de renglón solo por el wrap. */
.field-flow {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}
.field-flow label { flex: 1 1 220px; min-width: 220px; }

.google-btn-slot { display: flex; justify-content: center; min-height: 40px; }
.google-btn-slot > div { width: 100% !important; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 12px;
  margin: 2px 0;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--gridline);
}

.field-hint-right { margin: -6px 0 0; text-align: right; font-size: 12.5px; }
.auth-hint { margin: -4px 0 4px; font-size: 13px; color: var(--text-secondary); line-height: 1.4; }
.ok-text { color: var(--good); font-size: 13px; margin: 0; }

.error-text { color: var(--critical); font-size: 13px; margin: 0; }

.auth-switch { margin: 2px 0 0; font-size: 13px; color: var(--text-secondary); text-align: center; }
.link-btn {
  background: none; border: none; padding: 0; margin: 0;
  color: var(--brand-1); font-size: 13px; font-weight: 600; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}
.link-btn:hover { color: var(--brand-3); }

/* ---------------- App shell ---------------- */

.app-shell { flex-direction: row; align-items: stretch; }

.sidebar {
  flex: 0 0 232px;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  color: #eafcff;
  background: linear-gradient(190deg, var(--brand-ink), var(--brand-3) 65%, var(--brand-1) 130%);
  box-shadow: 2px 0 18px rgba(8, 51, 68, 0.18);
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 22px;
  font-weight: 700; font-size: 15px; letter-spacing: 0.01em;
}
.brand-mark.small {
  width: 30px; height: 30px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.side-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: rgba(234, 252, 255, 0.72);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav-item.active { background: rgba(255, 255, 255, 0.16); color: #fff; box-shadow: inset 3px 0 0 var(--brand-2); }
.nav-icon { flex: none; opacity: 0.9; }

.sidebar-footer { display: flex; flex-direction: column; gap: 12px; padding-top: 14px; }

.empresa-switch { display: flex; flex-direction: column; gap: 5px; }
.empresa-switch label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: rgba(234, 252, 255, 0.6); }
.empresa-switch select {
  padding: 7px 8px; border-radius: var(--radius-sm); border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1); color: #fff; font-size: 12.5px;
}
.empresa-switch select option { color: #0b0f10; }

.user-chip { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.07); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--brand-2), var(--brand-1));
  color: #06282f; font-weight: 700; font-size: 13px;
}
.user-chip-info { min-width: 0; }
.user-chip-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip-logout {
  display: inline-flex; align-items: center; gap: 5px;
  background: none; border: none; padding: 0; margin-top: 2px;
  color: rgba(234, 252, 255, 0.65); font-size: 11.5px; cursor: pointer;
}
.user-chip-logout:hover { color: #fff; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.page-header {
  padding: 20px 32px;
  border-bottom: 1px solid var(--gridline);
  background: var(--surface-1);
}
.page-header h1 { font-size: 19px; font-weight: 700; }

main { flex: 1; padding: 26px 32px 60px; max-width: 1440px; width: 100%; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

/* ---------------- Buttons ---------------- */

.btn {
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.btn:hover { border-color: var(--brand-1); color: var(--brand-1); }
.btn.primary {
  background: linear-gradient(135deg, var(--brand-1), var(--brand-3));
  color: #fff;
  border: none;
  box-shadow: 0 6px 16px -6px rgba(14, 116, 144, 0.55);
}
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.ghost { background: transparent; border-color: rgba(255, 255, 255, 0.35); color: inherit; }
.btn.danger { color: var(--critical); border-color: var(--critical); background: transparent; }
.btn.danger:hover { color: #fff; background: var(--critical); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.full { width: 100%; justify-content: center; display: flex; padding: 11px 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------------- Layout helpers ---------------- */

.page-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 20px; align-items: start; }
@media (max-width: 980px) { .page-grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-card);
}
.panel + .panel { margin-top: 20px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 10px; }
.panel-header h3 { font-size: 15.5px; }
.panel-header.small h4 { font-size: 13.5px; }

.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.subtab {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
}
.subtab:hover { border-color: var(--brand-1); color: var(--brand-1); }
.subtab.active { background: var(--brand-1); color: #fff; border-color: var(--brand-1); }

.recurso-grupos { display: flex; flex-direction: column; gap: 6px; }
.recurso-grupo-btn {
  text-align: left;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-1);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
}
.recurso-grupo-btn:hover { border-color: var(--brand-1); color: var(--brand-1); }
.recurso-grupo-btn.active { background: var(--brand-1); color: #fff; border-color: var(--brand-1); }

.stack { display: flex; flex-direction: column; gap: 10px; }

.form-stack { display: flex; flex-direction: column; gap: 12px; }
.form-stack label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 500; color: var(--text-secondary); }
.form-stack input, .form-stack select, .form-stack textarea {
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-primary);
  font-size: 13.5px;
  font-family: inherit;
}
.form-stack input:focus, .form-stack select:focus, .form-stack textarea:focus {
  outline: none; border-color: var(--brand-1);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-1) 15%, transparent);
}
.form-stack input[type="color"] { padding: 2px; height: 36px; }
.inline-fields { display: flex; gap: 8px; }
.inline-fields > * { flex: 1; }
.panel-footer { display: flex; gap: 10px; margin-top: 6px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }

.op-row { border: 1px solid var(--gridline); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 10px; }
.op-hint { font-size: 11.5px; color: var(--text-secondary); margin: -4px 0 6px; }
.field-hint { font-size: 11px; font-weight: 400; color: var(--text-secondary); }

fieldset.ciclo-fieldset { border: 1px solid var(--gridline); border-radius: var(--radius-sm); padding: 12px; margin: 0 0 12px; }
fieldset.ciclo-fieldset legend { padding: 0 6px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }

.switch-field { display: flex; align-items: center; gap: 10px; margin: 2px 0; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider { position: absolute; inset: 0; cursor: pointer; background: var(--gridline); border-radius: 999px; transition: background .15s; }
.switch-slider::before {
  content: ""; position: absolute; height: 16px; width: 16px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: transform .15s;
}
.switch input:checked + .switch-slider { background: var(--brand-1); }
.switch input:checked + .switch-slider::before { transform: translateX(18px); }
.switch input:focus-visible + .switch-slider { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-1) 25%, transparent); }

hr.divider { border: none; border-top: 1px solid var(--gridline); margin: 18px 0; }

/* ---------------- Tables ---------------- */

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--gridline); }
th { color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-sunken); }
td.actions { display: flex; gap: 6px; justify-content: flex-end; }
.table-wrap { overflow-x: auto; }

.color-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: middle; border: 1px solid var(--border); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
}
.pill.good { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.pill.critical { background: color-mix(in srgb, var(--critical) 15%, transparent); color: var(--critical); }
.pill.muted { background: var(--gridline); color: var(--text-secondary); }
.pill.warn { background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--warning); }

/* ---------------- Monitoreo: tarjetas ---------------- */

.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.summary-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
}
.summary-card p { margin: 0 0 6px; font-size: 11.5px; color: var(--text-muted); font-weight: 500; }
.summary-card h2 { font-size: 27px; font-variant-numeric: tabular-nums; }
.summary-card.accent h2 { color: var(--brand-1); }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

.machine-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.machine-card .card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; border-bottom: 1px solid var(--gridline);
}
.machine-card .card-head h3 { font-size: 14.5px; }

.card-body { padding: 15px 16px; display: flex; flex-direction: column; gap: 13px; flex: 1; }

.stat-value { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600; }

.metrica-rows { display: flex; flex-direction: column; gap: 8px; }
.metrica-item + .metrica-item { border-top: 1px solid var(--gridline); padding-top: 8px; }
.metrica-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.metrica-row-label { font-size: 12px; color: var(--text-muted); }
.metrica-row-valor { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }

/* Tarjeta de métricas: ciclo_confirmado (tiempo entre ciclos) */
.metrica-ciclos { margin-top: 8px; }
.metrica-ciclos-stats { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-muted); }
.metrica-ciclos-stats b { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.metrica-ciclos-chart { display: flex; align-items: flex-end; gap: 2px; height: 44px; margin-top: 6px; }
.metrica-ciclos-col { flex: 1; display: flex; align-items: flex-end; height: 100%; min-width: 2px; }
.metrica-ciclos-bar { width: 100%; background: var(--brand-1); border-radius: 2px 2px 0 0; min-height: 2px; }

/* Timeline: barra de colores que se llena a lo largo del turno */
.timeline { height: 9px; border-radius: 999px; background: var(--gridline); overflow: hidden; display: flex; position: relative; }
.timeline .seg { height: 100%; }
.timeline-wrap { display: flex; flex-direction: column; gap: 4px; }
.timeline-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-muted); }

/* ---------------- TarjetaPorTurno: semáforo verde/rojo fijo, no sigue el
   tema claro/oscuro — es una señal de piso de planta. ---------------- */
.turno-card {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.turno-card.is-verde .turno-card-head { padding: 10px 16px; font-weight: 700; font-size: 14.5px; color: #eafff0; background: #0b3d1f; }
.turno-card.is-verde .turno-card-body {
  background: #14532d;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 16px;
  text-align: center;
}
.turno-card.is-verde .turno-card-foot { background: #14532d; padding: 0 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.turno-col { display: flex; flex-direction: column; justify-content: center; gap: 3px; }
.turno-velocidad-real { font-size: 21px; font-weight: 700; color: #000; font-variant-numeric: tabular-nums; }
.turno-velocidad-plan { font-size: 11.5px; color: #14210b; font-weight: 500; }
.turno-oee-value { font-size: 27px; font-weight: 800; color: #000; font-variant-numeric: tabular-nums; }
.turno-oee-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; color: #14210b; font-weight: 600; }
.turno-paradas-count { font-size: 21px; font-weight: 700; color: #000; font-variant-numeric: tabular-nums; }
.turno-paradas-tiempo { font-size: 11.5px; color: #14210b; font-variant-numeric: tabular-nums; }
.turno-card.is-verde .timeline { background: rgba(0, 0, 0, 0.2); }
.turno-card.is-verde .timeline-labels { color: #cdeed9; }
.turno-card.is-verde .turno-card-foot .btn { color: #eafff0; border-color: rgba(255, 255, 255, 0.35); }

.turno-card.is-roja .turno-card-head-light { padding: 10px 16px; font-weight: 700; font-size: 14.5px; color: #0b0f10; background: #ffffff; }
.turno-card.is-roja .turno-card-body-roja {
  background: var(--critical);
  color: #fff;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}
.turno-motivo { font-size: 13.5px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; }
.turno-tiempo-parada { font-size: 32px; font-weight: 800; font-variant-numeric: tabular-nums; }
.turno-roja-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; width: 100%; margin-top: 8px; }
.turno-roja-stats .stat-value, .turno-roja-stats .stat-label { color: #fff; }
.turno-card.is-roja .turno-card-foot { background: var(--critical); padding: 0 16px 16px; }
.turno-card.is-roja .timeline { background: rgba(255, 255, 255, 0.25); }
.turno-card.is-roja .timeline-labels { color: #ffe1e1; }

/* ---------------- Monitoreo: agrupación por activo ---------------- */

.activo-group { margin-bottom: 22px; }
.activo-group-head {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  margin-bottom: 10px;
}
.activo-group-head h3 { font-size: 15px; margin-right: auto; }
.activo-group-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.activo-widgets { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

.machine-card .widget-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.machine-card.is-offline .card-body { color: var(--text-muted); }

.widget-menu { position: relative; }
.widget-menu summary {
  list-style: none; cursor: pointer; width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface-1); font-size: 13px;
}
.widget-menu summary::-webkit-details-marker { display: none; }
.widget-menu[open] summary { border-color: var(--brand-1); color: var(--brand-1); }
.widget-menu-body {
  position: absolute; right: 0; top: 32px; z-index: 5;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-card); padding: 10px 12px; min-width: 150px;
  display: flex; flex-direction: column; gap: 6px;
}
.widget-menu-body label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--text-secondary); cursor: pointer; }

/* ---------------- Monitoreo: nodos ---------------- */

.node-meta { margin: 0; font-size: 12px; color: var(--text-muted); }


/* ---------------- Toasts ---------------- */

.toast-host { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 999; }
.toast {
  padding: 11px 16px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  box-shadow: var(--shadow-pop); font-size: 13px; max-width: 320px;
}
.toast.error { border-color: var(--critical); color: var(--critical); }
.toast.success { border-left: 3px solid var(--good); }
.toast.info { border-left: 3px solid var(--warning); }

.empty-state { padding: 34px 20px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ---------------- Dashboards ---------------- */

.dash-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface-2); cursor: pointer;
}
.dash-list-item:hover { border-color: var(--brand-1); }
.dash-list-item h4 { font-size: 14px; font-weight: 600; }

.dash-detalle-header {
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
  margin-bottom: 18px;
}
.dash-detalle-header h3 { font-size: 17px; flex: 1; min-width: 120px; }
.dash-detalle-acciones { display: flex; gap: 8px; flex-wrap: wrap; }

.dash-tarjeta { position: relative; }
.dash-tarjeta:hover { cursor: pointer; filter: brightness(1.02); }
.dash-tarjeta-quitar {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface-1); color: var(--text-secondary);
  font-size: 14px; line-height: 1; cursor: pointer;
}
.dash-tarjeta-quitar:hover { color: var(--critical); border-color: var(--critical); }

.checkbox-list { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; margin: 4px 0 14px; }
.checkbox-list label { display: flex; align-items: center; gap: 8px; font-size: 13px; }

/* Modal genérico (abrirModal/cerrarModal en ui.js) */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(8, 15, 17, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; z-index: 100;
}
.modal {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop); padding: 22px 24px; width: 100%; max-width: 520px;
  max-height: calc(100vh - 48px); overflow-y: auto;
}
.modal h3 { font-size: 16px; margin-bottom: 14px; }

/* Drill-down histórico */
.hist-grafico-wrap { margin: 14px 0; }
.hist-bar-chart {
  display: flex; align-items: flex-end; gap: 3px; height: 140px;
  border-bottom: 1px solid var(--gridline); padding: 0 2px;
}
.hist-bar-col { flex: 1; display: flex; align-items: flex-end; height: 100%; min-width: 2px; }
.hist-bar { width: 100%; background: var(--brand-1); border-radius: 2px 2px 0 0; min-height: 2px; }
.hist-bar-labels { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11px; color: var(--text-muted); }
.hist-detalle-tabla { margin-top: 16px; }
.hist-detalle-tabla summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--brand-1); padding: 6px 0; }
.hist-detalle-tabla .table-wrap { margin-top: 10px; max-height: 320px; overflow-y: auto; }

/* Drill-down de ciclos de encendido: franja horizontal por minuto */
.franja-minutos { display: flex; height: 22px; border-radius: 4px; overflow: hidden; cursor: pointer; }
.franja-seg { height: 100%; }
.franja-hint { margin: 4px 0 0; font-size: 11px; color: var(--text-muted); }

/* Header del drill-down de ciclos de encendido: título + navegación de fecha
   (flechas día a día + selector de calendario para saltar directo). */
.drill-head-nav {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 14px;
}
.drill-head-nav h3 { margin-bottom: 0; }
.date-nav { display: flex; align-items: center; gap: 6px; }
.date-nav .btn:disabled { opacity: 0.35; cursor: not-allowed; }
.date-nav input[type="date"] {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: inherit; padding: 5px 8px; font-size: 13px;
}

/* Gráfico de barras por minuto de ciclos_encendido: clases propias (NO
   .hist-bar-chart/.hist-bar-col, que sigue usando el histórico genérico de
   dashboards.js con pocas barras). Con 1440 columnas fijas, el gap/padding/
   min-width de esas clases genéricas desbordan el contenedor y desalinean
   cada minuto respecto de .franja-minutos, que no tiene ese problema por no
   tener gap/padding/min-width. Mismo modelo de caja que .franja-minutos acá
   -cero gap, cero padding, sin min-width- para que ambas filas dividan el
   mismo ancho exactamente igual y una barra caiga siempre debajo de su
   minuto correspondiente en la franja. */
.ciclos-bar-chart {
  display: flex; align-items: flex-end; height: 260px;
  border-bottom: 1px solid var(--gridline);
}
.ciclos-bar-col { flex: 1; display: flex; align-items: flex-end; height: 100%; }
/* Ilumina TODA la columna (no solo la barrita, que a veces mide 4% de
   altura) para que apuntar un minuto exacto con el mouse sea más fácil;
   el detalle real (cantidad de ciclos, litros, amp) va en el title/tooltip. */
.ciclos-bar-col:hover { background: color-mix(in srgb, var(--brand-1) 12%, transparent); cursor: pointer; }

/* Modificador full-screen: solo lo usa el drill-down de ciclos de encendido
   (ver ciclos_encendido.js), el resto de los modales sigue con .modal normal. */
.modal.modal-fullscreen {
  width: calc(100vw - 48px);
  max-width: calc(100vw - 48px);
  height: calc(100vh - 48px);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

@media (max-width: 860px) {
  .login-split { flex-direction: column; }
  .login-brand { padding: 36px; }
  .sidebar { flex-basis: 200px; }
}
