* { box-sizing: border-box; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #e8ede6;
  color: #1a1a1a;
  margin: 0;
  padding: 0 24px 48px;
  line-height: 1.5;
  font-size: 13px;
}

/* ---------- Topbar ---------- */
.topbar {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 4px 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
  color: #1a1a1a;
}
.hero-logo {
  display: block;
  margin: 0 auto 18px;
  height: 120px;
  width: auto;
}
.top-right { display: flex; align-items: center; gap: 12px; font-size: 12px; }
.admin-link { color: #7a7a7a; text-decoration: none; }
.admin-link:hover { color: #1a1a1a; }
.admin-dot { color: #2d6a4f; font-weight: 600; }
.inline-form { display: inline; margin: 0; }

/* ---------- Flashes ---------- */
.flashes { max-width: 1100px; margin: 0 auto 12px; }
.flash {
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 8px;
  font-size: 13px;
}
.flash-success { background: #d8f0c8; color: #1f4d1f; }
.flash-error   { background: #fde2e2; color: #7a1f1f; }

/* ---------- Login ---------- */
.login-hero {
  max-width: 420px;
  margin: 0 auto;
  text-align: center;
  min-height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
}
.login-hero h1 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.4px;
  margin: 0 0 8px;
  color: #1a1a1a;
}
.login-hero .sub {
  font-size: 13px;
  color: #7a7a7a;
  margin: 0 0 24px;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
}
.login-form input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid #dfe6d8;
  border-radius: 14px;
  font-size: 13px;
  background: #fff;
  font-family: inherit;
  color: #1a1a1a;
}
.login-form input[type="password"]:focus {
  outline: none;
  border-color: #a8e6a1;
  box-shadow: 0 0 0 3px rgba(168, 230, 161, 0.35);
}
.login-form .btn-primary { width: 100%; }

/* ---------- Hero / upload ---------- */
.hero {
  max-width: 580px;
  margin: 0 auto 32px;
  text-align: center;
  min-height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
}
.hero h1 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.4px;
  margin: 0 0 8px;
  color: #1a1a1a;
}
.hero .sub {
  font-size: 13px;
  color: #7a7a7a;
  margin: 0 0 24px;
}

.drop-form { margin: 0; }
.drop {
  display: block;
  background: #fff;
  border-radius: 24px;
  padding: 48px 32px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  text-align: center;
}
.drop:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(20,20,20,.06);
}
.drop input[type="file"] {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.drop:focus-within {
  outline: 2px solid #a8e6a1;
  outline-offset: 2px;
}
.drop-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #a8e6a1;
  color: #141414;
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 14px;
}
.drop-label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 4px;
}
.drop-hint {
  display: block;
  font-size: 12px;
  color: #7a7a7a;
}

