/* Módulo «ECOSTOS y robots» (eko27 staff). Usa los tokens del tema (--surface, --line2, --ok…),
   así que hereda claro/oscuro/retro sin reglas propias por tema. JS en /js/ecostos-robots.js. */
.ec-root { display:flex; flex-direction:column; gap:16px; min-width:0; }
.ec-root .card { min-width:0; }
.ec-sr { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }

/* Foco visible en todo lo interactivo del módulo y sus diálogos. */
.ec-root :is(button, a, select, input, textarea, pre):focus-visible,
.ec-dlg :is(button, a, select, input, textarea, pre):focus-visible { outline:2px solid var(--brand); outline-offset:2px; }
.ec-root .switch input:focus-visible + .track { outline:2px solid var(--brand); outline-offset:2px; }

.ec-sec-h { display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; margin-bottom:12px; }
.ec-sec-h h3 { margin:0; font-size:16px; font-weight:800; }
.ec-sub { color:var(--muted); font-size:12.5px; line-height:1.45; }

/* Encabezado: estado global */
.ec-head { display:flex; flex-direction:column; gap:12px; }
.ec-head-top { display:flex; gap:12px; align-items:flex-start; justify-content:space-between; flex-wrap:wrap; }
.ec-head h2 { margin:0 0 4px; font-size:20px; font-weight:800; }
.ec-flags { display:flex; gap:10px; flex-wrap:wrap; }
.ec-flag { flex:1 1 280px; min-width:0; display:flex; gap:10px; align-items:flex-start; padding:10px 12px;
  border:1px solid var(--line2); border-radius:calc(var(--radius) / 2); background:var(--surface2); font-size:13px; line-height:1.45; }
.ec-flag .ec-ico { flex:none; width:22px; height:22px; display:grid; place-items:center; border-radius:50%; font-weight:800; font-size:12px; }
.ec-flag.ok .ec-ico { background:var(--ok-soft); color:var(--ok); border:1px solid var(--ok); }
.ec-flag.warn { background:var(--warn-soft); }
.ec-flag.warn .ec-ico { background:var(--surface); color:var(--warn); border:1px solid var(--warn); }
.ec-flag b { display:block; }
.ec-flag .btn.small { margin-top:6px; }
.ec-upd { display:flex; align-items:center; gap:8px; font-size:12px; color:var(--muted); flex-wrap:wrap; }

/* Pulso «actualizando ahora» */
.ec-live { display:inline-flex; align-items:center; gap:6px; font-weight:700; color:var(--warn); }
.ec-dot { width:8px; height:8px; border-radius:50%; background:var(--warn); flex:none; animation:ecPulse 1.2s ease-in-out infinite; }
@keyframes ecPulse { 0%,100% { opacity:1; transform:scale(1); } 50% { opacity:.35; transform:scale(.7); } }
@media (prefers-reduced-motion: reduce) { .ec-dot { animation:none; } }

/* Países */
.ec-paises { display:grid; grid-template-columns:repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap:12px; }
.ec-pais { background:var(--surface); border:1px solid var(--line2); border-radius:calc(var(--radius) / 1.5); padding:14px;
  display:flex; flex-direction:column; gap:8px; min-width:0; }
.ec-pais.run { border-color:var(--warn); }
.ec-pais.off { opacity:.7; }
.ec-pais-h { display:flex; gap:10px; align-items:center; min-width:0; }
.ec-code { flex:none; min-width:38px; height:28px; padding:0 6px; display:grid; place-items:center; font-weight:800; font-size:12.5px;
  letter-spacing:.06em; border:1px solid var(--line2); background:var(--surface2); border-radius:6px; font-family:"IBM Plex Mono",ui-monospace,monospace; }
