:root {
  --astro-teal: #00353E;
  --astro-gold: #BD9D4C;
  --astro-cream: #E0DCD2;
  --astro-teal-soft: #1a4a52;
  --astro-teal-line: #2a5a62;
  --page-bg: #f7f5f0;
  --ink: #18282c;
  --ink-muted: #5a6a6e;
  --surface: #ffffff;
  --danger: #a63a2b;
  --berica: #5a3f7a;
  --inwards: #2a6a5a;
  --unmatched: #8a6a1a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 53, 62, 0.06), 0 4px 12px rgba(0, 53, 62, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page-bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

header {
  background: var(--astro-teal);
  color: var(--astro-cream);
  padding: 24px 32px 20px;
  border-bottom: 3px solid var(--astro-gold);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--astro-gold);
  font-size: 13px;
  margin-bottom: 6px;
}

header h1 {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 600;
  color: #fff;
}

header .lede {
  margin: 0;
  color: var(--astro-cream);
  opacity: 0.85;
  font-size: 14px;
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 28px 32px 40px;
}

.dropzone {
  border: 2px dashed var(--astro-teal-line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover,
.dropzone.dragging {
  border-color: var(--astro-gold);
  background: #fffdf6;
}

.dropzone-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--astro-teal);
  margin-bottom: 4px;
}

.dropzone-sub {
  color: var(--ink-muted);
  font-size: 14px;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--astro-teal);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}

.link-btn:hover { color: var(--astro-gold); }

.hidden { display: none !important; }

.results {
  margin-top: 20px;
}

.results-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--ink-muted);
}

.file-meta {
  font-weight: 500;
  color: var(--ink);
}

.dot {
  margin: 0 6px;
  opacity: 0.5;
}

.totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.total-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--astro-teal);
}