.file-pills {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.file-pills li {
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  color: #1a1a1a;
}

.process-form { margin: 18px 0 0; }
.btn-primary {
  background: #141414;
  color: #fff;
  border: none;
  padding: 14px 28px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: inherit;
}
.btn-primary:hover { background: #2a2a2a; }
.btn-primary:disabled {
  background: #d4d4d4;
  color: #7a7a7a;
  cursor: not-allowed;
}
.btn-primary:disabled .arrow { background: #fff; }
.btn-primary .arrow {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #a8e6a1;
  color: #141414;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.ghost-form { margin: 8px 0 0; }
.link-muted {
  background: none;
  border: none;
  color: #7a7a7a;
  font-size: 12px;
  cursor: pointer;
  padding: 6px;
  font-family: inherit;
}
.link-muted:hover { color: #1a1a1a; }

.hint-note {
  margin-top: 16px;
  font-size: 12px;
  color: #92400e;
  background: #fef3c7;
  border-radius: 10px;
  padding: 8px 14px;
  display: inline-block;
}

/* ---------- Admin panel ---------- */
.admin-panel {
  max-width: 880px;
  margin: 48px auto 0;
  padding-top: 24px;
  border-top: 1px solid #d4dcce;
}
.admin-panel > h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #7a7a7a;
  font-weight: 600;
  margin: 0 0 14px;
  text-align: center;
}
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}
.admin-card {
  background: #fff;
  border-radius: 18px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.admin-card h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}
.admin-card .muted { margin: 0; color: #7a7a7a; font-size: 12px; }
.admin-card .ok-text { margin: 0; color: #2d6a4f; font-size: 12px; font-weight: 500; }
.admin-card .warn-text { margin: 0; color: #92400e; font-size: 12px; font-weight: 500; }
.admin-card .stack { display: flex; flex-direction: column; gap: 6px; margin: 0; }

.admin-card input[type="file"] {
  font-size: 12px;
  padding: 8px 10px;
  border: 1px dashed #c4d490;
  border-radius: 10px;
  background: #f5f7ec;
  color: #7a7a7a;
  width: 100%;
}

.btn-dark {
  background: #141414;
  color: #fff;
  border: none;
  padding: 9px 14px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.btn-dark:hover { background: #2a2a2a; }
.btn-ghost {
  background: #f1f4ed;
  color: #1a1a1a;
  border: none;
  padding: 9px 14px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.btn-ghost:hover { background: #e6ebde; }
.btn-ghost.danger-text { color: #991b1b; }
.btn-ghost.danger-text:hover { background: #fde2e2; }

.tracker-list { margin: 0; padding: 0; list-style: none; font-size: 12px; }
.tracker-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #f1f4ed;
}
.tracker-list li:last-child { border: none; }
.tracker-list a { color: #1a1a1a; text-decoration: none; }
.tracker-list a:hover { text-decoration: underline; }
.link-btn {
  background: none; border: none; color: #a8a8a8;
  cursor: pointer; font-size: 14px; padding: 0 4px;
  font-family: inherit;
}
.link-btn:hover { color: #991b1b; }

/* ---------- Progress overlay ---------- */
#proc-overlay {
  position: fixed; inset: 0;
  background: rgba(20,20,20,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; backdrop-filter: blur(3px);
}
#proc-overlay[hidden] { display: none !important; }
.proc-card {
  background: #fff;
  border-radius: 22px;
  padding: 30px 32px;
  min-width: min(480px, 92vw);
  box-shadow: 0 30px 80px rgba(0,0,0,.25);
  text-align: center;
}
.proc-card h3 { margin: 0 0 16px; color: #1a1a1a; font-size: 16px; font-weight: 600; }
.proc-bar {
  height: 10px;
  border-radius: 999px;
  background: #f1f4ed;
  overflow: hidden;
}
.proc-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: #a8e6a1;
  transition: width .35s ease;
}
.proc-pct { margin: 10px 0 4px; font-weight: 600; color: #1a1a1a; font-size: 14px; }
.proc-msg { margin: 6px 0 0; color: #7a7a7a; font-size: 12px; min-height: 1.4em; }
.proc-summary {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #d8f0c8; color: #1f4d1f;
  font-weight: 500; font-size: 13px;
}
.proc-summary.error { background: #fde2e2; color: #7a1f1f; }
#proc-close { margin-top: 14px; }

/* ---------- Summary chips ---------- */
.summary {
  max-width: 1100px;
  margin: 32px auto 16px;
  background: #fff;
  border-radius: 18px;
  padding: 18px 22px;
}
.summary h2 { margin: 0 0 10px; font-size: 13px; font-weight: 600; }
.counts { display: flex; flex-wrap: wrap; gap: 8px; }
.count-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.count-pill .count { font-size: 14px; font-weight: 700; }
.count-pill.ok     { background: #d8f0c8; color: #1f4d1f; }
.count-pill.warn   { background: #fef3c7; color: #92400e; }
.count-pill.danger { background: #fde2e2; color: #7a1f1f; }
.count-pill.orange { background: #ffedd5; color: #9a3412; }
.count-pill.grey   { background: #eef0e9; color: #4b4b4b; }

/* ---------- Results ---------- */
.results { max-width: 1100px; margin: 24px auto 0; }
.results-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.results-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.results-meta { font-size: 12px; color: #7a7a7a; font-weight: normal; }
.results-actions { display: flex; gap: 8px; }

.table-wrap {
  background: #fff;
  border-radius: 14px;
  overflow-x: auto;
}

/* ---------- Excel-style results table (kept faithful to .xlsx export) ---------- */
.xl-wrap { max-height: 70vh; overflow: auto; }
.xl-table {
  width: max-content;
  min-width: 100%;
  font-size: 12px;
  border-collapse: collapse;
}
.xl-table th, .xl-table td {
  padding: 6px 10px;
  border: 1px solid #eef0e9;
  white-space: nowrap;
  vertical-align: top;
  text-align: left;
}
.xl-table thead th {
  background: #141414;
  color: #fff;
  font-weight: 600;
  position: sticky; top: 0; z-index: 2;
  border-color: #1a1a1a;
}
.xl-table tbody tr:nth-child(even) td:not(.flag-cell) { background: #fafbf8; }
.xl-table tbody tr:hover td:not(.flag-cell) { background: #f1f4ed; }
.xl-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.xl-table td.filename { color: #6b7280; font-size: 11px; }
.xl-table td.detail.wrap {
  white-space: pre-wrap;
  max-width: 380px;
  color: #374151;
}
.xl-table .flag-cell {
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.3px;
  text-align: center;
}
.xl-table .flag-OK                       { background: #c6efce; color: #006100; }
.xl-table .flag-ALREADY_IN_LEDGER        { background: #ddebf7; color: #1f4e78; }
.xl-table .flag-PO_NOT_ON_INVOICE        { background: #ffeb9c; color: #9c5700; }
.xl-table .flag-MISSING_FIELDS           { background: #ffeb9c; color: #9c5700; }
.xl-table .flag-PO_NOT_FOUND_IN_TRACKER  { background: #ffc7ce; color: #9c0006; }
.xl-table .flag-OVERSPEND                { background: #ffc7ce; color: #9c0006; }
.xl-table .flag-DUPLICATE_INVOICE        { background: #ffd9b3; color: #9a3412; }
.xl-table .flag-EXTRACTION_FAILED        { background: #d9d9d9; color: #374151; }
.xl-table .flag-UNKNOWN                  { background: #f3f4f6; color: #6b7280; }
.xl-link {
  color: #1a1a1a;
  font-weight: 600;
  text-decoration: underline;
}
.xl-link.wa    { color: #128c7e; }
.xl-link.email { color: #b45309; }

.danger-text { color: #991b1b; }
.ok-text { color: #2d6a4f; }
.warn-text { color: #92400e; }
