:root {
  --bg-a: #f4f6fa;
  --bg-b: #edf0f7;
  --text: #1a2b4a;
  --muted: #8492a6;
  --border: #e8ecf1;
  --card: #ffffff;
  --navy: #1a2b4a;
  --blue: #5b8def;
  --purple: #7c6df0;
  --teal: #4ecdc4;
  --orange: #e8725a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "DM Sans", "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-a) 0%, var(--bg-b) 100%);
}

.app {
  min-height: 100vh;
  padding: 24px 28px 20px;
  max-width: 1680px;
  margin: 0 auto;
}

.loading {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filters {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.filter-item {
  display: grid;
  gap: 4px;
  min-width: 130px;
}

.filter-item span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filter-item input,
.filter-item select {
  border: 1px solid #d9e2ec;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  min-height: 36px;
}

.logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--blue), var(--purple));
}

h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.02em;
}

.subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.kpi-row-compare {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 22px 18px;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--blue);
}

.kpi-card[data-accent="navy"]::before {
  background: var(--navy);
}
.kpi-card[data-accent="purple"]::before {
  background: var(--purple);
}
.kpi-card[data-accent="teal"]::before {
  background: var(--teal);
}
.kpi-card[data-accent="orange"]::before {
  background: var(--orange);
}

.kpi-label {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 56px;
  line-height: 1.02;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-feature-settings: "tnum";
}

.kpi-sub {
  margin-top: 8px;
  color: #73859f;
  font-size: 14px;
}

.kpi-delta {
  margin-top: 10px;
  display: inline-block;
  font-size: 12px;
  border-radius: 999px;
  padding: 5px 10px;
  font-weight: 600;
}

.kpi-delta.up {
  color: #0f8f4a;
  background: #e8f7ef;
}

.kpi-delta.down {
  color: #c63a3a;
  background: #fcecec;
}

.kpi-delta.neutral {
  color: #5a6b80;
  background: #eef3f8;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
  align-items: stretch;
}

.grid-revenue-split {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
  align-items: stretch;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}

.panel-title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 700;
}

.panel canvas {
  width: 100% !important;
  height: 260px !important;
}

.panel-trend {
  display: flex;
  flex-direction: column;
  min-height: 280px;
}

.panel-trend canvas {
  flex: 1 1 0;
  min-height: 0;
  width: 100% !important;
  height: 100% !important;
}

.donut-wrap {
  width: min(100%, 320px);
  aspect-ratio: 1 / 1;
  margin: 0 auto 8px;
}

.grid-revenue-split .donut-wrap {
  width: min(100%, 200px);
  max-height: min(50vh, 200px);
}

.donut-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.split-list {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

.split-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.split-list li:last-child {
  border-bottom: none;
}

.split-name {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #5a6b80;
  font-size: 13px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.split-value {
  font-size: 14px;
  font-weight: 700;
}

.split-pct {
  color: var(--muted);
  font-size: 11px;
  margin-left: 6px;
}

.type-bars {
  display: grid;
  gap: 12px;
}

.type-row-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.type-name {
  font-size: 13px;
  font-weight: 600;
}

.type-amount {
  font-size: 13px;
  font-weight: 700;
}

.type-track {
  height: 8px;
  background: #f0f2f5;
  border-radius: 5px;
  overflow: hidden;
}

.type-fill {
  height: 100%;
  border-radius: 5px;
}

.type-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.emp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.emp-card {
  border-radius: 10px;
  padding: 14px 16px;
}

.emp-card[data-type="Employee"] {
  background: linear-gradient(135deg, #e8f5e9, #f1f8e9);
  border: 1px solid #c8e6c9;
}

.emp-card[data-type="Contractor"] {
  background: linear-gradient(135deg, #fff3e0, #fff8e1);
  border: 1px solid #ffe0b2;
}

.emp-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.emp-value {
  margin-top: 4px;
  font-size: 24px;
  font-weight: 700;
}

.emp-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.table-panel {
  margin-bottom: 10px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

th {
  text-align: left;
  padding: 9px 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 11px;
  border-bottom: 2px solid var(--border);
}

th.num,
td.num {
  text-align: right;
  font-feature-settings: "tnum";
}

td {
  padding: 9px 10px;
}

tbody tr:nth-child(even) {
  background: #f8fafc;
}

tbody tr td:first-child {
  font-weight: 600;
}

tfoot td {
  border-top: 2px solid var(--navy);
  font-weight: 700;
  padding-top: 12px;
}

.footer {
  text-align: center;
  color: #b0bec5;
  font-size: 11px;
  margin-top: 8px;
}

@media (max-width: 1200px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .filters {
    width: 100%;
    justify-content: flex-start;
  }

  .kpi-row,
  .grid-2,
  .grid-revenue-split {
    grid-template-columns: 1fr;
  }
}
