:root {
  --brand: #5b3fae;
  --brand-dark: #432d84;
  --brand-light: #efe9fb;
  --bg: #f7f6fb;
  --surface: #ffffff;
  --text: #221c35;
  --muted: #6b6480;
  --danger: #c23b3b;
  --border: #e1ddf0;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(45, 30, 90, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--brand);
  color: #fff;
  padding: 8px 12px;
  z-index: 100;
}
.skip-link:focus { left: 0; }

.hidden { display: none !important; }
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.muted { color: var(--muted); }
.muted.small { font-size: 0.85em; }

/* ---------- App bar ---------- */
.appbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.appbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--brand-dark);
}
.main-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1;
}
.navbtn {
  background: none;
  border: 1px solid transparent;
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text);
}
.navbtn:hover { background: var(--brand-light); }
.navbtn.active {
  background: var(--brand);
  color: #fff;
}
.appbar-lang {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
}
.appbar-lang select { padding: 4px 6px; border-radius: 6px; border: 1px solid var(--border); }

/* ---------- Main / views ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 20px; }
.view { display: none; }
.view.active { display: block; }
.view h2 { color: var(--brand-dark); }

.card-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow);
}
.card-form.inline {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
}
.card-form label { font-size: 0.85rem; color: var(--muted); }
.card-form input, .card-form select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
}

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
}
.btn:hover { background: var(--brand-light); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--danger); border-color: #f0c9c9; }
.btn.small { padding: 4px 10px; font-size: 0.8rem; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.event-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.event-card.current { border-color: var(--brand); }
.event-card h3 { margin: 0 0 6px; }
.row-actions { display: flex; gap: 6px; margin-top: 10px; }

.backup-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.status { font-size: 0.85rem; color: var(--brand-dark); }
.status.error { color: var(--danger); }

/* ---------- Tables ---------- */
.tables-list { display: flex; flex-direction: column; gap: 8px; }
.table-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  flex-wrap: wrap;
}
.table-row input, .table-row select { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; }
.table-icon { width: 20px; height: 20px; border: 2px solid var(--brand); flex-shrink: 0; }
.table-icon.round { border-radius: 50%; }
.table-icon.rect { border-radius: 3px; }

/* ---------- Guests table ---------- */
.guests-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.guests-table th, .guests-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; font-size: 0.9rem; }
[dir="rtl"] .guests-table th, [dir="rtl"] .guests-table td { text-align: right; }
.guests-table select { padding: 4px 6px; }

/* ---------- Seating ---------- */
.conflicts-panel {
  background: #fff6ec;
  border: 1px solid #f3d9ad;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.conflicts-panel h3 { margin-top: 0; }
#conflicts-list { margin: 0; padding-left: 20px; }
[dir="rtl"] #conflicts-list { padding-left: 0; padding-right: 20px; }
.conflict { margin-bottom: 4px; font-size: 0.9rem; }
.conflict-apart-violated, .conflict-together-violated { color: #a85c00; }
.conflict-capacity { color: var(--danger); }

.seating-toolbar { display: flex; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.seating-layout { display: grid; grid-template-columns: 220px 1fr; gap: 16px; margin-top: 12px; }
.seating-pool-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; min-height: 200px; }
.guest-pool { display: flex; flex-direction: column; gap: 6px; min-height: 100px; }
.seating-tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); }
.table-card h4 { margin: 0 0 8px; color: var(--brand-dark); }
.table-dropzone { min-height: 90px; border: 2px dashed var(--border); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 6px; }
.table-dropzone.dragover { border-color: var(--brand); background: var(--brand-light); }

.guest-chip {
  background: var(--brand-light);
  border: 1px solid var(--brand);
  color: var(--brand-dark);
  border-radius: 20px;
  padding: 5px 10px;
  font-size: 0.85rem;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  user-select: none;
}
.guest-chip.selected { background: var(--brand); color: #fff; }
.guest-chip .chip-x {
  border: none;
  background: transparent;
  cursor: pointer;
  color: inherit;
  font-weight: bold;
  line-height: 1;
  padding: 0 2px;
}

/* ---------- Constraints ---------- */
.constraints-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.constraints-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}

/* ---------- Print view (screen) ---------- */
.print-toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
.print-toolbar .btn.active { background: var(--brand); color: #fff; }
.escort-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.escort-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 10px;
  text-align: center;
  background: var(--surface);
}
.escort-card-name { font-weight: 700; font-size: 1.05rem; }
.escort-card-table { color: var(--muted); margin-top: 6px; }
.table-list-entry { margin-bottom: 14px; }
.table-list-entry h4 { margin-bottom: 4px; color: var(--brand-dark); }

/* ---------- Pro panel ---------- */
.pro-panel {
  max-width: 420px;
  margin: 0 auto;
  background: var(--surface);
  border: 2px solid var(--brand);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow);
}
.badge {
  display: inline-block;
  background: var(--brand-light);
  color: var(--brand-dark);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  margin-bottom: 10px;
}
.pro-price { font-size: 1.4rem; font-weight: 700; color: var(--brand); }
.pro-features { list-style: none; padding: 0; text-align: left; }
[dir="rtl"] .pro-features { text-align: right; }
.pro-features li::before { content: "\2713  "; color: var(--brand); }

/* ---------- Footer ---------- */
.app-footer {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 18px;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 30px;
}
.app-footer a { color: var(--brand); }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .seating-layout { grid-template-columns: 1fr; }
  .appbar { flex-direction: column; align-items: stretch; }
  .main-nav { justify-content: center; }
}

/* ---------- Print styles ---------- */
@media print {
  .no-print, .appbar, .app-footer, .print-toolbar, .needs-event > .card-form,
  #view-events, #view-tables, #view-guests, #view-seating, #view-constraints, #view-pro,
  .conflicts-panel, .seating-toolbar {
    display: none !important;
  }
  body, html { background: #fff; }
  #view-print.active { display: block !important; }
  .print-area { display: block !important; }
  .escort-cards-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .escort-card {
    break-inside: avoid;
    page-break-inside: avoid;
    border: 1px dashed #999;
  }
  .table-list-entry { break-inside: avoid; page-break-inside: avoid; }
}
