/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  min-width: 360px;
  min-height: 100vh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #F8FAFC;
  color: #0F172A;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ===== APP CONTAINER ===== */
.app {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  position: relative;
}

/* ===== HEADER ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 8px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #4F46E5, #7C3AED);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.header h1 {
  font-size: 22px;
  font-weight: 700;
  color: #0F172A;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.header-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  color: #4F46E5;
  background: #EEF2FF;
  padding: 2px 10px;
  border-radius: 20px;
  letter-spacing: 0.2px;
}

/* ===== CARDS ===== */
.card {
  background: #FFFFFF;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
  border: 1px solid #E2E8F0;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  animation: fadeSlideIn 0.25s ease-out;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.card-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: #0F172A;
  flex: 1;
}

.card-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-icon.blue   { background: #EEF2FF; color: #4F46E5; }
.card-icon.green  { background: #F0FDF4; color: #16A34A; }
.card-icon.purple { background: #FAF5FF; color: #9333EA; }
.card-icon.amber  { background: #FFFBEB; color: #D97706; }

/* ===== SYNC BUTTON ===== */
.sync-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: #EEF2FF;
  color: #4F46E5;
  border: 1px solid #C7D2FE;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sync-btn:hover {
  background: #E0E7FF;
  border-color: #A5B4FC;
}

.sync-btn:active {
  transform: scale(0.96);
}

.sync-btn.loading {
  opacity: 0.7;
  cursor: wait;
}

.sync-btn.loading svg {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ===== PROCESS GRID ===== */
.process-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.process-card {
  position: relative;
  cursor: pointer;
  display: block;
}

.process-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.process-card-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: 12px;
  border: 2px solid #E2E8F0;
  background: #FFFFFF;
  transition: all 0.2s ease;
  text-align: center;
}

.process-card-inner:hover {
  border-color: #C7D2FE;
  background: #F8FAFF;
}

.process-card input[type="radio"]:checked + .process-card-inner {
  border-color: #4F46E5;
  background: #EEF2FF;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.process-emoji {
  font-size: 22px;
  line-height: 1;
}

.process-name {
  font-size: 12px;
  font-weight: 500;
  color: #334155;
  line-height: 1.3;
}

.process-hint {
  font-size: 9px;
  font-weight: 400;
  color: #94A3B8;
  line-height: 1;
  margin-top: 2px;
}

.process-card input[type="radio"]:checked + .process-card-inner .process-name {
  color: #4F46E5;
  font-weight: 600;
}

.check-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #CBD5E1;
  background: white;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.process-card input[type="radio"]:checked ~ .check-dot {
  border-color: #4F46E5;
  background: #4F46E5;
}

.process-card input[type="radio"]:checked ~ .check-dot::after {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: white;
}

/* ===== INPUT FIELDS ===== */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-field {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #E2E8F0;
  border-radius: 10px;
  font-size: 13px;
  font-family: inherit;
  color: #0F172A;
  background: #FFFFFF;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

.input-field::placeholder {
  color: #94A3B8;
}

.input-field:focus {
  border-color: #4F46E5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.input-hint {
  font-size: 12px;
  color: #64748B;
  padding-left: 2px;
}

/* ===== MODERN SELECT DROPDOWN ===== */
.modern-select {
  position: relative;
  width: 100%;
}

.modern-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #FFFFFF;
  border: 1.5px solid #E2E8F0;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modern-select-trigger:hover {
  border-color: #C7D2FE;
  background: #FAFAFF;
}

.modern-select.open .modern-select-trigger {
  border-color: #4F46E5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.modern-select-value {
  font-size: 13px;
  color: #94A3B8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.modern-select-value.selected {
  color: #0F172A;
  font-weight: 500;
}

.modern-select-arrow {
  color: #94A3B8;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.modern-select.open .modern-select-arrow {
  transform: rotate(180deg);
  color: #4F46E5;
}

.modern-select-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #FFFFFF;
  border: 1.5px solid #4F46E5;
  border-top: none;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  z-index: 100;
  display: none;
  max-height: 280px;
  overflow: hidden;
}

.modern-select.open .modern-select-dropdown {
  display: block;
  animation: dropdownSlide 0.2s ease;
}

@keyframes dropdownSlide {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.modern-select-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #E2E8F0;
  background: #F8FAFC;
}

.modern-select-search svg {
  color: #94A3B8;
  flex-shrink: 0;
}

.modern-select-search input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 13px;
  color: #0F172A;
  outline: none;
  font-family: inherit;
}

.modern-select-search input::placeholder {
  color: #94A3B8;
}

.modern-select-options {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  max-height: 180px;
  overflow-y: auto;
}

.modern-select-options::-webkit-scrollbar {
  width: 6px;
}

.modern-select-options::-webkit-scrollbar-track {
  background: #F1F5F9;
}

.modern-select-options::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 3px;
}

