/* ── Design system ──────────────────────────────────────── */
:root {
  --font-size-base: 15px;
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --color-primary: #4A6FA5;
  --color-primary-dark: #3a5a8c;
  --color-bg: #f0f2f5;
  --color-surface: #ffffff;
  --color-text: #1a1a2e;
  --color-text-muted: #6c757d;
  --color-border: #dde1e7;
  --color-danger: #c0392b;
  --color-success: #27ae60;
  --color-warning: #e67e22;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);
  --transition: 150ms ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: var(--font-size-base); }

body {
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.55;
  min-height: 100vh;
}

/* ── Accessible mode ─────────────────────────────────────── */
body.accessible {
  --font-size-base: 18px;
  --color-text: #000;
  --color-text-muted: #444;
  --color-bg: #f5f5f0;
  --color-border: #999;
}
body.accessible .card { border: 2px solid var(--color-border); }

/* ── Layout ─────────────────────────────────────────────── */
.page-wrapper { max-width: 900px; margin: 0 auto; padding: 16px; }

header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

header .logo { font-weight: 700; font-size: 1.2rem; color: var(--color-primary); text-decoration: none; }
header nav a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
header nav a:hover, header nav a.active { background: var(--color-bg); color: var(--color-text); }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 12px;
}
.card-sm { padding: 14px 16px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity var(--transition), background var(--transition);
  text-decoration: none;
}
.btn:hover { opacity: 0.88; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-danger  { background: var(--color-danger); color: #fff; }
.btn-success { background: var(--color-success); color: #fff; }
.btn-ghost   { background: transparent; color: var(--color-text-muted); border: 1px solid var(--color-border); }
.btn-sm { padding: 5px 10px; font-size: 0.82rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Forms ──────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 5px; font-size: 0.88rem; font-weight: 500; color: var(--color-text-muted); }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color var(--transition);
}
.form-control:focus { outline: none; border-color: var(--color-primary); }
select.form-control { cursor: pointer; }

/* ── Alert / flash ──────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 14px;
}
.alert-error   { background: #fdecea; color: var(--color-danger); border: 1px solid #f5c6c2; }
.alert-success { background: #eafaf1; color: var(--color-success); border: 1px solid #b7e4c7; }

/* ── Filter chips ───────────────────────────────────────── */
.chip-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  transition: all var(--transition);
}
.chip.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ── Event card ─────────────────────────────────────────── */
.event-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border-left: 4px solid transparent;
  margin-bottom: 10px;
  transition: box-shadow var(--transition);
}
.event-card:hover { box-shadow: var(--shadow); }

.event-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

.event-body { flex: 1; min-width: 0; }
.event-name { font-weight: 600; font-size: 1rem; }
.event-name-he { font-size: 0.9rem; color: var(--color-text-muted); direction: rtl; }
.event-meta { font-size: 0.83rem; color: var(--color-text-muted); margin-top: 3px; }
.event-days { font-size: 0.82rem; font-weight: 600; color: var(--color-primary); margin-top: 2px; }

.event-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 1.1rem;
  padding: 4px;
  border-radius: 4px;
  transition: color var(--transition);
}
.icon-btn:hover { color: var(--color-text); }
.icon-btn.active { color: var(--color-primary); }

/* ── Tabs ────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--color-border); margin-bottom: 20px; }
.tab {
  padding: 9px 18px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
}
.tab:hover { color: var(--color-text); }
.tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-primary { background: #e8f0fa; color: var(--color-primary); }
.badge-danger  { background: #fdecea; color: var(--color-danger); }
.badge-muted   { background: #f0f0f0; color: var(--color-text-muted); }
.badge-success { background: #eafaf1; color: var(--color-success); }

/* ── Toggle ──────────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}
.toggle-row:last-child { border-bottom: none; }

.toggle {
  position: relative;
  width: 40px; height: 22px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--color-border);
  border-radius: 22px;
  cursor: pointer;
  transition: background var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  top: 3px; left: 3px;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle input:checked + .toggle-slider { background: var(--color-primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h3 { font-size: 1.1rem; }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--color-text-muted); }

/* ── Login page ──────────────────────────────────────────── */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #e8eef7 0%, #f0f2f5 100%);
}
.login-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
}
.login-card h1 { font-size: 1.5rem; margin-bottom: 4px; }
.login-card .subtitle { color: var(--color-text-muted); font-size: 0.88rem; margin-bottom: 24px; }

/* ── Prefs ───────────────────────────────────────────────── */
.tier-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}
.tier-row:last-child { border-bottom: none; }
.tier-label { font-size: 0.9rem; }
.tier-days { width: 70px; text-align: center; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 600px) {
  header { padding: 0 12px; }
  .page-wrapper { padding: 12px; }
  .event-card { flex-wrap: wrap; }
  .tier-row { grid-template-columns: 1fr auto; }
  .tier-days { display: none; }
}

/* ── Utility ─────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-muted { color: var(--color-text-muted); }
.text-center { text-align: center; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.empty-state { text-align: center; padding: 40px; color: var(--color-text-muted); }
