  :root {
    --bg: #fde7ef;
    --bg2: #fbd2e0;
    --surface: #ffffff;
    --surface2: #faf9f7;
    --border: #dddbd4;
    --border2: #c8c5bc;
    --text: #1a1916;
    --text2: #5a5850;
    --text3: #9a9890;
    --accent: #2d5a3d;
    --accent2: #3d7a55;
    --accent-light: #e8f2ec;
    --accent-text: #1e3d2a;
    --danger: #b84040;
    --danger-light: #fdf0f0;
    --warn: #b87020;
    --warn-light: #fdf5e8;
    --info: #2060a0;
    --info-light: #e8f0fa;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.10);
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; min-height: 100vh; display: flex; }

  /* SIDEBAR */
  .sidebar { width: 220px; min-height: 100vh; background: var(--text); display: flex; flex-direction: column; flex-shrink: 0; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; }
  .sidebar-logo { padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,0.08); }
  .sidebar-logo .brand { font-size: 15px; font-weight: 600; color: #fff; letter-spacing: -0.3px; }
  .sidebar-logo .sub { font-size: 11px; color: rgba(255,255,255,0.4); margin-top: 2px; font-family: 'DM Mono', monospace; }
  .sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
  .nav-section { font-size: 10px; font-weight: 600; color: rgba(255,255,255,0.3); letter-spacing: 0.08em; text-transform: uppercase; padding: 12px 10px 6px; }
  .nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; cursor: pointer; color: rgba(255,255,255,0.6); font-size: 13.5px; font-weight: 400; transition: all 0.15s; margin-bottom: 1px; }
  .nav-item:hover { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.9); }
  .nav-item.active { background: var(--accent); color: #fff; font-weight: 500; }
  .nav-icon { width: 16px; text-align: center; flex-shrink: 0; font-size: 15px; }
  .sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,0.08); }
  .user-pill { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,0.06); }
  .user-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: #fff; flex-shrink: 0; }
  .user-name { font-size: 12px; color: rgba(255,255,255,0.7); font-weight: 500; }

  /* MAIN */
  .main { margin-left: 220px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
  .topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 28px; height: 56px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
  .topbar-title { font-size: 16px; font-weight: 600; letter-spacing: -0.3px; }
  .topbar-right { display: flex; align-items: center; gap: 10px; }
  @keyframes titilar { 0%,100%{opacity:1} 50%{opacity:0.4} }
  .btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius); font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 500; cursor: pointer; border: none; transition: all 0.15s; text-decoration: none; }
  .btn-primary { background: var(--accent); color: #fff; }
  .btn-primary:hover { background: var(--accent2); }
  .btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border2); }
  .btn-secondary:hover { background: var(--bg2); }
  .btn-danger { background: var(--danger); color: #fff; }
  .btn-danger:hover { background: #a03030; }
  .btn-sm { padding: 5px 10px; font-size: 12px; }
  .content { padding: 28px; flex: 1; }

  /* CARDS & STATS */
  .stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
  .stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; }
  .stat-label { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.06em; }
  .stat-value { font-size: 26px; font-weight: 600; color: var(--text); margin-top: 4px; letter-spacing: -0.5px; font-family: 'DM Mono', monospace; }
  .stat-sub { font-size: 12px; color: var(--text3); margin-top: 3px; }
  .stat-badge { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 11px; font-weight: 600; }
  .badge-green { background: var(--accent-light); color: var(--accent-text); }
  .badge-red { background: var(--danger-light); color: var(--danger); }
  .badge-warn { background: var(--warn-light); color: var(--warn); }
  .badge-info { background: var(--info-light); color: var(--info); }
  .badge-gray { background: var(--bg2); color: var(--text2); }

  /* TABLES */
  .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
  .card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
  .card-title { font-size: 14px; font-weight: 600; }
  .search-box { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; flex: 1; max-width: 260px; }
  .search-box input { border: none; background: transparent; font-family: 'DM Sans', sans-serif; font-size: 13px; color: var(--text); outline: none; width: 100%; }
  table { width: 100%; border-collapse: collapse; }
  th { background: var(--surface2); color: var(--text2); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--border); }
  td { padding: 11px 16px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
  tr:last-child td { border-bottom: none; }
  tr:hover td { background: var(--surface2); }
  .actions { display: flex; gap: 6px; }

  /* FORMS & MODALS */
  .modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 200; align-items: center; justify-content: center; }
  .modal-overlay.open { display: flex; }
  .modal-box { background: var(--surface); border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,0.18); width: 90%; max-height: 90vh; overflow-y: auto; }
  .modal { background: var(--surface); border-radius: var(--radius-lg); width: 520px; max-width: 95vw; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
  .modal-header { padding: 20px 24px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
  .modal-title { font-size: 16px; font-weight: 600; }
  .modal-close { background: none; border: none; font-size: 20px; color: var(--text3); cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 4px; }
  .modal-close:hover { background: var(--bg2); }
  .modal-body { padding: 20px 24px; }
  .modal-footer { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
  .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .form-grid.cols-1 { grid-template-columns: 1fr; }
  .form-group { display: flex; flex-direction: column; gap: 5px; }
  .form-group.span2 { grid-column: span 2; }
  label { font-size: 12px; font-weight: 600; color: var(--text2); }
  input[type="text"], textarea, select { text-transform: uppercase; }
  input[type="text"]::placeholder, textarea::placeholder { text-transform: none; }
  input, select, textarea { font-family: 'DM Sans', sans-serif; font-size: 13px; color: var(--text); background: var(--bg); border: 1px solid var(--border2); border-radius: 8px; padding: 8px 11px; outline: none; transition: border 0.15s; width: 100%; }
  input:focus, select:focus, textarea:focus { border-color: var(--accent); background: var(--surface); }
  textarea { resize: vertical; min-height: 70px; }

  /* PAGE SECTIONS */
  .page { display: none; }
  .page.active { display: block; }
  .section-title { font-size: 20px; font-weight: 600; letter-spacing: -0.4px; margin-bottom: 20px; }

  /* DASHBOARD CHARTS */
  .charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
  .chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; }
  .chart-title { font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 14px; }
  .bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
  .bar-label { font-size: 12px; color: var(--text2); width: 110px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .bar-track { flex: 1; background: var(--bg2); border-radius: 4px; height: 8px; overflow: hidden; }
  .bar-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width 0.6s; }
  .bar-val { font-size: 12px; font-family: 'DM Mono', monospace; color: var(--text2); width: 70px; text-align: right; flex-shrink: 0; }

  /* CALCULADORA */
  /* Calculadora removida — usar Asistente de Costos */
  .mat-row { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 10px; }
  .mat-row .form-group { flex: 1; }
  .mat-row .btn { flex-shrink: 0; align-self: flex-end; padding: 8px 10px; }

  /* FACTURACION */
  .factura-preview { background: #fff; border: 2px solid var(--border); border-radius: var(--radius-lg); padding: 32px; font-size: 13px; }
  .factura-header { display: flex; justify-content: space-between; margin-bottom: 24px; padding-bottom: 20px; border-bottom: 2px solid var(--text); }
  .factura-tipo { font-size: 48px; font-weight: 700; color: var(--accent); font-family: 'DM Mono', monospace; }
  .factura-table th, .factura-table td { padding: 8px 10px; font-size: 12px; }
  .factura-table { margin: 16px 0; }
  .factura-total { text-align: right; margin-top: 16px; padding-top: 14px; border-top: 2px solid var(--text); }
  .factura-total .monto { font-size: 24px; font-weight: 700; font-family: 'DM Mono', monospace; color: var(--accent); }

  /* REPORTES */
  .reportes-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 24px; }
  .reporte-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; cursor: pointer; transition: all 0.15s; }
  .reporte-card:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
  .reporte-icon { font-size: 24px; margin-bottom: 10px; }
  .reporte-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
  .reporte-desc { font-size: 12px; color: var(--text3); }

  /* EMPTY STATE */
  .empty { text-align: center; padding: 48px 24px; color: var(--text3); }
  .empty-icon { font-size: 40px; margin-bottom: 12px; }
  .empty-title { font-size: 15px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
  .empty-sub { font-size: 13px; }

  /* TOAST */
  .toast { position: fixed; bottom: 24px; right: 24px; background: var(--text); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 13px; font-weight: 500; z-index: 999; transform: translateY(80px); opacity: 0; transition: all 0.25s; box-shadow: var(--shadow-lg); }
  .toast.show { transform: translateY(0); opacity: 1; }
  .toast.success { background: var(--accent); }
  .toast.error { background: var(--danger); }

  .num { font-family: 'DM Mono', monospace; }
  .text-right { text-align: right; }
  .flex-gap { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
  .mt { margin-top: 14px; }
  .stock-low { color: var(--danger); font-weight: 600; }
  .stock-ok { color: var(--accent); font-weight: 600; }
  hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

  /* ASISTENTE DE COSTO */
  .wizard-modal { width: 760px; }
  .wizard-steps { display: flex; align-items: center; gap: 0; padding: 20px 24px 0; }
  .wizard-step-item { display: flex; align-items: center; flex: 1; }
  .wizard-step-item:last-child { flex: none; }
  .wizard-step-circle { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex-shrink: 0; border: 2px solid var(--border2); background: var(--surface); color: var(--text3); transition: all 0.2s; cursor: pointer; }
  .wizard-step-circle:hover:not(.active) { border-color: var(--accent2); color: var(--accent2); background: var(--accent-light); }
  .wizard-step-circle.active { background: var(--accent); border-color: var(--accent); color: #fff; }
  .wizard-step-circle.done { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
  .wizard-step-line { flex: 1; height: 2px; background: var(--border); margin: 0 4px; transition: background 0.2s; }
  .wizard-step-line.done { background: var(--accent); }
  .wizard-step-label { font-size: 10px; color: var(--text3); margin-top: 4px; text-align: center; white-space: nowrap; }
  .wizard-step-label.active { color: var(--accent); font-weight: 600; }
  .wizard-panels { padding: 20px 24px; min-height: 260px; }
  .wizard-panel { display: none; }
  .wizard-panel.active { display: block; }
  .wizard-nav { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
  .wizard-step-title { font-size: 15px; font-weight: 600; margin-bottom: 16px; color: var(--text); }
  .wizard-row { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 10px; }
  .wizard-row .form-group { flex: 1; }
  .costo-resumen { background: var(--accent); color: #fff; border-radius: var(--radius-lg); padding: 18px 20px; margin-top: 4px; }
  .costo-resumen .cr-line { display: flex; justify-content: space-between; font-size: 13px; padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,0.15); }
  .costo-resumen .cr-line:last-child { border-bottom: none; font-weight: 600; font-size: 15px; padding-top: 10px; }
  .costo-resumen .cr-label { opacity: 0.85; }
  .costo-resumen .cr-val { font-family: 'DM Mono', monospace; font-weight: 500; }

  /* TALLES */
  .talle-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 8px; border: 1.5px solid var(--border2); background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 500; font-family: 'DM Mono', monospace; color: var(--text2); transition: background 0.12s, border-color 0.12s, color 0.12s; user-select: none; }
  .talle-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
  .talle-chip.selected { background: var(--accent); border-color: var(--accent); color: #fff; }
  .talle-chip.selected:hover { background: var(--accent2); }
  /* PASO 4 - MANO DE OBRA */
  .wiz4-campo-row { display:flex; align-items:center; gap:12px; padding:10px 18px; border-bottom:1px solid var(--border); transition:background 0.1s; }
  .wiz4-campo-row:hover { background:var(--surface2); }
  .wiz4-campo-icono { font-size:17px; width:24px; text-align:center; flex-shrink:0; }
  .wiz4-campo-label { font-size:13px; font-weight:500; color:var(--text); flex:1; }
  .wiz4-campo-input { width:130px; flex-shrink:0; text-align:right; font-family:'DM Mono',monospace; font-size:13px; font-weight:500; }
  .wiz4-campo-subtotal { width:70px; text-align:right; font-family:'DM Mono',monospace; font-size:12px; color:var(--accent); font-weight:600; flex-shrink:0; }


  /* PANEL LATERAL RESUMEN DE COSTO */
  .wiz-resumen-panel {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    width: 230px;
    max-height: 90vh;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-right: none;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 210;
    display: none;
    flex-direction: column;
    overflow: hidden;
  }
  .wiz-resumen-panel.open { display: flex; }
  .wiz-resumen-scroll { overflow-y: auto; flex: 1; }
  /* Bloque por paso */
  .wrb { }
  .wrb-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 7px 12px;
    color: #fff;
    font-size: 12px; font-weight: 700;
  }
  .wrb-header.telas    { background: #2d8c4e; }
  .wrb-header.insumos  { background: #c0392b; }
  .wrb-header.mano     { background: #2980b9; }
  .wrb-table { width: 100%; border-collapse: collapse; }
  .wrb-table th {
    font-size: 10px; font-weight: 600; color: var(--text3);
    text-transform: uppercase; letter-spacing: 0.04em;
    padding: 4px 12px; text-align: left;
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
  }
  .wrb-table th.right, .wrb-table td.right { text-align: right; }
  .wrb-table td {
    font-size: 12px; color: var(--text);
    padding: 5px 12px;
    border-bottom: 1px solid var(--border);
  }
  .wrb-table tr:last-child td { border-bottom: none; }
  .wrb-table tr.total-row td {
    font-weight: 700; font-size: 12px;
    background: var(--surface2);
    border-top: 1.5px solid var(--border2);
  }

  .wiz5-precio-celda { font-size:14px; font-weight:700; font-family:'DM Mono',monospace; color:var(--text); }
  .wrb-header.denominacion { background: #6d4c8e; }
  .wrb-header.precios       { background: #b7860b; }
  .wrb-actual { margin-left: auto; font-size: 10px; opacity: 0.8; }
  .wrb-key  { font-size: 11px; color: var(--text3); }
  .wrb-val  { font-size: 12px; font-weight: 600; color: var(--text); }
  .wrb-precio { font-weight: 700; color: var(--accent); }
  .wrb-empty { font-size: 11px; color: var(--text3); padding: 6px 12px 8px; font-style: italic; }
  /* Total general */
  .wiz-resumen-total {
    padding: 10px 14px;
    background: var(--text);
    color: #fff;
    display: flex; justify-content: space-between; align-items: baseline;
    flex-shrink: 0;
  }
  .wiz-resumen-total-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.75; }
  .wiz-resumen-total-monto { font-size: 18px; font-weight: 700; font-family: 'DM Mono', monospace; }

  /* SELECTOR DE COLORES — CORTES */
  /* selector de color — botón compacto en la fila */
  .color-picker-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 4px 8px; border: 1.5px solid var(--border2); border-radius: 6px;
    background: var(--surface); cursor: pointer; font-size: 12px; font-weight: 500;
    color: var(--text); min-width: 120px; white-space: nowrap;
    font-family: 'DM Sans', sans-serif; transition: border-color 0.15s;
  }
  .color-picker-btn:hover { border-color: var(--accent); }
  .color-picker-btn.activo { border-color: var(--accent); background: var(--accent-light); }
  .color-swatch { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; border: 1px solid rgba(0,0,0,0.12); }
  /* panel de colores expandido — debajo de la planilla, ancho completo */
  .color-panel-expandido {
    display: none; margin-top: 10px;
    background: var(--surface); border: 1.5px solid var(--accent);
    border-radius: var(--radius-lg); padding: 14px 16px;
    animation: fadeIn 0.15s ease;
  }
  .color-panel-expandido.open { display: block; }
  @keyframes fadeIn { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:translateY(0); } }
  .color-panel-titulo { font-size:11px; font-weight:700; color:var(--accent); text-transform:uppercase; letter-spacing:0.06em; margin-bottom:10px; }
  .color-panel-grid { display: flex; flex-wrap: wrap; gap: 6px; }
  .color-opt {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 10px; border-radius: 7px; cursor: pointer; border: 1.5px solid transparent;
    font-size: 12px; font-weight: 500; color: var(--text2);
    transition: all 0.1s; background: var(--bg);
  }
  .color-opt:hover { border-color: var(--border2); background: var(--surface); }
  .color-opt.selected { border-color: var(--accent); background: var(--accent-light); color: var(--accent-text); font-weight: 700; }
  .color-opt-swatch { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; border: 1px solid rgba(0,0,0,0.12); }
  .color-otros-input { margin-top:10px; padding-top:10px; border-top:1px dashed var(--border); display:none; }
  .corte-planilla-table { border-collapse: collapse; min-width: 100%; }
  .corte-planilla-table th {
    padding: 9px 14px; border: 1px solid var(--border);
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.05em; background: var(--surface2); text-align: center;
    font-family: 'DM Mono', monospace;
  }
  .corte-planilla-table th:first-child { text-align: center; min-width: 160px; }
  .corte-planilla-table td {
    padding: 6px 8px; border: 1px solid var(--border); text-align: center; vertical-align: middle;
  }
  .corte-planilla-table td:first-child { padding: 4px 8px; }
  .corte-planilla-input {
    width: 64px; text-align: center;
    font-family: 'DM Mono', monospace; font-size: 14px; font-weight: 600;
    border: 1.5px solid var(--border); border-radius: 6px;
    padding: 5px 4px; background: var(--surface);
  }
  .corte-planilla-input:focus { border-color: var(--accent); outline: none; }
