:root {
  --bg: #f3f4ef;
  --surface: #ffffff;
  --surface-2: #f7f8f3;
  --text: #1f241e;
  --muted: #5f675c;
  --line: #dde1d6;
  --accent: #1d6f4a;
  --accent-soft: #dceee5;
  --danger: #b23d3d;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  background: radial-gradient(circle at top left, #ffffff 0%, var(--bg) 50%, #ecefe6 100%);
  color: var(--text);
}

.app-shell {
  max-width: 1400px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.language-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.language-select {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
}

.england-flag-logo {
  position: relative;
  width: 88px;
  height: 64px;
  border: 1px solid #d7d7d7;
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
  flex-shrink: 0;
}

.england-flag-h,
.england-flag-v {
  position: absolute;
  background: #c8102e;
}

.england-flag-h {
  left: 0;
  right: 0;
  top: 50%;
  height: 14px;
  transform: translateY(-50%);
}

.england-flag-v {
  top: 0;
  bottom: 0;
  left: 50%;
  width: 14px;
  transform: translateX(-50%);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
}

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

.layout {
  display: grid;
  grid-template-columns: 280px 1fr 360px;
  gap: 16px;
  min-height: 0;
  flex: 1;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

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

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

.events-title-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.events-header .filters {
  width: 100%;
}

.tree,
.events-list,
.odds-content {
  padding: 12px;
}

.tree {
  overflow: auto;
}

.events-list {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#oddsList {
  overflow: auto;
  padding: 0 12px 12px;
}

.btn {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.btn:hover {
  border-color: #c4cbbb;
}

.btn.ghost {
  background: transparent;
}

.btn.small {
  padding: 6px 8px;
  font-size: 12px;
}

.chip {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}

.state {
  margin: 12px;
  border-radius: 10px;
  border: 1px dashed var(--line);
  padding: 12px;
  color: var(--muted);
  font-size: 14px;
}

.state-loading {
  background: #fdfef8;
}

.state-error {
  border-color: #e6c9c9;
  color: var(--danger);
  background: #fff5f5;
}

.state-empty {
  background: #fbfbfb;
}

.tree ul {
  list-style: none;
  margin: 0;
  padding-left: 14px;
}

.tree .tree-node-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 8px;
}

.tree .tree-node-row:hover {
  background: var(--surface-2);
}

.tree .tree-node-btn {
  flex: 1;
  text-align: left;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  color: var(--text);
  font-size: 14px;
}

.tree .tree-node-btn.active {
  color: var(--accent);
  font-weight: 700;
}

.tree .unknown {
  color: #7f5a0d;
  border: 1px solid #e9d6a2;
  background: #fff8e6;
  border-radius: 999px;
  font-size: 11px;
  padding: 2px 6px;
}

.expand-btn {
  width: 20px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  position: relative;
  overflow: visible;
}

.custom-filter-wrap {
  position: relative;
  display: inline-flex;
}

.custom-range {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 30;
  width: min(430px, 88vw);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
}

.range-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.range-field input {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
  min-height: 32px;
}

.filter-btn {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
}

.filter-btn.active {
  background: var(--accent-soft);
  border-color: #a9ceb9;
  color: var(--accent);
  font-weight: 700;
}

.event-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.event-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}

.match-title {
  font-size: 15px;
  font-weight: 700;
}

.meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.status {
  border-radius: 999px;
  font-size: 11px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-live {
  color: #0f6a40;
  background: #e2f5eb;
  border-color: #b9dec8;
}

.status-upcoming {
  color: #1f4d8f;
  background: #eaf1fc;
  border-color: #cad9f4;
}

.status-finished {
  color: #6c6c6c;
  background: #f3f3f3;
  border-color: #dfdfdf;
}

.best-odds {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.odd-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px;
  background: var(--surface-2);
  font-size: 12px;
}

.odd-pill strong {
  display: block;
  color: var(--text);
  margin-bottom: 2px;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
}

.open-details-btn {
  border: 1px solid #a9ceb9;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}

#matchMeta {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

#matchMeta .match-title {
  margin-bottom: 6px;
}

.odds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.odds-table th,
.odds-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 6px;
  text-align: left;
}

.odds-table th {
  color: var(--muted);
  font-weight: 600;
}

.odds-updated {
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 240px 1fr;
  }

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

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

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

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .england-flag-logo {
    width: 76px;
    height: 56px;
  }

  .layout {
    display: flex;
    flex-direction: column;
  }

  .best-odds {
    grid-template-columns: 1fr;
  }

  .custom-range {
    left: auto;
    right: 0;
    width: min(420px, 88vw);
    flex-direction: column;
    align-items: stretch;
  }
}
