/* ─── Variables ─────────────────────────────────────────────── */
:root {
  --blue:        #1B4F72;
  --blue-mid:    #2471A3;
  --blue-light:  #D6EAF8;
  --blue-xlight: #EBF5FB;
  --green:       #1E8449;
  --green-light: #D5F5E3;
  --red:         #C0392B;
  --red-light:   #FADBD8;
  --yellow:      #D68910;
  --yellow-light:#FEF9E7;
  --gray-100:    #F8F9FA;
  --gray-200:    #E9ECEF;
  --gray-300:    #DEE2E6;
  --gray-400:    #CED4DA;
  --gray-500:    #ADB5BD;
  --gray-600:    #6C757D;
  --gray-700:    #495057;
  --gray-800:    #343A40;
  --white:       #FFFFFF;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:   0 4px 12px rgba(0,0,0,.1),  0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:   0 10px 30px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.06);
  --radius:      12px;
  --radius-sm:   8px;
  --transition:  0.2s ease;
  --font:        'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ─── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}

/* ─── Header ────────────────────────────────────────────────── */
.site-header {
  background: linear-gradient(135deg, var(--blue) 0%, #154360 100%);
  padding: 1.5rem 2rem;
  box-shadow: var(--shadow-md);
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.header-icon {
  width: 48px; height: 48px;
  background: rgba(255,255,255,.15);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.header-icon svg { width: 26px; height: 26px; stroke: #fff; }
.site-header h1 { font-size: 1.5rem; font-weight: 700; color: #fff; letter-spacing: -.3px; }
.site-header p  { font-size: .9rem;  color: rgba(255,255,255,.7); margin-top: 2px; }

/* ─── Main container ────────────────────────────────────────── */
.main-container {
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 1.5rem 5rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ─── Card ──────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.5rem;
}
.card-header h2 { font-size: 1.05rem; font-weight: 600; color: var(--gray-800); }
.step-badge {
  width: 28px; height: 28px;
  background: var(--blue);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700;
  flex-shrink: 0;
}
.step-badge.green { background: var(--green); }

/* ─── Upload grid ───────────────────────────────────────────── */
.upload-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
}
@media (max-width: 720px) {
  .upload-grid { grid-template-columns: 1fr; }
}

/* ─── Drop zone ─────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 2.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--gray-100);
  position: relative;
  min-height: 180px;
  display: flex; align-items: center; justify-content: center;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--blue-mid);
  background: var(--blue-xlight);
}
.drop-zone.drag-over { transform: scale(1.01); }
.drop-inner { pointer-events: none; }
.drop-icon {
  width: 56px; height: 56px;
  background: var(--blue-light);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
}
.drop-icon svg { width: 28px; height: 28px; stroke: var(--blue); }
.drop-title { font-size: 1rem; font-weight: 600; color: var(--gray-700); }
.drop-sub   { font-size: .85rem; color: var(--gray-500); margin-top: 4px; }
.drop-badge {
  display: inline-block;
  margin-top: .75rem;
  padding: 3px 10px;
  background: var(--blue-light);
  color: var(--blue);
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .3px;
}

/* ─── Frete panel ───────────────────────────────────────────── */
.frete-panel {
  display: flex; flex-direction: column; gap: .75rem;
}
.frete-label {
  display: flex; align-items: center; gap: 6px;
  font-size: .875rem; font-weight: 600; color: var(--gray-700);
}
.required-dot {
  color: var(--red);
  font-size: 1.1rem;
  line-height: 1;
}
.frete-input-wrap {
  display: flex; align-items: center;
  border: 2px solid var(--gray-300);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color var(--transition);
}
.frete-input-wrap:focus-within { border-color: var(--blue-mid); box-shadow: 0 0 0 3px rgba(36,113,163,.12); }
.frete-prefix {
  padding: 0 .75rem;
  background: var(--gray-100);
  color: var(--gray-600);
  font-weight: 600;
  font-size: .95rem;
  border-right: 2px solid var(--gray-300);
  height: 46px; display: flex; align-items: center;
}
.frete-input-wrap input {
  flex: 1; border: none; outline: none;
  padding: .75rem 1rem;
  font-size: 1.1rem; font-weight: 600;
  font-family: var(--font);
  color: var(--blue);
  background: transparent;
}
.frete-hint { font-size: .8rem; color: var(--gray-500); }

.stats-mini { display: flex; gap: .5rem; margin-top: .5rem; }
.stat-chip {
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--blue-xlight);
  color: var(--blue);
  font-size: .8rem; font-weight: 600;
  border: 1px solid var(--blue-light);
}

/* ─── File list ─────────────────────────────────────────────── */
.file-list-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .5rem 0 .75rem;
  font-size: .875rem; font-weight: 600;
  color: var(--gray-600);
  border-top: 1px solid var(--gray-200);
  margin-top: 1.25rem;
}
.file-count-badge {
  padding: 2px 10px;
  background: var(--blue-light);
  color: var(--blue);
  border-radius: 20px;
  font-size: .78rem; font-weight: 600;
}
.file-list {
  max-height: 220px;
  overflow-y: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
}
.file-list::-webkit-scrollbar { width: 4px; }
.file-list::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 2px; }
.file-item {
  display: grid;
  grid-template-columns: 1fr 80px 90px;
  align-items: center;
  padding: .6rem 1rem;
  font-size: .83rem;
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--transition);
  gap: .5rem;
}
.file-item:last-child { border-bottom: none; }
.file-item:hover { background: var(--gray-100); }
.file-name { font-weight: 500; color: var(--gray-700); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { color: var(--gray-500); font-size: .78rem; }
.status-badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .75rem; font-weight: 600;
  white-space: nowrap;
}
.status-wait  { background: var(--yellow-light); color: var(--yellow); }
.status-ok    { background: var(--green-light);  color: var(--green); }
.status-error { background: var(--red-light);    color: var(--red); }

/* ─── Actions bar ───────────────────────────────────────────── */
.actions-bar {
  display: flex;
  gap: .75rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 1.25rem 1.75rem;
  margin-bottom: 1.25rem;
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .65rem 1.4rem;
  border-radius: var(--radius-sm);
  font-size: .9rem; font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 2px 8px rgba(27,79,114,.3);
}
.btn-primary:hover:not(:disabled) {
  background: #154360;
  box-shadow: 0 4px 14px rgba(27,79,114,.4);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border: 1.5px solid var(--gray-300);
}
.btn-ghost:hover:not(:disabled) { background: var(--gray-100); border-color: var(--gray-400); }

.btn-dl {
  flex: 1;
  justify-content: center;
  padding: .75rem 1rem;
  font-size: .875rem;
}
.btn-zip  { background: var(--blue);  color: #fff; box-shadow: 0 2px 8px rgba(27,79,114,.25); }
.btn-csv  { background: #1E8449;      color: #fff; box-shadow: 0 2px 8px rgba(30,132,73,.25); }
.btn-xlsx { background: #1E5799;      color: #fff; box-shadow: 0 2px 8px rgba(30,87,153,.25); }
.btn-zip:hover  { background: #154360;  transform: translateY(-1px); }
.btn-csv:hover  { background: #196F3D;  transform: translateY(-1px); }
.btn-xlsx:hover { background: #1A4C87;  transform: translateY(-1px); }

/* ─── Processing animation ──────────────────────────────────── */
.processing-scene {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3rem;
  padding: 2rem 1rem 1.5rem;
}

.proc-side {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  align-items: center;
}

.xml-file {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: .72rem; font-weight: 700; letter-spacing: .5px;
}
.xml-icon-wrap {
  width: 48px; height: 56px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.xml-icon-wrap.old { background: var(--yellow-light); }
.xml-icon-wrap.old svg { stroke: var(--yellow); width: 28px; height: 28px; }
.xml-icon-wrap.new { background: var(--green-light); }
.xml-icon-wrap.new svg { stroke: var(--green); width: 28px; height: 28px; }
.xml-file.xml-old span { color: var(--yellow); }
.xml-file.xml-new span { color: var(--green); }

/* Stagger animations */
.xml-old.anim-1 { animation: floatLeft 2.4s 0s    ease-in-out infinite; }
.xml-old.anim-2 { animation: floatLeft 2.4s .3s   ease-in-out infinite; }
.xml-old.anim-3 { animation: floatLeft 2.4s .6s   ease-in-out infinite; }
.xml-new.anim-1 { animation: floatRight 2.4s .4s  ease-in-out infinite; }
.xml-new.anim-2 { animation: floatRight 2.4s .7s  ease-in-out infinite; }
.xml-new.anim-3 { animation: floatRight 2.4s 1.0s ease-in-out infinite; }

@keyframes floatLeft {
  0%,100% { transform: translateX(0)   opacity: 1; }
  50%      { transform: translateX(8px); opacity: .7; }
}
@keyframes floatRight {
  0%,100% { transform: translateX(0);   opacity: 1; }
  50%      { transform: translateX(-8px); opacity: .7; }
}

/* Converter box */
.proc-center { display: flex; flex-direction: column; align-items: center; gap: .75rem; }
.converter-box {
  width: 90px; height: 90px;
  background: linear-gradient(135deg, var(--blue-xlight), var(--blue-light));
  border: 2px solid var(--blue-light);
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.gear-wrap { position: relative; width: 52px; height: 52px; }
.gear {
  position: absolute;
  color: var(--blue-mid);
}
.gear-big   { width: 44px; height: 44px; top: 4px; left: 4px; animation: spin 3s linear infinite; }
.gear-small { width: 26px; height: 26px; top: 0; right: 0;    animation: spin 3s linear infinite reverse; opacity: .5; }
@keyframes spin { to { transform: rotate(360deg); } }

.scanner-line {
  position: absolute;
  top: 0; left: -100%;
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(27,79,114,.15), transparent);
  animation: scan 1.8s ease-in-out infinite;
}
@keyframes scan {
  0%   { left: -40%; }
  100% { left: 110%; }
}
.proc-label {
  font-size: .78rem; font-weight: 700; color: var(--blue);
  letter-spacing: .5px;
  background: var(--blue-xlight);
  padding: 3px 10px; border-radius: 20px;
}

/* Progress bar */
.progress-wrap { padding: .5rem 0; }
.progress-bar-bg {
  height: 8px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: .75rem;
}
.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--blue), var(--blue-mid));
  border-radius: 4px;
  transition: width .4s ease;
}
.progress-footer {
  display: flex; justify-content: space-between; align-items: center;
}
.progress-msg { font-size: .875rem; color: var(--gray-600); font-weight: 500; }
.progress-pct { font-size: .875rem; font-weight: 700; color: var(--blue); }

/* ─── Summary cards ─────────────────────────────────────────── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.summary-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  padding: 1.1rem 1.25rem 1rem;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: .3rem;
  min-width: 0;
}
.summary-card .s-label {
  font-size: .72rem; color: var(--gray-500); font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.summary-card .s-value {
  font-size: 1.25rem; font-weight: 700; color: var(--gray-800);
  line-height: 1.25; word-break: break-word;
}
.summary-card .s-sub { font-size: .75rem; color: var(--gray-400); margin-top: 2px; }
.summary-card.blue  { border-left: 4px solid var(--blue); }
.summary-card.green { border-left: 4px solid var(--green); }
.summary-card.red   { border-left: 4px solid var(--red); }
.summary-card.yellow{ border-left: 4px solid var(--yellow); }

/* ─── Tables ────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .855rem;
}
.data-table th {
  background: var(--gray-100);
  padding: .8rem 1rem;
  text-align: left;
  font-size: .73rem;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}
.data-table th.center { text-align: center; }
.data-table th.right  { text-align: right; }
.data-table td {
  padding: .75rem 1rem;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.data-table td.center { text-align: center; }
.data-table td.right  { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--gray-100); }

.emit-name  { font-weight: 600; color: var(--gray-800); }
.emit-cnpj  { font-size: .75rem; color: var(--gray-500); margin-top: 2px; }
.nf-numbers { font-size: .8rem; color: var(--gray-600); max-width: 220px; white-space: normal; line-height: 1.4; }
.val-strong { font-weight: 700; color: var(--gray-800); }
.frete-val  { font-weight: 700; color: var(--green); }

.dl-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.btn-dl-sm {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 5px 12px;
  border-radius: 6px;
  background: var(--blue-xlight);
  color: var(--blue);
  border: 1px solid var(--blue-light);
  font-size: .76rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: all var(--transition);
  width: 68px;
}
.btn-dl-sm:hover { background: var(--blue-light); transform: translateY(-1px); }
.btn-dl-pdf { background: #FDEDEC; color: var(--red); border-color: #F5B7B1; }
.btn-dl-pdf:hover { background: #F5B7B1; }

/* ─── Download bar ──────────────────────────────────────────── */
.download-bar {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow-sm);
  margin-top: 1.5rem;
}
.download-bar-label {
  font-size: .72rem; font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase; letter-spacing: .6px;
  margin-bottom: 1rem;
}
.download-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: .875rem;
}

/* ─── Utilities ─────────────────────────────────────────────── */
.hidden { display: none !important; }
.fade-in { animation: fadeIn .35s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Modal PDF ─────────────────────────────────────────────── */
.pdf-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.pdf-modal.hidden { display: none; }
.pdf-modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.pdf-modal-box {
  position: relative; z-index: 1; width: 90vw; max-width: 900px;
  height: 88vh; background: var(--white); border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.3); display: flex; flex-direction: column; overflow: hidden;
}
.pdf-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem; background: var(--blue); color: #fff;
  font-size: .9rem; font-weight: 600;
}
.pdf-modal-actions { display: flex; gap: .5rem; align-items: center; }
.btn-modal-print {
  display: flex; align-items: center; gap: .4rem;
  background: #fff; color: var(--blue); border: none; border-radius: 6px;
  padding: .4rem .85rem; font-size: .8rem; font-weight: 600; cursor: pointer;
}
.btn-modal-print:hover { background: var(--blue-light); }
.btn-modal-close {
  background: transparent; border: none; color: #fff;
  font-size: 1.1rem; cursor: pointer; padding: .2rem .5rem; border-radius: 4px;
}
.btn-modal-close:hover { background: rgba(255,255,255,.2); }
#pdf-frame { flex: 1; width: 100%; border: none; }

/* ─── Footer ────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: .78rem;
  color: var(--gray-400);
  border-top: 1px solid var(--gray-200);
  background: var(--white);
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 640px) {
  .processing-scene { gap: 1.5rem; }
  .proc-side { display: none; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
}
