/* ============================================================================
   Proyecto Genesis — estilos comunes del portal
   Los colores vienen de tema.css (marca). Aqui solo hay forma y estructura.
   ============================================================================ */
@import url("tema.css?v=20261111");

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--fondo);
  color: var(--tinta);
  font-family: var(--fuente);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--marca-700); text-decoration: none; }
a:hover { color: var(--acento-osc); }
:focus-visible { outline: 3px solid rgba(15, 163, 177, 0.45); outline-offset: 2px; }

svg.ic {
  width: 18px; height: 18px; flex: none;
  stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ============================================================================
   Estructura: menu lateral + contenido
   ============================================================================ */
.app-shell {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--marca-900);
  color: #C9D5E3;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}

.sb-brand {
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.sb-brand img { height: 34px; width: auto; display: block; }

.sb-portal {
  margin: 14px 12px 4px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 10px;
  color: #FFFFFF;
}
a.sb-portal:hover { background: rgba(255, 255, 255, 0.09); color: #FFFFFF; }
.sb-portal-pt {
  width: 10px; height: 10px; border-radius: 50%; flex: none;
  background: var(--portal);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.10);
}
.sb-portal small { display: block; font-size: 11px; color: #8DA2BA; line-height: 1.2; }
.sb-portal b { font-size: 13.5px; font-weight: 600; }
.sb-portal svg.ic { margin-left: auto; color: #8DA2BA; }

.sb-nav { padding: 8px 10px; flex: 1; overflow-y: auto; }
.sb-sec {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #6E83A0;
  padding: 14px 12px 6px;
  font-weight: 600;
}
.sb-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  margin-bottom: 2px;
  border-radius: 7px;
  color: #C9D5E3;
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
}
.sb-link svg { width: 18px; height: 18px; stroke: currentColor; fill: none; flex-shrink: 0; }
.sb-link:hover { background: rgba(255, 255, 255, 0.06); color: #FFFFFF; }
.sb-link.act { background: rgba(15, 163, 177, 0.14); color: #FFFFFF; font-weight: 600; }
.sb-link.act::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--acento);
}
.sb-link .tag-prox {
  margin-left: auto; font-size: 10px; padding: 2px 6px; border-radius: 99px;
  background: rgba(255, 255, 255, 0.12); color: #C9D5E3;
}
.sb-foot {
  padding: 14px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 12px;
}
.sb-foot b { display: block; color: #FFFFFF; font-size: 12.5px; font-weight: 600; }
.sb-foot span { color: #6E83A0; font-size: 11.5px; }

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

/* ============================================================================
   Barra superior
   ============================================================================ */
.topbar {
  background: var(--superficie);
  border-bottom: 1px solid var(--borde);
  padding: 10px 28px;
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.tb-menu {
  display: none;
  border: 0; background: none; padding: 6px; margin-left: -6px;
  color: var(--tinta); cursor: pointer;
}
.tb-menu svg { width: 22px; height: 22px; }
.tb-title { min-width: 0; flex: 1; }
.tb-title h1 { margin: 0; font-size: 18px; font-weight: 700; color: var(--tinta); }
.tb-title small { display: block; color: var(--tinta-2); font-size: 12.5px; }
.tb-right { display: flex; align-items: center; gap: 14px; }

.search-box { position: relative; width: 260px; }
.search-box input {
  width: 100%; height: 36px; padding: 0 12px 0 34px;
  border: 1px solid var(--borde); border-radius: var(--radio-sm);
  background: var(--superficie); font-size: 13px; color: var(--tinta); outline: none;
}
.search-box input:focus { border-color: var(--acento); box-shadow: 0 0 0 3px var(--acento-suave); }
.search-box svg {
  position: absolute; left: 11px; top: 10px; width: 16px; height: 16px;
  stroke: var(--tinta-3); fill: none;
}

.user-pill {
  display: flex; align-items: center; gap: 10px;
  padding-left: 14px; border-left: 1px solid var(--borde);
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--marca-700); color: #FFFFFF;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none;
}
.user-pill b { display: block; font-size: 13px; color: var(--tinta); line-height: 1.2; }
.user-pill small { display: block; font-size: 11.5px; color: var(--tinta-2); }

.page-wrap { padding: 24px 28px 44px; max-width: 1440px; width: 100%; margin: 0 auto; }

/* ============================================================================
   Indicadores
   ============================================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 16px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  color: var(--tinta);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.kpi-card:hover { border-color: var(--marca-700); color: var(--tinta); }
.kpi-card.act { border-color: var(--acento); box-shadow: 0 0 0 3px var(--acento-suave); }
.kpi-info span { display: block; font-size: 12.5px; font-weight: 500; color: var(--tinta-2); margin-bottom: 4px; }
.kpi-info b { font-size: 26px; font-weight: 700; color: var(--tinta); line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-info small { display: block; font-size: 12px; color: var(--tinta-2); margin-top: 3px; }
.kpi-icon {
  width: 42px; height: 42px; border-radius: 10px;
  display: grid; place-items: center; font-size: 18px; flex-shrink: 0;
}
.kpi-icon svg.ic { width: 20px; height: 20px; }
.kpi-card.k-proc .kpi-icon { background: var(--marca-100); color: var(--marca-700); }
.kpi-card.k-ok   .kpi-icon { background: var(--ok-suave);     color: var(--ok); }
.kpi-card.k-hoy  .kpi-icon { background: var(--alerta-suave); color: var(--alerta); }
.kpi-card.k-atr  .kpi-icon { background: var(--error-suave);  color: var(--error); }
.kpi-card.k-atr  b         { color: var(--error); }
.kpi-card.k-fin  .kpi-icon { background: var(--acento-suave); color: var(--acento-osc); }

/* ============================================================================
   Paneles y flujo de etapas
   ============================================================================ */
.panel {
  background: var(--superficie);
  border-radius: var(--radio);
  border: 1px solid var(--borde);
  margin-bottom: 20px;
}
.panel-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--borde-suave);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 700; color: var(--tinta); }
.panel-head small { color: var(--tinta-2); font-size: 12.5px; }

.pipeline-wrap {
  padding: 16px 18px;
  display: grid;
  grid-template-columns: repeat(9, minmax(96px, 1fr));
  gap: 8px;
  overflow-x: auto;
}
.pipe-step {
  position: relative;
  border: 1px solid var(--borde);
  background: var(--superficie-2);
  border-radius: 8px;
  padding: 10px 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
}
.pipe-step:hover { border-color: var(--marca-700); background: var(--marca-50); }
.pipe-step.act { background: var(--acento-suave); border-color: var(--acento); }
.pipe-step .p-num { font-size: 10.5px; font-weight: 600; color: var(--tinta-3); text-transform: uppercase; }
.pipe-step.act .p-num { color: var(--acento-osc); }
.pipe-step .p-nom {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  font-size: 12px; font-weight: 600; line-height: 1.3; min-height: 2.6em; margin: 3px 0 8px;
  color: var(--tinta); overflow: hidden;
}
.pipe-step .p-row { display: flex; align-items: center; justify-content: space-between; }
.pipe-step .p-cnt { font-size: 20px; font-weight: 700; color: var(--marca-700); font-variant-numeric: tabular-nums; }
.pipe-step.act .p-cnt { color: var(--acento-osc); }
.pipe-step .p-atr {
  font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 99px;
  background: var(--error-suave); color: var(--error);
}

/* ============================================================================
   Filtros y tablas
   ============================================================================ */
.filter-bar {
  padding: 12px 18px;
  border-bottom: 1px solid var(--borde-suave);
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
}
.f-ctrl {
  height: 36px; padding: 0 12px;
  border: 1px solid var(--borde); border-radius: var(--radio-sm);
  background: var(--superficie); font-size: 13px; color: var(--tinta); outline: none;
}
.f-ctrl:focus { border-color: var(--acento); box-shadow: 0 0 0 3px var(--acento-suave); }

.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  text-align: left; padding: 10px 16px;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
  color: var(--tinta-2); background: var(--superficie-2);
  border-bottom: 1px solid var(--borde); white-space: nowrap;
}
table.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--borde-suave); vertical-align: middle; }
table.tbl tbody tr { cursor: pointer; transition: background 0.12s; }
table.tbl tbody tr:hover { background: var(--marca-50); }
table.tbl tbody tr:last-child td { border-bottom: 0; }
.ord-id { font-weight: 700; color: var(--marca-700); font-size: 14px; font-variant-numeric: tabular-nums; }
.sub-txt { display: block; font-size: 12px; color: var(--tinta-2); }
.vacio { padding: 36px 20px; text-align: center; color: var(--tinta-2); }

