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

:root {
  --brand:    #2ba85f;
  --brand-lt: #def7e8;
  --brand-dk: #1f8a4b;
  --green:    #1f8a4b; --green-lt: #e8f8ee;
  --amber:    #b45309; --amber-lt: #fef3c7;
  --red:      #dc2626; --red-lt:   #fee2e2;
  --blue:     #2563eb; --blue-lt:  #dbeafe;
  --g0:  #ffffff;
  --g50: #fafcfb; --g100:#eef5f0;
  --g200:#dbe7df; --g300:#bfd2c4;
  --g400:#7b8f81; --g500:#56685c;
  --g600:#3f4e44; --g700:#27322d; --g900:#0e1814;
  --nav-h: 60px;
  --r: 14px;
  --sh:  0 1px 3px rgba(14,24,20,.07), 0 1px 2px rgba(14,24,20,.04);
  --sh2: 0 8px 30px rgba(14,24,20,.09);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Roboto', system-ui, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(43,168,95,.12), transparent 28%),
    radial-gradient(circle at bottom right, rgba(14,24,20,.05), transparent 24%),
    linear-gradient(180deg, #fbfdfb 0%, #f3f8f4 100%);
  color: var(--g900);
  min-height: 100vh;
  padding-top: var(--nav-h);
}

/* ── NAVBAR ── */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: rgba(250,253,251,.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(43,168,95,.13);
  transition: box-shadow .25s;
}
.nav.scrolled { box-shadow: 0 2px 16px rgba(14,24,20,.08); }

.nav-inner {
  max-width: 960px; margin: 0 auto;
  height: 100%; padding: 0 24px;
  display: flex; align-items: center;
}

.nav-brand {
  display: flex; align-items: center;
  text-decoration: none; flex-shrink: 0;
  background: transparent; border: none;
}
.nav-lockup {
  width: auto; height: 44px; display: block;
  transition: transform .2s, opacity .2s;
  background: transparent;
}
.nav-brand:hover .nav-lockup { transform: translateY(-1px); opacity: .96; }

.nav-links { display: flex; align-items: center; gap: 2px; margin-left: 28px; }
.nav-link {
  padding: 6px 14px; border-radius: 8px;
  font-size: .82rem; font-weight: 500; color: var(--g500);
  text-decoration: none;
  transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--g900); background: var(--g100); }
.nav-link.active { color: var(--brand-dk); background: var(--brand-lt); box-shadow: inset 0 0 0 1px rgba(43,168,95,.08); }

/* ── SECTIONS ── */
.section { max-width: 960px; margin: 0 auto; padding: 40px 24px; }
.section + .section { padding-top: 0; }
.section-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 20px;
}
.section-title { font-size: 1.05rem; font-weight: 700; color: var(--g900); letter-spacing: -.02em; }
.section-sub { font-size: .78rem; color: var(--g400); font-weight: 400; margin-top: 2px; }

/* ── CARD ── */
.card {
  background: var(--g0);
  border-radius: var(--r);
  border: 1px solid var(--g200);
  box-shadow: var(--sh);
  padding: 24px;
  animation: fadeUp .3s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── UPLOAD ── */
.upload-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start;
}
@media(max-width:640px){ .upload-grid { grid-template-columns: 1fr; } }

.dz {
  border: 2px dashed var(--g300); border-radius: 12px;
  padding: 36px 20px; text-align: center; cursor: pointer;
  transition: border-color .2s, background .2s, transform .15s;
}
.dz:hover,.dz.over { border-color: var(--brand); background: var(--brand-lt); transform: scale(1.01); }
.dz input { display: none; }
.dz-icon {
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--g100); border: 1px solid var(--g200);
  margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s;
}
.dz:hover .dz-icon { transform: translateY(-3px); }
.dz-icon svg { width: 22px; height: 22px; stroke: var(--g400); fill: none; }
.dz-text  { font-size: .87rem; color: var(--g600); }
.dz-text strong { color: var(--brand); cursor: pointer; font-weight: 600; }
.dz-hint  { font-size: .73rem; color: var(--g400); margin-top: 4px; }
.dz-file  { margin-top: 9px; font-size: .78rem; color: var(--g700); font-weight: 500; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border-radius: 9px; border: none;
  font-size: .85rem; font-weight: 600; cursor: pointer;
  font-family: 'Roboto', sans-serif;
  transition: background .15s, opacity .15s, transform .1s, box-shadow .15s;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn-brand { background: var(--brand); color: #fff; box-shadow: 0 2px 10px rgba(91,84,245,.3); }
.btn-brand:hover:not(:disabled) { background: var(--brand-dk); box-shadow: 0 4px 16px rgba(91,84,245,.4); }
.btn-sm   { padding: 5px 12px; font-size: .75rem; border-radius: 7px; }
.btn-ghost { background: var(--g100); color: var(--g700); border: 1px solid var(--g200); box-shadow: none; }
.btn-ghost:hover:not(:disabled) { background: var(--g200); }

.actions { margin-top: 14px; display: flex; align-items: center; gap: 8px; }

.prog { display: none; margin-top: 12px; }
.prog.on { display: block; }
.prog-track { background: var(--g200); border-radius: 99px; height: 3px; overflow: hidden; }
.prog-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--brand), #74d39a);
  border-radius: 99px; transition: width .4s ease;
}
.prog-lbl { font-size: .7rem; color: var(--g500); margin-top: 5px; }