.modern-select-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.modern-select-option:hover {
  background: #EEF2FF;
}

.modern-select-option.active {
  background: #4F46E5;
  color: white;
}

.modern-select-option-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #E2E8F0;
  border-radius: 6px;
  font-size: 14px;
  flex-shrink: 0;
}

.modern-select-option.active .modern-select-option-icon {
  background: rgba(255, 255, 255, 0.2);
}

.modern-select-option-text {
  flex: 1;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modern-select-option-badge {
  font-size: 10px;
  background: #FEF3C7;
  color: #D97706;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 500;
}

.modern-select-option.active .modern-select-option-badge {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.modern-select-empty {
  padding: 20px;
  text-align: center;
  color: #94A3B8;
  font-size: 13px;
}

.modern-select-footer {
  border-top: 1px solid #E2E8F0;
  padding: 8px;
}

.modern-select-manual {
  width: 100%;
  padding: 8px 12px;
  background: #F8FAFC;
  border: 1px dashed #CBD5E1;
  border-radius: 6px;
  font-size: 12px;
  color: #64748B;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.modern-select-manual:hover {
  background: #EEF2FF;
  border-color: #4F46E5;
  color: #4F46E5;
}

/* ===== UPLOAD ZONE ===== */
.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed #CBD5E1;
  border-radius: 12px;
  padding: 24px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #FAFBFC;
}

.upload-zone:hover {
  border-color: #4F46E5;
  background: #F8FAFF;
}

.upload-zone.has-files {
  border-color: #16A34A;
  background: #F0FDF4;
  padding: 12px 16px;
}

.upload-zone.drag-over {
  border-color: #4F46E5;
  border-width: 2px;
  background: #EEF2FF;
  transform: scale(1.02);
}

.upload-zone input[type="file"] {
  display: none;
}

.upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

.upload-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #EEF2FF;
  color: #4F46E5;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.upload-text {
  font-size: 13px;
  font-weight: 500;
  color: #334155;
}

.upload-hint {
  font-size: 11px;
  color: #94A3B8;
}

/* ===== FILE COUNT & LIST ===== */
.file-count {
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  color: #16A34A;
  margin-top: 10px;
  padding: 6px 12px;
  background: #F0FDF4;
  border-radius: 8px;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #F8FAFC;
  border-radius: 8px;
  border: 1px solid #E2E8F0;
  flex-wrap: wrap;
}

