:root {
  --brand: #9D162E; --brand-dark: #7a1024; --bg: #f8fafc; --border: #e2e8f0; --tinta: #1e293b; --gris: #64748b;
  --frio: #2E7A9E; --calor: #C0392B; --verde: #3F7D3F; --ambar: #E0A030;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif; background: var(--bg); color: var(--tinta); font-size: 14px; }
body { display: flex; flex-direction: column; }

/* cabecera */
.tc-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.6rem 1.25rem; background: var(--brand); color: #fff; flex-wrap: wrap; }
.tc-header-title { font-size: 1.05rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.02em; }
.tc-header-sub { font-size: 0.78rem; font-weight: 400; opacity: 0.85; text-transform: none; letter-spacing: 0; display: block; }
.tc-header-acc { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.tc-header select { background: rgba(255,255,255,0.95); }
.tc-header .tc-btn { background: transparent; color: #fff; border-color: rgba(255,255,255,0.5); }
.tc-header .tc-btn:hover { background: rgba(255,255,255,0.15); color: #fff; border-color: #fff; }

/* controles */
select, input[type="text"], input[type="number"] { font: inherit; font-size: 0.86rem; padding: 0.28rem 0.4rem; border: 1px solid var(--border); border-radius: 0.3rem; background: #fff; color: var(--tinta); min-width: 0; }
input[type="number"] { text-align: right; width: 100%; }
select { width: 100%; }
select:focus, input:focus { outline: 2px solid rgba(157,22,46,0.25); border-color: var(--brand); }
.tc-btn { display: inline-flex; align-items: center; gap: 0.35rem; font: inherit; font-size: 0.82rem; font-weight: 600; padding: 0.36rem 0.7rem; border-radius: 0.35rem; border: 1px solid var(--border); background: #fff; color: var(--tinta); cursor: pointer; white-space: nowrap; }
.tc-btn:hover { border-color: var(--brand); color: var(--brand); }
.tc-btn-primario { background: var(--brand); border-color: var(--brand); color: #fff; }
.tc-btn-primario:hover { background: var(--brand-dark); color: #fff; }
.tc-btn-mini { font-size: 0.75rem; padding: 0.2rem 0.45rem; }
.tc-btn svg { width: 15px; height: 15px; }

/* pestañas */
.tc-tabs { display: flex; gap: 0.25rem; align-items: flex-end; padding: 0.6rem 1.25rem 0; border-bottom: 1px solid var(--border); background: #fff; }
.tc-tab { font: inherit; font-weight: 700; font-size: 0.9rem; padding: 0.5rem 1rem; border: 1px solid transparent; border-bottom: none; border-radius: 0.4rem 0.4rem 0 0; background: transparent; color: var(--gris); cursor: pointer; display: inline-flex; gap: 0.4rem; align-items: center; }
.tc-tab .num { display: inline-grid; place-items: center; width: 1.3rem; height: 1.3rem; border-radius: 50%; background: var(--border); color: var(--gris); font-size: 0.75rem; }
.tc-tab.activa { color: var(--brand); border-color: var(--border); background: var(--bg); margin-bottom: -1px; }
.tc-tab.activa .num { background: var(--brand); color: #fff; }
.tc-tabs-sep { flex: 1; }
.tc-nombre { font-weight: 600; font-size: 0.95rem; border: 1px dashed transparent; padding: 0.25rem 0.5rem; margin-bottom: 0.35rem; width: 24rem; max-width: 40vw; }
.tc-nombre:hover { border-color: var(--border); }

/* paneles */
.tc-vista { flex: 1; min-height: 0; display: none; grid-template-columns: 26rem 1fr; gap: 0.9rem; padding: 0.9rem 1.25rem 1rem; }
.tc-vista.activa { display: grid; }
.tc-lateral { overflow-y: auto; min-height: 0; padding-right: 0.25rem; }
.tc-centro { display: flex; flex-direction: column; gap: 0.9rem; min-height: 0; overflow-y: auto; }
.tc-panel { background: #fff; border: 1px solid var(--border); border-radius: 0.5rem; padding: 0.7rem 0.85rem; margin-bottom: 0.75rem; }
details.tc-panel > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 0.5rem; }
details.tc-panel > summary::-webkit-details-marker { display: none; }
details.tc-panel > summary::before { content: '›'; font-weight: 700; color: var(--brand); transform: rotate(0); transition: transform 0.15s; display: inline-block; width: 0.8rem; }
details.tc-panel[open] > summary::before { transform: rotate(90deg); }
.tc-panel h2, details.tc-panel > summary { margin: 0; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--brand); font-weight: 800; }
details.tc-panel[open] > summary { margin-bottom: 0.6rem; }
.tc-campos { display: grid; grid-template-columns: 1fr 8.5rem; gap: 0.35rem 0.6rem; align-items: center; }
.tc-campos label { font-size: 0.84rem; color: var(--tinta); }
.tc-campos .ancho { grid-column: 1 / -1; }
.tc-campos .u { color: var(--gris); font-size: 0.78rem; }
.tc-nota { font-size: 0.76rem; color: var(--gris); margin: 0.45rem 0 0; line-height: 1.35; }
.tc-fila-sel { display: grid; grid-template-columns: 1fr 4.6rem; gap: 0.35rem; }
.tc-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 0.35rem; overflow: hidden; }
.tc-seg button { font: inherit; font-size: 0.82rem; font-weight: 600; padding: 0.32rem 0.7rem; border: none; background: #fff; color: var(--gris); cursor: pointer; }
.tc-seg button.activo { background: var(--brand); color: #fff; }
.tc-seg button + button { border-left: 1px solid var(--border); }

/* paramentos */
.tc-sup { border-top: 1px solid var(--border); padding: 0.45rem 0; display: grid; grid-template-columns: 3.6rem 1fr 1.2fr; gap: 0.3rem 0.4rem; align-items: center; }
.tc-sup:first-of-type { border-top: none; }
.tc-sup b { font-size: 0.82rem; }
.tc-sup .sub { grid-column: 2 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem; font-size: 0.75rem; color: var(--gris); align-items: center; }
.tc-sup .sub label { display: flex; align-items: center; gap: 0.3rem; }
.tc-sup .sub input { width: 4.2rem; }

/* listas de huecos y emisores */
.tc-item { border: 1px solid var(--border); border-left: 3px solid var(--frio); border-radius: 0.35rem; padding: 0.45rem 0.5rem; margin-bottom: 0.45rem; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.3rem; align-items: end; }
.tc-item.puerta { border-left-color: #9a6b44; }
.tc-item.emisor { border-left-color: #e0703a; }
.tc-item .cab { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr auto; gap: 0.3rem; align-items: center; }
.tc-item label { font-size: 0.7rem; color: var(--gris); display: flex; flex-direction: column; gap: 0.1rem; }
.tc-acciones { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: 0.3rem; }

/* vista 3D */
.tc-3d { position: relative; background: #fff; border: 1px solid var(--border); border-radius: 0.5rem; min-height: 360px; flex: 1; overflow: hidden; }
.tc-3d > canvas { width: 100%; height: 100%; display: block; }
.tc-3d-barra { position: absolute; top: 0.5rem; left: 0.5rem; display: flex; gap: 0.35rem; flex-wrap: wrap; z-index: 2; }
.tc-leyenda { position: absolute; right: 0.6rem; bottom: 0.6rem; background: rgba(255,255,255,0.92); border: 1px solid var(--border); border-radius: 0.35rem; padding: 0.35rem 0.5rem; font-size: 0.72rem; color: var(--gris); z-index: 2; }
.tc-leyenda .barra { width: 11rem; height: 0.55rem; border-radius: 0.2rem; margin: 0.2rem 0; }
.tc-leyenda .ext { display: flex; justify-content: space-between; }
.tc-leyenda .cats { display: flex; gap: 0.5rem; }
.tc-leyenda .cats span::before { content: ''; display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 2px; margin-right: 0.25rem; vertical-align: -1px; background: var(--c); }
.tc-ayuda3d { position: absolute; left: 0.6rem; bottom: 0.5rem; font-size: 0.7rem; color: var(--gris); z-index: 2; }

/* tablas */
table.tc-t { border-collapse: collapse; width: 100%; font-size: 0.82rem; }
table.tc-t th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--gris); border-bottom: 1px solid var(--border); padding: 0.3rem 0.4rem; font-weight: 700; }
table.tc-t td { padding: 0.28rem 0.4rem; border-bottom: 1px solid #f1f5f9; }
table.tc-t td.n { text-align: right; font-variant-numeric: tabular-nums; }
table.tc-t .chip { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 2px; vertical-align: -2px; margin-right: 0.3rem; border: 1px solid rgba(0,0,0,0.1); }
.ok { color: var(--verde); font-weight: 700; }
.no { color: var(--calor); font-weight: 700; }

/* resultados */
.tc-dos { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.tc-mapas { display: grid; grid-template-columns: 1.1fr 1fr; gap: 0.9rem; min-height: 360px; height: 44vh; }
.tc-mapas .tc-3d { min-height: 0; }
.tc-planta { background: #fff; border: 1px solid var(--border); border-radius: 0.5rem; position: relative; min-height: 0; }
.tc-planta canvas { width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
.tc-kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.6rem; }
.tc-kpi { background: #fff; border: 1px solid var(--border); border-radius: 0.5rem; padding: 0.55rem 0.7rem; }
.tc-kpi .t { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--gris); font-weight: 700; }
.tc-kpi b { display: block; font-size: 1.65rem; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 0.1rem; }
.tc-kpi .s { font-size: 0.74rem; color: var(--gris); }
.tc-cat { display: grid; place-items: center; min-width: 2.2rem; height: 2.2rem; border-radius: 0.35rem; color: #fff; font-weight: 800; font-size: 1.35rem; margin-top: 0.15rem; }
.tc-escala { position: relative; height: 0.6rem; border-radius: 0.3rem; margin-top: 0.4rem; background: linear-gradient(90deg, #215294, #5696c4 25%, #f4f1ea 50%, #e28454 75%, #9d162e); }
.tc-escala i { position: absolute; top: -0.25rem; width: 0.25rem; height: 1.1rem; background: var(--tinta); border-radius: 2px; transform: translateX(-50%); }
.tc-escala-et { display: flex; justify-content: space-between; font-size: 0.64rem; color: var(--gris); margin-top: 0.15rem; }
.tc-barras .fila { display: grid; grid-template-columns: 7.5rem 1fr 4.6rem; gap: 0.4rem; align-items: center; font-size: 0.78rem; margin: 0.15rem 0; }
.tc-barras .b { height: 0.75rem; border-radius: 0.2rem; }
.tc-barras .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--gris); }
.tc-aviso { background: #fff7e6; border: 1px solid #f3d9a4; color: #7a5410; border-radius: 0.35rem; padding: 0.4rem 0.6rem; font-size: 0.78rem; margin-top: 0.5rem; }
.tc-solo-plano { display: none; }
.modo-plano .tc-solo-plano { display: block; }
.modo-plano .tc-solo-punto { display: none; }
.tc-tpr { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.3rem 0.6rem; font-size: 0.78rem; margin-top: 0.4rem; }
.tc-tpr span { color: var(--gris); }

@media (max-width: 1200px) {
  .tc-vista { grid-template-columns: 1fr; }
  .tc-mapas { grid-template-columns: 1fr; height: auto; }
  .tc-mapas > div { height: 360px; }
  .tc-kpis { grid-template-columns: repeat(2, 1fr); }
  .tc-dos { grid-template-columns: 1fr; }
}

.tc-campos .tc-seg button { padding: 0.3rem 0.5rem; }
.tc-planta .tc-leyenda { top: 0.5rem; bottom: auto; }
.tc-kpi .tc-cat { width: 2.4rem; }