.tips { display: flex; flex-direction: column; gap: 10px; }
.tip {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 12px; border-radius: 9px;
  background: var(--g50); border: 1px solid var(--g100);
}
.tip-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); flex-shrink: 0; margin-top: 5px; }
.tip-title { font-size: .8rem; font-weight: 600; color: var(--g700); }
.tip-text  { font-size: .74rem; color: var(--g500); margin-top: 2px; line-height: 1.4; }

/* ── RESULT PANEL ── */
#res { display: none; animation: slideDown .3s cubic-bezier(.16,1,.3,1) both; }
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-12px) scale(.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.res-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; padding-bottom: 14px;
  border-bottom: 1px solid var(--g100);
}
.res-title {
  display: flex; align-items: center; gap: 8px;
  font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; color: var(--brand);
}
.res-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--brand);
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .5; transform: scale(.7); }
}

.res-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media(max-width:580px){ .res-grid { grid-template-columns: 1fr; } }
.res-col { min-width: 0; }

.sec {
  font-size: .63rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--g400); margin-bottom: 10px;
}

.vendor-row { display: flex; align-items: flex-start; gap: 12px; }
.vendor-av {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 9px;
  background: var(--brand-lt); display: flex; align-items: center;
  justify-content: center; font-size: .9rem; font-weight: 700; color: var(--brand);
}
.vendor-name { font-size: .97rem; font-weight: 700; overflow-wrap: anywhere; }
.vendor-meta { font-size: .74rem; color: var(--g500); margin-top: 3px; line-height: 1.5; overflow-wrap: anywhere; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }

.fin { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
@media(max-width:600px){ .fin { grid-template-columns: 1fr 1fr; gap: 5px; } }
@media(max-width:480px){ .fin { grid-template-columns: 1fr; gap: 6px; } }
.fin-cell {
  background: var(--g50); border: 1px solid var(--g200);
  border-radius: 9px; padding: 9px 10px;
  transition: transform .15s; min-width: 0;
}
.fin-cell:hover { transform: translateY(-1px); }
.fin-cell.main { background: var(--brand-lt); border-color: rgba(43,168,95,.18); }
.fin-lbl {
  font-size: .57rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--g400); margin-bottom: 2px; overflow-wrap: anywhere;
}
.fin-val { font-size: 0.95rem; font-weight: 700; color: var(--g900); overflow-wrap: anywhere; }
.fin-cell.main .fin-val { color: var(--brand); font-size: 1.15rem; }
.fin-sub { font-size: .67rem; color: var(--g400); margin-top: 2px; overflow-wrap: anywhere; }

.cat-row { display: flex; align-items: center; gap: 11px; }
.cat-av {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700; letter-spacing: -.01em;
}
.cat-av.found  { background: var(--green-lt); color: var(--green); }
.cat-av.missing{ background: var(--g100); color: var(--g400); }
.cat-name { font-size: .92rem; font-weight: 700; overflow-wrap: anywhere; }
.cat-name.missing { color: var(--g400); font-style: italic; }
.cat-sub  { font-size: .72rem; color: var(--g500); margin-top: 2px; overflow-wrap: anywhere; }

.dg { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
@media(max-width:400px){ .dg { grid-template-columns: 1fr; } }
.dg-cell {
  background: var(--g50); border: 1px solid var(--g200);
  border-radius: 8px; padding: 8px 10px; min-width: 0;
}
.dg-lbl {
  font-size: .61rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--g400); margin-bottom: 2px;
}
.dg-val { font-size: .82rem; font-weight: 500; color: var(--g700); overflow-wrap: anywhere; }

