:root {
  --bg: #0b1020;
  --panel: rgba(17, 24, 39, 0.9);
  --panel-2: rgba(20, 28, 47, 0.96);
  --text: #edf2ff;
  --muted: #9aa6c4;
  --line: rgba(148, 163, 184, 0.18);
  --accent: #7c5cff;
  --accent-2: #5eead4;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  --danger: #fb7185;
  --success: #34d399;
}

body.theme-light {
  --bg: #eef3ff;
  --panel: rgba(255, 255, 255, 0.95);
  --panel-2: rgba(255, 255, 255, 0.98);
  --text: #142033;
  --muted: #5b6885;
  --line: rgba(100, 116, 139, 0.18);
  --accent: #5b45ff;
  --accent-2: #0f9e9e;
  --shadow: 0 20px 60px rgba(16, 24, 40, 0.12);
  --danger: #e11d48;
  --success: #059669;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, Arial, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(124, 92, 255, 0.18), transparent 30%),
    radial-gradient(circle at top left, rgba(94, 234, 212, 0.12), transparent 28%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

body.lang-he {
  font-family: Heebo, Inter, Arial, sans-serif;
}

.app-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}
.brand-wrap {
  display: flex;
  gap: 12px;
  align-items: center;
}
.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent-2);
  margin-bottom: 4px;
}
.hero h1 {
  margin: 0;
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.1;
}
.subtext {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.main-layout {
  display: grid;
  grid-template-columns: 1.12fr 0.88fr;
  gap: 14px;
  align-items: start;
}

.panel {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 16px;
  backdrop-filter: blur(16px);
}
.panel-header h2, .results-title-row h3 {
  margin: 0;
}
.panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.split {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.tight { margin-bottom: 10px; }

.top-fields {
  display: grid;
  grid-template-columns: 1.4fr 0.6fr;
  gap: 10px;
  margin-bottom: 10px;
}
.top-fields.second-row {
  grid-template-columns: 1fr 1fr;
}
.event-name-field, .years-field, .client-field, .adar-field { min-width: 0; }
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field > span, .field legend {
  font-size: 13px;
  font-weight: 600;
}
input, select, button {
  font: inherit;
}
input, select {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
}
body.theme-light input, body.theme-light select {
  background: rgba(255, 255, 255, 0.85);
}
fieldset.radio-group {
  margin: 0;
  padding: 10px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-inline-end: 14px;
  margin-top: 6px;
  color: var(--text);
  font-size: 13px;
}
.radio-group input {
  width: auto;
  margin: 0;
}

.calendar-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 6px;
}
.calendar-panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
  background: rgba(255,255,255,0.02);
}
.calendar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.calendar-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.month-trigger {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 17px;
  font-weight: 800;
  padding: 0;
  cursor: pointer;
  text-align: start;
  line-height: 1.15;
}
.month-trigger:hover { color: var(--accent-2); }
.calendar-mini-note {
  color: var(--muted);
  font-size: 11px;
  padding-top: 4px;
}
.weekday-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 6px;
}
.weekday-header span {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}
.calendar-grid.compact {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.day-cell {
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: rgba(255,255,255,0.03);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 6px 3px;
  cursor: pointer;
}
.day-cell:hover {
  border-color: rgba(124, 92, 255, 0.55);
  background: rgba(124, 92, 255, 0.14);
}
.day-cell.empty {
  visibility: hidden;
  pointer-events: none;
}
.day-cell.selected {
  background: linear-gradient(180deg, rgba(124,92,255,.35), rgba(94,234,212,.22));
  border-color: rgba(94,234,212,.65);
}
.day-main {
  font-weight: 800;
  font-size: 13px;
}
.day-sub {
  font-size: 10px;
  color: var(--muted);
}
body.lang-he .day-main, body.lang-he .day-sub, body.lang-he .month-trigger, body.lang-he .mini-value, body.lang-he #selectedHebSummary, body.lang-he #selectedGregSummary {
  direction: rtl;
}
.picked-summary {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  min-height: 16px;
}

.action-row {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}
.primary-btn, .ghost-btn, .scope-btn {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 12px;
  cursor: pointer;
  transition: .15s ease;
}
.primary-btn {
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: white;
  border-color: transparent;
  font-weight: 700;
}
.ghost-btn, .scope-btn {
  background: rgba(255,255,255,.04);
  color: var(--text);
}
.small { padding: 6px 10px; border-radius: 10px; }
.ghost-btn:hover, .scope-btn:hover { border-color: rgba(124,92,255,.55); }
.primary-btn:hover { transform: translateY(-1px); }

.export-strip {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.export-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: rgba(255,255,255,.025);
}
.export-title {
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 14px;
}
.scope-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.scope-btn { flex: 1 1 80px; }

.mini-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.mini-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
}
.mini-label {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 6px;
}
.mini-value {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.results-column {
  min-width: 0;
}
.results-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.results-list {
  min-height: 220px;
  max-height: 340px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.results-list.empty {
  color: var(--muted);
  display: grid;
  place-items: center;
}
.result-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255,255,255,.03);
}
.result-date {
  font-weight: 700;
  margin-bottom: 3px;
  font-size: 14px;
}
.result-sub {
  color: var(--muted);
  font-size: 12px;
}
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(124,92,255,.18);
  border: 1px solid rgba(124,92,255,.35);
  font-weight: 700;
  font-size: 13px;
}

.picker-dialog {
  border: 0;
  padding: 0;
  background: transparent;
}
.picker-dialog::backdrop {
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
}
.dialog-card {
  width: min(460px, calc(100vw - 24px));
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  color: var(--text);
  padding: 14px;
}
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.dialog-head h3 { margin: 0; }
.month-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.month-option {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  background: rgba(255,255,255,.04);
  color: var(--text);
  cursor: pointer;
}
.month-option.active {
  background: rgba(124,92,255,.18);
  border-color: rgba(94,234,212,.55);
}

.toast {
  position: fixed;
  inset-inline-end: 20px;
  bottom: 20px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 14px;
  color: white;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: var(--shadow);
  z-index: 20;
}
.toast.error { background: rgba(127, 29, 29, 0.94); }

@media (max-width: 1080px) {
  .main-layout { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .calendar-pair, .results-grid, .mini-cards, .top-fields, .top-fields.second-row, .export-strip {
  grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-columns: 1fr;
  }
  .hero {
    flex-direction: column;
    align-items: stretch;
  }
  .hero-actions { justify-content: flex-start; }
}
@media (max-width: 560px) {
  .app-shell { padding: 12px; }
  .panel { padding: 14px; border-radius: 16px; }
  .day-cell { min-height: 40px; border-radius: 10px; }
  .month-grid { grid-template-columns: repeat(2, 1fr); }
  .day-main { font-size: 12px; }
  .day-sub { font-size: 9px; }
}


.single-export {
  grid-template-columns: 1fr;
}

#monthPickerYear {
  appearance: none;
  -webkit-appearance: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
body.theme-light #monthPickerYear {
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(243,246,255,0.98));
}
#monthPickerYear option {
  background: #111827;
  color: #eef2ff;
}
body.theme-light #monthPickerYear option {
  background: #ffffff;
  color: #142033;
}

.radio-group {
  gap: 10px 18px;
}

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