:root {
  --background: #121317;
  --surface-low: #1a1b20;
  --surface: #1f1f24;
  --surface-high: #292a2e;
  --surface-highest: #343439;
  --surface-bright: #38393d;
  --outline: rgba(145, 143, 160, 0.18);
  --outline-soft: rgba(200, 196, 215, 0.12);
  --primary: #c5c0ff;
  --primary-container: #5a4dde;
  --secondary: #7df4ff;
  --tertiary: #ffb3b0;
  --success: #4ade80;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text: #e3e2e7;
  --text-muted: rgba(200, 196, 215, 0.72);
  --label-font: 'Space Grotesk', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --body-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--body-font);
  color: var(--text);
  background: radial-gradient(900px 520px at 18% -10%, rgba(90, 77, 222, 0.38), transparent 60%),
              radial-gradient(720px 440px at 96% 12%, rgba(125, 244, 255, 0.12), transparent 58%),
              var(--background);
}

.aurora-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(680px 420px at 76% 100%, rgba(255, 179, 176, 0.08), transparent 70%);
}

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

.glass-panel {
  background: rgba(31, 31, 36, 0.56);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(200, 196, 215, 0.08);
}

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 256px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  padding: 24px 14px;
  background: rgba(26, 27, 32, 0.95);
  border-right: 1px solid rgba(200, 196, 215, 0.08);
}

.brand-block {
  padding: 6px 14px 18px;
}

.brand-block h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.brand-block p {
  margin: 6px 0 0;
  color: var(--primary);
  opacity: 0.88;
  font-family: var(--label-font);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
}

.nav-item {
  text-decoration: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px;
  border-radius: 12px;
  border-right: 2px solid transparent;
  transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
  font-size: 14px;
  font-weight: 600;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(56, 57, 61, 0.65);
}

.nav-item.active {
  color: var(--primary);
  background: linear-gradient(90deg, rgba(90, 77, 222, 0.18), rgba(90, 77, 222, 0));
  border-right-color: var(--primary);
}

.sidebar-footer {
  padding: 12px 8px 0;
  border-top: 1px solid rgba(200, 196, 215, 0.1);
}

.btn-primary,
.btn-secondary {
  border: 0;
  border-radius: 12px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  font-family: var(--label-font);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease, background-color 0.2s ease;
}

.btn-primary {
  width: 100%;
  color: #130067;
  font-weight: 700;
  background: linear-gradient(110deg, var(--primary), var(--primary-container));
}

.btn-primary:hover,
.btn-secondary:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn-secondary {
  color: var(--primary);
  border: 1px solid var(--outline-soft);
  background: rgba(52, 52, 57, 0.45);
}

.network-pill {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #9be8b6;
  font-family: var(--label-font);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 10px;
}

.network-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 6px rgba(74, 222, 128, 0.14);
  animation: heartbeat 1.8s infinite;
}