.items-tbl { width: 100%; border-collapse: collapse; font-size: .8rem; table-layout: fixed; }
.items-tbl th {
  text-align: left; padding: 5px 7px;
  font-size: .6rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--g400);
  border-bottom: 1px solid var(--g200);
}
.items-tbl th:last-child, .items-tbl td:last-child { text-align: right; }
.items-tbl td { padding: 7px; color: var(--g700); border-bottom: 1px solid var(--g100); word-break: break-word; overflow-wrap: anywhere; }
.items-tbl tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .68rem; font-weight: 600; }
.b-purple { background: var(--brand-lt); color: var(--brand); }
.b-green  { background: var(--green-lt);  color: var(--green); }
.b-amber  { background: var(--amber-lt);  color: var(--amber); }
.b-gray   { background: var(--g100); color: var(--g600); border: 1px solid var(--g200); }

.err {
  background: var(--red-lt); border: 1px solid #fca5a5;
  border-radius: var(--r); padding: 11px 14px;
  color: var(--red); font-size: .82rem; display: none;
  margin-bottom: 16px;
  animation: fadeUp .2s ease;
}

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--g100); border: 1px solid var(--g200);
  border-radius: 99px; padding: 2px 9px;
  font-size: .68rem; font-weight: 500; color: var(--g600);
}
.receipt-id {
  font-size: .66rem; color: var(--g400);
  font-family: 'Roboto Mono', monospace; margin-top: 5px;
  overflow-wrap: anywhere;
}
.meta-row { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; min-width: 0; }

details { margin-top: 0; }
summary {
  cursor: pointer; font-size: .76rem; font-weight: 500;
  color: var(--g500); user-select: none; transition: color .15s;
}
summary:hover { color: var(--brand); }
pre {
  margin-top: 10px; background: var(--g900); color: #94a3b8;
  padding: 14px; border-radius: 9px; overflow: auto;
  font-family: 'Roboto Mono', monospace;
  font-size: .71rem; line-height: 1.55; max-height: 300px;
  max-width: 100%; white-space: pre-wrap;
  word-break: break-word; overflow-wrap: anywhere;
}

.divider { height: 1px; background: var(--g100); margin: 14px 0; }

details, summary, pre, .receipt-id, .meta-row { max-width: 100%; min-width: 0; }
.modal-file, .t-file, .t-name, .vendor-meta { overflow-wrap: anywhere; }

/* ── HISTORIAL ── */
.module {
  background: var(--g0); border-radius: var(--r); border: 1px solid var(--g200);
  box-shadow: var(--sh); overflow: hidden;
  animation: fadeUp .35s ease .1s both;
}
.module-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--g100);
}
.module-title { font-size: .88rem; font-weight: 700; color: var(--g900); }
.module-sub   { font-size: .72rem; color: var(--g400); font-weight: 400; margin-top: 1px; }
.module-meta  { font-size: .73rem; color: var(--g400); }

.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .81rem; }
.tbl thead tr { border-bottom: 1px solid var(--g200); }
.tbl th {
  text-align: left; padding: 9px 16px;
  font-size: .62rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--g400);
  background: var(--g50); white-space: nowrap;
}
.tbl th.r, .tbl td.r { text-align: right; }
.tbl th.c, .tbl td.c { text-align: center; }
.tbl tbody tr { border-bottom: 1px solid var(--g100); cursor: pointer; transition: background .12s; }
.tbl tbody tr:last-child { border-bottom: none; }
.tbl tbody tr:hover { background: var(--g50); }
.tbl td { padding: 12px 16px; color: var(--g700); vertical-align: middle; }

.row-main { animation: rowFadeIn .3s ease both; }
@keyframes rowFadeIn {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}

