* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, 'Helvetica Neue', Arial, 'Noto Sans', 'Apple Color Emoji', 'Segoe UI Emoji';
  background: #f6f7fb;
  color: #222;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  background: #0f62fe;
  color: #fff;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  height: 40px;
  width: auto;
  filter: brightness(0) invert(1); /* Makes the logo white */
}

.header-title h1 { 
  margin: 0; 
  font-size: 20px; 
  line-height: 1.2;
}

.subtitle {
  margin: 0;
  font-size: 14px;
  opacity: 0.8;
  font-weight: normal;
}

.header-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.tooltip { cursor: help; background: #fff2; padding: 2px 8px; border-radius: 12px; }

.dollar-rate {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.1);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.dollar-label {
  font-size: 14px;
  opacity: 0.9;
}

.dollar-value {
  font-weight: 600;
  font-size: 16px;
  color: #fff;
}

.dollar-value.loaded {
  color: #4ade80;
}

.dollar-value.error {
  color: #f87171;
}

@media (max-width: 640px) {
  .app-header {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
  
  .header-info {
    justify-content: center;
  }
  
  .dollar-rate {
    font-size: 14px;
  }
}

.container {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 16px;
}

.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  padding: 16px 18px;
  margin-bottom: 18px;
}
.card h2 { margin-top: 0; font-size: 18px; }

/* Overlay de acesso restrito */
.access-gate {
  position: fixed;
  inset: 0;
  background: rgba(17,24,39,0.55);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  z-index: 9999;
}
.access-modal {
  width: min(520px, 92vw);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.18);
  padding: 18px;
  text-align: center;
}
.access-controls { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; margin-top: 8px; }
.access-controls input { padding: 10px 12px; border: 1px solid #cdd1d6; border-radius: 8px; font-size: 14px; }
@media (max-width: 520px) { .access-controls { grid-template-columns: 1fr; } }



.form-row { display: grid; grid-template-columns: 220px 1fr; align-items: center; gap: 8px; margin: 10px 0; }
.form-row label { font-weight: 600; }
.form-row input, .form-row select {
  padding: 8px 10px;
  border: 1px solid #cdd1d6;
  border-radius: 8px;
  font-size: 14px;
}
.form-row.full-width { grid-template-columns: 220px 1fr; }

.produtos-list { display: grid; gap: 8px; }
.prod-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.prod-row {
  display: grid;
  grid-template-columns: 2fr 0.8fr 1fr auto;
  gap: 8px;
  align-items: center;
}
.prod-row input[type="text"], .prod-row input[type="number"] {
  width: 100%;
}
/* override remover button to be clear */
.prod-row .prod-remove {
  background: #c0392b !important;
  color: #fff !important;
  border: none !important;
  padding: 6px 10px !important;
  border-radius: 4px !important;
}
/* when only one row, collapse the last column */
.prod-row.no-remove {
  grid-template-columns: 2fr 0.8fr 1fr !important;
}
.prod-row .error {
  grid-column: 1 / -1;
  color: #c0392b;
  font-size: 12px;
}
/* small visual tweaks */
.section h2 { margin-top: 16px; }
.result-group h3 { margin-top: 12px; }
.prod-row .prod-remove { border: 1px solid #cdd1d6; background: #fff; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.prod-actions { margin-top: 6px; }

/* pequenas correções visuais */
.small { font-size: 12px; }
.hint { color: #5f6b7a; }
.error { color: #d93025; font-size: 12px; min-height: 16px; }
.muted { color: #5f6b7a; }

.actions { display: flex; gap: 8px; margin-top: 8px; }
button { padding: 8px 12px; border-radius: 8px; border: 1px solid #cdd1d6; background: #fff; cursor: pointer; }
button.primary { background: #0f62fe; color: #fff; border-color: #0f62fe; }
button.danger { background: #f44336; color: #fff; border-color: #f44336; }
button:disabled { opacity: 0.6; cursor: not-allowed; }

.status { margin-bottom: 8px; color: #5f6b7a; }
.info { margin-bottom: 12px; font-weight: 600; }
.manual-fx { display: grid; grid-template-columns: 220px 1fr 1fr 1fr; gap: 8px; align-items: center; }
.manual-fx input { width: 100%; }

.resultado { line-height: 1.5; }
.result-group { margin-bottom: 14px; }
.result-group h3 { margin: 6px 0; font-size: 15px; }
.result-row { display: grid; grid-template-columns: 300px 1fr; gap: 8px; }
.result-row .label { color: #5f6b7a; }
.result-row .value { font-weight: 600; }

.app-footer { text-align: center; padding: 18px; color: #5f6b7a; }

/* Estilos para o modal de resultado */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: #ffffff;
    margin: 5% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover {
    color: #f1f1f1;
}

.modal-body {
    padding: 20px;
}

.result-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    border-left: 4px solid #667eea;
}

.result-section h3 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 1.1rem;
}

.result-section p {
    margin: 5px 0;
    color: #555;
}

.result-section.products {
    border-left-color: #28a745;
}

.result-section.taxes {
    border-left-color: #ffc107;
}

.result-section.final-total {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-left: none;
    text-align: center;
}

.result-section.final-total h3,
.result-section.final-total p {
    color: white;
}

.result-section.unit-value {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border-left: none;
    text-align: center;
}

.result-section.unit-value h3,
.result-section.unit-value p {
    color: white;
}

.unit-cost {
    font-size: 1.2rem;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.2);
    padding: 10px;
    border-radius: 6px;
    margin-top: 10px;
}

.subtotal {
    font-weight: bold;
    background: rgba(0, 0, 0, 0.05);
    padding: 8px;
    border-radius: 4px;
    margin-top: 8px;
    border-top: 1px solid #ddd;
}

.total-final {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 10px 0;
}

.source-info {
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
}
