:root {
  --brand: #7a1f3d;
  --brand-2: #a3324f;
  --brand-soft: #f6e9ed;
  --ink: #1f1d1a;
  --muted: #6b665e;
  --line: #e4dfd6;
  --bg: #f6f3ee;
  --card: #ffffff;
  --ok: #1f7a4d;
  --ok-soft: #e3f3ea;
  --warn: #a15c00;
  --warn-soft: #fdf0dc;
  --bad: #b3261e;
  --bad-soft: #fbe5e3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.45; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
img { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }

/* Layout */
.topbar { background: var(--brand); color: #fff; }
.topbar .inner { max-width: 1120px; margin: 0 auto; padding: 14px 16px; display: flex; align-items: center; gap: 16px; }
.topbar a { color: #fff; text-decoration: none; }
.topbar .brand { font-weight: 700; font-size: 1.05rem; }
.topbar .spacer { flex: 1; }
main { max-width: 1120px; margin: 0 auto; padding: 20px 16px 60px; }
main.narrow { max-width: 680px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }

/* Forms */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
label .req { color: var(--bad); }
input, select, textarea {
  width: 100%; font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: 0; border-color: transparent; }
input[type=checkbox], input[type=radio] { width: auto; margin-right: 6px; transform: scale(1.15); }
.check { display: flex; align-items: flex-start; gap: 6px; font-weight: normal; }
.field { margin-bottom: 14px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 3px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--brand);
  background: var(--brand); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--brand-2); }
.btn.secondary { background: #fff; color: var(--brand); }
.btn.secondary:hover { background: var(--brand-soft); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--brand); padding: 6px 8px; }
.btn.danger { background: #fff; color: var(--bad); border-color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Badges / alerts */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--brand-soft); color: var(--brand); }
.badge.ok, .badge.publicada { background: var(--ok-soft); color: var(--ok); }
.badge.warn, .badge.borrador { background: var(--warn-soft); color: var(--warn); }
.badge.bad, .badge.cancelada { background: var(--bad-soft); color: var(--bad); }
.badge.finalizada { background: #ececec; color: #555; }
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; background: var(--brand-soft); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fbfaf7; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #fbf7f8; }

/* Cartelera */
.event-card { display: flex; flex-direction: column; overflow: hidden; padding: 0; text-decoration: none; color: inherit; transition: transform .12s; }
.event-card:hover { transform: translateY(-2px); }
.event-card .img { aspect-ratio: 16/9; background: linear-gradient(135deg, var(--brand), #d17a3a); display: flex; align-items: flex-end; padding: 12px; color: #fff; font-weight: 700; }
.event-card .img img { width: 100%; height: 100%; object-fit: cover; }
.event-card .body { padding: 14px 16px 18px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.event-card h3 { margin: 0; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filters select { width: auto; min-width: 180px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.kpi .v { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: .8rem; color: var(--muted); }
.bars { display: grid; gap: 4px; }
.bar { display: grid; grid-template-columns: 110px 1fr 60px; gap: 8px; align-items: center; font-size: .85rem; }
.bar .track { background: #efebe4; border-radius: 4px; height: 14px; overflow: hidden; }
.bar .fill { background: var(--brand); height: 100%; }
.bar .fill.alt { background: #d17a3a; }

/* Tickets */
.ticket { border: 2px dashed var(--line); border-radius: 12px; padding: 16px; text-align: center; background: #fff; }
.ticket img { width: 230px; height: 230px; image-rendering: pixelated; }
.ticket .code { font-family: ui-monospace, Consolas, monospace; letter-spacing: 2px; font-size: 1.05rem; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: none; padding: 10px 14px; font: inherit; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(20,15,10,.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: var(--radius); max-width: 640px; width: 100%; padding: 22px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal.wide { max-width: 900px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 100; max-width: 90vw; }
.toast.bad { background: var(--bad); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

@media (max-width: 640px) {
  h1 { font-size: 1.35rem; }
  .card { padding: 16px; }
  .bar { grid-template-columns: 80px 1fr 46px; }
  .filters select { width: 100%; }
}
@media print {
  .topbar, .no-print, .btn { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
.spacer { flex: 1; }