.file-name {
  flex: 1;
  font-size: 12px;
  color: #334155;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.file-row .machine-input,
.file-row .contrato-input,
.file-row .estoque-maquina-input {
  width: 140px;
  padding: 6px 10px;
  border: 1.5px solid #E2E8F0;
  border-radius: 8px;
  font-size: 11px;
  font-family: inherit;
  color: #0F172A;
  background: white;
  outline: none;
  flex-shrink: 0;
  transition: border-color 0.2s;
}

.file-row .machine-input:focus,
.file-row .contrato-input:focus,
.file-row .estoque-maquina-input:focus {
  border-color: #4F46E5;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

.file-row .machine-input::placeholder,
.file-row .contrato-input::placeholder,
.file-row .estoque-maquina-input::placeholder {
  color: #94A3B8;
}

.file-row .contrato-input {
  border-color: #93C5FD;
}

.file-row .estoque-maquina-input {
  border-color: #A78BFA;
}

/* Checkbox Serviço */
.servico-check-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #475569;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  user-select: none;
}

.servico-check {
  width: 14px;
  height: 14px;
  accent-color: #7C3AED;
  cursor: pointer;
  margin: 0;
}

/* ===== EXECUTE BUTTON ===== */
.btn-execute {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 32px);
  margin: 16px;
  height: 48px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  color: white;
  background: linear-gradient(135deg, #4F46E5, #6366F1);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
  letter-spacing: 0.2px;
  box-sizing: border-box;
}

.btn-execute:hover {
  background: linear-gradient(135deg, #4338CA, #4F46E5);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
  transform: translateY(-1px);
}

.btn-execute:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.btn-execute:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-execute .btn-icon {
  flex-shrink: 0;
}

/* ===== STATUS AREA ===== */
.status-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.status-area::-webkit-scrollbar {
  width: 4px;
}

.status-area::-webkit-scrollbar-track {
  background: transparent;
}

.status-area::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 4px;
}

.status-message {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  animation: fadeSlideIn 0.2s ease-out;
}

.status-message.loading {
  background: #EFF6FF;
  color: #1D4ED8;
  border-left: 3px solid #3B82F6;
}

.status-message.success {
  background: #F0FDF4;
  color: #15803D;
  border-left: 3px solid #22C55E;
}

.status-message.error {
  background: #FEF2F2;
  color: #B91C1C;
  border-left: 3px solid #EF4444;
}

.status-message.warning {
  background: #FFFBEB;
  color: #B45309;
  border-left: 3px solid #F59E0B;
}

/* ===== RESULTADO ===== */
.resultado {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  padding: 16px;
  animation: fadeSlideIn 0.3s ease-out;
}

.resultado h3 {
  font-size: 14px;
  font-weight: 600;
  color: #0F172A;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.resumo {
  background: #F8FAFC;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid #E2E8F0;
}

.resumo p {
  margin: 3px 0;
  font-size: 13px;
  color: #334155;
}

.resumo strong {
  color: #0F172A;
  font-weight: 600;
}

.docs-lista {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.doc-item {
  background: #FAFBFC;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  padding: 10px 14px;
  transition: box-shadow 0.15s ease;
}

.doc-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.doc-item.sucesso {
  border-left: 3px solid #22C55E;
}

.doc-item.erro_erp,
.doc-item.erro_extracao,
.doc-item.erro_fatal {
  border-left: 3px solid #EF4444;
}

.doc-item.parcial {
  border-left: 3px solid #F59E0B;
}

.doc-item.conta-nao-encontrada {
  border-left: 3px solid #8B5CF6;
  background: #FEFBFF;
}

.conta-alerta {
  margin-top: 8px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #FEF3C7, #FDE68A20);
  border: 1px solid #F59E0B40;
  border-radius: 8px;
}

.conta-alerta-titulo {
  font-size: 12px !important;
  font-weight: 600 !important;
  color: #92400E !important;
  margin-bottom: 4px !important;
}

.conta-alerta-msg {
  font-size: 11px !important;
  color: #78716C !important;
  margin-bottom: 6px !important;
}

.conta-sugestao {
  font-size: 12px !important;
  color: #4F46E5 !important;
  padding: 4px 8px;
  background: white;
  border-radius: 6px;
  border: 1px solid #E0E7FF;
  margin-top: 4px !important;
}

.doc-item p {
  margin: 2px 0;
  font-size: 12px;
  color: #64748B;
}

.doc-item p:first-child {
  color: #0F172A;
}

.doc-item strong {
  font-weight: 600;
}

/* ===== PROCESSING OVERLAY ===== */
.processing-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.processing-card {
  background: white;
  border-radius: 16px;
  padding: 32px 40px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  max-width: 320px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #E2E8F0;
  border-top-color: #4F46E5;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.processing-title {
  font-size: 16px;
  font-weight: 600;
  color: #0F172A;
  margin-bottom: 6px;
}

.processing-subtitle {
  font-size: 13px;
  color: #64748B;
  line-height: 1.4;
}

/* ===== UTILITY ===== */
.hidden {
  display: none !important;
}

/* ===== LOGIN SCREEN ===== */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 40px);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 320px;
  background: white;
  border-radius: 16px;
  padding: 32px 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.login-header {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #4F46E5, #7C3AED);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: white;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: #0F172A;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 13px;
  color: #64748B;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-field label {
  font-size: 13px;
  font-weight: 500;
  color: #475569;
}

.login-field input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #E2E8F0;
  border-radius: 10px;
  font-size: 14px;
  transition: all 0.2s;
  background: #F8FAFC;
}

.login-field input:focus {
  outline: none;
  border-color: #4F46E5;
  background: white;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.login-field input::placeholder {
  color: #94A3B8;
}

.login-error {
  padding: 10px 12px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: 8px;
  color: #DC2626;
  font-size: 13px;
  text-align: center;
}

.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #4F46E5, #7C3AED);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
}

.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.login-btn:active {
  transform: translateY(0);
}

.login-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

/* ===== HEADER ACTIONS ===== */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.header-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #F1F5F9;
  border: none;
  border-radius: 10px;
  color: #64748B;
  cursor: pointer;
  transition: all 0.2s;
}