.total-card.astro { border-top-color: var(--astro-teal); }
.total-card.berica { border-top-color: var(--berica); }
.total-card.inwards { border-top-color: var(--inwards); }
.total-card.unmatched { border-top-color: var(--unmatched); background: #fffbf0; }

.total-label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

.total-amount {
  display: flex;
  align-items: center;
  gap: 8px;
}

.big {
  font-size: 26px;
  font-weight: 700;
  color: var(--astro-teal);
  font-variant-numeric: tabular-nums;
}

.total-card.berica .big { color: var(--berica); }
.total-card.inwards .big { color: var(--inwards); }
.total-card.unmatched .big { color: var(--unmatched); }

.copy-btn {
  background: var(--astro-cream);
  border: 1px solid transparent;
  color: var(--astro-teal);
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.copy-btn:hover { background: var(--astro-gold); color: var(--astro-teal); }
.copy-btn.copied { background: var(--astro-teal); color: #fff; }

.total-meta {
  margin-top: 4px;
  font-size: 13px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.grand-total {
  background: var(--astro-teal);
  color: #fff;
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.grand-total strong {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--astro-gold);
}

.sanity {
  font-size: 13px;
  opacity: 0.8;
}

.sanity.warn { color: #ffb347; }

.view-link {
  display: inline-block;
  margin-top: 10px;
  background: none;
  border: none;
  padding: 0;
  color: var(--ink-muted);
  font-size: 12px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.view-link:hover {
  color: var(--astro-teal);
  text-decoration: underline;
}

.total-card.astro .view-link:hover { color: var(--astro-teal); }
.total-card.berica .view-link:hover { color: var(--berica); }
.total-card.inwards .view-link:hover { color: var(--inwards); }
.total-card.unmatched .view-link:hover { color: var(--unmatched); }

.detail-panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  max-height: 70vh;
  overflow: auto;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.detail-head h2 {
  margin: 0;
  font-size: 17px;
  color: var(--astro-teal);
}

.detail-meta {
  color: var(--ink-muted);
  font-size: 13px;
  margin-bottom: 12px;
  font-variant-numeric: tabular-nums;
}

.detail-panel table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.detail-panel th,
.detail-panel td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.detail-panel th {
  color: var(--ink-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  background: var(--surface);
}

.detail-panel th.num,
.detail-panel td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.detail-panel tfoot td {
  font-weight: 700;
  color: var(--astro-teal);
  border-top: 2px solid var(--astro-teal);
  border-bottom: none;
  padding-top: 10px;
}

.detail-summary {
  margin: 8px 0 18px;
  padding: 12px 14px;
  background: var(--astro-cream);
  border-radius: 8px;
}

.detail-summary h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 0;
}

.summary-table td {
  padding: 6px 4px;
  border-bottom: 1px dashed rgba(0, 53, 62, 0.15);
}

.summary-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.summary-table td.radios {
  white-space: nowrap;
  text-align: right;
}

.summary-table td.radios label {
  margin-left: 8px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.summary-table td.radios input {
  margin-right: 3px;
  vertical-align: middle;
  cursor: pointer;
}

.summary-totals {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 2px solid rgba(0, 53, 62, 0.2);
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  font-size: 14px;
}

.summary-totals .tot {
  display: flex;
  align-items: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}

.summary-totals .tot strong {
  color: var(--astro-teal);
  font-size: 16px;
}

.summary-totals .tot.berica strong { color: var(--berica); }
.summary-totals .tot.split strong { color: var(--inwards); }
.summary-totals .tot.warn strong { color: var(--unmatched); }

.review-banner {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 14px;
}

.review-banner.pending {
  background: #fff4d6;
  border: 1px solid #e0c77c;
  color: #6b5410;
}

.review-banner.done {
  background: #e6f3ea;
  border: 1px solid #9cc6ae;
  color: #1c5a38;
}

.summary-table tr.pending td:first-child {
  border-left: 3px solid var(--unmatched);
  padding-left: 10px;
}

.summary-table tr.allocated td:first-child {
  border-left: 3px solid #4a9060;
  padding-left: 10px;
}

.summary-table tr.alloc-astro td:first-child { border-left-color: var(--astro-teal); }
.summary-table tr.alloc-berica td:first-child { border-left-color: var(--berica); }
.summary-table tr.alloc-split td:first-child { border-left-color: var(--inwards); }

.review-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px 2px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  border-radius: 999px;
  letter-spacing: 0.05em;
  vertical-align: middle;
  animation: nudge 1.4s ease-in-out infinite;
}

@keyframes nudge {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-1px); }
}

.summary-totals .copy-btn {
  margin-left: 4px;
}

.summary-group-name {
  font-weight: 500;
}

.summary-sub {
  font-weight: 400;
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 2px;
}

.actions { margin-top: 6px; }

.primary {
  background: var(--astro-gold);
  color: var(--astro-teal);
  border: none;
  border-radius: var(--radius);
  padding: 10px 18px;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
}

.primary:hover { background: #cdae5c; }

.error {
  margin-top: 16px;
  background: #fff1ee;
  border: 1px solid #e5b5ab;
  color: var(--danger);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  white-space: pre-wrap;
}

.refresh-status {
  margin-top: 16px;
  background: #fffdf6;
  border: 1px solid var(--astro-gold);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.refresh-title {
  font-weight: 600;
  color: var(--astro-teal);
  margin-bottom: 10px;
  font-size: 15px;
}

.refresh-sub {
  margin-top: 8px;
  font-size: 13px;
  color: var(--ink-muted);
}

.progress-bar {
  height: 6px;
  background: var(--astro-cream);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.progress-bar-inner {
  position: absolute;
  left: -40%;
  top: 0;
  bottom: 0;
  width: 40%;
  background: var(--astro-gold);
  border-radius: 999px;
  animation: indeterminate 1.4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes indeterminate {
  0% { left: -40%; }
  100% { left: 100%; }
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--astro-teal);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: 0 6px 16px rgba(0, 53, 62, 0.25);
  z-index: 100;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.toast.show { opacity: 1; }
.toast.err { background: var(--danger); }

.dropzone.busy {
  opacity: 0.5;
  pointer-events: none;
}

footer {
  max-width: 880px;
  margin: 0 auto;
  padding: 8px 32px 24px;
  color: var(--ink-muted);
  font-size: 12px;
}

.footer-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
}

.footer-row.muted { opacity: 0.7; }
