/* Stands — hoja de estilos única, sin frameworks ni compilación.
   Es una aplicación de tabla: manda la densidad. En una pantalla tiene que
   caber una calle entera de stands sin tener que hacer scroll para comparar. */

:root {
  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --primary-soft: #eff4ff;

  --ink: #16202e;          /* azul casi negro de la barra lateral */
  --ink-2: #1f2b3c;

  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f9fafc;
  --border: #e3e8ef;
  --border-strong: #cdd5e0;

  --text: #1b2430;
  --muted: #626e7e;
  --faint: #98a2b1;

  --green: #15803d;
  --green-soft: #e8f7ee;
  --amber: #b45309;
  --amber-soft: #fdf3e3;
  --red: #dc2626;
  --red-soft: #fdecec;
  --blue-soft: #eaf1fe;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(21, 32, 46, .07);
  --shadow: 0 4px 14px rgba(21, 32, 46, .09);

  --sidebar-w: 220px;
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font); font-size: 14.5px; line-height: 1.5;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 23px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 1em; }

.ico { width: 17px; height: 17px; flex: 0 0 17px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.tiny { font-size: 11.5px; }
.small { font-size: 12.5px; }
.strong { font-weight: 650; }
.mono { font-family: var(--mono); }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mt0 { margin-top: 0; } .mt1 { margin-top: 8px; } .mt2 { margin-top: 16px; } .mt3 { margin-top: 26px; }
.mb0 { margin-bottom: 0; } .mb1 { margin-bottom: 8px; } .mb2 { margin-bottom: 16px; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.hidden { display: none !important; }

/* ------------------------------------------------------------------ layout */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--ink); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: block; padding: 18px 16px 14px; color: #fff; }
.brand:hover { text-decoration: none; }
.wordmark { font-size: 20px; line-height: 1; letter-spacing: -.02em; }
.wordmark .a { font-weight: 300; color: #fff; }
.wordmark .b { font-weight: 700; color: #6ea8fe; }
.brand .sede {
  font-size: 10px; color: #7d8aa0; letter-spacing: .12em;
  text-transform: uppercase; margin-top: 4px;
}

.nav { padding: 4px 8px 10px; flex: 1; }
.nav-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: #7d8aa0; font-weight: 700; padding: 14px 10px 5px;
}
.nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: #cdd6e3; font-size: 14px; font-weight: 500; margin-bottom: 1px;
}
.nav a:hover { background: #223043; color: #fff; text-decoration: none; }
.nav a.active { background: var(--primary); color: #fff; font-weight: 650; }
.nav a .ico { opacity: .75; }
.nav a:hover .ico, .nav a.active .ico { opacity: 1; }
.nav a .count {
  margin-left: auto; font-size: 11px; font-weight: 700; color: #fff;
  background: var(--red); border-radius: 20px; padding: 0 6px; min-width: 18px; text-align: center;
}

.sidebar-foot { border-top: 1px solid #26364c; padding: 10px; }
.usuario {
  display: flex; align-items: center; gap: 9px; padding: 7px 8px;
  border-radius: var(--radius-sm); color: #cdd6e3;
}
.usuario .nombre { display: block; font-size: 13px; font-weight: 600; color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usuario .rol { display: block; font-size: 11px; color: #7d8aa0; }
.avatar {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%;
  background: var(--primary); color: #fff; display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em;
}
.salir {
  width: 100%; margin-top: 8px; background: #223043; color: #cdd6e3;
  border: 1px solid #2f4159; border-radius: var(--radius-sm);
  padding: 6px; font-size: 12.5px; font-family: inherit; cursor: pointer;
}
.salir:hover { background: #2b3c53; color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 54px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
  position: sticky; top: 0; z-index: 40;
}
.topbar .titulo { font-weight: 650; font-size: 15px; }
.topbar .spacer { flex: 1; }
.menu-movil { display: none; }

.content { padding: 20px 22px 60px; width: 100%; }
.content.wide { max-width: none; }
.page-head { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .sub { color: var(--muted); font-size: 13.5px; margin: 2px 0 0; }

/* ------------------------------------------------------------------ botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 13px; font-size: 14px; font-weight: 550; font-family: inherit;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); cursor: pointer;
  transition: background .12s, border-color .12s; white-space: nowrap; line-height: 1.4;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-ok { background: var(--green); border-color: var(--green); color: #fff; }
.btn-danger { color: var(--red); border-color: #f0c9c9; }
.btn-danger:hover { background: var(--red-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 4px 9px; font-size: 12.5px; }
.btn-lg { padding: 11px 20px; font-size: 15.5px; font-weight: 650; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* --------------------------------------------------------------- formularios */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], input[type=file], select, textarea {
  width: 100%; padding: 7px 10px; font-size: 14px; font-family: inherit; color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea { min-height: 80px; resize: vertical; }
.campo { margin-bottom: 12px; }
.campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.check { display: flex; align-items: center; gap: 7px; font-weight: 500; color: var(--text); font-size: 13.5px; }
.check input { width: auto; }
.ayuda { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ------------------------------------------------------------------ tarjetas */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 16px; }
.card-head { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.card-head h3 { margin: 0; }
.card-body { padding: 14px 16px; }
.card-foot { padding: 11px 16px; border-top: 1px solid var(--border); background: var(--surface-2); }

.alert { padding: 10px 13px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 10px; border: 1px solid; }
.alert-success { background: var(--green-soft); border-color: #bfe6cd; color: #14532d; }
.alert-error   { background: var(--red-soft);   border-color: #f3c9c9; color: #7f1d1d; }
.alert-warning { background: var(--amber-soft); border-color: #f0dcb4; color: #78350f; }
.alert-info    { background: var(--blue-soft);  border-color: #c9dcfb; color: #1e3a8a; }
.flashes { padding: 12px 22px 0; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px;
  border-radius: 20px; font-size: 11.5px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
}
.chip-ok { background: var(--green-soft); border-color: #bfe6cd; color: #14532d; }
.chip-aviso { background: var(--amber-soft); border-color: #f0dcb4; color: #78350f; }
.chip-mal { background: var(--red-soft); border-color: #f3c9c9; color: #7f1d1d; }
.chip-info { background: var(--blue-soft); border-color: #c9dcfb; color: #1e3a8a; }

/* --------------------------------------------------------------- indicadores */
.cifras { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.cifra { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 15px; }
.cifra .que { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.cifra .cuanto { font-size: 25px; font-weight: 680; letter-spacing: -.02em; margin-top: 3px; line-height: 1.1; }
.cifra .cuanto .unidad { font-size: 14px; font-weight: 550; color: var(--muted); margin-left: 3px; }
.cifra .pie { font-size: 12px; color: var(--muted); margin-top: 3px; }
.cifra.destacada { background: var(--ink); border-color: var(--ink); }
.cifra.destacada .que { color: #8fa3bd; }
.cifra.destacada .cuanto { color: #fff; }
.cifra.destacada .cuanto .unidad, .cifra.destacada .pie { color: #8fa3bd; }

/* ------------------------------------------------------------------- tablas */
.tabla-wrap { overflow-x: auto; }
table.tabla { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tabla th, table.tabla td { padding: 7px 9px; text-align: left; border-bottom: 1px solid var(--border); }
table.tabla thead th {
  background: var(--surface-2); font-size: 11px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); font-weight: 700; white-space: nowrap;
  position: sticky; top: 54px; z-index: 10; border-bottom: 1px solid var(--border-strong);
}
table.tabla tbody tr:hover { background: var(--primary-soft); }
table.tabla td.num, table.tabla th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tabla tr.grupo td {
  background: var(--surface-2); font-weight: 700; font-size: 12px;
  text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
}
table.tabla tfoot td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--border-strong); }
table.tabla tr.excluido td { opacity: .45; text-decoration: line-through; }
table.tabla tr.incompleto td.calc { color: var(--red); }

/* Celdas de edición dentro de la tabla: sin bordes hasta que se tocan, para
   que doscientas filas no parezcan doscientos formularios. */
.tabla input[type=text], .tabla input[type=number], .tabla select {
  padding: 3px 5px; font-size: 13px; border-color: transparent;
  background: transparent; border-radius: 4px;
}
.tabla input:hover, .tabla select:hover { border-color: var(--border-strong); background: var(--surface); }
.tabla input:focus, .tabla select:focus { background: var(--surface); }
.tabla input.mini { width: 62px; text-align: right; font-variant-numeric: tabular-nums; }
.tabla select.tipo { width: 118px; }
.tabla td.codigo { font-family: var(--mono); font-weight: 650; white-space: nowrap; }
.fila-sucia { background: #fffdf0 !important; }

/* Barra de filtros pegada bajo la cabecera */
.filtros {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 10px 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 12px;
}
.filtros select, .filtros input { width: auto; min-width: 130px; }
.filtros .sep { width: 1px; height: 24px; background: var(--border); }

/* Barra de guardar, siempre visible al fondo */
.barra-guardar {
  position: sticky; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--border-strong);
  padding: 10px 16px; display: flex; align-items: center; gap: 12px;
  box-shadow: 0 -4px 14px rgba(21, 32, 46, .07);
}

/* Dibujo del stand en la ficha: se ve de un golpe qué lado está cerrado */
.croquis { display: grid; grid-template-columns: 34px 1fr 34px; grid-template-rows: 30px 1fr 30px;
  gap: 4px; width: 260px; height: 190px; }
.croquis .lado {
  border: 2px dashed var(--border-strong); border-radius: 4px; background: var(--surface-2);
  display: grid; place-items: center; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: var(--faint); cursor: pointer;
}
.croquis .lado.medianera { background: #dbe4f0; border: 2px solid #7d93b0; color: #33475f; }
.croquis .lado.visto { background: #cfe3d3; border: 2px solid #4f8f68; color: #1c4a30; }
.croquis .centro { grid-column: 2; grid-row: 2; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
.croquis .centro .medida { font-size: 15px; font-weight: 700; }
.croquis .lado.f { grid-column: 2; grid-row: 3; }
.croquis .lado.t { grid-column: 2; grid-row: 1; }
.croquis .lado.i { grid-column: 1; grid-row: 2; }
.croquis .lado.d { grid-column: 3; grid-row: 2; }

/* ------------------------------------------------------------------- plano */
.plano-caja { position: relative; display: inline-block; max-width: 100%; }
.plano-img { display: block; max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.marca-zona {
  position: absolute; transform: translate(-50%, -50%);
  background: var(--primary); color: #fff; border: 2px solid #fff;
  border-radius: 20px; padding: 2px 9px; font-size: 12px; font-weight: 700;
  font-family: inherit; cursor: pointer; box-shadow: var(--shadow);
  opacity: .9; transition: transform .1s, opacity .1s;
}
.marca-zona:hover { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
.marca-zona.zona-activa { background: var(--red); opacity: 1; transform: translate(-50%, -50%) scale(1.25); }
tr.zona-activa td { background: var(--primary-soft); font-weight: 650; }

/* Los tramos medidos, dibujados encima del plano y pinchables. El SVG se
   estira con la imagen (preserveAspectRatio=none) y el trazo no, gracias a
   vector-effect: así una línea se ve igual de gruesa en cualquier zoom. */
.capa-tramos { position: absolute; inset: 0; width: 100%; height: 100%; }
.tramo { stroke-width: 7px; stroke-linecap: round; cursor: pointer; opacity: .75; }
.tramo:hover { opacity: 1; stroke-width: 11px; }
.tramo-muro  { stroke: #1d4ed8; }
.tramo-palo  { stroke: #c2410c; }
.tramo-fuera { stroke: #b9c0cb; opacity: .4; }
/* Tramos de otra zona: se ven, pero apagados y sin poder tocarlos. */
.tramo.apagado { opacity: .12; pointer-events: none; }
.tramo.apagado:hover { stroke-width: 7px; }

.selector-zona {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.selector-zona .que {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 700; margin-right: 4px;
}
.leyenda { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.leyenda i { width: 14px; height: 4px; border-radius: 2px; display: inline-block; }
.leyenda .mu { background: #1d4ed8; }
.leyenda .pa { background: #c2410c; }
.leyenda .fu { background: #b9c0cb; }

.vacio { text-align: center; padding: 46px 20px; color: var(--muted); }
.vacio .grande { font-size: 17px; font-weight: 600; color: var(--text); margin-bottom: 6px; }

pre.crudo {
  background: var(--ink); color: #cdd6e3; padding: 14px; border-radius: var(--radius);
  font-family: var(--mono); font-size: 12px; line-height: 1.6; overflow-x: auto;
  max-height: 60vh; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
}

/* ------------------------------------------------------------------- entrada */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--ink); }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 14px;
  padding: 30px 28px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login-card .wordmark { font-size: 26px; text-align: center; margin-bottom: 4px; }
.login-card .wordmark .a { color: var(--ink); }
.login-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }

/* ------------------------------------------------------------------ impresión */
@media print {
  .sidebar, .topbar, .barra-guardar, .no-print, .filtros { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  body { background: #fff; font-size: 11px; }
  .card { border: none; box-shadow: none; page-break-inside: avoid; }
  table.tabla thead th { position: static; background: #eee !important; -webkit-print-color-adjust: exact; }
  .cifra { border: 1px solid #ccc; }
  .cifra.destacada { background: #fff; }
  .cifra.destacada .cuanto, .cifra.destacada .que, .cifra.destacada .pie { color: #000; }
  a { color: #000; text-decoration: none; }
}

/* ------------------------------------------------------------------- móvil */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: -100%; z-index: 60; transition: left .2s; }
  .sidebar.abierta { left: 0; }
  .menu-movil { display: block; background: none; border: none; cursor: pointer; padding: 6px; }
  .menu-movil span { display: block; width: 20px; height: 2px; background: var(--text); margin: 4px 0; }
  .content { padding: 14px; }
  .velo { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 55; }
  .velo.visible { display: block; }
}
