:root {
  color-scheme: dark;
  --bg: #101214;
  --panel: #181d20;
  --text: #f2f5f7;
  --muted: #9aa6ad;
  --line: #313940;
  --green: #51c878;
  --yellow: #e0bd4f;
  --red: #ef6461;
  --cyan: #43b8d8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(1320px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 24px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.summary,
.connection {
  min-width: 110px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.connection.live {
  color: var(--green);
}

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 8px;
  padding-top: 14px;
}

.metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  transition:
    border-color 180ms ease,
    background 180ms ease,
    transform 180ms ease;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  font-size: 26px;
}

.metric.active strong {
  color: var(--green);
}

.metric.locked strong {
  color: var(--red);
}

.metric.watch strong {
  color: var(--yellow);
}

.metric.risk strong {
  color: var(--cyan);
}

.metric.changed {
  animation: metric-pop 520ms ease;
}

.metric.changed.increase {
  border-color: rgba(81, 200, 120, 0.85);
  background: rgba(81, 200, 120, 0.08);
}

.metric.changed.decrease {
  border-color: rgba(239, 100, 97, 0.85);
  background: rgba(239, 100, 97, 0.08);
}

.match-list {
  display: grid;
  gap: 6px;
  padding-top: 14px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 10px;
  align-items: end;
  padding-top: 12px;
}

.sport-filter {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.sport-filter-button {
  flex: 0 0 auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.sport-filter-button span {
  margin-left: 6px;
  color: var(--cyan);
}

.sport-filter-button.active {
  border-color: rgba(67, 184, 216, 0.75);
  background: rgba(67, 184, 216, 0.1);
  color: var(--text);
}

.search-box {
  display: grid;
  gap: 5px;
}

.search-box span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.search-box input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.search-box input:focus {
  border-color: rgba(67, 184, 216, 0.75);
}

.match-row {
  display: grid;
  grid-template-columns: 164px minmax(280px, 1.5fr) 136px 72px minmax(180px, 1fr);
  align-items: center;
  gap: 14px;
  min-height: 58px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.match-row:hover {
  border-color: rgba(67, 184, 216, 0.55);
  background: #1c2428;
  transform: translateY(-1px);
}

.match-row.locked {
  border-color: rgba(239, 100, 97, 0.65);
  background: #211a1b;
  box-shadow: inset 3px 0 0 var(--red);
  animation: locked-glow 1.8s ease-in-out infinite;
}

.match-lock {
  display: grid;
  gap: 4px;
}

.lock-badge {
  width: fit-content;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
}

.lock-badge.open {
  background: rgba(81, 200, 120, 0.12);
  color: var(--green);
}

.lock-badge.locked {
  background: rgba(239, 100, 97, 0.18);
  color: var(--red);
}

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

.league {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.league span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sport-badge {
  flex: 0 0 auto;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--cyan);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.fixture {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
}

.fixture span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fixture strong {
  text-align: center;
}

.match-meta {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.risk-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  font-size: 18px;
}

.risk-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--green);
}

.risk-dot.medium {
  background: var(--yellow);
}

.risk-dot.high {
  background: var(--red);
}

.signals-line {
  overflow: hidden;
  color: #d8dee2;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-drawer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  justify-content: flex-end;
  background: rgba(5, 9, 12, 0.62);
}

.detail-drawer.open {
  display: flex;
}

.drawer-panel {
  width: min(760px, 100%);
  height: 100%;
  overflow: auto;
  border-left: 1px solid var(--line);
  background: #10202a;
  box-shadow: -18px 0 42px rgba(0, 0, 0, 0.38);
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: #0d1a22;
}

.drawer-header h2 {
  margin: 0;
  font-size: 22px;
}

.drawer-header p:last-child {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.drawer-risk {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #10202a;
}

.drawer-risk div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #142730;
}

.drawer-risk span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.drawer-risk strong {
  font-size: 18px;
}

.success-text {
  color: var(--green);
}

.danger-text {
  color: var(--red);
}

.drawer-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border-bottom: 1px solid var(--line);
}

.drawer-tab {
  padding: 12px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: #0d1a22;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.drawer-tab.active {
  border-bottom-color: var(--cyan);
  color: var(--text);
}

.drawer-section {
  display: none;
  padding: 14px 18px 22px;
}

.drawer-section.active {
  display: block;
}

.widget-shell {
  min-height: 360px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1a22;
}

.widget-shell api-sports-widget {
  display: block;
  width: 100%;
}

.widget-empty {
  padding: 22px;
  color: var(--muted);
}

#risk-json {
  margin: 0;
  min-height: 240px;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1a22;
  color: #d8dee2;
  font-size: 12px;
}

.history-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.history-item {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0b1a22;
}

.history-item.locked {
  border-color: rgba(239, 100, 97, 0.55);
}

.history-time,
.history-main div {
  display: grid;
  gap: 4px;
}

.history-time span,
.history-main span,
.history-main p,
.history-empty {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

@keyframes metric-pop {
  0% {
    transform: translateY(0) scale(1);
  }

  35% {
    transform: translateY(-1px) scale(1.025);
  }

  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes locked-glow {
  0%,
  100% {
    border-color: rgba(239, 100, 97, 0.45);
  }

  50% {
    border-color: rgba(239, 100, 97, 0.95);
  }
}

@media (max-width: 920px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 24px;
  }

  .top-actions {
    width: 100%;
  }

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

  .board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary,
  .connection {
    flex: 1;
  }

  .match-row {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 8px;
  }

  .fixture {
    grid-template-columns: minmax(0, 1fr) 52px;
  }

  .fixture span:last-child {
    grid-column: 1 / -1;
  }

  .risk-cell {
    justify-content: flex-start;
  }

  .drawer-panel {
    width: 100%;
  }

  .drawer-risk {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .board {
    grid-template-columns: 1fr;
  }

  .metric strong {
    font-size: 24px;
  }
}
