:root {
  --ink: #07110f;
  --ink-soft: #2b413d;
  --muted: #607570;
  --green: #0b8f72;
  --gold: #f2a91b;
  --line: rgba(7, 17, 15, 0.14);
  --surface: rgba(255, 255, 255, 0.72);
  --shadow: 0 26px 70px rgba(7, 17, 15, 0.12);
  --max: 1100px;
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

html, body { margin: 0; }

body {
  min-height: 100vh;
  overflow-x: hidden;
  background: linear-gradient(180deg, #f7fbff 0%, #dceaf8 42%, #cde2dd 100%);
  color: var(--ink);
  font-family: Heebo, "Noto Sans Hebrew", "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(7, 17, 15, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(7, 17, 15, 0.028) 1px, transparent 1px);
  background-size: 76px 76px;
}

.topbar {
  position: sticky;
  top: 14px;
  z-index: 30;
  width: min(calc(100% - 28px), var(--max));
  margin: 14px auto 0;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(248, 251, 250, 0.78);
  backdrop-filter: blur(10px);
  box-shadow: 0 16px 40px rgba(7, 17, 15, 0.1);
}

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 900; color: var(--ink); text-decoration: none; }
.mark {
  width: 40px; height: 40px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--ink); color: #fff; font-family: Rubik, Heebo, sans-serif;
}

.back-link {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--ink-soft);
  font-weight: 900;
}

main {
  width: min(calc(100% - 28px), var(--max));
  margin: 24px auto 32px;
  display: grid;
  gap: 16px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 20px;
}

.title {
  margin: 0;
  font-family: Rubik, Heebo, sans-serif;
  font-size: clamp(2rem, 5.6vw, 3.25rem);
  line-height: 0.96;
}

.sub {
  margin: 14px 0 0;
  color: var(--ink-soft);
  font-size: 1.08rem;
  line-height: 1.7;
}

.form-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

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

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

.field input,
.field select {
  width: 100%;
  min-height: 46px;
  border-radius: 7px;
  border: 1px solid rgba(7, 17, 15, 0.18);
  background: rgba(255, 255, 255, 0.9);
  padding: 0 12px;
  font: inherit;
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: none;
}

.date-parts {
  min-height: 46px;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  align-items: center;
  overflow: hidden;
  direction: ltr;
  border-radius: 7px;
  border: 1px solid rgba(7, 17, 15, 0.18);
  background: rgba(255, 255, 255, 0.9);
  padding: 0 8px;
}

.date-parts select {
  min-height: 36px;
  border: 0;
  background: transparent;
  width: auto;
  min-width: 0;
  padding: 0 1px;
  text-align: right;
  font-weight: 700;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

.date-year {
  min-width: 4.2ch;
}

.date-month,
.date-day {
  min-width: 2.4ch;
}

.date-parts select:focus-visible {
  outline: 2px solid rgba(47, 125, 246, 0.45);
  outline-offset: 2px;
}

.date-sep {
  color: #6d7d79;
  font-family: Rubik, Heebo, sans-serif;
  font-weight: 700;
  line-height: 1;
}

.actions {
  display: flex;
  align-items: end;
}

.run {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 7px;
  background: var(--gold);
  color: var(--ink);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(242, 169, 27, 0.28);
}

.run:disabled {
  cursor: wait;
  opacity: 0.86;
}

.results-loader {
  display: grid;
  place-items: center;
  min-height: 220px;
}

.loader-wrap {
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
  color: var(--ink-soft);
}

.loader-spinner {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid rgba(7, 17, 15, 0.14);
  border-top-color: var(--gold);
  animation: spin 850ms linear infinite;
}

.loader-title {
  margin: 2px 0 0;
  font-family: Rubik, Heebo, sans-serif;
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--ink);
}

.loader-sub {
  margin: 0;
  font-size: 0.94rem;
  color: var(--muted);
}

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

.comparison-panel {
  display: grid;
  gap: 10px;
}

