/* ===== Paleta base =====
   Azul   #045FA6  (primario)
   Naranja #F16522  (acento / acción)
   Gris    #BEBEBE  (neutro / bordes)
*/

/* ===== Tema LIGHT (por defecto) ===== */
:root {
  --brand-blue: #045FA6;
  --brand-blue-600: #034e88;
  --brand-orange: #F16522;
  --brand-orange-600: #d9531a;
  --brand-gray: #BEBEBE;
  --brand-navy: #04325e;       /* acción secundaria fuerte (mismo tono que la barra) */
  --brand-navy-600: #021f3a;

  /* Estimados desde la captura del sistema de diseño ViaOne; ajustar con los hex de Figma */
  --nav: #04325e;              /* barra superior y tabs (azul marino) */
  --nav-text: #ffffff;
  --nav-muted: rgba(255, 255, 255, .72);
  --nav-hover: rgba(255, 255, 255, .1);
  --nav-active-bg: #e8f0f8;    /* tab activo */
  --nav-active-text: #045FA6;
  --disabled-bg: #d9dce1;
  --disabled-text: #8a929c;

  --bg: #e9ecf0;
  --shell: #f3f4f6;            /* fondo de página (gris claro) */
  --panel: #ffffff;            /* tarjetas */
  --panel-2: #f3f4f6;
  --border: #d5d9de;
  --text: #1f2933;
  --muted: #5f6b7a;
  --primary: var(--brand-blue);
  --primary-hover: var(--brand-blue-600);
  --accent: var(--brand-navy);       /* el sistema de diseño no usa naranja en acciones */
  --accent-hover: var(--brand-navy-600);
  --green: #1a7f37;
  --amber: var(--brand-orange);
  --red: #cf222e;
  --shadow: 0 10px 40px rgba(35, 40, 47, .12);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* ===== Tema DARK ===== */
:root[data-theme="dark"] {
  --brand-blue: #2b86d1;
  --brand-blue-600: #045FA6;
  --brand-orange: #F16522;
  --brand-orange-600: #ff7a3d;
  --brand-gray: #6b7280;

  --nav: #021f3a;
  --nav-active-bg: #17212d;
  --nav-active-text: #6db3ee;
  --disabled-bg: #263241;
  --disabled-text: #6f7c8a;

  --bg: #0c1117;
  --shell: #121a24;
  --panel: #17212d;
  --panel-2: #1d2836;
  --border: #2b3947;
  --text: #e6edf3;
  --muted: #97a3b0;
  --primary: var(--brand-blue);
  --primary-hover: var(--brand-blue-600);
  --accent: #0b5cad;
  --accent-hover: #1a74cc;
  --green: #2ea043;
  --amber: var(--brand-orange);
  --red: #f85149;
  --shadow: 0 10px 40px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding: 28px 16px;
}

/* Contenedor central del dashboard */
.shell {
  max-width: 1080px;
  margin: 0 auto;
  background: var(--shell);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

code { font-family: var(--mono); background: rgba(255,255,255,.06); padding: 1px 5px; border-radius: 4px; font-size: .9em; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; background: var(--nav); color: var(--nav-text);
}
.topbar code { background: rgba(255,255,255,.14); color: var(--nav-text); }
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 42px; height: 42px; border-radius: 10px; display: block;
}
.version-pill {
  display: inline-block; margin-left: 8px; vertical-align: middle;
  font-size: 11px; font-weight: 700; font-family: var(--mono);
  padding: 2px 8px; border-radius: 999px;
  background: rgba(255,255,255,.14); color: var(--nav-text); border: 1px solid rgba(255,255,255,.25);
}
.topbar h1 { font-size: 18px; margin: 0; color: var(--nav-text); }
.subtitle { margin: 2px 0 0; color: var(--nav-muted); font-size: 13px; }

.topbar-right { display: flex; align-items: center; gap: 12px; }

/* Toggle deslizante de tema */
.theme-switch {
  position: relative; display: inline-flex; align-items: center;
  width: 58px; height: 30px; padding: 0; border-radius: 999px;
  background: var(--brand-gray); border: none; cursor: pointer; transition: background .2s;
}
:root[data-theme="dark"] .theme-switch { background: var(--brand-blue); }
.theme-switch-track { position: absolute; inset: 0; border-radius: 999px; }
.theme-switch-knob {
  position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #ffffff; box-shadow: 0 1px 3px rgba(0,0,0,.35);
  display: grid; place-items: center; transition: transform .2s;
}
.theme-switch-icon { font-size: 14px; line-height: 1; }
.theme-switch-icon.sun-on { color: #f0a020; }   /* estado claro: sol */
.theme-switch-icon.moon-on { color: #045FA6; }  /* estado oscuro: luna */
:root[data-theme="dark"] .theme-switch-knob { transform: translateX(28px); }
.theme-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.bridge-status {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
  padding: 6px 12px; border-radius: 999px; border: 1px solid rgba(255,255,255,.25); color: var(--nav-text);
}
.bridge-status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.bridge-status.online .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.bridge-status.offline .dot { background: var(--red); }
.bridge-status.unknown .dot { background: var(--amber); }

.tabs { display: flex; gap: 6px; padding: 10px 28px 0; background: var(--nav); border-top: 1px solid rgba(255,255,255,.12); }
.tab {
  position: relative; background: transparent; border: none; color: var(--nav-text);
  font-size: 14px; font-weight: 600; padding: 12px 18px; cursor: pointer;
  border-radius: 8px 8px 0 0; transition: color .15s, background .15s; top: 1px;
}
.tab:hover { background: var(--nav-hover); }
.tab.active { color: var(--nav-active-text); background: var(--nav-active-bg); }
/* Indicador inferior de la pestaña activa */
.tab.active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 0;
  background: transparent;
}
/* Numerito de cada tab */
.tab .tab-num {
  display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: 8px;
  border-radius: 50%; background: rgba(255,255,255,.16); color: var(--nav-text);
  font-size: 12px; font-weight: 700; vertical-align: middle;
}
.tab.active .tab-num { background: var(--primary); color: #fff; }

.panel { display: none; padding: 24px 28px 40px; max-width: 980px; }
.panel.active { display: block; }
.panel.wide { max-width: none; }

/* ===== Modo AWS: se ocultan las funciones que solo existen en el puente local ===== */
.cloud-only { display: none; }
body[data-mode="cloud"] .local-only { display: none !important; }
body[data-mode="cloud"] .cloud-only { display: inline; }

/* ===== Sesión y login ===== */
.session-box { display: flex; align-items: center; gap: 8px; color: var(--nav-text); font-size: 13px; }
.session-user { font-weight: 600; }
.session-box .btn.ghost { color: var(--nav-text); border-color: rgba(255,255,255,.35); }
.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(4, 50, 94, .75);
}
.overlay[hidden] { display: none; }
.login-card {
  width: 100%; max-width: 380px; background: var(--shell); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px; padding: 24px; box-shadow: var(--shadow);
}
.login-card h2 { margin: 0 0 4px; font-size: 18px; }
.login-card .hint { margin: 0 0 14px; }
.login-card .btn { width: 100%; }
.login-error { margin: 0 0 12px; color: var(--red); font-size: 13px; }

/* ===== Pipeline: HUs en proceso por ambiente ===== */
.pipeline-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.pipeline-head .hint { flex: 1 1 520px; margin: 0 0 16px; }
.pipeline-tools { display: flex; align-items: center; gap: 12px; }
.pipeline-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.pcol { border: 1px solid var(--border); border-radius: 10px; background: var(--panel); overflow: hidden; }
.pcol-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.pcol-head h2 { margin: 0; font-size: 15px; }
.pcol-count { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(4,95,166,.15); color: var(--primary); }
.pcol-head .btn { margin-left: auto; }
.pcol-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.pcol-err { margin: 6px; color: var(--red); font-size: 13px; }
.pcard { border: 1px solid var(--border); border-radius: 8px; background: var(--shell); padding: 8px 10px; }
.pcard summary { cursor: pointer; display: flex; align-items: center; gap: 8px; }
.pcard .hu-code { font-family: var(--mono); font-weight: 700; font-size: 13px; }
.pcard .hu-tag { margin-left: auto; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: rgba(207,34,46,.15); color: var(--red); }
.pcard .hu-tag.ok { background: rgba(26,127,55,.15); color: var(--green); }
.pcard ul { margin: 8px 0 2px; padding-left: 0; list-style: none; font-size: 12px; }
.pcard li { display: flex; gap: 8px; padding: 2px 0; }
.pcard li code { font-family: var(--mono); }
.pcard li .ptype { color: var(--muted); min-width: 52px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 600; }
input, select, textarea {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 10px 12px; border-radius: 8px; font-size: 14px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
textarea { resize: vertical; font-family: var(--mono); }

.zone { border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: 20px; background: var(--panel); }
.zone-existing { border-left: 3px solid var(--amber); }
.zone-new { border-left: 3px solid var(--green); }
.zone-head h2 { font-size: 15px; margin: 0 0 4px; }
.zone-head p { margin: 0 0 14px; color: var(--muted); font-size: 13px; }

.rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.row { display: grid; grid-template-columns: 130px 1fr 34px; gap: 8px; align-items: center; }
.row select, .row input { padding: 8px 10px; font-size: 13px; }
.row .del {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; cursor: pointer; height: 34px; font-size: 16px; line-height: 1;
}
.row .del:hover { color: var(--red); border-color: var(--red); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.btn {
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  padding: 10px 18px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.secondary { background: var(--panel-2); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.small { padding: 6px 12px; font-size: 12px; }
.btn:disabled,
.btn.primary:disabled,
.btn.accent:disabled { background: var(--disabled-bg); border-color: var(--disabled-bg); color: var(--disabled-text); cursor: not-allowed; }

.result {
  margin-top: 20px; border: 1px solid var(--border); border-radius: 10px; padding: 16px;
  background: var(--panel); font-size: 14px;
}
.result.ok { border-left: 3px solid var(--green); }
.result.warn { border-left: 3px solid var(--amber); }
.result.err { border-left: 3px solid var(--red); }
.result h3 { margin: 0 0 10px; font-size: 15px; }
.result pre { background: var(--panel-2); padding: 12px; border-radius: 8px; overflow-x: auto; font-family: var(--mono); font-size: 12.5px; }
.result table { width: 100%; border-collapse: collapse; font-size: 13px; }
.result th, .result td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.ok { background: rgba(46,160,67,.2); color: #4ac26b; }
.badge.drift { background: rgba(210,153,34,.2); color: #e0a92e; }
.badge.err { background: rgba(248,81,73,.2); color: #ff6a63; }

.preview { margin-top: 16px; border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; background: var(--panel); }
.preview summary { cursor: pointer; font-weight: 600; font-family: var(--mono); font-size: 13px; }
.preview pre { background: var(--panel-2); padding: 12px; border-radius: 8px; overflow-x: auto; font-family: var(--mono); font-size: 12.5px; }

.foot { padding: 18px 28px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12.5px; }

/* ===== Picker de HUs a promover ===== */
.field-label-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.hu-picker {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px;
  border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--panel-2);
  min-height: 60px;
}
.hu-empty { grid-column: 1 / -1; margin: 6px; color: var(--muted); font-size: 13px; }

.hu-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--shell); cursor: pointer;
  transition: border-color .12s, background .12s;
}
.hu-item:hover { border-color: var(--primary); }
.hu-item.checked { border-color: var(--primary); background: rgba(4,95,166,.1); }
.hu-item input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.hu-item .hu-code { font-family: var(--mono); font-weight: 700; font-size: 13px; }
.hu-item .hu-db { font-size: 11px; color: var(--muted); }
.hu-item .hu-tag {
  margin-left: auto; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: rgba(207,34,46,.15); color: var(--red);
}
.hu-item .hu-tag.ok { background: rgba(26,127,55,.15); color: var(--green); }

/* ===== Subida de archivos (deploy / rollback) ===== */
.hint { color: var(--muted); font-size: 13px; margin: 0 0 20px; line-height: 1.6; }

.zone-deploy { border-left: 3px solid var(--brand-blue); }
.zone-rollback { border-left: 3px solid var(--brand-orange); }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border: 2px dashed var(--border); border-radius: 12px; padding: 26px; cursor: pointer;
  background: var(--panel-2); color: var(--muted); text-align: center; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--primary); color: var(--text); outline: none; }
.dropzone.dragover { border-color: var(--accent); background: rgba(241,101,34,.08); color: var(--text); }
.dz-icon { font-size: 26px; line-height: 1; }
.dz-text { font-size: 13px; }

.file-list { list-style: none; counter-reset: item; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.file-list:empty { display: none; }
.file-item {
  display: grid; grid-template-columns: 28px 1fr auto 34px; gap: 12px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--shell);
}
.file-item.invalid { border-color: var(--red); background: rgba(207,34,46,.06); }
.file-order {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 13px; font-family: var(--mono);
}
.zone-rollback .file-order { background: var(--accent); }
.file-item.invalid .file-order { background: var(--red); }
.file-info { min-width: 0; }
.file-name { font-family: var(--mono); font-size: 13px; font-weight: 600; }
.file-object { font-size: 12px; color: var(--muted); }
.file-msg { font-size: 11.5px; }
.file-msg.ok { color: var(--green); }
.file-msg.err { color: var(--red); }
.file-del {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; cursor: pointer; height: 34px; font-size: 16px; line-height: 1;
}
.file-del:hover { color: var(--red); border-color: var(--red); }
