:root {
  --bg: #080b12;
  --panel: #101827;
  --panel-2: #0d1422;
  --line: rgba(148, 163, 184, 0.18);
  --line-strong: rgba(148, 163, 184, 0.28);
  --text: #f8fafc;
  --muted: #94a3b8;
  --soft: #64748b;
  --blue: #3b82f6;
  --violet: #8b5cf6;
  --green: #34d399;
  --yellow: #f59e0b;
  --red: #fb7185;
  --grad: linear-gradient(135deg, #3b82f6, #8b5cf6 62%, #a855f7);
  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Noto Sans SC", "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overflow-x: hidden; }
body {
  background:
    radial-gradient(900px 520px at 18% -8%, rgba(59, 130, 246, 0.22), transparent 62%),
    radial-gradient(760px 520px at 90% 8%, rgba(139, 92, 246, 0.18), transparent 62%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button, select { font: inherit; }

.dash-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(8, 11, 18, 0.82);
  backdrop-filter: blur(18px);
}

.dash-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.dash-brand img { width: 30px; height: 30px; }
.dash-brand span span {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.dash-nav {
  display: grid;
  gap: 8px;
  margin-top: 36px;
}
.dash-nav a {
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
}
.dash-nav a:hover,
.dash-nav a.is-active {
  color: var(--text);
  background: rgba(148, 163, 184, 0.08);
  border-color: var(--line);
}

.dash-source {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 24px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(16, 24, 39, 0.72);
}
.dash-source__label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.dash-source__value {
  margin-top: 8px;
  font-weight: 700;
}

.dash-main {
  min-width: 0;
  padding: 32px;
}

.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 28px;
}
.dash-kicker,
.panel-head p {
  margin: 0 0 8px;
  color: var(--blue);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.dash-header h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 48px);
  letter-spacing: 0;
  line-height: 1.05;
}

.dash-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.dash-btn,
.dash-select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 24, 39, 0.86);
  color: var(--text);
  padding: 0 14px;
}
.dash-btn {
  cursor: pointer;
  font-weight: 700;
}
.dash-btn:hover,
.dash-select:hover {
  border-color: var(--line-strong);
  background: rgba(30, 41, 59, 0.92);
}
.dash-btn--danger { color: var(--red); }

.dash-grid {
  display: grid;
  gap: 18px;
}
.dash-grid--kpis {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 18px;
}
.dash-grid--main {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: stretch;
}

.kpi-card,
.dash-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(16, 24, 39, 0.92), rgba(13, 20, 34, 0.92));
  box-shadow: 0 24px 70px -48px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.kpi-card {
  padding: 20px;
  min-height: 138px;
}
.kpi-card span,
.kpi-card em {
  display: block;
  color: var(--muted);
  font-size: 13px;
}
.kpi-card strong {
  display: block;
  margin: 14px 0 8px;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1;
  letter-spacing: 0;
}
.kpi-card em {
  font-family: var(--mono);
  font-style: normal;
  color: var(--soft);
}

.dash-panel {
  padding: 22px;
  min-width: 0;
}
.dash-panel--wide { grid-column: span 2; }
.dash-panel--table {
  margin-top: 18px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.panel-head h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}
.panel-head > span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.trend-chart {
  height: 260px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: end;
  gap: 10px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.trend-bar {
  min-width: 0;
  display: grid;
  align-items: end;
  gap: 8px;
  height: 100%;
}
.trend-bar i {
  display: block;
  min-height: 4px;
  border-radius: 6px 6px 2px 2px;
  background: var(--grad);
  box-shadow: 0 14px 30px -16px rgba(139, 92, 246, 0.9);
}
.trend-bar span {
  overflow: hidden;
  color: var(--soft);
  font-family: var(--mono);
  font-size: 10px;
  text-align: center;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.rank-list {
  display: grid;
  gap: 12px;
}
.rank-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}
.rank-row__label {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.rank-row__value {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}
.rank-row__bar {
  grid-column: 1 / -1;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.13);
}
.rank-row__bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--grad);
}

.donut-wrap {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 18px;
  align-items: center;
}
.donut-wrap canvas {
  width: 180px;
  height: 180px;
}
.donut-legend {
  display: grid;
  gap: 10px;
}
.legend-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}
.legend-row i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
}

.event-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.event-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}
.event-table th,
.event-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
}
.event-table th {
  color: var(--soft);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(15, 23, 42, 0.72);
}
.event-table td {
  color: var(--muted);
}
.event-table tr:last-child td { border-bottom: 0; }
.event-badge {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--text);
  background: rgba(59, 130, 246, 0.16);
  font-family: var(--mono);
  font-size: 11px;
}

.empty-state {
  padding: 34px;
  margin-bottom: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  text-align: center;
}
.empty-state h3 {
  margin: 0 0 8px;
}
.empty-state p {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 1180px) {
  body { grid-template-columns: 1fr; }
  .dash-sidebar {
    position: relative;
    height: auto;
    display: flex;
    align-items: center;
    gap: 20px;
  }
  .dash-nav {
    display: flex;
    flex-wrap: wrap;
    margin-top: 0;
  }
  .dash-source {
    position: static;
    margin-left: auto;
  }
  .dash-grid--kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash-grid--main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .dash-main { padding: 20px; }
  .dash-header { flex-direction: column; }
  .dash-actions { justify-content: flex-start; }
  .dash-grid--kpis,
  .dash-grid--main { grid-template-columns: 1fr; }
  .dash-panel--wide { grid-column: span 1; }
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .dash-sidebar { align-items: flex-start; flex-direction: column; }
  .dash-source { width: 100%; margin-left: 0; }
}