.header-btn:hover {
  background: #EEF2FF;
  color: #4F46E5;
}

.header-btn.logout-btn:hover {
  background: #FEE2E2;
  color: #DC2626;
}

/* ===== APP FOOTER ===== */
.app-footer {
  display: flex;
  justify-content: center;
  padding: 12px 0;
  margin-top: 8px;
  border-top: 1px solid #E2E8F0;
}

.config-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  color: #64748B;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.config-btn:hover {
  background: #EEF2FF;
  border-color: #C7D2FE;
  color: #4F46E5;
}

.config-btn:active {
  transform: scale(0.98);
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: #FFFFFF;
  border-radius: 16px;
  width: 90%;
  max-width: 340px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.25s ease;
  overflow: hidden;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #E2E8F0;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: #0F172A;
}

.modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #F1F5F9;
  border: none;
  border-radius: 6px;
  color: #64748B;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
}

.modal-close:hover {
  background: #FEE2E2;
  color: #DC2626;
}

.modal-body {
  padding: 20px;
}

.modal-description {
  font-size: 13px;
  color: #64748B;
  margin-bottom: 20px;
  text-align: center;
}

.config-section {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #F1F5F9;
}

.config-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.config-section h4 {
  font-size: 14px;
  font-weight: 600;
  color: #0F172A;
  margin-bottom: 6px;
}

.config-info {
  font-size: 12px;
  color: #94A3B8;
  margin-bottom: 10px;
}

.config-info.synced {
  color: #16A34A;
}

.config-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: linear-gradient(135deg, #4F46E5, #7C3AED);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.config-action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.config-action-btn:active {
  transform: translateY(0);
}

.config-action-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.config-action-btn.loading svg {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.config-clear-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 10px 16px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: 8px;
  color: #DC2626;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.config-clear-btn:hover {
  background: #FEE2E2;
  border-color: #FCA5A5;
}

/* Modal de configurações maior */
.config-modal-large {
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
}

/* Header da seção com botão de adicionar */
.config-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.config-section-header h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #1F2937;
}

/* Botão de adicionar (+) */
.config-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: #E8F5E9;
  border: 1px solid #81C784;
  border-radius: 6px;
  color: #2E7D32;
  cursor: pointer;
  transition: all 0.2s ease;
}

.config-add-btn:hover {
  background: #C8E6C9;
  border-color: #66BB6A;
  transform: scale(1.05);
}

/* Lista de itens */
.config-list {
  max-height: 150px;
  overflow-y: auto;
  margin-bottom: 10px;
  border-radius: 8px;
}

.config-list::-webkit-scrollbar {
  width: 6px;
}

.config-list::-webkit-scrollbar-track {
  background: #F3F4F6;
  border-radius: 3px;
}

.config-list::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 3px;
}

/* Item individual da lista */
.config-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #F9FAFB;
  border: 1px solid #E5E7EB;
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 13px;
  color: #374151;
  transition: all 0.15s ease;
}

.config-list-item:hover {
  background: #F3F4F6;
  border-color: #D1D5DB;
}

.config-list-item:last-child {
  margin-bottom: 0;
}

.config-list-item-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 8px;
}

/* Botões de ação do item */
.config-item-actions {
  display: flex;
  gap: 4px;
}

.config-item-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  opacity: 0.7;
}

.config-item-btn:hover {
  opacity: 1;
}

.config-item-edit {
  background: #E0E7FF;
  color: #4338CA;
}

.config-item-edit:hover {
  background: #C7D2FE;
}

.config-item-delete {
  background: #FEE2E2;
  color: #DC2626;
}

.config-item-delete:hover {
  background: #FECACA;
}

/* Formulário de adicionar/editar */
.config-add-form {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  padding: 8px;
  background: #F0F9FF;
  border: 1px solid #BAE6FD;
  border-radius: 8px;
}

.config-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #D1D5DB;
  border-radius: 6px;
  font-size: 13px;
  color: #1F2937;
  outline: none;
  transition: border-color 0.2s ease;
}

.config-input:focus {
  border-color: #6366F1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.config-confirm-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: #10B981;
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.15s ease;
}

.config-confirm-btn:hover {
  background: #059669;
}

.config-cancel-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: #9CA3AF;
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.15s ease;
}

.config-cancel-btn:hover {
  background: #6B7280;
}

