* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f1f5f9; color: #1e293b; min-height: 100vh; }
.app { max-width: 1100px; margin: 0 auto; padding: 28px 24px; }

/* Header */
.header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.header-left { display: flex; align-items: center; gap: 14px; }
.header-icon { width: 44px; height: 44px; background: #0f172a; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.header-text h1 { font-size: 20px; font-weight: 700; color: #0f172a; letter-spacing: -0.3px; }
.header-text p { font-size: 13px; color: #64748b; margin-top: 1px; }
.mode-toggle { display: flex; background: white; border-radius: 8px; padding: 3px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.mode-btn { padding: 8px 16px; border: none; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; background: transparent; color: #64748b; transition: all 0.15s; }
.mode-btn.active { background: #0f172a; color: white; }
.user-menu { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #475569; }
.user-menu span { font-weight: 600; color: #0f172a; }

/* Main grid */
.main-grid { display: grid; grid-template-columns: 1fr 360px; gap: 20px; align-items: start; }

/* Panel */
.panel { background: white; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); overflow: hidden; }
.panel-header { padding: 18px 20px 0; }
.panel-header h2 { font-size: 15px; font-weight: 700; color: #0f172a; }
.panel-header h3 { font-size: 15px; font-weight: 700; color: #0f172a; }
.panel-header p { font-size: 12px; color: #64748b; margin-top: 2px; }
.panel-body { padding: 16px 20px 20px; }

/* Field */
.field { margin-bottom: 16px; }
.field-label { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.field-label span { font-size: 11px; font-weight: 700; color: #334155; text-transform: uppercase; letter-spacing: 0.5px; }
.field-label .tag { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 4px; }
.tag-manual { background: #dbeafe; color: #1e40af; }
.tag-auto { background: #d1fae5; color: #065f46; }
.field input, .field select, .field textarea { width: 100%; padding: 10px 12px; border: 2px solid #e2e8f0; border-radius: 8px; font-size: 14px; font-family: inherit; transition: all 0.15s; background: white; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.08); }
.field input[readonly] { background: #f8fafc; color: #64748b; border-color: #e2e8f0; }

/* Quick select */
.quick-select { display: flex; gap: 6px; flex-wrap: wrap; }
.quick-btn { padding: 7px 14px; border: 1.5px solid #e2e8f0; border-radius: 7px; background: white; font-size: 13px; font-weight: 500; color: #475569; cursor: pointer; transition: all 0.15s; }
.quick-btn:hover { border-color: #3b82f6; color: #3b82f6; }
.quick-btn.active { background: #0f172a; color: white; border-color: #0f172a; }

/* Ticket list (batch) */
.ticket-list { margin-top: 12px; }
.ticket-list-header { display: grid; grid-template-columns: 40px 1fr 80px 40px; gap: 8px; padding: 8px 12px; font-size: 11px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px; background: #f8fafc; border-radius: 8px 8px 0 0; }
.ticket-row { display: grid; grid-template-columns: 40px 1fr 80px 40px; gap: 8px; align-items: center; padding: 8px 12px; border-bottom: 1px solid #f1f5f9; background: white; }
.ticket-row:last-child { border-bottom: none; border-radius: 0 0 8px 8px; }
.ticket-row:hover { background: #fafafa; }
.ticket-num { font-size: 12px; font-weight: 600; color: #94a3b8; text-align: center; }
.ticket-row input { padding: 7px 10px; border: 1.5px solid #e2e8f0; border-radius: 6px; font-size: 13px; font-family: inherit; width: 100%; }
.ticket-row input:focus { outline: none; border-color: #3b82f6; }
.ticket-delete { width: 32px; height: 32px; border: none; background: #fef2f2; color: #ef4444; border-radius: 6px; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; }
.ticket-delete:hover { background: #fee2e2; }

.add-row-btn { width: 100%; padding: 10px; margin-top: 8px; border: 2px dashed #cbd5e1; border-radius: 8px; background: #f8fafc; color: #64748b; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.add-row-btn:hover { border-color: #3b82f6; color: #3b82f6; background: #eff6ff; }

/* Paste area */
.paste-area { margin-top: 12px; }
.paste-box { width: 100%; min-height: 80px; padding: 12px; border: 2px dashed #cbd5e1; border-radius: 8px; background: #f8fafc; font-size: 13px; font-family: inherit; resize: vertical; }
.paste-box:focus { outline: none; border-color: #3b82f6; background: white; }
.paste-hint { font-size: 12px; color: #94a3b8; margin-top: 6px; }

/* Buttons */
.btn { padding: 11px 18px; border: none; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.15s; font-family: inherit; }
.btn-primary { background: #0f172a; color: white; }
.btn-primary:hover { background: #1e293b; }
.btn-primary:disabled { background: #cbd5e1; cursor: not-allowed; }
.btn-success { background: #10b981; color: white; }
.btn-success:hover { background: #059669; }
.btn-success:disabled { background: #cbd5e1; cursor: not-allowed; }

/* Preview panel */
.preview-panel { position: sticky; top: 20px; }
.preview-card { background: white; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); overflow: hidden; margin-bottom: 12px; }
.preview-card-header { background: #0f172a; color: white; padding: 12px 16px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.preview-card-body { padding: 14px 16px; }
.preview-item { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid #f1f5f9; }
.preview-item:last-child { border-bottom: none; }
.preview-label { font-size: 12px; color: #64748b; }
.preview-value { font-size: 12px; font-weight: 600; color: #0f172a; text-align: right; max-width: 60%; }
.preview-value.code { font-family: 'SF Mono', monospace; color: #3b82f6; }
.preview-value.auto { color: #059669; }

.ticket-preview-item { padding: 10px 0; border-bottom: 1px solid #f1f5f9; }
.ticket-preview-item:last-child { border-bottom: none; }
.ticket-preview-code { font-family: 'SF Mono', monospace; font-size: 13px; font-weight: 700; color: #3b82f6; }
.ticket-preview-meta { font-size: 11px; color: #64748b; margin-top: 2px; }

/* Proceso */
#procesoPanel { border-left: 4px solid #3b82f6; }
#procesoTitulo { font-size: 15px; font-weight: 700; color: #0f172a; }

/* Historial */
.historial-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f1f5f9; font-size: 12px; }
.historial-item:last-child { border-bottom: none; }
.historial-estado { font-weight: 700; min-width: 80px; }
.historial-estado.OK { color: #059669; }
.historial-estado.ERROR { color: #dc2626; }
.historial-estado.PENDIENTE { color: #d97706; }

.modo-prueba-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: #fefce8;
  border: 1px solid #fde047;
  border-radius: 8px;
}

.error-msg {
  background: #fef2f2;
  color: #991b1b;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
}

/* Utilidades */
.hidden { display: none !important; }

@media (max-width: 768px) {
  .app { padding: 12px; }
  .header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .main-grid { grid-template-columns: 1fr; }
  .preview-panel { position: static; }
  .ticket-list-header, .ticket-row { grid-template-columns: 30px 1fr 70px 36px; }
}
