:root {
  --ink: #202124;
  --muted: #687076;
  --line: #d9dee2;
  --paper: #f7f4ef;
  --panel: #ffffff;
  --teal: #0f766e;
  --teal-soft: #d7f2ee;
  --coral: #d95f43;
  --coral-soft: #f9ddd4;
  --gold: #b98516;
  --gold-soft: #f5e7bd;
  --green: #2f7d4f;
  --shadow: 0 12px 30px rgba(47, 52, 58, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 22px clamp(16px, 4vw, 44px);
  background: #fffaf2;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.1;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.75rem, 3vw, 2.75rem);
}

h2 {
  font-size: clamp(1.25rem, 2vw, 1.75rem);
}

h3 {
  font-size: 1rem;
}

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

.filters label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.filters input {
  height: 38px;
  min-width: 142px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

button {
  height: 38px;
  padding: 0 14px;
  color: #fff;
  background: var(--teal);
  border: 1px solid var(--teal);
  border-radius: 6px;
  cursor: pointer;
}

button.ghost {
  color: var(--teal);
  background: transparent;
}

.button-link {
  display: inline-grid;
  place-items: center;
  height: 38px;
  padding: 0 14px;
  color: var(--teal);
  background: transparent;
  border: 1px solid var(--teal);
  border-radius: 6px;
  text-decoration: none;
  font-weight: 700;
}

main {
  padding: 24px clamp(16px, 4vw, 44px) 42px;
}

.hero-band {
  display: grid;
  grid-template-columns: minmax(290px, 1.1fr) minmax(300px, 1.8fr);
  gap: 16px;
  margin-bottom: 20px;
}

.latest-panel,
.panel,
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.latest-panel {
  min-height: 176px;
  display: grid;
  align-content: space-between;
  gap: 18px;
  padding: 20px;
}

.draw-line {
  display: grid;
  gap: 12px;
}

.number-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ball,
.star {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.95rem;
}

.ball {
  color: #fff;
  background: var(--teal);
}

.star {
  color: #3d2a00;
  background: var(--gold-soft);
  border: 1px solid #d2ad4f;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
}

.kpi {
  min-height: 84px;
  padding: 14px;
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.kpi strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.2rem, 2vw, 1.8rem);
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin: 0 0 18px;
}

.tab {
  flex: 0 0 auto;
  color: var(--ink);
  background: #fffaf2;
  border-color: var(--line);
}

.tab.active {
  color: #fff;
  background: var(--coral);
  border-color: var(--coral);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: grid;
  gap: 16px;
}

.section-grid {
  display: grid;
  gap: 16px;
}

.section-grid.two {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.section-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel {
  min-width: 0;
  padding: 16px;
}

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

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

.panel-head span {
  color: var(--muted);
  font-size: 0.82rem;
}

.heatmap {
  display: grid;
  gap: 6px;
}

.heatmap.balls {
  grid-template-columns: repeat(10, minmax(36px, 1fr));
}

.heatmap.stars {
  grid-template-columns: repeat(4, minmax(42px, 1fr));
}

.heatmap.eurodreams-balls {
  grid-template-columns: repeat(8, minmax(42px, 1fr));
}

.heatmap.dream-heatmap {
  grid-template-columns: repeat(5, minmax(42px, 1fr));
}

.heat-cell {
  min-height: 54px;
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 6px 4px;
  border: 1px solid rgba(32, 33, 36, 0.08);
  border-radius: 6px;
}

.heat-cell strong {
  font-size: 0.98rem;
}

.heat-cell span {
  font-size: 0.72rem;
  color: rgba(32, 33, 36, 0.72);
}

.bar-list {
  display: grid;
  gap: 8px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(76px, 150px) 1fr minmax(48px, auto);
  align-items: center;
  gap: 10px;
  min-height: 28px;
}

.bar-row .label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.bar-track {
  height: 11px;
  background: #edf0ee;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  min-width: 2px;
  background: var(--teal);
}

.bar-row .value {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.compact .bar-row {
  grid-template-columns: minmax(86px, 170px) 1fr minmax(56px, auto);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  padding: 9px 8px;
  border-bottom: 1px solid #eceff1;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.mini-numbers {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.mini {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: #fff;
  background: var(--teal);
  font-size: 0.76rem;
  font-weight: 800;
}

.mini.star-mini {
  color: #3d2a00;
  background: var(--gold-soft);
  border: 1px solid #d2ad4f;
}

.combo-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.combo-list.wide-combos {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.combo {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: #f7fbfa;
  border: 1px solid #b8d6d1;
  border-radius: 8px;
}

.combo strong {
  font-size: 0.9rem;
}

.combo span {
  color: var(--muted);
  font-size: 0.82rem;
}

.combo .mini-numbers {
  gap: 8px;
  align-items: center;
}

.combo-number {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: #ffffff !important;
  background: #064e45;
  border: 2px solid #032f2a;
  border-radius: 50%;
  font-size: 1.08rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.45);
  box-shadow:
    inset 0 -2px 0 rgba(0, 0, 0, 0.22),
    0 1px 3px rgba(0, 0, 0, 0.12);
}

.combo-number.star-mini {
  color: #2f2100 !important;
  background: #ffd966;
  border-color: #a97400;
  text-shadow: none;
}

.prediction-note {
  padding: 12px 14px;
  color: #59440b;
  background: var(--gold-soft);
  border: 1px solid #d2ad4f;
  border-radius: 8px;
  font-size: 0.9rem;
}

.prediction-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 12px;
}

.prediction-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.synthesis-panel {
  border-color: #b8d6d1;
}

.synthesis-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(300px, 1.5fr);
  gap: 14px;
  align-items: start;
}

.synthesis-main {
  display: grid;
  gap: 12px;
}

.synthesis-main .prediction-ball,
.synthesis-main .prediction-star {
  width: 46px;
  height: 46px;
  font-size: 1.08rem;
}

.synthesis-main p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.synthesis-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.synthesis-metrics div {
  min-height: 54px;
  padding: 8px 6px;
  background: #fbfcfb;
  border: 1px solid #edf0ee;
  border-radius: 6px;
  text-align: center;
}

.synthesis-metrics span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.synthesis-metrics strong {
  display: block;
  margin-top: 5px;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

.prediction-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.prediction-card-head span {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: #fff;
  background: var(--coral);
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.78rem;
}

.prediction-card p {
  min-height: 54px;
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.prediction-numbers {
  display: grid;
  gap: 8px;
}

.prediction-ball,
.prediction-star {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.88rem;
}

.prediction-ball {
  color: #fff;
  background: var(--teal);
}

.prediction-star {
  color: #3d2a00;
  background: var(--gold-soft);
  border: 1px solid #d2ad4f;
}

.prediction-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.prediction-metrics div {
  min-height: 48px;
  padding: 7px 5px;
  background: #fbfcfb;
  border: 1px solid #edf0ee;
  border-radius: 6px;
  text-align: center;
}

.prediction-metrics span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.prediction-metrics strong {
  display: block;
  margin-top: 4px;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.signal-list {
  display: grid;
  gap: 10px;
}

.signal-row {
  display: grid;
  grid-template-columns: minmax(110px, 150px) 1fr;
  gap: 12px;
  align-items: center;
  min-height: 34px;
}

.signal-row > span {
  color: var(--muted);
  font-weight: 700;
}

.signal-value {
  min-width: 0;
  font-weight: 800;
}

.method-list {
  display: grid;
  gap: 10px;
}

.method-row {
  display: grid;
  gap: 4px;
  min-height: 56px;
  padding: 10px;
  background: #fbfcfb;
  border: 1px solid #edf0ee;
  border-radius: 6px;
}

.method-row strong {
  font-size: 0.92rem;
}

.method-row span {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

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

.advanced-card {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.advanced-rank {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: #fff;
  background: var(--coral);
  border-radius: 50%;
  font-weight: 800;
}

.advanced-main {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.advanced-score {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.advanced-metrics {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
}

.advanced-metrics div {
  min-height: 46px;
  padding: 7px 5px;
  background: #fff;
  border: 1px solid #edf0ee;
  border-radius: 6px;
  text-align: center;
}

.advanced-metrics span {
  display: block;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
}

.advanced-metrics strong {
  display: block;
  margin-top: 4px;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.grid-form,
.csv-tools {
  display: grid;
  gap: 12px;
}

.grid-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.grid-form input,
.csv-tools input,
.csv-tools textarea {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.csv-tools textarea {
  resize: vertical;
  min-height: 130px;
  line-height: 1.4;
}

.grid-inputs {
  display: grid;
  grid-template-columns: repeat(7, minmax(48px, 1fr));
  gap: 8px;
}

.grid-inputs input {
  text-align: center;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.manual-star {
  background: var(--gold-soft) !important;
  border-color: #d2ad4f !important;
}

.grid-status {
  min-height: 42px;
}

.grid-status > div,
.empty-state {
  padding: 12px 14px;
  color: var(--muted);
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.grid-status strong {
  color: var(--ink);
}

.status-error {
  color: #7d1d0f !important;
  background: var(--coral-soft) !important;
  border-color: #e9a694 !important;
}

.icon-action {
  width: 30px;
  height: 30px;
  padding: 0;
  color: var(--coral);
  background: transparent;
  border-color: #e9a694;
  font-size: 1.25rem;
  line-height: 1;
}

.matrix {
  display: grid;
  gap: 10px;
}

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

.matrix-cells {
  display: grid;
  grid-template-columns: repeat(25, minmax(12px, 1fr));
  gap: 3px;
}

.matrix-cell {
  aspect-ratio: 1;
  min-height: 12px;
  border-radius: 2px;
  background: var(--teal-soft);
}

canvas {
  width: 100%;
  max-height: 280px;
  display: block;
}

.error {
  padding: 16px;
  color: #7d1d0f;
  background: var(--coral-soft);
  border: 1px solid #e9a694;
  border-radius: 8px;
}

@media (max-width: 980px) {
  .topbar,
  .hero-band,
  .section-grid.two,
  .section-grid.three,
  .prediction-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
    align-items: start;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .matrix-cells {
    grid-template-columns: repeat(10, minmax(18px, 1fr));
  }

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

  .advanced-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

@media (max-width: 560px) {
  main {
    padding-inline: 12px;
  }

  .topbar {
    padding-inline: 12px;
  }

  .filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .filters label,
  .filters input,
  .filters button {
    min-width: 0;
    width: 100%;
  }

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

  .heatmap.balls {
    grid-template-columns: repeat(5, minmax(44px, 1fr));
  }

  .heatmap.eurodreams-balls {
    grid-template-columns: repeat(4, minmax(44px, 1fr));
  }

  .heatmap.dream-heatmap {
    grid-template-columns: repeat(5, minmax(42px, 1fr));
  }

  .bar-row {
    grid-template-columns: minmax(62px, 110px) 1fr minmax(42px, auto);
  }

  .prediction-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .advanced-card {
    grid-template-columns: 1fr;
  }

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

  .grid-inputs {
    grid-template-columns: repeat(4, minmax(48px, 1fr));
  }

  .signal-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}
