:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --panel: #ffffff;
  --ink: #000000;
  --muted: #575757;
  --line: #e0e0dc;
  --brand-dark: #000000;
  --brand-ink: #ffffff;
  --accent: #ffdd17;
  --accent-2: #000000;
  --chart-primary: #ffdd17;
  --chart-secondary: #000000;
  --chart-track: #efefeb;
  --chart-axis: #d8d8d2;
  --danger: #b42318;
  --soft: #fff8bc;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Unbounded", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease, background-color 0.15s ease;
}

button:hover {
  filter: brightness(1.04);
}

button:active {
  transform: translateY(1px);
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px;
  background: var(--brand-dark);
  color: var(--brand-ink);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.brand-logo {
  display: block;
  width: 62px;
  height: 54px;
  object-fit: contain;
  flex: 0 0 auto;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h2,
.panel h3,
.panel p {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
  line-height: 1.1;
  font-weight: 900;
  text-transform: uppercase;
}

.brand p {
  color: #d7d7d7;
  font-size: 11px;
}

.upload-zone {
  display: grid;
  gap: 7px;
  padding: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  min-height: 140px;
  align-content: center;
}

.upload-zone:hover {
  border-color: rgba(255, 221, 23, 0.85);
  background: rgba(255, 221, 23, 0.12);
}

.upload-zone input {
  display: none;
}

.upload-zone span:last-child {
  color: #d7d7d7;
  font-size: 12px;
}

.upload-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #000;
  font-size: 22px;
  line-height: 1;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.sidebar .panel {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: none;
}

.compact {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.compact h2 {
  font-size: 15px;
}

.period-pair {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.period-pair strong {
  font-size: 13px;
}

label {
  display: grid;
  gap: 6px;
  color: inherit;
  font-size: 13px;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.09);
  color: inherit;
}

.dashboard input,
.dashboard select {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

select option {
  color: var(--ink);
}

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

.quick-ranges button,
.danger-button,
.primary-button,
.secondary-button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 8px 11px;
  font-weight: 700;
}

.quick-ranges button {
  background: rgba(255, 255, 255, 0.11);
  color: var(--brand-ink);
}

.danger-button {
  margin-top: auto;
  background: rgba(180, 35, 24, 0.16);
  color: #ffd8d4;
}

.primary-button {
  background: var(--accent);
  color: #000;
}

.secondary-button {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.dashboard {
  display: grid;
  gap: 18px;
  padding: 26px;
  align-content: start;
  position: relative;
  overflow: hidden;
}

.dashboard::before {
  content: "";
  position: fixed;
  right: -110px;
  top: 92px;
  width: 340px;
  height: 230px;
  background: var(--accent);
  border-radius: 58% 42% 52% 48%;
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
}

.dashboard::after {
  content: "";
  position: fixed;
  right: 36px;
  top: 370px;
  width: 96px;
  height: 96px;
  background-image: radial-gradient(#000 3px, transparent 4px);
  background-size: 24px 24px;
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
}

.dashboard > * {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  min-width: 0;
}

.topbar > div {
  min-width: 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar h2 {
  max-width: 680px;
  font-size: clamp(21px, 2.2vw, 32px);
  line-height: 1.18;
  letter-spacing: 0;
  font-weight: 700;
  text-transform: none;
}

.empty-state {
  display: none;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.empty-state.is-visible {
  display: block;
}

.empty-state h2,
.empty-state p {
  margin: 0;
}

.empty-state p {
  max-width: 720px;
  margin-top: 7px;
  color: var(--muted);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  min-width: 0;
}

.kpi-grid article {
  display: grid;
  gap: 8px;
  min-height: 132px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--accent);
}

.kpi-grid article:nth-child(2),
.kpi-grid article:nth-child(4) {
  border-top-color: var(--accent-2);
}

.kpi-grid span,
.comparison span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.kpi-tax-note {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  font-weight: 800;
  color: var(--ink);
}

.kpi-grid strong {
  font-size: clamp(22px, 2vw, 30px);
  line-height: 1;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.kpi-grid small {
  color: var(--muted);
}

.fiscal-motivator {
  position: relative;
  display: grid;
  align-items: center;
  gap: 18px;
  min-height: 158px;
  margin-top: 16px;
  padding: 18px 22px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--accent);
  box-shadow: var(--shadow);
}

.fiscal-motivator[hidden] {
  display: none;
}

.fiscal-motivator::before {
  content: "";
  position: absolute;
  inset: auto -36px -74px auto;
  width: 210px;
  height: 210px;
  border-radius: 50%;
  background: #fff;
}

.fiscal-motivator-copy {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 7px;
  padding-right: clamp(176px, 25vw, 286px);
}

.fiscal-motivator-kicker {
  width: fit-content;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.fiscal-motivator strong {
  max-width: 780px;
  color: var(--ink);
  font-size: clamp(23px, 3vw, 40px);
  line-height: 1.02;
  font-weight: 900;
}

.fiscal-motivator small {
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.fiscal-motivator img {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 1;
  width: clamp(132px, 17vw, 188px);
  object-fit: contain;
  object-position: bottom center;
  transform: scaleX(-1);
  filter: drop-shadow(0 12px 16px rgba(0, 0, 0, 0.22));
}

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

.chart-panel,
.table-panel,
.content-grid .panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  align-items: start;
}

.panel-heading h3 {
  font-size: 18px;
  font-weight: 900;
}

.panel-heading p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
}

.chart-tooltip {
  position: fixed;
  z-index: 20;
  min-width: 86px;
  padding: 7px 9px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--ink);
  color: var(--accent);
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity 120ms ease;
}

.chart-tooltip.is-visible {
  opacity: 1;
}

.comparison {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.comparison div {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 8px;
  background: #fbfbf8;
  border: 1px solid var(--line);
}

.comparison strong {
  font-size: 24px;
}

.comparison small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.mapping-list {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
  font-size: 13px;
}

.mapping-list dt {
  color: var(--muted);
  font-weight: 800;
}

.mapping-list dd {
  margin: 0;
}

.table-wrap {
  overflow: auto;
}

.table-controls label {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-direction: row;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
}

.table-controls select {
  min-height: 34px;
  width: 84px;
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.pagination {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding-top: 14px;
}

.pagination button {
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #000;
  font-weight: 900;
  padding: 8px 12px;
}

.pagination button:disabled {
  cursor: not-allowed;
  filter: grayscale(1);
  opacity: 0.35;
}

.pagination span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td.money,
th.money {
  text-align: right;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  background: #e7f6ec;
  color: #17663a;
  border: 1px solid #9fd8b5;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.paid {
  background: #e7f6ec;
  color: #17663a;
  border: 1px solid #9fd8b5;
}

.status-pill.open {
  background: #fff6a6;
  color: #000;
  border: 1px solid #ffdd17;
}

.status-pill.overdue {
  background: #ffe7e3;
  color: var(--danger);
  border: 1px solid #f4aaa1;
}

.overdue-days {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 8px;
  padding: 4px 8px;
  background: #fff4ed;
  color: var(--danger);
  font-size: 12px;
  font-weight: 800;
}

.material-preview {
  display: inline-block;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
  white-space: nowrap;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .kpi-grid,
  .content-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .dashboard,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .comparison {
    grid-template-columns: 1fr;
    display: grid;
  }

  .kpi-grid,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .fiscal-motivator {
    grid-template-columns: 1fr;
    padding: 16px 16px 0;
  }

  .fiscal-motivator-copy {
    padding-right: 86px;
  }

  .fiscal-motivator img {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 104px;
    transform: scaleX(-1);
  }
}