/* Estados */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok   { background: var(--ok-suave);     color: var(--ok); }
.badge.pend { background: var(--alerta-suave); color: var(--alerta); }
.badge.err  { background: var(--error-suave);  color: var(--error); }
.badge.real { background: var(--marca-100);    color: var(--marca-700); }
.badge.info { background: var(--info-suave);   color: var(--info); }

/* Botones */
.btn {
  height: 38px; padding: 0 16px;
  border: 1px solid var(--borde); border-radius: var(--radio-sm);
  background: var(--superficie);
  font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--marca-700);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--marca-700); background: var(--superficie); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.prim { background: var(--acento); border-color: var(--acento); color: #FFFFFF; }
.btn.prim:hover { background: var(--acento-osc); border-color: var(--acento-osc); }
.btn.oro { background: var(--acento); border-color: var(--acento); color: #FFFFFF; }
.btn.oro:hover { background: var(--acento-osc); }
.btn.peligro { background: var(--superficie); border-color: var(--error); color: var(--error); }
.btn.peligro:hover { background: var(--error-suave); }
.btn.ghost { border-color: transparent; background: none; color: var(--tinta-2); }
.btn.ghost:hover { color: var(--marca-700); background: var(--marca-50); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 12.5px; }
.btn svg.ic { width: 16px; height: 16px; }

/* Avisos dentro de la pagina */
.aviso {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radio-sm);
  background: var(--info-suave); color: var(--tinta); font-size: 13px; margin-bottom: 16px;
}
.aviso.ok { background: var(--ok-suave); }
.aviso.alerta { background: var(--alerta-suave); }
.aviso.error { background: var(--error-suave); }

/* ============================================================================
   Panel lateral deslizante (detalle de la orden)
   ============================================================================ */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(11, 37, 69, 0.45);
  z-index: 90; opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0;
  width: min(680px, 95vw); height: 100vh;
  background: var(--superficie);
  box-shadow: -12px 0 40px rgba(15, 27, 45, 0.18);
  z-index: 100;
  transform: translateX(100%);
  transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drw-head {
  padding: 18px 24px;
  background: var(--marca-900);
  color: #FFFFFF;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 3px solid var(--acento);
}
.drw-head h3 { margin: 0; font-size: 18px; }
.drw-head small { color: #9FB3C8; font-size: 12px; display: block; margin-top: 2px; }
.drw-close {
  background: rgba(255, 255, 255, 0.10); border: none; color: #FFFFFF;
  width: 34px; height: 34px; border-radius: 50%; font-size: 18px; cursor: pointer;
}
.drw-close:hover { background: rgba(255, 255, 255, 0.18); }
.drw-body { padding: 22px 24px; overflow-y: auto; flex: 1; }
.drw-sec { margin-bottom: 22px; }
.drw-sec h4 {
  margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--marca-700); border-bottom: 1px solid var(--borde-suave); padding-bottom: 6px;
}

/* Receta: OD / OI */
.rx-table {
  width: 100%; border-collapse: collapse;
  border: 1px solid var(--borde); border-radius: 8px; overflow: hidden; font-size: 13px;
}
.rx-table th {
  background: var(--marca-50); color: var(--marca-900);
  padding: 8px 10px; font-size: 11.5px; text-align: center; border-bottom: 1px solid var(--borde);
}
.rx-table td {
  padding: 9px 10px; text-align: center; border-bottom: 1px solid var(--borde-suave);
  font-weight: 600; font-variant-numeric: tabular-nums;
}
.rx-eye { background: var(--superficie-2); color: var(--marca-700); font-weight: 700; text-align: left !important; }

/* Linea de tiempo de etapas */
.tl-list { display: flex; flex-direction: column; gap: 8px; }
.tl-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 8px;
  border: 1px solid var(--borde); background: var(--superficie-2);
}
.tl-item.done { border-left: 4px solid var(--ok); background: var(--superficie); }
.tl-item.curr { border-left: 4px solid var(--acento); background: var(--acento-suave); }
.tl-item.halt { border-left: 4px solid var(--error); background: var(--error-suave); }
.tl-item.wait { opacity: 0.6; }
.tl-dot {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.tl-item.done .tl-dot { background: var(--ok-suave); color: var(--ok); }
.tl-item.curr .tl-dot { background: var(--acento); color: #FFFFFF; }
.tl-item.halt .tl-dot { background: var(--error); color: #FFFFFF; }
.tl-item.wait .tl-dot { background: var(--borde); color: var(--tinta-2); }
.tl-main { flex: 1; }
.tl-main b { font-size: 13px; color: var(--tinta); }
.tl-main small { display: block; font-size: 12px; color: var(--tinta-2); }

.pie { text-align: center; color: var(--tinta-3); font-size: 12px; padding: 18px; margin-top: auto; }

/* ============================================================================
   Aviso de sesion vencida (lo crea js/sesion.js)
   ============================================================================ */
.vx-velo {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(11, 37, 69, 0.45);
  display: grid; place-items: center; padding: 16px;
}
.vx-modal {
  background: var(--superficie); border-radius: 12px;
  max-width: 400px; width: 100%; padding: 26px; box-shadow: var(--sombra-alta);
}
.vx-modal-ic {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--alerta-suave); color: var(--alerta); margin-bottom: 14px;
}
.vx-modal-ic svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; }
.vx-modal h3 { margin: 0 0 6px; font-size: 17px; color: var(--tinta); }
.vx-modal p { margin: 0 0 20px; color: var(--tinta-2); line-height: 1.5; }
.vx-modal-acc { display: flex; justify-content: flex-end; gap: 10px; }

/* ============================================================================
   Tablet y telefono: el menu lateral se pliega
   ============================================================================ */
.sb-cortina { display: none; }
@media (max-width: 960px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; left: 0; top: 0; width: 264px;
    transform: translateX(-100%); transition: transform 0.2s ease;
  }
  .sidebar.abierto { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, 0.3); }
  .sb-cortina.abierto { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(11, 37, 69, 0.35); }
  .tb-menu { display: block; }
  .topbar, .page-wrap { padding-left: 16px; padding-right: 16px; }
  .search-box { width: 180px; }
  .user-pill .up-txt, .user-pill b, .user-pill small { display: none; }
}
@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-card { padding: 14px; }
  .kpi-icon { display: none; }
  .search-box { display: none; }
  .user-pill { padding-left: 0; border-left: 0; }
  .user-pill .btn span { display: none; }
}