.t-vendor { display: flex; align-items: center; gap: 10px; }
.t-av {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  background: var(--brand-lt); display: flex; align-items: center;
  justify-content: center; font-size: .82rem; font-weight: 700;
  color: var(--brand); transition: transform .15s;
}
.tbl tbody tr:hover .t-av { transform: scale(1.08); }
.t-name { font-weight: 600; color: var(--g900); max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-file { font-size: .68rem; color: var(--g400); margin-top: 1px; max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-amount { font-weight: 700; color: var(--g900); white-space: nowrap; }

.conf-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.conf-high { background: var(--green); }
.conf-mid  { background: var(--amber); }
.conf-low  { background: var(--g300); }

.t-arrow {
  display: inline-block; width: 22px; height: 22px; border-radius: 6px;
  border: 1px solid var(--g200); background: var(--g50);
  color: var(--g400); font-size: .75rem; line-height: 22px; text-align: center;
  transition: background .12s, color .12s, border-color .12s;
}
.tbl tbody tr:hover .t-arrow { background: var(--brand-lt); color: var(--brand); border-color: rgba(43,168,95,.18); }

.tbl-empty { padding: 48px 20px; text-align: center; color: var(--g400); font-size: .83rem; animation: fadeUp .3s ease; }
.tbl-empty p { margin-top: 4px; font-size: .76rem; color: var(--g300); }

/* ── MODAL ── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15,23,42,.4);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; padding: 24px;
}
.modal-backdrop.open { display: flex; animation: fadeBackdrop .18s ease both; }
@keyframes fadeBackdrop { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--g0); border-radius: 16px; border: 1px solid var(--g200);
  box-shadow: 0 24px 80px rgba(0,0,0,.2);
  width: 100%; max-width: 600px; max-height: calc(100vh - 80px);
  overflow-y: auto; overflow-x: hidden;
  animation: modalUp .22s cubic-bezier(.16,1,.3,1) both;
}
@keyframes modalUp {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 20px 22px 16px; border-bottom: 1px solid var(--g100);
  position: sticky; top: 0; background: var(--g0); z-index: 1;
  border-radius: 16px 16px 0 0;
}
.modal-title { font-size: 1rem; font-weight: 700; color: var(--g900); }
.modal-file  { font-size: .72rem; color: var(--g400); margin-top: 2px; font-family: 'Roboto Mono', monospace; }
.modal-close {
  width: 28px; height: 28px; flex-shrink: 0; border-radius: 7px;
  background: var(--g100); border: none; cursor: pointer;
  font-size: .85rem; color: var(--g600); line-height: 28px; text-align: center;
  transition: background .15s;
}
.modal-close:hover { background: var(--g200); }

.modal-body { padding: 22px; overflow-x: hidden; }
.modal-section { margin-bottom: 22px; }
.modal-section:last-child { margin-bottom: 0; }
.modal-section, .modal-kv, .modal-fin { min-width: 0; }

.modal-fin {
  display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) minmax(0,1fr); gap: 8px;
  margin-top: 10px;
}
@media(max-width:400px){ .modal-fin { grid-template-columns: 1fr 1fr; } }

.modal-kv { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 6px; margin-top: 10px; }
.modal-cell { background: var(--g50); border: 1px solid var(--g200); border-radius: 8px; padding: 9px 11px; min-width: 0; }
.modal-lbl { font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--g400); margin-bottom: 3px; }
.modal-val { font-size: .83rem; font-weight: 500; color: var(--g700); overflow-wrap: anywhere; }
.modal-val.big { font-size: 1.15rem; font-weight: 700; color: var(--brand); }

.modal-row { display: flex; align-items: flex-start; gap: 10px; margin-top: 10px; }
.modal-av {
  width: 36px; height: 36px; flex-shrink: 0; border-radius: 8px;
  background: var(--brand-lt); display: flex; align-items: center;
  justify-content: center; font-size: .85rem; font-weight: 700; color: var(--brand);
}
.modal-av.green { background: var(--green-lt); color: var(--green); }
.modal-vendor-name { font-size: .9rem; font-weight: 700; margin-bottom: 3px; overflow-wrap: anywhere; }

.m-items-tbl { width: 100%; border-collapse: collapse; font-size: .78rem; margin-top: 8px; table-layout: fixed; }
.m-items-tbl th {
  text-align: left; padding: 5px 7px;
  font-size: .59rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--g400); border-bottom: 1px solid var(--g200);
}
.m-items-tbl th:last-child, .m-items-tbl td:last-child { text-align: right; }
.m-items-tbl td { padding: 7px; color: var(--g700); border-bottom: 1px solid var(--g100); word-break: break-word; overflow-wrap: anywhere; }
.m-items-tbl tr:last-child td { border-bottom: none; }

.modal-footer {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--g100);
}
.modal-footer > * { min-width: 0; }

@media(max-width:640px) {
  .nav-inner { padding: 0 16px; }
  .nav-lockup { height: 36px; }
  .section { padding-inline: 16px; }
  .card { padding: 18px; }
  .modal { max-height: calc(100vh - 28px); }
  .modal-body, .modal-footer { padding-left: 16px; padding-right: 16px; }
  .modal-fin, .modal-kv { grid-template-columns: 1fr; }
}
