:root{
  --bg:#0a192f; --card:#112240; --card2:#0f2345; --text:#ccd6f6;
  --muted:#92a4c7; --accent:#64ffda; --red:#ff4b2b; --orange:#ff9f43; --line:#233554;
  --chip:#1d2d50;
}
*{ box-sizing:border-box; }
body{
  margin:0; height:100vh; overflow:hidden;
  display:flex; background:var(--bg); color:var(--text);
  font-family:system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial;
}

/* TOPBAR móvil */
#topbar{
  display:none;
  position: sticky;
  top:0;
  z-index:60;
  background:#020c1b;
  border-bottom:1px solid rgba(100,255,218,0.35);
  padding:10px 12px;
  gap:10px;
  align-items:center;
}
.hamb{
  border:1px solid rgba(100,255,218,0.25);
  background: rgba(100,255,218,0.08);
  color: var(--text);
  padding:8px 10px;
  border-radius:12px;
  font-weight:900;
  cursor:pointer;
}
.hamb.close{ display:none; }

#overlay{
  display:none;
  position:fixed;
  inset:0;
  background: rgba(0,0,0,0.55);
  z-index:55;
}

.topbar-title{ display:flex; flex-direction:column; gap:1px; }
.muted{ color:var(--muted); }

#sidebar{
  width:280px; background:#020c1b; border-right:1px solid var(--accent);
  padding:18px; display:flex; flex-direction:column; gap:10px;
}
.side-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  margin-bottom:6px;
}

h1{ margin:0 0 6px; font-size:18px; color:var(--accent); letter-spacing:0.3px;}
.sub{ color:var(--muted); font-size:12px; margin-top:-4px; }

.nav-btn{
  background:var(--card); border:1px solid rgba(100,255,218,0.15); color:var(--text);
  padding:12px; border-radius:10px; cursor:pointer; text-align:left;
  display:flex; align-items:center; gap:10px;
}
.nav-btn.active{ border-left:4px solid var(--accent); color:var(--accent); }

main{ flex:1; padding:22px; overflow:auto; }
.section{ display:none; }
.section.active{ display:block; }

.row{ display:flex; gap:14px; flex-wrap:wrap; }
.card{
  background:var(--card); border:1px solid rgba(100,255,218,0.12);
  padding:16px; border-radius:16px; box-shadow:0 10px 30px -15px rgba(2,12,27,0.7);
  margin-bottom:14px;
}
.card h3{ margin:0 0 10px; font-size:16px; }
.card h4{ margin:0 0 10px; font-size:14px; color:var(--accent); }
.help{ color:var(--muted); font-size:12px; margin-top:6px; line-height:1.35; }

label{ font-size:12px; color:var(--muted); display:block; margin:8px 0 4px; }
input, select, textarea{
  width:100%;
  background:var(--chip); border:1px solid var(--line);
  padding:9px 10px; color:var(--text); border-radius:10px; outline:none;
}
textarea{ resize:vertical; min-height:72px; }

.btn{
  background:var(--accent); color:var(--bg);
  border:none; padding:10px 12px; border-radius:10px;
  cursor:pointer; font-weight:700;
}
.btn.ghost{
  background:transparent; color:var(--text); border:1px solid rgba(100,255,218,0.25);
  font-weight:600;
}
.btn.danger{
  background:transparent; border:1px solid rgba(255,75,43,0.5);
  color:#ffd2cb;
}
.btn.small{ padding:7px 10px; border-radius:10px; font-weight:700; }

.badge{
  display:inline-block; padding:4px 8px; border-radius:999px;
  background:rgba(100,255,218,0.12); border:1px solid rgba(100,255,218,0.25);
  color:var(--accent); font-size:12px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

table{ width:100%; border-collapse:collapse; }
th, td{ border-bottom:1px solid var(--line); padding:10px 8px; text-align:left; }
th{ color:var(--muted); font-size:12px; font-weight:700; }
td{ font-size:13px; }

.grid-puestos{ display:grid; gap:10px; }
.puesto-box{
  background:var(--bg); border:1px solid rgba(255,255,255,0.08);
  padding:10px; border-radius:14px; min-height:72px;
}
.puesto-title{ font-size:11px; color:var(--muted); letter-spacing:0.2px;}
.puesto-name{ font-weight:800; margin-top:4px; }
.puesto-meta{ font-size:12px; color:var(--muted); margin-top:4px; }
.alerta-hueco{ border:1px dashed var(--orange); }

.relevo-info{
  margin-top:10px; padding:9px 10px; border-radius:12px;
  background:rgba(255,210,0,0.12); border:1px solid rgba(255,210,0,0.35);
  color:#ffeaa0; font-weight:700; font-size:12px;
}

.split{ display:grid; grid-template-columns: 1fr 1fr; gap:14px; }

/* Context bar */
#contextBar{
  position: sticky;
  top: 0;
  z-index: 25;
  backdrop-filter: blur(8px);
}

/* AMARILLO asegurado (gana siempre) */
#contextBar.card.contextbar{
  background: linear-gradient(180deg, rgba(255, 214, 64, 0.22), rgba(255, 214, 64, 0.12)) !important;
  border: 1px solid rgba(255, 214, 64, 0.65) !important;
}
#contextBar.card.contextbar label{
  color: rgba(255, 238, 160, 0.92) !important;
}
#contextBar.card.contextbar .badge{
  background: rgba(0,0,0,0.18) !important;
  border-color: rgba(0,0,0,0.28) !important;
  color: #ffeaa0 !important;
}

.hr{ height:1px; background:var(--line); margin:12px 0; }
.inline{ display:flex; gap:10px; align-items:end; flex-wrap:wrap; }
.inline > div{ flex:1; min-width:180px; }

/* Responsive: tablet */
@media (max-width: 980px){
  body{ overflow:auto; height:auto; }
  main{ padding:14px; }
  .split{ grid-template-columns: 1fr; }
}

/* Móvil: drawer */
@media (max-width: 640px){
  body{ flex-direction: column; height:auto; overflow:auto; }
  #topbar{ display:flex; }

  #sidebar{
    position:fixed;
    top:0; left:0;
    height:100vh;
    width: 86vw;
    max-width: 330px;
    transform: translateX(-110%);
    transition: transform .25s ease;
    z-index: 70;
    border-right:1px solid rgba(100,255,218,0.35);
  }
  #sidebar.open{ transform: translateX(0); }
  #overlay.show{ display:block; }
  .hamb.close{ display:block; }

  main{ padding:10px; }
  .card{ padding:12px; border-radius:14px; }
  .card h3{ font-size:14px; }
  .help{ font-size:12px; }

  .puesto-box{ padding:8px; border-radius:12px; min-height:58px; }
  .puesto-title{ font-size:10px; }
  .puesto-name{ font-size:12px; }
  .puesto-meta{ font-size:11px; }

  .grid-puestos{ overflow-x:auto; padding-bottom:6px; }
}

/* Compact mode */
body.compact-mode .card{ padding:12px; }
body.compact-mode .puesto-box{ padding:8px; min-height:58px; }
body.compact-mode .puesto-title{ font-size:10px; }
body.compact-mode .puesto-meta{ font-size:11px; }

#cuadranteOut{ --minCol:170px; }

/* Visual para orientación horizontal en pantalla (puestos en columna) */
body.paso-horizontal .grid-puestos{
  grid-template-columns: 1fr !important;
}