/* ═══════════════════════════════════════════════════════
   PRESUPUESTOS — Estilos del wizard de generación
   Usa las variables globales del tema (legajos.css)
   para que dark mode funcione automáticamente.
   ═══════════════════════════════════════════════════════ */

  #page-presupuestos.active {
    background: var(--bg);
    min-height: calc(100vh - 56px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 32px 16px 60px;
  }

  #page-presupuestos * ,
  #page-presupuestos *::before,
  #page-presupuestos *::after { box-sizing: border-box; }

  .shell { width: 100%; max-width: 760px; }

  /* ── Cabecera ── */
  .app-header {
    display: flex; align-items: center; gap: 16px;
    padding: 20px 28px;
    background: #1A3A5C;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    color: #fff;
  }
  html.dark .app-header { background: #0f1e36; }
  .app-header .logo {
    width: 64px; height: 64px; background: #fff;
    border-radius: 10px; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; padding: 4px;
  }
  html.dark .app-header .logo { background: #12141c; }
  .app-header .logo img { width: 56px; height: 56px; object-fit: contain; }
  .app-header h1 { font-size: 17px; font-weight: 600; }
  .app-header p  { font-size: 12px; opacity: .75; margin-top: 2px; }

  /* ── Barra de progreso ── */
  .progress-wrap {
    background: #2E6DA4;
    padding: 0 28px;
    display: flex; align-items: center; gap: 12px;
  }
  html.dark .progress-wrap { background: #1a3560; }
  .step-pills { display: flex; gap: 0; flex: 1; padding: 14px 0; }
  .pill {
    flex: 1; height: 4px; background: rgba(255,255,255,.25);
    border-radius: 2px; margin: 0 2px; transition: background .3s;
  }
  .pill.done   { background: #fff; }
  .pill.active { background: rgba(255,255,255,.7); }
  .step-label  { font-size: 12px; color: rgba(255,255,255,.85); white-space: nowrap; padding: 14px 0; }

  /* ── Card principal ── */
  .card-wrap {
    background: var(--surface);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    border-top: none;
    padding: 32px 32px 28px;
    min-height: 400px;
  }

  /* ── Pasos ── */
  .step { display: none; animation: fadeUp .22s ease; }
  .step.active { display: block; }
  @keyframes fadeUp { from { opacity:0; transform:translateY(8px) } to { opacity:1; transform:none } }

  .step-heading {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 24px; padding-bottom: 16px;
    border-bottom: 1.5px solid var(--border);
  }
  .step-ico {
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--accent-bg);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; flex-shrink: 0;
  }
  .step-heading h2 { font-size: 16px; font-weight: 600; color: var(--accent); }
  .step-heading p  { font-size: 12px; color: var(--text-2); margin-top: 2px; }

  /* ── Campos de formulario ── */
  .field-group { margin-bottom: 16px; }
  .field-group label {
    display: block; font-size: 12px; font-weight: 600;
    color: var(--text-2); letter-spacing: .04em;
    text-transform: uppercase; margin-bottom: 6px;
  }
  .field-group input,
  .field-group select,
  .field-group textarea {
    width: 100%; border: 1.5px solid var(--border-md);
    border-radius: var(--radius-sm); padding: 9px 12px;
    font-size: 14px; font-family: inherit;
    color: var(--text); background: var(--surface);
    transition: border-color .15s, box-shadow .15s; outline: none;
  }
  .field-group input:focus,
  .field-group select:focus,
  .field-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(107,130,255,.15);
  }
  .field-group textarea { min-height: 80px; resize: vertical; }
  .field-label { font-size: 12px; font-weight: 600; color: var(--text-2);
    letter-spacing: .04em; text-transform: uppercase; margin-bottom: 6px; display: block; }
  .row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

  /* ── Toggle ── */
  .toggle-card {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px; margin-bottom: 14px;
    background: var(--surface);
  }
  .toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .toggle-row .info h3 { font-size: 14px; font-weight: 600; color: var(--text); }
  .toggle-row .info p  { font-size: 12px; color: var(--text-2); margin-top: 2px; }

  .sw { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
  .sw input { opacity: 0; width: 0; height: 0; }
  .sw-slider {
    position: absolute; inset: 0;
    background: var(--border-md); border-radius: 24px;
    cursor: pointer; transition: .2s;
  }
  .sw-slider::before {
    content: ''; position: absolute;
    width: 18px; height: 18px; left: 3px; top: 3px;
    background: var(--surface); border-radius: 50%;
    transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
  }
  .sw input:checked + .sw-slider { background: var(--accent); }
  .sw input:checked + .sw-slider::before { transform: translateX(20px); }
  .collapsible { display: none; margin-top: 14px; }
  .collapsible.open { display: block; }

  /* ── Materiales ── */
  .mat-header {
    display: grid; grid-template-columns: 1fr 80px 110px 36px;
    gap: 8px; margin-bottom: 6px;
  }
  .mat-header span {
    font-size: 11px; font-weight: 600; color: var(--text-2);
    text-transform: uppercase; letter-spacing: .05em; padding-left: 4px;
  }
  .mat-row {
    display: grid; grid-template-columns: 1fr 80px 110px 36px;
    gap: 8px; margin-bottom: 8px; align-items: center;
  }
  .mat-row input { margin: 0; }
  .btn-del {
    width: 36px; height: 36px;
    border: 1.5px solid rgba(239,68,68,.35);
    background: rgba(239,68,68,.08);
    border-radius: var(--radius-sm); color: #ef4444;
    font-size: 16px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
  }
  .btn-del:hover { background: rgba(239,68,68,.18); }
  .btn-add-row {
    width: 100%; border: 1.5px dashed var(--accent);
    background: transparent; color: var(--accent);
    border-radius: var(--radius-sm); padding: 9px;
    font-size: 13px; font-weight: 500; cursor: pointer;
    transition: background .15s; margin-top: 4px; font-family: inherit;
  }
  .btn-add-row:hover { background: var(--accent-bg); }
  .mat-total { text-align: right; font-size: 13px; color: var(--accent); font-weight: 600; margin-top: 8px; }

  /* ── Fotos ── */
  .drop-zone {
    border: 2px dashed var(--border-md);
    border-radius: var(--radius-sm);
    padding: 28px 20px; text-align: center; cursor: pointer;
    transition: border-color .2s, background .2s; margin-bottom: 12px;
    background: var(--surface);
  }
  .drop-zone:hover,
  .drop-zone.dragover { border-color: var(--accent); background: var(--accent-bg); }
  .drop-zone.dragover { transform: scale(1.01); }
  .drop-zone .dz-ico { font-size: 32px; margin-bottom: 8px; }
  .drop-zone p     { font-size: 13px; color: var(--text-2); }
  .drop-zone small { font-size: 11px; color: var(--text-3); display: block; margin-top: 4px; }
  .drop-zone input[type=file] { display: none; }

  .photo-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px; margin-bottom: 14px;
  }
  .photo-thumb {
    position: relative; aspect-ratio: 1;
    border-radius: var(--radius-sm); overflow: hidden;
    border: 1px solid var(--border);
  }
  .photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
  .photo-thumb .ph-name {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,.55); color: #fff; font-size: 9px;
    padding: 3px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .photo-thumb .ph-del {
    position: absolute; top: 4px; right: 4px;
    background: rgba(0,0,0,.5); border: none; border-radius: 50%;
    width: 22px; height: 22px; color: #fff; font-size: 13px; line-height: 1;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
  }
  .photo-thumb .ph-caption { position: absolute; bottom: 18px; left: 0; right: 0; padding: 2px 5px; }
  .photo-thumb .ph-caption input {
    width: 100%; background: rgba(255,255,255,.85);
    border: none; border-radius: 3px; font-size: 9px; padding: 2px 4px; color: #222;
  }

  /* ── Informe de estado ── */
  .informe-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .inf-item {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--surface-2); border-radius: var(--radius-sm);
    padding: 8px 12px; gap: 8px; border: 1px solid var(--border);
  }
  .inf-item span { font-size: 13px; color: var(--text); }
  .inf-item select {
    width: 100px; font-size: 12px; padding: 4px 6px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); flex-shrink: 0;
  }
  .inf-item select.bueno   { border-color: #22c55e; color: #16a34a; }
  .inf-item select.regular { border-color: #f59e0b; color: #d97706; }
  .inf-item select.malo    { border-color: #ef4444; color: #dc2626; }

  /* ── Checkboxes de trabajos ── */
  .trabajo-check-row {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); cursor: default;
    transition: border-color .15s, background .15s;
    font-size: 14px; color: var(--text); user-select: none;
    flex-direction: column; align-items: flex-start;
    background: var(--surface);
  }
  .trabajo-check-row input[type=checkbox] {
    width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0;
  }
  .trabajo-check-row.checked { border-color: var(--accent); background: var(--accent-bg); }
  .trabajo-precio-wrap { display: none; flex-direction: row; align-items: center; gap: 6px; }

  /* ── Resumen ── */
  .summary-section {
    background: var(--surface-2); border-radius: var(--radius-sm);
    padding: 14px 18px; margin-bottom: 12px;
    border: 1px solid var(--border);
  }
  .summary-section h3 {
    font-size: 11px; font-weight: 700; color: var(--text-2);
    text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px;
  }
  .summary-row {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 13px; color: var(--text);
    padding: 4px 0; border-bottom: 1px solid var(--border);
  }
  .summary-row:last-child { border-bottom: none; }
  .summary-row .lbl { color: var(--text-2); }
  .summary-row .val { font-weight: 500; }
  .badge { font-size: 11px; padding: 2px 10px; border-radius: 20px; font-weight: 500; }
  .badge.ok  { background: #dcfce7; color: #16a34a; }
  .badge.no  { background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); }
  .badge.cnt { background: var(--accent-bg); color: var(--accent-text); }
  html.dark .badge.ok { background: #14532d; color: #4ade80; }

  .total-bar {
    background: linear-gradient(135deg, #1e3a6e 0%, #1A3A5C 100%);
    color: #fff; border-radius: var(--radius-sm);
    padding: 14px 20px; display: flex; justify-content: space-between;
    align-items: center; margin-top: 12px; margin-bottom: 24px;
    box-shadow: 0 2px 12px rgba(26,58,92,.30);
  }
  html.dark .total-bar { background: linear-gradient(135deg, #1a2d5e 0%, #0f1e3a 100%); }
  .total-bar .lbl { font-size: 13px; opacity: .85; }
  .total-bar .sub { font-size: 11px; opacity: .65; margin-top: 3px; }
  .total-bar .num { font-size: 22px; font-weight: 700; letter-spacing: -.5px; }

  /* ── Navegación ── */
  .nav-bar {
    display: flex; justify-content: space-between; align-items: center;
    padding-top: 24px; border-top: 1px solid var(--border); margin-top: 8px;
  }
  .btn-back {
    background: transparent; border: 1.5px solid var(--border);
    color: var(--text-2); border-radius: var(--radius-sm);
    padding: 10px 20px; font-size: 14px; font-weight: 500;
    cursor: pointer; transition: border-color .15s, background .15s; font-family: inherit;
  }
  .btn-back:hover { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); }
  .btn-next {
    background: var(--accent); color: #fff; border: none;
    border-radius: var(--radius-sm); padding: 10px 24px;
    font-size: 14px; font-weight: 600; cursor: pointer;
    transition: background .15s, transform .1s; font-family: inherit;
    display: flex; align-items: center; gap: 8px;
    box-shadow: 0 2px 8px rgba(107,130,255,.30);
  }
  .btn-next:hover { filter: brightness(1.1); }
  .btn-next:active { transform: scale(.97); }
  .btn-next.green { background: #16a34a; box-shadow: 0 2px 8px rgba(22,163,74,.30); }
  .btn-next.green:hover { background: #15803d; }

  /* ── Loader ── */
  #loader { display: none; flex-direction: column; align-items: center; justify-content: center; min-height: 300px; gap: 16px; }
  #loader.show { display: flex; }
  .spinner {
    width: 44px; height: 44px;
    border: 4px solid var(--accent-bg); border-top-color: var(--accent);
    border-radius: 50%; animation: spin .8s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }
  #loader p     { font-size: 15px; font-weight: 500; color: var(--accent); }
  #loader small { font-size: 12px; color: var(--text-2); }

  /* ── Éxito ── */
  #success { display: none; flex-direction: column; align-items: center; text-align: center; padding: 24px 0 12px; gap: 12px; }
  #success.show { display: flex; }
  .success-ico { font-size: 52px; }
  #success h2 { font-size: 20px; font-weight: 700; color: var(--accent); }
  #success p  { font-size: 13px; color: var(--text-2); max-width: 340px; }
  .btn-nuevo {
    margin-top: 8px; background: var(--accent-bg); color: var(--accent);
    border: none; border-radius: var(--radius-sm); padding: 10px 22px;
    font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
    transition: background .15s;
  }
  .btn-nuevo:hover { filter: brightness(.95); }

  /* ── Contador de cantidad ── */
  .qty-control {
    display: flex; align-items: center;
    border: 1px solid var(--border-md); border-radius: var(--radius-sm); overflow: hidden;
  }
  .qty-control button {
    width: 28px; height: 28px; border: none; background: var(--accent-bg);
    color: var(--accent); font-size: 16px; font-weight: 700;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background .12s; flex-shrink: 0; padding: 0; line-height: 1;
  }
  .qty-control button:hover { filter: brightness(.95); }
  .qty-control input[type=number] {
    border: none; border-left: 1px solid var(--border-md); border-right: 1px solid var(--border-md);
    border-radius: 0; text-align: center; font-weight: 600; color: var(--accent);
    background: var(--surface);
  }
  .qty-control input[type=number]::-webkit-inner-spin-button,
  .qty-control input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; }

  /* ── Filas de medida múltiple ── */
  .medida-row {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 7px 10px;
  }
  .medida-row select {
    font-size: 13px; padding: 4px 8px;
    border: 1px solid var(--border-md); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--accent); font-weight: 500; margin-bottom: 0;
  }
  .medida-row .medida-sep { font-size: 11px; color: var(--text-3); }
  .medida-row .btn-rm-medida {
    width: 24px; height: 24px; border-radius: 50%;
    border: 1px solid rgba(239,68,68,.35); background: rgba(239,68,68,.08);
    color: #ef4444; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; margin-left: auto; flex-shrink: 0; transition: background .12s;
  }
  .medida-row .btn-rm-medida:hover { background: rgba(239,68,68,.18); }
  .btn-add-medida {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 12px; color: var(--accent); background: var(--accent-bg);
    border: 1px dashed var(--accent); border-radius: var(--radius-sm);
    padding: 5px 12px; cursor: pointer; transition: background .12s; font-family: inherit;
  }
  .btn-add-medida:hover { filter: brightness(.95); }

  /* ── Preview de trabajos ── */
  #trabajo-preview {
    background: var(--surface-2);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 14px 16px; font-size: 13px; color: var(--text-2); line-height: 1.6;
  }

  /* ── Tarjeta de presupuesto (wrapper para historial expandible) ── */
  .prs-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 8px;
    background: var(--surface);
    transition: box-shadow .15s;
  }
  .prs-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
  .prs-card .adm-item {
    border: none !important;
    border-radius: 0 !important;
    margin-bottom: 0 !important;
  }

  /* ── Panel de historial ── */
  .prs-historial-panel {
    border-top: 1px solid var(--border);
    padding: 16px 20px 12px;
    background: var(--surface-2);
    animation: fadeUp .2s ease;
  }
  .prs-historial-loading,
  .prs-historial-vacio {
    font-size: 13px; color: var(--text-3);
    display: flex; align-items: center; gap: 8px;
    padding: 4px 0;
  }

  /* ── Timeline horizontal ── */
  .prs-timeline {
    display: flex; align-items: flex-start;
    overflow-x: auto; padding: 8px 0 4px;
    gap: 0;
  }

  .prs-tl-item {
    display: flex; flex-direction: column; align-items: center;
    position: relative; min-width: 110px; flex: 1;
  }

  /* línea horizontal entre items */
  .prs-tl-item:not(.prs-tl-ultimo)::after {
    content: '';
    position: absolute;
    top: 14px; left: 50%; right: 0;
    width: calc(100% - 30px / 2);
    height: 2px; background: var(--border);
    transform: translateX(15px);
    z-index: 0;
  }

  .prs-tl-linea { display: none; }
  .prs-tl-linea-hidden { display: none; }

  .prs-tl-dot {
    width: 30px; height: 30px; border-radius: 50%;
    border: 2px solid; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    z-index: 1; position: relative; background: var(--surface);
  }

  .prs-tl-content {
    text-align: center; margin-top: 8px; padding: 0 6px;
  }

  .prs-tl-estado {
    font-size: 12px; font-weight: 600; line-height: 1.3;
  }
  .prs-tl-meta {
    font-size: 11px; color: var(--text-3); margin-top: 2px; line-height: 1.4;
  }
