:root {
  color-scheme: dark;
  --bg: #111312;
  --bg-deep: #0b0d0c;
  --surface: #191d1b;
  --surface-2: #202622;
  --surface-3: #151816;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(52, 211, 153, 0.42);
  --text: #f4f7f5;
  --muted: #9ba7a0;
  --accent: #34d399;
  --accent-2: #38bdf8;
  --green: #63e68b;
  --yellow: #f5cf5a;
  --red: #ff6b6b;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.26);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg-deep);
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 160px),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
select {
  font: inherit;
}

.app {
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 16px 16px 32px;
}

.topbar,
.filters,
.panel,
.kpi-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(25, 29, 27, 0.96);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 18px;
}

.title-block {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: 28px;
  font-weight: 750;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 17px;
  font-weight: 750;
}

.subtitle {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.status {
  min-width: 128px;
  border: 1px solid rgba(52, 211, 153, 0.24);
  border-radius: 8px;
  padding: 9px 11px;
  background: var(--surface-3);
  color: var(--green);
  font-size: 13px;
  font-weight: 750;
  text-align: center;
}

button,
.export-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 8px;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}

button {
  border: 0;
  background: var(--accent);
  color: #07100b;
  cursor: pointer;
}

button:hover {
  background: #55e7ad;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.export-link {
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: var(--surface-2);
  color: var(--text);
}

.export-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 10px;
  margin-top: 10px;
  padding: 10px;
}

label,
.filter-control {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

input,
select,
.multi-select-button {
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface-3);
  color: var(--text);
  outline: none;
}

input:focus,
select:focus,
.multi-select-button:focus {
  border-color: var(--line-strong);
}

.filter-label {
  min-height: 14px;
}

.multi-select {
  position: relative;
  min-width: 0;
}

.multi-select-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  text-align: left;
}

.multi-select-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-select-button::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-left: 10px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px);
}

.multi-select.open .multi-select-button {
  border-color: var(--line-strong);
}

.multi-select-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: none;
  max-height: 250px;
  overflow: auto;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  background: #121512;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
  padding: 6px;
}

.multi-select.open .multi-select-menu {
  display: grid;
  gap: 4px;
}

.multi-option {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  border-radius: 6px;
  padding: 5px 6px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.multi-option:hover {
  background: rgba(255, 255, 255, 0.05);
}

.multi-option input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.multi-empty {
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.kpi-card {
  min-height: 104px;
  padding: 13px;
}

.kpi-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.kpi-card strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: clamp(22px, 2.3vw, 30px);
  font-weight: 700;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.kpi-card small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.kpi-card.error {
  border-color: rgba(255, 107, 107, 0.45);
}

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

.panel {
  min-height: 280px;
  min-width: 0;
  padding: 13px;
}

.panel-wide {
  grid-column: 1 / -1;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.panel-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.legend {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.fact-dot,
.plan-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.fact-dot {
  background: var(--accent);
}

.plan-dot {
  background: var(--accent-2);
}

.bar-chart,
.plan-chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(50px, 1fr);
  align-items: end;
  gap: 9px;
  height: 226px;
  padding-top: 6px;
}

.bar {
  display: grid;
  grid-template-rows: 1fr auto auto;
  align-items: end;
  gap: 7px;
  height: 100%;
  min-width: 0;
}

.bar-fill {
  width: 100%;
  min-height: 8px;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, var(--accent), #16895c);
  box-shadow: 0 0 18px rgba(52, 211, 153, 0.18);
}

.plan-chart {
  height: 240px;
}

.plan-column {
  display: grid;
  grid-template-rows: 1fr auto auto;
  align-items: end;
  gap: 8px;
  height: 100%;
  min-width: 0;
}

.plan-bars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: end;
  gap: 6px;
  height: 100%;
}

.plan-bar {
  min-height: 8px;
  border-radius: 8px 8px 3px 3px;
}

.plan-bar.fact {
  background: linear-gradient(180deg, var(--accent), #16895c);
}

.plan-bar.plan {
  background: linear-gradient(180deg, var(--accent-2), #16719b);
  opacity: 0.68;
}

.plan-caption {
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.bar-value,
.bar-label {
  overflow-wrap: anywhere;
  text-align: center;
  font-size: 12px;
}

.bar-value {
  color: var(--muted);
}

.bar-label {
  color: var(--text);
}

.list-chart {
  display: grid;
  gap: 11px;
}

.list-row {
  display: grid;
  gap: 7px;
}

.list-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.list-meta strong {
  min-width: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

.list-meta span {
  flex: 0 0 auto;
  color: var(--muted);
}

.track {
  height: 10px;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 160px;
  border: 1px dashed rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
}

.empty-state.compact {
  min-height: 92px;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

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

th,
td {
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
}

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

td {
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
}

.tag {
  display: inline-flex;
  border-radius: 8px;
  padding: 4px 9px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.tag.won {
  background: rgba(99, 230, 139, 0.14);
  color: var(--green);
}

.tag.lost {
  background: rgba(255, 107, 107, 0.15);
  color: var(--red);
}

.tag.open {
  background: rgba(245, 207, 90, 0.14);
  color: var(--yellow);
}

@media (max-width: 1120px) {
  .filters,
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .topbar,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

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

@media (max-width: 560px) {
  .app {
    padding: 10px;
  }

  .filters,
  .kpis {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 24px;
  }

  .bar-chart,
  .plan-chart {
    grid-auto-columns: minmax(42px, 1fr);
    gap: 7px;
  }
}