/* Lista vazia */
.config-list-empty {
  padding: 12px;
  text-align: center;
  color: #9CA3AF;
  font-size: 12px;
  font-style: italic;
}

/* ================================
   PWA MOBILE STYLES
   ================================ */

/* Mobile Capture Options */
.mobile-capture-options {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 16px;
}

.capture-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  background: linear-gradient(145deg, #1E293B 0%, #0F172A 100%);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 16px;
  color: #E2E8F0;
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 1;
  max-width: 100px;
}

.capture-btn:hover, .capture-btn:active {
  border-color: rgba(99, 102, 241, 0.6);
  background: linear-gradient(145deg, #2D3B50 0%, #1E293B 100%);
  transform: scale(1.02);
}

.capture-btn svg {
  color: #6366F1;
}

.capture-btn span {
  font-size: 11px;
  font-weight: 500;
}

.camera-btn:hover svg, .camera-btn:active svg { color: #22C55E; }
.gallery-btn:hover svg, .gallery-btn:active svg { color: #F59E0B; }
.file-btn:hover svg, .file-btn:active svg { color: #3B82F6; }

/* Install Banner */
.install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%);
  color: white;
  z-index: 10000;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

.install-banner p {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
}

.install-btn {
  padding: 8px 16px;
  background: white;
  color: #4F46E5;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.dismiss-btn {
  background: transparent;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 0 8px;
  opacity: 0.8;
}

/* Desktop only class */
.desktop-only {
  display: block;
}

/* ================================
   RESPONSIVE STYLES
   ================================ */

@media (max-width: 768px) {
  /* App container */
  .app {
    width: 100vw;
    min-height: 100vh;
    max-width: 100%;
  }
  
  /* Header */
  .header {
    padding: 12px 16px;
    border-radius: 0;
  }
  
  .header h1 {
    font-size: 18px;
  }
  
  /* Cards */
  .card {
    margin: 8px;
    padding: 16px;
    border-radius: 12px;
  }
  
  .card-header h2 {
    font-size: 14px;
  }
  
  /* Process Grid - 2 columns on mobile */
  .process-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  
  .process-card {
    padding: 12px 8px;
  }
  
  .process-name {
    font-size: 11px;
  }
  
  .process-hint {
    font-size: 9px;
  }
  
  .process-emoji {
    font-size: 20px;
  }
  
  /* Inputs */
  .input-field,
  .config-input {
    font-size: 16px; /* Prevent zoom on iOS */
    padding: 14px 12px;
  }
  
  /* Execute Button */
  .btn-execute {
    margin: 16px;
    padding: 16px;
    font-size: 16px;
    border-radius: 12px;
    width: calc(100% - 32px);
    box-sizing: border-box;
  }
  
  /* Status area */
  .status-area {
    margin: 8px;
    max-height: 150px;
  }
  
  /* Upload zone */
  .upload-zone {
    padding: 24px 16px;
  }
  
  .upload-text {
    font-size: 14px;
  }
  
  /* File list */
  .file-item {
    padding: 10px 12px;
    font-size: 13px;
  }
  
  /* Modal */
  .modal-card {
    margin: 8px;
    max-height: 90vh;
    width: calc(100% - 16px);
    border-radius: 16px;
  }
  
  .modal-body {
    padding: 16px;
    max-height: calc(90vh - 100px);
  }
  
  /* Processing overlay */
  .processing-card {
    margin: 20px;
    padding: 30px 20px;
  }
  
  /* Modern select dropdown - full width on mobile */
  .modern-select-dropdown {
    position: fixed;
    left: 8px;
    right: 8px;
    top: auto;
    bottom: 60px;
    max-height: 60vh;
  }
  
  /* Login */
  .login-card {
    margin: 16px;
    padding: 32px 24px;
    width: calc(100% - 32px);
    max-width: 400px;
  }
  
  .login-title {
    font-size: 24px;
  }
}

/* Very small screens */
@media (max-width: 380px) {
  .process-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
  
  .process-card {
    padding: 10px 6px;
  }
  
  .process-name {
    font-size: 10px;
  }
  
  .mobile-capture-options {
    gap: 8px;
  }
  
  .capture-btn {
    padding: 16px 12px;
  }
}

/* Safe area for notched phones */
@supports (padding-top: env(safe-area-inset-top)) {
  .app {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  
  .install-banner {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

/* Capture count badge */
.capture-count {
  position: absolute;
  top: -8px;
  right: -8px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
  min-width: 20px;
  text-align: center;
}

.capture-btn {
  position: relative;
}
