:root{
  --bg:#0b1020;
  --panel:#0f1733;
  --panel2:#101a3a;
  --text:#eef2ff;
  --muted:#aab4e6;
  --line:rgba(255,255,255,.08);
  --shadow: 0 20px 80px rgba(0,0,0,.55);
  --primary:#7c5cff;
  --primary2:#31d0ff;
  --danger:#ff4d6d;
  --ok:#24d18a;
  --warn:#ffd166;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family:var(--sans);
  color:var(--text);
  background: var(--bg);
}

.app{ max-width:1200px; margin:0 auto; padding:22px 18px 60px; }

.header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:18px 18px;
  border:1px solid var(--line);
  border-radius:18px;
  background:linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  box-shadow:var(--shadow);
  backdrop-filter: blur(10px);
}

.brand{ display:flex; align-items:center; gap:12px; }
.logo{
  width:44px; height:44px;
  border-radius:14px;
  display:grid; place-items:center;
  font-weight:800;
  background:linear-gradient(135deg, rgba(124,92,255,.95), rgba(49,208,255,.75));
  box-shadow: 0 12px 35px rgba(124,92,255,.35);
}
.brandTitle{ font-weight:750; letter-spacing:.2px; }
.brandSubtitle{ color:var(--muted); font-size:13px; margin-top:2px; }

.headerActions{ display:flex; gap:10px; flex-wrap:wrap; justify-content:flex-end; }

.btn{
  appearance:none;
  border:none;
  color:var(--text);
  font-weight:650;
  padding:10px 14px;
  border-radius:12px;
  background:linear-gradient(135deg, rgba(124,92,255,.95), rgba(49,208,255,.70));
  cursor:pointer;
  box-shadow: 0 12px 28px rgba(124,92,255,.25);
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
}
.btn:hover{ transform: translateY(-1px); filter:saturate(1.05); }
.btn:active{ transform: translateY(0); filter:saturate(.95); }
.btn:focus-visible{ outline:2px solid rgba(49,208,255,.6); outline-offset:2px; }

.btnSecondary{
  background:rgba(255,255,255,.06);
  border:1px solid var(--line);
  box-shadow:none;
}
.btnSecondary:hover{ background:rgba(255,255,255,.08); }
.btnGhost{
  background:transparent;
  border:1px solid var(--line);
  box-shadow:none;
}
.btnDanger{
  background:rgba(255,77,109,.12);
  border:1px solid rgba(255,77,109,.28);
  box-shadow:none;
  color:#ffd7df;
}

.main{ margin-top:18px; }
.panel{
  border:1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
  border-radius:18px;
  box-shadow:var(--shadow);
  overflow:hidden;
}

.panelTop{
  padding:16px 16px 14px;
  border-bottom:1px solid var(--line);
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
}
.filters{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:flex-end;
}

.navFilters{
  width: 100%;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}