.comparison-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.comparison-chip {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(7, 17, 15, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  color: #4e5f5b;
  font-family: Rubik, Heebo, sans-serif;
  font-size: 0.82rem;
  font-weight: 900;
}

.comparison-chip-strong {
  border-color: rgba(11, 143, 114, 0.3);
  background: rgba(221, 247, 239, 0.84);
  color: #0a7360;
}

.comparison-table-wrap {
  border: 1px solid rgba(7, 17, 15, 0.13);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.56);
  overflow-x: auto;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.comparison-table thead th {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(7, 17, 15, 0.12);
  background: rgba(247, 251, 251, 0.78);
  color: #50615d;
  font-family: Rubik, Heebo, sans-serif;
  font-size: 0.84rem;
  font-weight: 900;
  text-align: right;
}

.comparison-table tbody th,
.comparison-table tbody td {
  padding: 16px;
  border-bottom: 1px solid rgba(7, 17, 15, 0.1);
  text-align: right;
}

.comparison-table tbody tr:last-child th,
.comparison-table tbody tr:last-child td {
  border-bottom: none;
}

.comparison-table tbody th {
  color: #5b6c68;
  font-size: 0.92rem;
  font-weight: 800;
}

.comparison-table tbody td {
  color: #334642;
  font-family: Rubik, Heebo, sans-serif;
  font-size: 1.34rem;
  font-weight: 700;
  line-height: 1.08;
}

.comparison-table td.value-strong {
  color: #0b6f5d;
  font-size: 1.62rem;
  font-weight: 800;
}

.num-ltr {
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
}

.chart-box {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.5);
  padding: 10px;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

#resultChart {
  width: 100%;
  aspect-ratio: 760 / 260;
  margin-top: 8px;
}

.legend {
  margin-top: 8px;
  display: flex;
  gap: 14px;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 800;
}

.dot {
  width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-inline-start: 6px;
}

.dot-strategy { background: linear-gradient(105deg, #2f7df6, #0b8f72 58%, #f2a91b); }
.dot-index { background: rgba(111, 133, 128, 0.92); }

.download {
  margin-top: 18px;
  margin-inline: auto;
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  width: min(100%, 280px);
  border-radius: 7px;
  border: 0;
  background: var(--gold);
  color: var(--ink);
  text-decoration: none;
  font-family: Rubik, Heebo, sans-serif;
  font-size: 0.98rem;
  font-weight: 900;
  box-shadow: 0 14px 30px rgba(242, 169, 27, 0.3);
  transition: transform 180ms ease, box-shadow 180ms ease, filter 180ms ease;
}

.download:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 34px rgba(242, 169, 27, 0.34);
  filter: saturate(1.04);
}

.download:active {
  transform: translateY(0);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 980px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .actions { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .topbar {
    width: min(calc(100% - 20px), var(--max));
    margin-top: 10px;
    min-height: 56px;
    padding: 8px 10px;
    gap: 8px;
  }

  .brand {
    gap: 8px;
    font-size: 0.95rem;
  }

  .mark {
    width: 36px;
    height: 36px;
    font-size: 0.82rem;
  }

  .back-link {
    min-height: 40px;
    padding: 0 10px;
    font-size: 0.92rem;
  }

  main {
    width: min(calc(100% - 20px), var(--max));
    margin-top: 14px;
  }

  .panel {
    padding: 14px;
  }

  .chart-head {
    gap: 4px;
    flex-direction: column;
    align-items: flex-start;
  }

  .legend {
    flex-wrap: wrap;
    gap: 8px 14px;
  }

  .download {
    width: 100%;
    justify-content: center;
    text-align: center;
  }
}

@media (max-width: 680px) {
  body { font-size: 16px; }
  body::before { background-size: 48px 48px; }
  .topbar { top: 8px; }
  .title { font-size: 2.2rem; }
  .sub { font-size: 1rem; line-height: 1.6; }
  .form-grid { grid-template-columns: 1fr; }

  .brand span:last-child {
    display: none;
  }

  .back-link {
    padding: 0 9px;
    font-size: 0.86rem;
  }

  .field input,
  .field select,
  .date-parts select {
    font-size: 16px;
  }

  .date-parts {
    gap: 4px;
    padding: 0 6px;
  }

  .comparison-panel {
    gap: 8px;
  }

  .comparison-meta {
    justify-content: flex-start;
  }

  .comparison-chip {
    min-height: 30px;
    padding: 0 10px;
    font-size: 0.74rem;
  }

  .comparison-table {
    min-width: 0;
  }

  .comparison-table thead th {
    padding: 11px 10px;
    font-size: 0.73rem;
  }

  .comparison-table tbody th,
  .comparison-table tbody td {
    padding: 12px 10px;
  }

  .comparison-table tbody th {
    font-size: 0.8rem;
  }

  .comparison-table tbody td {
    font-size: 1.03rem;
  }

  .comparison-table td.value-strong {
    font-size: 1.14rem;
  }

  .chart-box {
    padding: 10px 8px;
  }

  .chart-head {
    font-size: 0.8rem;
  }

  #resultChart {
    aspect-ratio: 760 / 300;
  }

  .legend {
    margin-top: 6px;
    font-size: 0.78rem;
  }

  .download {
    min-height: 50px;
    font-size: 0.95rem;
  }
}
