:root {
  --bg: #f3efe6;
  --panel: rgba(255, 252, 245, 0.88);
  --panel-border: rgba(55, 39, 28, 0.12);
  --ink: #2d2118;
  --muted: #695448;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --error: #b42318;
  --success: #1f7a1f;
  --pending: #9a6700;
  --shadow: 0 24px 60px rgba(45, 33, 24, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(163, 91, 35, 0.22), transparent 30%),
    linear-gradient(180deg, #faf6ee 0%, #f3efe6 100%);
}

.shell {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 72px;
}

.hero {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-dark);
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.2rem, 4vw, 3.5rem);
  line-height: 1;
}

.lede {
  width: min(700px, 100%);
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.6;
}

.panel {
  backdrop-filter: blur(12px);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.panel + .panel {
  margin-top: 20px;
}

.stack {
  display: grid;
  gap: 18px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 0.92rem;
  font-weight: 700;
}

input:not([type="file"]),
select,
.button {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(45, 33, 24, 0.14);
  padding: 14px 16px;
  font: inherit;
}

input:not([type="file"]),
select {
  background: rgba(255, 255, 255, 0.88);
}

input[readonly] {
  color: var(--muted);
}

.field-label {
  font-size: 0.92rem;
  font-weight: 700;
}

.file-picker {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px 14px;
  align-items: center;
}

.file-trigger {
  width: auto;
  min-width: 180px;
  box-shadow: none;
}

.file-name {
  min-width: 0;
  color: var(--muted);
}

.visually-hidden-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  text-decoration: none;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
  box-shadow: 0 12px 24px rgba(15, 118, 110, 0.2);
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.button.secondary {
  width: auto;
  background: linear-gradient(135deg, #7c4f2d, #b06f31);
  box-shadow: 0 12px 24px rgba(124, 79, 45, 0.2);
}

.hidden {
  display: none;
}

.status-banner {
  border-radius: 14px;
  padding: 14px 16px;
  font-weight: 700;
}

.status-banner.is-pending {
  background: rgba(154, 103, 0, 0.1);
  color: var(--pending);
}

.status-banner.is-success {
  background: rgba(31, 122, 31, 0.1);
  color: var(--success);
}

.status-banner.is-error {
  background: rgba(180, 35, 24, 0.1);
  color: var(--error);
}

.summary dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 18px 0 0;
}

.summary div {
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  padding: 14px 16px;
}

.summary dt {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.summary dd {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.download {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.pivot {
  margin-top: 24px;
}

.pivot-card {
  border-top: 1px solid rgba(45, 33, 24, 0.08);
  padding-top: 22px;
}

.pivot-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 18px;
}

.pivot-eyebrow {
  margin: 0 0 4px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-dark);
}

.pivot-header h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 2.4vw, 1.8rem);
}

.pivot-total {
  margin: 0;
  min-width: 180px;
  border-radius: 16px;
  background: rgba(15, 118, 110, 0.08);
  padding: 12px 16px;
  color: var(--muted);
  text-align: right;
}

.pivot-total strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 1.2rem;
}

.pivot-table-shell {
  overflow-x: auto;
  border-radius: 18px;
  border: 1px solid rgba(45, 33, 24, 0.08);
  background: rgba(255, 255, 255, 0.8);
}

.pivot-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
}

.pivot-table th,
.pivot-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(45, 33, 24, 0.08);
  text-align: right;
  white-space: nowrap;
}

.pivot-table thead th {
  background: rgba(45, 33, 24, 0.05);
  color: var(--muted);
  font-size: 0.84rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pivot-table th:first-child,
.pivot-table td:first-child {
  text-align: left;
}

.pivot-table tbody tr:nth-child(even) {
  background: rgba(15, 118, 110, 0.03);
}

.pivot-table tfoot th,
.pivot-table tfoot td,
.pivot-table .total-cell {
  font-weight: 700;
  color: var(--ink);
}

.pivot-table tfoot th,
.pivot-table tfoot td {
  background: rgba(176, 111, 49, 0.1);
  border-bottom: 0;
}

.errors ul {
  margin: 18px 0 0;
  padding-left: 20px;
  color: var(--error);
  line-height: 1.5;
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 20px, 980px);
    padding-top: 28px;
  }

  .panel {
    padding: 18px;
    border-radius: 20px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .file-picker {
    grid-template-columns: 1fr;
  }

  .file-trigger {
    width: 100%;
  }

  .pivot-header {
    align-items: stretch;
    flex-direction: column;
  }

  .pivot-total {
    min-width: 0;
    width: 100%;
    text-align: left;
  }

}
