:root {
  --red: #e30613;
  --red-dark: #c00510;
  --red-soft: #fff1f2;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 10px 30px rgba(17, 24, 39, 0.06);
  --radius: 14px;
  --sidebar: 250px;
}

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

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

button, input, select, textarea {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 8px 10px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--red);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 20px;
}

.brand h1 {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
}

.brand p {
  font-size: 12px;
  color: var(--muted);
}

.nav-btn {
  border: none;
  background: transparent;
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  color: #374151;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s ease;
}

.nav-btn:hover { background: #f3f4f6; }
.nav-btn.active {
  background: var(--red-soft);
  color: var(--red);
}

.nav-cta {
  margin-top: 8px;
  background: var(--red);
  color: #fff;
}

.nav-cta:hover { background: var(--red-dark); }
.nav-cta.active { background: var(--red); color: #fff; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 14px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.main {
  padding: 28px 32px 40px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.page-header h2 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.page-header p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 15px;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: var(--red);
  color: #fff;
  box-shadow: 0 8px 20px rgba(227, 6, 19, 0.25);
}

.btn-primary:hover { background: var(--red-dark); }

.btn-secondary {
  background: #fff;
  color: #374151;
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: #f9fafb; }

.btn-danger {
  background: #fff;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.stat-card label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 30px;
  color: var(--red);
  font-weight: 800;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}

.panel-body { padding: 20px; }

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

.table th, .table td {
  padding: 14px 20px;
  text-align: left;
  border-bottom: 1px solid #f3f4f6;
  font-size: 14px;
}

.table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.table tr:hover td { background: #fafafa; }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
}

.actions-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.action-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.15s ease;
}

.action-btn-edit {
  color: #374151;
}

.action-btn-edit:hover {
  border-color: #fca5a5;
  background: var(--red-soft);
  color: var(--red);
}

.action-btn-delete {
  color: #b91c1c;
  border-color: #fecaca;
}

.action-btn-delete:hover {
  background: #fff1f2;
}

.event-title-btn {
  border: none;
  background: transparent;
  padding: 0;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.event-title-btn:hover strong {
  color: var(--red);
  text-decoration: underline;
}

.event-row:hover td {
  background: #fafafa;
}

/* ── Status badges ── */
.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge-paid { background: #dcfce7; color: #166534; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-failed { background: #fee2e2; color: #991b1b; }
.badge-returned { background: #ffedd5; color: #9a3412; }
.badge-refunded { background: #f3f4f6; color: #4b5563; }
.badge-partial { background: #ede9fe; color: #5b21b6; }

.badge-active { background: #dcfce7; color: #166534; }

.btn-danger {
  background: #b91c1c;
  color: #fff;
  border: none;
}

.btn-danger:hover { background: #991b1b; }

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 8px;
}

.row-returned td {
  opacity: 0.65;
  background: #fafafa;
}

.row-returned td:first-child strong {
  text-decoration: line-through;
  color: var(--muted);
}

/* ── Return modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay[hidden] { display: none; }

.modal {
  width: 100%;
  max-width: 440px;
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.modal-head h3 {
  margin: 0;
  font-size: 20px;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.modal-desc {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 16px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* ── Clickable rows ── */
.clickable-row { cursor: pointer; }
.clickable-row:hover td { background: #fafafa; }

/* ── Two-column grid ── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* ── Mini stat ── */
.stat-mini strong { font-size: 24px; }

/* ── Filter bar ── */
.filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 220px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  background: #fff;
}

.search-input:focus {
  outline: none;
  border-color: #fca5a5;
  box-shadow: 0 0 0 4px rgba(227, 6, 19, 0.12);
}

.chip-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: 0.15s ease;
}

.chip:hover { background: #f9fafb; }
.chip.active {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

/* ── Detail list ── */
.detail-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.detail-list > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.detail-list span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.detail-list strong {
  font-size: 14px;
  text-align: right;
}

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid .full { grid-column: 1 / -1; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
  color: #374151;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fff;
  color: var(--text);
}

.field textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: #fca5a5;
  box-shadow: 0 0 0 4px rgba(227, 6, 19, 0.12);
}

.category-select {
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

.upload-zone {
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  padding: 28px;
  text-align: center;
  background: #fafafa;
  cursor: pointer;
  transition: 0.15s ease;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--red);
  background: var(--red-soft);
}

.upload-zone p {
  color: var(--muted);
  font-size: 14px;
  margin-top: 8px;
}

.map-preview {
  margin-top: 14px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  max-height: 280px;
}

.map-preview img {
  width: 100%;
  display: block;
  object-fit: cover;
}

.sections-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-row {
  display: grid;
  grid-template-columns: 1fr 140px 44px;
  gap: 10px;
  align-items: center;
}

.section-price-wrap {
  position: relative;
}

.section-price-wrap span {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-weight: 700;
}

.section-price-wrap input {
  padding-left: 28px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  color: #9ca3af;
  font-size: 18px;
}

.icon-btn:hover {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fff5f5;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #111827;
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(8px);
  transition: 0.2s ease;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .form-grid { grid-template-columns: 1fr; }
  .section-row { grid-template-columns: 1fr; }
  .main { padding: 20px 16px 32px; }
}