.navStack{
  flex: 1 1 auto;
  min-width: 0;
  position: relative;
}
.parentTabs{ flex-wrap: wrap; }
.parentTab[data-parent="archivos"]::after,
.parentTab[data-parent="produccion"]::after{
  content: " ▾";
  opacity: .88;
  font-weight: 800;
}
#subtabsWrap.subtabsWrap{
  margin-top: 8px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0;
}
#subtabsWrap .subtabs{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
}
.subtabs .subtab{
  background: rgba(255,255,255,.055);
  border: 1px solid var(--line);
  color: rgba(238,242,255,.88);
  box-shadow: none;
}
.subtabs .subtab:hover{ background: rgba(255,255,255,.09); }
.subtabs .subtab[aria-selected="true"]{
  background: rgba(124,92,255,.18);
  border-color: rgba(124,92,255,.4);
}
.navSearchField{
  flex: 0 0 auto;
  margin-left: auto;
  align-self: center;
}
.navSearchField input{ min-width: 220px; }
.legacyTabsHidden{
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.loginGate{
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 10, 20, .92);
}
.loginCard{
  width: min(400px, 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 22px 18px;
  background: linear-gradient(180deg, rgba(16,26,58,.98), rgba(12,18,40,.95));
  box-shadow: var(--shadow);
}
.loginCard h1{
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 800;
}
.loginCard p{
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.loginCard .field span{ display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.loginCard input{ width: 100%; min-width: 0; }
.loginErr{ color: #ffb4c0; font-size: 13px; margin-top: 8px; min-height: 1.2em; }
.loginCard .btn{ width: 100%; margin-top: 14px; }
.headerApiField > span{ display: none !important; }

.field{ display:flex; flex-direction:column; gap:6px; }
.field > span{ color:var(--muted); font-size:12px; }
input, select{
  background: rgba(12,18,40,.7);
  border:1px solid var(--line);
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  min-width: 220px;
  height: 38px;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 20px;
}
select{ min-width: 190px; }
input:focus,select:focus{ outline:2px solid rgba(124,92,255,.4); outline-offset:1px; }
input::placeholder{ color:rgba(170,180,230,.65); }

.tabs{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.tab{
  appearance:none;
  border:1px solid var(--line);
  background: rgba(255,255,255,.04);
  color: rgba(238,242,255,.92);
  border-radius:999px;
  padding:8px 12px;
  cursor:pointer;
  font-weight:650;
  font-size:13px;
}
.tab[aria-selected="true"]{
  background: rgba(124,92,255,.22);
  border-color: rgba(124,92,255,.45);
}

.sectionHeader{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  padding:12px 14px;
  border-bottom:1px solid var(--line);
  background: rgba(12,18,40,.40);
}
.sectionTitle{ font-weight:800; }
.sectionActions{ display:flex; gap:10px; flex-wrap:wrap; justify-content:flex-end; }

.dlgBody{ padding:14px 16px; }
.dlgBody .grid2{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
}
.dlgTableWrap{
  border:1px solid var(--line);
  border-radius:14px;
  overflow:hidden;
  margin-top:10px;
  background: rgba(12,18,40,.5);
}
.dlgTableActions{
  display:flex;
  justify-content:flex-end;
  margin-top:10px;
}
.dlgBody .table td input,
.dlgBody .table td select{
  width:100%;
  min-width:0;
}

/* Diálogo: la tabla global usa min-width:980px; acá forzamos ancho real para ver todas las columnas */
.dlgBody .dlgTableWrap .table.tableRecipeItems,
.dlgBody .dlgTableWrap .table.tableFabCheck{
  table-layout: fixed;
  min-width: 0;
  width: 100%;
}
.dlgBody .dlgTableWrap .table.tableRecipeItems thead th,
.dlgBody .dlgTableWrap .table.tableRecipeItems tbody td,
.dlgBody .dlgTableWrap .table.tableFabCheck thead th,
.dlgBody .dlgTableWrap .table.tableFabCheck tbody td{
  color: var(--text);
}
.dlgBody .dlgTableWrap .table.tableRecipeItems th:nth-child(1),
.dlgBody .dlgTableWrap .table.tableRecipeItems td:nth-child(1){ width: 58%; }
.dlgBody .dlgTableWrap .table.tableRecipeItems th:nth-child(2),
.dlgBody .dlgTableWrap .table.tableRecipeItems td:nth-child(2){ width: 22%; }
.dlgBody .dlgTableWrap .table.tableRecipeItems th:nth-child(3),
.dlgBody .dlgTableWrap .table.tableRecipeItems td:nth-child(3){ width: 20%; }

.dlgBody .dlgTableWrap .table.tableFabCheck th:nth-child(1),
.dlgBody .dlgTableWrap .table.tableFabCheck td:nth-child(1){ width: 58%; }
.dlgBody .dlgTableWrap .table.tableFabCheck th:nth-child(2),
.dlgBody .dlgTableWrap .table.tableFabCheck td:nth-child(2){ width: 27%; }
.dlgBody .dlgTableWrap .table.tableFabCheck th:nth-child(3),
.dlgBody .dlgTableWrap .table.tableFabCheck td:nth-child(3){ width: 15%; }

.dlgBody .dlgTableWrap td{ vertical-align: middle; }
.dlgBody .dlgTableWrap td .iconBtn{ width: 100%; }

.dlgBody .dlgTableWrap td input,
.dlgBody .dlgTableWrap td select{
  height: 38px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(12,18,40,.7);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 20px;
}
.dlgBody .dlgTableWrap td select{ appearance: none; }
.dlgBody .dlgTableWrap .chkItem{
  width: 22px;
  height: 22px;
  accent-color: var(--primary);
  cursor: pointer;
}
.elabHelp{
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.elabHelp strong{ color: var(--text); }
.elabFooter{
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.elabFooter .btn{ width: 100%; }
.dlgBody textarea{
  width:100%;
  min-height:120px;
  resize:vertical;
  background: rgba(12,18,40,.7);
  border:1px solid var(--line);
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  font-family:var(--sans);
  font-size:13px;
  line-height:20px;
}

.kpis{ display:flex; gap:12px; flex-wrap:wrap; }
.kpi{
  border:1px solid var(--line);
  background: rgba(255,255,255,.04);
  border-radius:14px;
  padding:10px 12px;
  min-width: 160px;
}
.kpiLabel{ color:var(--muted); font-size:12px; }
.kpiValue{ font-size:18px; font-weight:760; margin-top:3px; color: var(--text); }

.tableWrap{ overflow:auto; }
.table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  min-width: 980px;
}
thead th{
  text-align:left;
  font-size:12px;
  color:rgba(170,180,230,.9);
  font-weight:700;
  padding:12px 12px;
  background: rgba(12,18,40,.55);
  border-bottom:1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
}
tbody td{
  padding:12px 12px;
  border-bottom:1px solid rgba(255,255,255,.06);
  vertical-align:middle;
  color: var(--text);
}
tbody tr:hover td{
  background: rgba(255,255,255,.03);
}
.mono{ font-family:var(--mono); }
.num{ text-align:right; font-variant-numeric: tabular-nums; }

.pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:4px 10px;
  border-radius:999px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.04);
  color:rgba(238,242,255,.92);
  font-size:12px;
}
.dot{ width:8px; height:8px; border-radius:50%; background:var(--ok); }
.dot.warn{ background:var(--warn); }
.dot.danger{ background:var(--danger); }

.rowActions{ display:flex; justify-content:flex-end; gap:8px; }
.iconBtn{
  appearance:none;
  border:1px solid var(--line);
  background: rgba(255,255,255,.04);
  color:var(--text);
  border-radius:12px;
  padding:8px 10px;
  cursor:pointer;
}
.iconBtn:hover{ background: rgba(255,255,255,.06); }

.empty{
  padding:44px 18px;
  text-align:center;
}
.emptyTitle{ font-weight:780; font-size:18px; }
.emptySubtitle{ color:var(--muted); margin-top:6px; }
.emptyActions{ margin-top:14px; display:flex; gap:10px; justify-content:center; flex-wrap:wrap; }

.dlg::backdrop{ background: rgba(0,0,0,.6); backdrop-filter: blur(2px); }
.dlg{
  border:none;
  padding:0;
  background:transparent;
}
.dlgCard{
  width:min(820px, calc(100vw - 26px));
  border:1px solid var(--line);
  background: linear-gradient(180deg, rgba(16,26,58,.95), rgba(12,18,40,.92));
  border-radius:18px;
  box-shadow:var(--shadow);
  overflow:hidden;
}
.dlgHeader{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  padding:16px 16px 12px;
  border-bottom:1px solid var(--line);
}
.dlgTitle{ font-weight:800; color: var(--text); }
.dlgSubtitle{ color:var(--muted); font-size:12px; margin-top:3px; }
.grid{
  display:grid;
  grid-template-columns: 1.2fr .8fr 1fr .6fr .6fr .6fr;
  gap:10px;
  padding:14px 16px;
}
.grid input{ min-width:0; }
.dlgFooter{
  display:flex;
  justify-content:space-between;
  gap:12px;
  padding:14px 16px 16px;
  border-top:1px solid var(--line);
  align-items:center;
}
.dlgFooterRight{ display:flex; gap:10px; align-items:center; }
.dangerZone{ display:flex; align-items:center; }

.toastHost{
  position: fixed;
  right: 14px;
  bottom: 14px;
  display:flex;
  flex-direction:column;
  gap:10px;
  z-index: 100001;
}
.toast{
  border:1px solid var(--line);
  background: rgba(16,26,58,.92);
  border-radius:14px;
  padding:10px 12px;
  box-shadow: 0 18px 60px rgba(0,0,0,.45);
  min-width: 240px;
}
.toastTitle{ font-weight:760; font-size:13px; }
.toastMsg{ color:var(--muted); font-size:12px; margin-top:3px; }

@media (max-width: 980px){
  .grid{ grid-template-columns: 1fr 1fr; }
  input, select{ min-width: 180px; }
}