.ec-pais-h .n { font-weight:700; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ec-pais-h .m { color:var(--muted); font-size:12px; }
.ec-pais-h .chip { margin-left:auto; flex:none; }
.ec-kv { display:grid; grid-template-columns:1fr auto; gap:3px 10px; font-size:12.5px; }
.ec-kv dt { color:var(--muted); } .ec-kv dd { margin:0; text-align:right; font-weight:600; font-variant-numeric:tabular-nums; }
.ec-bar { height:8px; background:var(--surface2); border:1px solid var(--line2); border-radius:999px; overflow:hidden; }
.ec-bar > span { display:block; height:100%; background:var(--ok); }
.ec-pais-f { display:flex; justify-content:space-between; align-items:center; gap:8px; flex-wrap:wrap; font-size:12px; color:var(--muted); }

/* Robots */
.ec-tools { display:flex; gap:10px; align-items:flex-end; flex-wrap:wrap; }
.ec-tools > div { min-width:0; }
.ec-root table td { vertical-align:middle; }
.ec-root td.nw, .ec-root th.nw, .ec-dlg td.nw, .ec-dlg th.nw { white-space:nowrap; }
.ec-root td.num, .ec-root th.num, .ec-dlg td.num, .ec-dlg th.num { text-align:right; font-variant-numeric:tabular-nums; }
.ec-rname { font-weight:700; }
.ec-rmeta { color:var(--muted); font-size:12px; margin-top:2px; overflow-wrap:anywhere; }
.ec-actions { display:flex; gap:6px; flex-wrap:wrap; }
.ec-actions .btn.small { padding:6px 10px; }
.ec-root .switch input:checked + .track { background:var(--ok); }
.ec-sw { display:inline-flex; align-items:center; gap:8px; font-size:12px; }
.ec-scope { display:inline-flex; align-items:center; gap:6px; flex-wrap:wrap; font-size:13px; }

/* Diálogos (formulario y detalle de corrida) */
.ec-dlg .dlg-body h3 { margin-bottom:6px; }
.ec-form { display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:12px 14px; margin-top:14px; }
.ec-form .full { grid-column:1 / -1; }
.ec-form .input { width:100%; }
.ec-form textarea.input { min-height:72px; resize:vertical; font:inherit; }
.ec-form .hint { color:var(--muted); font-size:11.5px; margin-top:4px; line-height:1.4; }
.ec-form [hidden] { display:none !important; }
.ec-chk { display:inline-flex; align-items:center; gap:8px; font-size:13px; cursor:pointer; }
.ec-chk input { width:16px; height:16px; }
.ec-freq { display:flex; gap:6px; flex-wrap:wrap; margin-top:6px; }
.ec-freq .btn.small { padding:5px 10px; font-size:12px; }
.ec-freq .btn[aria-pressed="true"] { outline:2px solid var(--brand); outline-offset:-2px; font-weight:800; }
@media (max-width:640px) { .ec-form { grid-template-columns:1fr; } }

.ec-det-meta { display:flex; flex-wrap:wrap; gap:8px 16px; font-size:13px; margin:8px 0 12px; align-items:center; }
.ec-det-meta span { white-space:nowrap; }
.ec-counts { display:flex; gap:10px; flex-wrap:wrap; margin-bottom:12px; }
.ec-counts > div { flex:1 1 110px; border:1px solid var(--line2); padding:8px 10px; border-radius:8px; }
.ec-counts .n { font-size:20px; font-weight:800; font-variant-numeric:tabular-nums; }
.ec-counts .l { font-size:11.5px; color:var(--muted); font-weight:600; }
.ec-err { margin:0 0 12px; padding:10px 12px; border:1px solid var(--bad); background:var(--bad-soft); color:var(--bad); font-size:13px; border-radius:8px; overflow-wrap:anywhere; }
.ec-log { margin:0; max-height:320px; overflow:auto; padding:10px 12px; border:1px solid var(--line2); background:var(--surface2);
  font-family:"IBM Plex Mono",ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; font-size:12px; line-height:1.5;
  white-space:pre-wrap; word-break:break-word; border-radius:8px; }
.ec-dlg h4 { margin:16px 0 8px; font-size:14px; font-weight:800; }
.ec-var { font-weight:700; white-space:nowrap; }
.ec-var.up { color:var(--bad); } .ec-var.down { color:var(--ok); } .ec-var.eq { color:var(--muted); }
.ec-desc { max-width:340px; min-width:180px; }

/* Proveedor de IA de los robots (Cursor / xAI) */
.ec-prov { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.ec-prov [aria-checked="true"] { outline: 2px solid var(--ok, currentColor); outline-offset: 1px; }
/* Pausar / reanudar todos */
.ec-pausa { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; padding: 8px 10px; border: 1px dashed var(--line, #d6dbe3); border-radius: 10px; }
.ec-pausa.on { border-style: solid; border-color: var(--warn, #d9a300); background: color-mix(in srgb, var(--warn, #d9a300) 10%, transparent); }
.ec-pausa .ec-sub { margin: 0; }
.ec-pausa .btn.danger { background: #c62828; border: 1px solid #c62828; color: #fff; box-shadow: none; }
.ec-pausa .btn.danger:hover { background: #a91f1f; }
