:root {
  --bg: #0b0f1a;
  --surface: #121826;
  --surface-2: #1a2234;
  --border: #263149;
  --text: #eaf0fb;
  --muted: #93a0bd;
  --brand: #6c8cff;
  --brand-2: #4bd6c8;
  --danger: #ff6b6b;
  --radius: 16px;
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.bg-decor {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(600px 400px at 15% 0%, rgba(108, 140, 255, 0.18), transparent 60%),
    radial-gradient(700px 500px at 90% 10%, rgba(75, 214, 200, 0.12), transparent 55%);
}

main, .site-header, .site-footer { position: relative; z-index: 1; }

/* HEADER */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px clamp(16px, 5vw, 48px);
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; }
.brand-mark { font-size: 24px; }
.brand-name span { color: var(--brand); }
.badge-beta {
  font-size: 12px; font-weight: 700; letter-spacing: 0.5px;
  color: var(--brand-2);
  border: 1px solid rgba(75, 214, 200, 0.4);
  padding: 4px 10px; border-radius: 999px;
}

main {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(16px, 4vw, 40px);
}

/* HERO */
.hero { text-align: center; max-width: 720px; margin: 24px auto 0; }
.hero h1 {
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 800;
  line-height: 1.15;
  margin: 0 0 16px;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #fff, #b9c6e6);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.subtitle { color: var(--muted); font-size: clamp(15px, 2.2vw, 18px); margin: 0 auto 32px; max-width: 560px; }

#uploadForm { display: flex; flex-direction: column; gap: 16px; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px;
  padding: clamp(28px, 6vw, 52px);
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.1s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--brand); background: var(--surface-2); outline: none; }
.dropzone.dragover { border-color: var(--brand-2); background: var(--surface-2); transform: scale(1.01); }
.dz-icon { font-size: 40px; }
.dz-title { font-size: 18px; font-weight: 600; }
.dz-sub { color: var(--muted); font-size: 14px; }
.dz-sub .link { color: var(--brand); font-weight: 600; }
.dz-files {
  margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
}
.dz-files .chip {
  font-size: 13px; font-weight: 600; color: var(--brand-2);
  background: rgba(75, 214, 200, 0.1); padding: 6px 12px; border-radius: 999px;
  max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.trust-row {
  display: flex; flex-wrap: wrap; gap: 20px; justify-content: center;
  margin-top: 28px; color: var(--muted); font-size: 14px;
}

.quota {
  margin-top: 18px; font-size: 13px; color: var(--muted);
}
.quota b { color: var(--brand-2); }
.quota.exhausted b { color: var(--danger); }

/* BUTTONS */
.btn-primary, .btn-secondary {
  font-family: inherit; font-size: 15px; font-weight: 600;
  padding: 13px 22px; border-radius: 12px; cursor: pointer;
  border: 1px solid transparent; transition: transform 0.1s, filter 0.2s, background 0.2s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--brand), #8a6cff);
  color: #fff; box-shadow: 0 8px 24px -8px rgba(108, 140, 255, 0.7);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-secondary {
  background: var(--surface-2); color: var(--text); border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--brand); }

/* STATE PANELS */
.state-panel {
  text-align: center; max-width: 480px; margin: 60px auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 48px 32px; box-shadow: var(--shadow);
}
.state-panel h2 { margin: 20px 0 8px; }
.muted { color: var(--muted); }
.spinner {
  width: 52px; height: 52px; margin: 0 auto; border-radius: 50%;
  border: 4px solid var(--border); border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-icon { font-size: 44px; }
#retryBtn { margin-top: 20px; }

/* RESULTS */
.results {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: clamp(20px, 4vw, 32px);
  box-shadow: var(--shadow); animation: fade 0.35s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.results-head {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start;
  justify-content: space-between; margin-bottom: 24px;
}
.results-head h2 { margin: 0 0 4px; }
.results-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.notice {
  background: rgba(255, 107, 107, 0.08); border: 1px solid rgba(255, 107, 107, 0.35);
  color: #ffb9b9; border-radius: 12px; padding: 12px 16px; margin-bottom: 20px; font-size: 14px;
}
.notice ul { margin: 6px 0 0; padding-left: 20px; }

.invoice { margin-bottom: 28px; }
.invoice + .invoice { border-top: 1px solid var(--border); padding-top: 24px; }
.invoice-head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; margin-bottom: 16px;
}
.invoice-head h3 { margin: 0; font-size: 17px; }
.invoice-head .inv-badge {
  font-size: 12px; font-weight: 600; color: var(--brand-2);
  background: rgba(75, 214, 200, 0.1); padding: 3px 10px; border-radius: 999px;
}

.info-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px; margin-bottom: 24px;
}
.info-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px;
}
.info-card h4 {
  margin: 0 0 12px; font-size: 13px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--brand-2);
}
.info-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 14px; border-bottom: 1px solid rgba(38, 49, 73, 0.5); }
.info-row:last-child { border-bottom: none; }
.info-row .k { color: var(--muted); flex-shrink: 0; }
.info-row .v { text-align: right; font-weight: 500; word-break: break-word; }
.info-row .v.empty { color: #55617d; font-weight: 400; }

.items-block h4 { margin: 0 0 12px; font-size: 15px; color: var(--muted); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
thead th {
  background: var(--surface-2); text-align: left; padding: 12px 14px;
  font-weight: 600; color: var(--muted); white-space: nowrap;
  position: sticky; top: 0; border-bottom: 1px solid var(--border);
}
tbody td { padding: 11px 14px; border-bottom: 1px solid rgba(38, 49, 73, 0.6); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(108, 140, 255, 0.06); }
td.num, th.num { text-align: right; white-space: nowrap; }

/* FOOTER */
.site-footer {
  text-align: center; padding: 28px; color: var(--muted); font-size: 13px;
}

@media (max-width: 560px) {
  .results-head { flex-direction: column; }
  .results-actions { width: 100%; }
  .results-actions button { flex: 1; }
}
