:root{
  --ibero-red:#E00034;
  --ibero-red-dark:#b10029;
  --bg:#0b0f18;
  --panel:#121826;
  --text:#e6edf3;
  --muted:#94a3b8;
  --divider:#1f2937;
  --line:#334155;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0; background:var(--bg); color:var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
}

/* Topbar with IBERO colors */
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 16px; background:var(--ibero-red); color:white;
}
.topbar .brand{ display:flex; align-items:center; gap:10px; }
.topbar .logo{ height:28px; width:auto; }
.topbar h1{ margin:0; font-size:18px; font-weight:700; letter-spacing:.2px; }
.topbar .actions{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }

/* Segmented */
.segmented{
  display:inline-flex; border:1px solid rgba(255,255,255,.25);
  border-radius:14px; overflow:hidden;
}
.seg{
  background: rgba(0,0,0,.18); color:white;
  border:0; padding:8px 12px; cursor:pointer; font-weight:800;
}
.seg:hover{ background: rgba(0,0,0,.25); }
.seg.on{ background: rgba(255,255,255,.2); }

.container{
  display:grid; grid-template-columns: 1fr 340px;
  height: calc(100vh - 60px);
}

#viewer{ position:relative; background:#0a0f1a; }
.canvas2d{
  width:100%; height:100%;
  display:block;
}
#stats{
  background:var(--panel); border-left:1px solid var(--divider);
  padding:16px; overflow:auto;
}
.hintbar{
  position:absolute; left:8px; bottom:8px;
  background: rgba(0,0,0,.35);
  padding:6px 10px; border-radius:10px;
  font-size:12px; color:#cbd5e1;
}

/* Cards */
.card{
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 14px;
  padding: 12px 12px;
  margin-bottom: 12px;
}
.card h2{
  margin:0 0 10px 0;
  font-size:14px; letter-spacing:.2px;
}

/* Buttons */
.btn{
  background:#1f2937; color:var(--text); padding:8px 12px;
  border:1px solid #263244; border-radius:12px; cursor:pointer; font-weight:700;
  user-select:none;
}
.btn:hover{ border-color:var(--line); }
.btn.primary{ background:var(--ibero-red); border-color:var(--ibero-red-dark); }
.btn.primary:hover{ background:var(--ibero-red-dark); }

.file{ display:none; }

.btn:disabled{
  opacity:.55; cursor:not-allowed;
}

/* Descargar DXF resaltado cuando viene de conversión */
#btnDownloadDxf.hot{
  background: #E00034;
  border-color: rgba(224,0,52,.95);
  box-shadow: 0 0 0 2px rgba(224,0,52,.25) inset, 0 0 18px rgba(224,0,52,.35);
  filter: saturate(1.2) brightness(1.05);
}

/* Dropzone */
.dropzone{
  border:2px dashed var(--line);
  border-radius:12px; padding:14px;
  text-align:center; color:var(--muted);
  transition:.2s; margin-bottom:12px;
}
.dropzone.dragover{
  border-color: var(--ibero-red);
  color: var(--ibero-red);
  background: rgba(224,0,52,.08);
}

/* Stats */
.kv{ margin:0; }
.kv dt{ color:var(--muted); font-size:12px; }
.kv dd{
  margin:0 0 10px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size:14px;
}

.controls-block{
  margin:14px 0 8px;
  border-top:1px solid var(--divider);
  padding-top:10px;
}

.row{ display:flex; gap:8px; align-items:center; }
.row.wrap{ flex-wrap:wrap; }
.row.between{ justify-content:space-between; width:100%; }
.small{ font-size:13px; color:var(--muted); }
.note{ font-size:12px; color:var(--muted); margin-top:10px; }

.select{
  width:100%;
  padding:8px 10px;
  border-radius:12px;
  background:#0b1220;
  border:1px solid var(--line);
  color: #e2e8f0;
  outline:none;
}

.preview{
  width:100%;
  height:auto;
  background:#0a0f1a;
  border:1px solid rgba(255,255,255,.06);
  border-radius:12px;
}

/* Inputs */
input[type="number"]{
  width:90px;
  padding:6px;
  border-radius:10px;
  outline:none;
  background:#0b1220;
  border:1px solid var(--line);
  color:#e2e8f0;
}

/* Layers */
.layers{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.layer-row{
  display:flex;
  align-items:center;
  gap:10px;
  padding:6px 8px;
  background: rgba(0,0,0,.18);
  border:1px solid rgba(255,255,255,.05);
  border-radius:12px;
}
.layer-dot{
  width:10px; height:10px; border-radius:50%;
  border:1px solid rgba(255,255,255,.2);
}
.layer-name{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size:12px;
  color:#cbd5e1;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  flex:1;
}
.layer-count{
  font-size:11px;
  color:var(--muted);
}

/* Responsive */
@media (max-width: 980px){
  .container{ grid-template-columns: 1fr; height:auto; }
  #viewer{ height: 64vh; min-height: 320px; }
  .topbar{ align-items:flex-start; gap:10px; }
}

/* Estado activo (ej. Regla) */
.btn.on{
  background: rgba(224,0,52,.28);
  box-shadow: 0 0 0 2px rgba(224,0,52,.18) inset;
  border: 1px solid #ffffff;
  color: var(--text);
  background: rgba(230,51,93,.14);
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  user-select: none;
}

/* Descargar DXF destacado después de convertir */
.btn.hot{
  background:#34c759;
  border-color:#2ea84a;
  color:#041008;
}
.btn.primary.hot{
  background:#34c759;
  border-color:#2ea84a;
  color:#041008;
}