@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Space+Grotesk:wght@500;700&display=swap");

:root {
  --canvas: #f3f0e8;
  --paper: rgba(255, 255, 255, 0.92);
  --paper-strong: #ffffff;
  --ink: #172033;
  --ink-soft: #53607a;
  --line: rgba(23, 32, 51, 0.12);
  --line-strong: rgba(23, 32, 51, 0.2);
  --navy: #11213e;
  --ochre: #c57c0a;
  --ochre-soft: rgba(197, 124, 10, 0.12);
  --teal: #245f63;
  --error: #9e2a2b;
  --shadow: 0 28px 80px rgba(17, 33, 62, 0.12);
  --shadow-tight: 0 16px 34px rgba(17, 33, 62, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Inter", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(197, 124, 10, 0.14), transparent 26%),
    radial-gradient(circle at bottom right, rgba(36, 95, 99, 0.14), transparent 22%),
    linear-gradient(180deg, #fffdf8 0%, var(--canvas) 100%);
}

.pivot-shell {
  width: min(100%, 1680px);
  margin: 0 auto;
  padding: 18px 24px 40px;
}

.pivot-header {
  display: grid;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 32px;
  background: var(--paper);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-tight);
}

.pivot-header-main,
.pivot-hero,
.pivot-actions,
.control-grid,
.filter-group-header,
.summary-strip,
.pivot-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.pivot-header-main,
.pivot-hero,
.control-grid,
.summary-strip,
.pivot-panel-header {
  flex-wrap: wrap;
}

.pivot-brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: inherit;
  text-decoration: none;
}

.pivot-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--navy), #1a3562);
  color: #ffffff;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
}

.pivot-brand-copy {
  display: grid;
  gap: 2px;
}

.pivot-brand-copy strong,
.pivot-return-link,
.summary-label,
.control-field span,
.pivot-eyebrow,
.pivot-note,
.filter-group-header span,
.pivot-status {
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.pivot-brand-copy strong,
.summary-label,
.control-field span,
.pivot-eyebrow {
  font-size: 0.78rem;
}

.pivot-brand-copy span,
.pivot-copy,
.pivot-note,
.filter-group-header span,
.pivot-status {
  color: var(--ink-soft);
}

.pivot-return-link {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-tight);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
}

.pivot-return-link:hover {
  background: var(--navy);
  color: #ffffff;
}

.pivot-hero h1,
.pivot-panel h2 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
}

.pivot-hero h1 {
  max-width: 720px;
  font-size: clamp(2.3rem, 5vw, 4.2rem);
  line-height: 0.94;
  letter-spacing: -0.045em;
  text-transform: uppercase;
}

.pivot-copy {
  max-width: 760px;
  margin: 14px 0 0;
  font-size: 1rem;
  line-height: 1.6;
}

button,
select,
input {
  font: inherit;
}

.action-button,
.ghost-button,
.filter-chip {
  appearance: none;
  border: 1px solid transparent;
  cursor: pointer;
}

.action-button,
.ghost-button {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 14px;
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.action-button {
  background: var(--ochre);
  color: #ffffff;
}

.ghost-button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.pivot-main {
  display: grid;
  gap: 18px;
  padding-top: 18px;
}

.control-panel,
.pivot-panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--paper);
  box-shadow: var(--shadow-tight);
}

.control-tabs {
  display: inline-flex;
  gap: 8px;
  margin-bottom: 18px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
}

.control-tab {
  appearance: none;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.control-tab.is-active {
  background: var(--navy);
  color: #ffffff;
}

.control-tab-panel {
  display: none;
}

.control-tab-panel.is-active {
  display: block;
}

.control-grid {
  align-items: end;
}

.control-field {
  display: grid;
  gap: 10px;
  min-width: 220px;
  flex: 1 1 220px;
}

.control-field select {
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper-strong);
  color: var(--ink);
}

.control-field input {
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper-strong);
  color: var(--ink);
}

.control-actions {
  display: flex;
  align-items: end;
  flex: 0 0 auto;
}

.filter-groups {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.filter-visibility-copy {
  display: grid;
  gap: 8px;
}

.filter-visibility-copy .pivot-copy {
  margin: 0;
  max-width: none;
}

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

.filter-visibility-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink-soft);
  font-size: 0.86rem;
  font-weight: 700;
}

.filter-visibility-option.is-active {
  border-color: rgba(17, 33, 62, 0.28);
  background: rgba(17, 33, 62, 0.08);
  color: var(--ink);
}

.filter-visibility-option input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.filter-group {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.74);
}

.filter-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 700;
}

.filter-chip.is-active {
  background: var(--navy);
  border-color: var(--navy);
  color: #ffffff;
}

.summary-strip {
  flex-wrap: wrap;
}

.summary-card {
  flex: 1 1 220px;
  display: grid;
  gap: 8px;
  padding: 20px 22px;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(17, 33, 62, 0.97), rgba(36, 95, 99, 0.88));
  color: #ffffff;
  box-shadow: var(--shadow);
}

.summary-card strong {
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  line-height: 1;
}

.summary-label {
  margin: 0;
  color: rgba(255, 255, 255, 0.74);
  font-weight: 700;
}

.pivot-panel h2 {
  font-size: 1.6rem;
}

.pivot-note,
.pivot-status {
  font-size: 0.74rem;
  font-weight: 700;
}

.pivot-status {
  margin-top: 12px;
}

.pivot-status.is-error {
  color: var(--error);
}

.pivot-table-wrap {
  overflow-x: auto;
  margin-top: 16px;
}

.pivot-table {
  width: 100%;
  min-width: 860px;
  border-collapse: separate;
  border-spacing: 0;
}

.pivot-table th,
.pivot-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.pivot-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f9f6ef;
  color: var(--ink-soft);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

.pivot-table tbody th {
  background: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
}

.total-cell,
.grand-total,
.pivot-table tfoot th,
.pivot-table tfoot td {
  font-weight: 800;
  background: rgba(197, 124, 10, 0.08);
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: 18px;
  color: var(--ink-soft);
  text-align: center;
}

@media (max-width: 900px) {
  .pivot-shell {
    padding-inline: 14px;
  }

  .pivot-header,
  .control-panel,
  .pivot-panel {
    padding: 18px;
    border-radius: 22px;
  }

  .pivot-hero h1 {
    font-size: clamp(2rem, 9vw, 3rem);
  }

  .pivot-actions,
  .pivot-return-link {
    width: 100%;
  }

  .pivot-return-link {
    left: 14px;
    right: 14px;
    bottom: 14px;
  }

  .action-button,
  .ghost-button {
    flex: 1 1 180px;
  }
}