:root {
  --bg: #f3f6fb;
  --ink: #1a2332;
  --muted: #64748b;
  --white: #ffffff;
  --blue: #3b82f6;
  --orange: #f97316;
  --green: #22c55e;
  --green-deep: #16a34a;
  --violet: #8b5cf6;
  --rose: #f43f5e;
  --sky: #0ea5e9;
  --shadow: 0 8px 24px rgba(26, 35, 50, 0.08);
  --radius: 16px;
  --font: "Nunito", "Segoe UI", sans-serif;
  --display: "Outfit", "Nunito", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 0% 0%, rgba(59, 130, 246, 0.14), transparent 55%),
    radial-gradient(800px 380px at 100% 0%, rgba(249, 115, 22, 0.12), transparent 50%),
    var(--bg);
}

.wrap {
  width: min(1240px, calc(100% - 1.25rem));
  margin: 0 auto;
  padding: 0.65rem 0 1.75rem;
}

/* compact top toolbar — always one row */
.toolbar {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.65rem 0.85rem;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.75rem;
}

.brand {
  margin: 0 0.15rem 0 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.45rem;
  letter-spacing: -0.03em;
  text-decoration: none;
  color: var(--ink) !important;
  line-height: 1;
  white-space: nowrap;
  flex: 0 0 auto;
}

.brand span { color: var(--orange); }

.month-nav {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
}

.nav-btn {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--blue), var(--sky));
  color: #fff !important;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none !important;
}

.nav-btn svg {
  width: 20px;
  height: 20px;
  display: block;
}

.nav-btn:hover { filter: brightness(1.06); }
.nav-btn.is-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.nav-selects {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.35rem;
}

.nav-selects select,
.compare-box select {
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid #e2e8f0;
  background: #f8fafc url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M1 1l5 5 5-5'/%3E%3C/svg%3E") right 0.55rem center / 11px no-repeat;
  border-radius: 10px;
  padding: 0.4rem 1.7rem 0.4rem 0.65rem;
  font: inherit;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--ink);
}

.nav-selects select:focus,
.compare-box select:focus {
  outline: none;
  border-color: var(--blue);
}

.compare-box {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
  flex: 0 0 auto;
}

.compare-box .label {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
}

.compare-box .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--orange);
}

/* charts first */
.charts {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.chart-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.65rem 0.75rem 0.25rem;
}

.chart-card.primary {
  padding-top: 0.75rem;
}

.chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 0.85rem;
  margin-bottom: 0.15rem;
  padding: 0 0.15rem;
}

.chart-card h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 800;
}

.chip {
  background: linear-gradient(135deg, #dbeafe, #eff6ff);
  color: #1d4ed8;
  font-weight: 800;
  font-size: 0.88rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
}

.chip-violet {
  background: linear-gradient(135deg, #ede9fe, #f5f3ff);
  color: #6d28d9;
}

.chip-sky {
  background: linear-gradient(135deg, #e0f2fe, #f0f9ff);
  color: #0369a1;
}

.invoice-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.55rem 0.75rem;
  margin: 0.35rem 0 0.55rem;
  padding: 0.15rem 0.15rem 0.35rem;
}

.inv-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.inv-field span {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.inv-field input[type="date"] {
  border: 2px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 10px;
  padding: 0.42rem 0.65rem;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  min-width: 10.5rem;
}

.inv-field input[type="date"]:focus {
  outline: none;
  border-color: var(--sky);
}

.inv-btn {
  border: none;
  border-radius: 10px;
  padding: 0.5rem 1rem;
  font: inherit;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  cursor: pointer;
}

.inv-btn:hover { filter: brightness(1.05); }

.inv-hint {
  margin: 0;
  flex: 1 1 12rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  align-self: center;
}

.invoice-kpis .yk.highlight {
  background: linear-gradient(135deg, #e0f2fe, #f0f9ff);
  border-color: #bae6fd;
}

.invoice-kpis .yk.highlight strong {
  color: #0369a1;
}

.year-pick {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.year-pick label {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
}

.year-pick select {
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 10px;
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-weight: 800;
  color: var(--ink);
}

.year-kpis {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.55rem;
  margin: 0.35rem 0 0.5rem;
}

.year-kpis .yk {
  background: #f8fafc;
  border: 1px solid #e8eef7;
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
}

.year-kpis .label {
  display: block;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}

.year-kpis strong {
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.year-kpis strong small {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 700;
}

.year-kpis em {
  display: block;
  margin-top: 0.15rem;
  font-style: normal;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
}

@media (max-width: 960px) {
  .year-kpis { grid-template-columns: 1fr 1fr; }
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.85rem;
}

.legend-row span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 700;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.swatch.blue { background: var(--blue); }
.swatch.orange { background: var(--orange); }

.chart-box {
  min-height: 320px;
}

.chart-box.tall {
  min-height: 380px;
}

.chart-card.primary .chart-box {
  min-height: 420px;
}

/* KPI below charts — compact */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.65rem;
}

.kpi {
  position: relative;
  overflow: hidden;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.7rem 0.85rem 0.75rem;
}

.kpi::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
}

.kpi.blue::before { background: linear-gradient(180deg, var(--blue), var(--sky)); }
.kpi.orange::before { background: linear-gradient(180deg, var(--orange), #fb923c); }
.kpi.green::before { background: linear-gradient(180deg, var(--green), #4ade80); }
.kpi.violet::before { background: linear-gradient(180deg, var(--violet), #a78bfa); }

.kpi .label {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi .value {
  margin: 0.2rem 0 0;
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.kpi .value small {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  margin-left: 0.12rem;
}

.kpi .meta {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  font-weight: 700;
}

.kpi .meta.up { color: var(--rose); }
.kpi .meta.down { color: var(--green-deep); }
.kpi .meta.flat { color: var(--muted); }

.kpi .meta .sub-inline {
  color: var(--muted);
  font-weight: 600;
}

.kpi .sub {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 960px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .toolbar { flex-wrap: wrap; }
  .compare-box { margin-left: 0; }
  .chart-card.primary .chart-box { min-height: 360px; }
}

@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .chart-card.primary .chart-box,
  .chart-box { min-height: 300px; }
  .nav-selects select { max-width: 42vw; }
}