@keyframes heartbeat {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.main-content {
  margin-left: 256px;
  min-height: 100vh;
  position: relative;
}

.top-header {
  position: fixed;
  top: 0;
  right: 0;
  left: 256px;
  z-index: 30;
  min-height: 74px;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(200, 196, 215, 0.1);
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-wrap {
  width: 360px;
  position: relative;
}

.search-wrap.inline {
  width: 100%;
  max-width: 460px;
}

.search-wrap span {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(200, 196, 215, 0.66);
  font-size: 20px;
}

.search-wrap input {
  width: 100%;
  height: 40px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: rgba(13, 14, 18, 0.95);
  color: var(--text);
  padding: 0 14px 0 42px;
  font-size: 13px;
}

.search-wrap input:focus,
select:focus,
.address-form input:focus {
  outline: none;
  border-color: rgba(125, 244, 255, 0.45);
  box-shadow: 0 0 0 3px rgba(125, 244, 255, 0.08);
}

.header-signal,
.last-update {
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--label-font);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.content-shell {
  padding: 100px 28px 28px;
}

.page-head {
  margin-bottom: 18px;
}

.page-head h2 {
  margin: 0;
  font-size: 34px;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.page-head p {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-family: var(--label-font);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: reveal 0.28s ease;
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.kpi-card {
  grid-column: span 3;
  min-height: 126px;
  border-radius: var(--radius);
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.kpi-card.wide {
  grid-column: span 6;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 76px;
  height: 76px;
  background: radial-gradient(circle at top left, rgba(197, 192, 255, 0.16), transparent 72%);
  pointer-events: none;
}

.kpi-card.glow-tertiary::before {
  background: radial-gradient(circle at top left, rgba(255, 179, 176, 0.17), transparent 72%);
}

.kpi-card.glow-warning::before {
  background: radial-gradient(circle at top left, rgba(245, 158, 11, 0.17), transparent 72%);
}

.kpi-card.glow-danger::before {
  background: radial-gradient(circle at top left, rgba(239, 68, 68, 0.17), transparent 72%);
}

.kpi-top {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.kpi-top .material-symbols-outlined {
  font-size: 19px;
}

.kpi-value {
  margin-top: 14px;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.section-card {
  border-radius: var(--radius);
  padding: 18px;
}

.section-card h3 {
  margin: 0 0 14px;
  font-size: 17px;
  font-weight: 700;
}

.chart {
  min-height: 220px;
}

.view-toolbar {
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

select,
.address-form input,
.address-form button {
  height: 40px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: rgba(13, 14, 18, 0.95);
  color: var(--text);
  padding: 0 12px;
  font-size: 13px;
}

.address-form {
  display: grid;
  grid-template-columns: 2fr 1fr 2fr auto;
  gap: 10px;
  margin-bottom: 10px;
}

.address-form button {
  background: linear-gradient(110deg, var(--primary), var(--primary-container));
  color: #130067;
  font-family: var(--label-font);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  border: 0;
}

.inline-message {
  color: var(--text-muted);
  font-size: 12px;
  min-height: 18px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

thead th {
  text-align: left;
  font-family: var(--label-font);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: 10px;
  color: rgba(200, 196, 215, 0.7);
  padding: 11px 12px;
  border-bottom: 1px solid var(--outline);
}

tbody td {
  padding: 12px;
  font-size: 13px;
  color: var(--text);
  border-bottom: 1px solid rgba(145, 143, 160, 0.12);
  vertical-align: top;
}

tbody tr:hover {
  background: rgba(56, 57, 61, 0.26);
}

.address {
  font-family: var(--label-font);
  color: var(--secondary);
  font-size: 12px;
  letter-spacing: 0.02em;
}

.timestamp {
  color: var(--text-muted);
  font-size: 12px;
}

.amount {
  color: var(--text);
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 2px 8px;
  min-height: 22px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge.completed {
  background: rgba(74, 222, 128, 0.14);
  color: #9be8b6;
}

.badge.cancelled {
  background: rgba(239, 68, 68, 0.15);
  color: #ff9ca1;
}

.badge.forced {
  background: rgba(245, 158, 11, 0.15);
  color: #f7c56e;
}

.badge.low {
  background: rgba(125, 244, 255, 0.14);
  color: #a9f7ff;
}

.badge.medium {
  background: rgba(245, 158, 11, 0.15);
  color: #f7c56e;
}

.badge.high {
  background: rgba(251, 146, 60, 0.16);
  color: #ffc083;
}

.badge.critical {
  background: rgba(239, 68, 68, 0.18);
  color: #ff9ca1;
}

.flag-reasons {
  color: #ffc7cb;
  font-size: 12px;
  background: rgba(147, 0, 10, 0.12);
  border: 1px solid rgba(255, 180, 171, 0.16);
  border-radius: 12px;
  padding: 10px 12px;
}

.flag-reasons ul {
  margin: 6px 0 0;
  padding-left: 16px;
}

.trace-btn {
  height: 30px;
  min-width: 62px;
  font-size: 10px;
  padding: 0 10px;
}

.trace-row {
  display: none;
}

.trace-row.open {
  display: table-row;
}

.trace-row td {
  background: rgba(24, 24, 31, 0.85);
}

.trace-timeline {
  display: grid;
  gap: 8px;
}

.trace-item {
  border: 1px solid rgba(145, 143, 160, 0.22);
  border-radius: 10px;
  padding: 10px;
  background: rgba(13, 14, 18, 0.65);
}

.trace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.trace-level {
  font-family: var(--label-font);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
  color: var(--primary);
}

.trace-type {
  font-size: 11px;
  color: var(--text);
  font-weight: 700;
}

.trace-time {
  font-size: 11px;
  color: var(--text-muted);
}

.trace-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 14px;
  font-size: 12px;
  color: var(--text-muted);
}

.trace-explain {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(145, 143, 160, 0.26);
  display: grid;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
}

.trace-explain-row strong {
  color: var(--text);
}

.trace-empty {
  color: var(--text-muted);
  font-size: 12px;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 48px 16px;
  font-size: 13px;
}

.pagination {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(145, 143, 160, 0.16);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pagination-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-btn {
  height: 34px;
  min-width: 68px;
  font-size: 10px;
  letter-spacing: 0.06em;
}

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.pagination-page {
  font-family: var(--label-font);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  color: var(--text-muted);
}

.bar-chart {
  display: grid;
  gap: 10px;
}

.bar-item {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: 10px;
}

.bar-label {
  color: var(--text-muted);
  font-family: var(--label-font);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.bar-container {
  height: 30px;
  border-radius: 10px;
  background: rgba(52, 52, 57, 0.55);
  box-shadow: inset 0 0 0 1px rgba(145, 143, 160, 0.14);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  min-width: 36px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0 9px;
  color: #130067;
  font-family: var(--label-font);
  font-size: 11px;
  font-weight: 700;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.35s ease;
}

.bar-fill.low {
  background: linear-gradient(90deg, #9df6ff, #7df4ff);
}

.bar-fill.medium {
  background: linear-gradient(90deg, #ffd48f, #f59e0b);
}

.bar-fill.high {
  background: linear-gradient(90deg, #ffb981, #fb923c);
}

.bar-fill.critical {
  background: linear-gradient(90deg, #ffb6b2, #ef4444);
}

@media (max-width: 1200px) {
  .kpi-card {
    grid-column: span 4;
  }

  .kpi-card.wide {
    grid-column: span 12;
  }
}

@media (max-width: 1024px) {
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(200, 196, 215, 0.08);
  }

  .main-content {
    margin-left: 0;
  }

  .top-header {
    left: 0;
    position: sticky;
  }

  .content-shell {
    padding-top: 20px;
  }

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

@media (max-width: 768px) {
  .top-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px;
  }

  .header-left,
  .header-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .search-wrap,
  .search-wrap.inline {
    width: 100%;
    max-width: 100%;
  }

  .content-shell {
    padding: 16px 12px 20px;
  }

  .page-head h2 {
    font-size: 28px;
  }

  .kpi-card {
    grid-column: span 12;
  }

  .view-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .filters {
    width: 100%;
    flex-direction: column;
  }

  .filters select {
    width: 100%;
  }

  .address-form {
    grid-template-columns: 1fr;
  }

  table {
    min-width: 680px;
  }

  .pagination {
    flex-direction: column;
    align-items: flex-start;
  }

  .trace-body {
    grid-template-columns: 1fr;
  }
}
