*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: #1f2937;
  background: #f3f4f6;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* Topbar */
.topbar {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { font-weight: 600; font-size: 15px; color: #111827; }
.brand-sub { font-size: 13px; color: #9ca3af; margin-left: 10px; }

.btn-reset {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
  color: #374151;
  cursor: pointer;
}
.btn-reset:hover { background: #fef2f2; border-color: #fecaca; color: #dc2626; }

/* Page */
.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 24px 40px;
}

.panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}

.upload-bar { padding: 16px; margin-bottom: 20px; }
.upload-bar-row { display: flex; gap: 12px; align-items: center; }

.dropzone {
  flex: 1;
  border: 1px dashed #d1d5db;
  border-radius: 6px;
  padding: 16px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.dragover {
  border-color: #2563eb;
  background: #f9fafb;
}
.dropzone-label { font-size: 13px; font-weight: 500; color: #374151; }
.dropzone-hint { font-size: 12px; color: #9ca3af; margin-left: 8px; }

.status-box {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
}
.status-box.ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.status-box.warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.status-box.err { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.empty-state {
  padding: 80px 20px;
  text-align: center;
  color: #9ca3af;
  font-size: 14px;
  background: #fff;
  border: 1px dashed #e5e7eb;
  border-radius: 6px;
}

/* Compare list — tiap SO: kiri struk, kanan kalkulasi */
.compare-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.compare-row {
  display: grid;
  grid-template-columns: minmax(280px, 42%) 1fr;
  gap: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
  min-height: 320px;
}

@media (max-width: 960px) {
  .compare-row { grid-template-columns: 1fr; }
}

.compare-left {
  background: #f9fafb;
  border-right: 1px solid #e5e7eb;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.compare-right {
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.struk-img {
  width: 100%;
  flex: 1;
  object-fit: contain;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  min-height: 240px;
  cursor: zoom-in;
}

.compare-left-meta {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.compare-filename {
  font-size: 12px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.compare-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  margin-bottom: 8px;
}

.compare-right-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}
.compare-right-title {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  display: flex;
  align-items: center;
  gap: 8px;
}

.so-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 99px;
}
.so-badge.ok { background: #ecfdf5; color: #059669; }
.so-badge.warn { background: #fffbeb; color: #d97706; }
.so-badge.err { background: #fef2f2; color: #dc2626; }

.compare-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}
.btn-text {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: #2563eb;
  cursor: pointer;
  padding: 0;
}
.btn-text:hover { text-decoration: underline; }
.btn-text.danger { color: #dc2626; }

.so-error {
  padding: 8px 12px;
  font-size: 13px;
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 4px;
  margin-bottom: 12px;
}

/* Tables */
.table-wrap {
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  overflow-x: auto;
  flex: 1;
}
.so-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.so-table thead { background: #f9fafb; border-bottom: 1px solid #e5e7eb; }
.so-table th {
  padding: 7px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.so-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}
.so-table tbody tr:last-child td { border-bottom: none; }

.col-no { width: 28px; text-align: center; }
.col-code { width: 110px; }
.col-name { min-width: 120px; }
.col-qty { width: 56px; text-align: right; }
.col-price, .col-total { width: 90px; text-align: right; }
.col-action { width: 28px; text-align: center; }

.cell-mono { font-variant-numeric: tabular-nums; }
.cell-muted { color: #9ca3af; font-size: 11px; }

.cell-input {
  width: 100%;
  border: 1px solid #e5e7eb;
  background: #fff;
  font-family: inherit;
  font-size: 12px;
  color: #111827;
  padding: 4px 6px;
  border-radius: 3px;
}
.cell-input:focus { outline: none; border-color: #2563eb; }
.qty-input { width: 52px; text-align: right; }

.delete-btn {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px;
}
.delete-btn:hover { color: #dc2626; }

.so-footer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #f3f4f6;
}
.totals-table {
  border-collapse: collapse;
  font-size: 12px;
  margin-left: auto;
  width: 100%;
  max-width: 480px;
}
.totals-table th {
  padding: 0 0 6px 12px;
  text-align: right;
  font-weight: 500;
  font-size: 10px;
  color: #9ca3af;
  text-transform: uppercase;
}
.totals-table td {
  padding: 3px 0 3px 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.totals-table .lbl { color: #6b7280; text-align: left; padding-right: 12px; white-space: normal; min-width: 150px; }
.totals-table .val-shot { color: #6b7280; }
.totals-table .val-calc { color: #111827; font-weight: 500; }
.totals-table .val-diff.zero { color: #059669; font-weight: 600; }
.totals-table .val-diff.nonzero { color: #dc2626; font-weight: 600; }
.totals-table .grand .lbl,
.totals-table .grand .val-calc,
.totals-table .grand .val-diff { font-weight: 700; font-size: 14px; }

.selisih-summary {
  margin-top: 10px;
  margin-left: auto;
  max-width: 480px;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  text-align: right;
}
.selisih-summary.ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.selisih-summary.bad { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.row-footer-actions {
  margin-top: 10px;
  display: flex;
  gap: 12px;
}

/* Loading */
.loading {
  position: fixed; inset: 0;
  background: rgba(255,255,255,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.loading-inner {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 16px 28px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

/* Lightbox */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
