:root {
  --red: #9e0000;
  --red-deep: #6f0000;
  --gold: #f5b451;
  --cream: #faebc8;

  --bg: #fbf6ea;
  --surface: #ffffff;
  --surface-2: #f6eedb;
  --text: #2a1410;
  --muted: #7a625a;
  --border: #ead9b8;
  --accent: var(--red);
  --accent-text: #ffffff;

  --ok: #1f7a3d;
  --ok-bg: #e2f3e6;
  --warn: #9a5b00;
  --warn-bg: #fdefd2;
  --pend: #8a6e64;
  --pend-bg: #f1e7e2;
  --bad: #a11d1d;
  --bad-bg: #f9e0e0;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 20, 10, .06), 0 4px 16px rgba(60, 20, 10, .06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #160c0a;
    --surface: #221310;
    --surface-2: #2c1814;
    --text: #f6e9d2;
    --muted: #b49b8d;
    --border: #3d241e;
    --accent: #e0483a;
    --ok: #7fd59a; --ok-bg: #173522;
    --warn: #f5c56e; --warn-bg: #3a2a10;
    --pend: #c9b1a6; --pend-bg: #33221d;
    --bad: #ff8b8b; --bad-bg: #3d1717;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: "Bricolage Grotesque", Inter, sans-serif; line-height: 1.15; margin: 0; }
h2 { font-size: 1.1rem; font-weight: 800; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .82rem; font-weight: 500; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: .9em; }
a { color: var(--accent); }

/* ---------- buttons & inputs ---------- */
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 10px; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-deep); border-color: var(--red-deep); }
.btn-google { display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 12px 16px; font-size: 1rem; }
.user-name { font-size: .85rem; opacity: .9; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-small { padding: 4px 10px; font-size: .85rem; }
.btn-link { border: 0; background: none; color: var(--accent); padding: 4px 0; }
.btn-icon { border: 0; background: var(--surface-2); width: 36px; height: 36px; padding: 0; border-radius: 50%; }
.btn-ghost-light { background: transparent; color: var(--cream); border-color: rgba(250, 235, 200, .35); }
.btn-ghost-light:hover { border-color: var(--cream); }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px; min-width: 0;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 1px;
}

/* ---------- login ---------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(circle at 50% 0%, #b31010 0%, var(--red) 40%, #5a0000 100%);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border-radius: 20px; padding: 32px 28px;
  display: grid; gap: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-mark { width: 64px; height: auto; justify-self: center; }
.login-card h1 { text-align: center; font-size: 1.6rem; }
.login-card p.muted { text-align: center; margin: -8px 0 4px; }
.login-card label { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; }
.error { color: var(--bad); background: var(--bad-bg); padding: 8px 12px; border-radius: 8px; margin: 0; font-size: .9rem; }

/* ---------- topbar ---------- */
.topbar {
  background: linear-gradient(180deg, var(--red) 0%, #8a0000 100%);
  color: var(--cream);
  position: sticky; top: 0; z-index: 20;
  box-shadow: 0 2px 12px rgba(80, 0, 0, .25);
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 14px 16px 10px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { height: 46px; width: auto; display: block; }
.topbar-meta { display: flex; flex-direction: column; line-height: 1.2; }
.year { font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; font-size: 1.3rem; color: var(--gold); }
.event-line { font-size: .8rem; opacity: .85; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: .82rem; background: rgba(0,0,0,.18); padding: 5px 12px; border-radius: 999px; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: #9b9b9b; }
.live.on .dot { background: #5ee38a; box-shadow: 0 0 0 0 rgba(94,227,138,.7); animation: pulse 2s infinite; }
.live.err .dot { background: var(--gold); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(94,227,138,.6); } 70% { box-shadow: 0 0 0 8px rgba(94,227,138,0); } 100% { box-shadow: 0 0 0 0 rgba(94,227,138,0); } }

.tabs {
  max-width: 1240px; margin: 0 auto; padding: 0 12px; display: flex; gap: 2px; overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none; background: none; border: 0; color: var(--cream); opacity: .75; font: inherit; font-weight: 600;
  padding: 10px 14px 12px; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap;
}
.tab:hover { opacity: 1; }
.tab.active { opacity: 1; border-bottom-color: var(--gold); }
.pill { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: rgba(0,0,0,.22); font-size: .75rem; text-align: center; }

.demo-banner {
  max-width: 1240px; margin: 14px auto 0; padding: 10px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  background: var(--warn-bg); color: var(--warn); border-radius: 12px; font-size: .9rem;
  width: calc(100% - 32px);
}
.demo-banner .btn { margin-left: auto; }

/* ---------- layout ---------- */
.container { max-width: 1240px; margin: 0 auto; padding: 20px 16px 60px; }
.view { display: grid; gap: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card h2 { margin-bottom: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1000px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; font-size: 1.9rem; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.kpi.hero { background: var(--red); border-color: var(--red); color: #fff; }
.kpi.hero .label, .kpi.hero .sub { color: var(--cream); }

/* bars */
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 70px; gap: 10px; align-items: center; font-size: .9rem; }
.bar-row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { display: block; height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .5s ease; }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.money { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border); }
.money div { font-size: .8rem; color: var(--muted); }
.money strong { display: block; font-size: 1.05rem; color: var(--text); font-variant-numeric: tabular-nums; }

/* recent */
.recent { list-style: none; margin: 0; padding: 0; display: grid; }
.recent li { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); cursor: pointer; border-radius: 8px; }
.recent li:last-child { border-bottom: 0; }
.recent li:hover { background: var(--surface-2); }
.avatar { width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--surface-2); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.recent .who { flex: 1; min-width: 0; }
.recent .who strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent .who span { font-size: .82rem; color: var(--muted); }
.recent .when { font-size: .8rem; color: var(--muted); text-align: right; white-space: nowrap; }

/* toolbar & tables */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search { flex: 1 1 280px; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .center { text-align: center; }
.table .nowrap { white-space: nowrap; }
.table .strong { font-weight: 600; }
.table .sub { display: block; font-size: .8rem; color: var(--muted); }
.table tr.is-new td { animation: flash 2.5s ease-out; }
.table tr.is-cancel td { opacity: .5; }
@keyframes flash { 0% { background: rgba(245, 180, 81, .55); } 100% { background: transparent; } }
.empty, .hint { padding: 14px; margin: 0; color: var(--muted); font-size: .85rem; }

/* chips */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.chip-Pago { background: var(--ok-bg); color: var(--ok); }
.chip-Parcial { background: var(--warn-bg); color: var(--warn); }
.chip-Pendente { background: var(--pend-bg); color: var(--pend); }
.chip-Cancelado { background: var(--bad-bg); color: var(--bad); }
.tag { display: inline-block; font-size: .7rem; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); margin-left: 6px; vertical-align: middle; }
.tag-menor { background: var(--warn-bg); color: var(--warn); }
.check { width: 18px; height: 18px; accent-color: var(--ok); cursor: pointer; }

/* care lists */
.care { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.care li { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); cursor: pointer; }
.care li strong { display: block; }
.care li span { font-size: .85rem; color: var(--muted); }
.care .none { cursor: default; color: var(--muted); background: none; padding: 0; }

/* drawer */
.backdrop { position: fixed; inset: 0; background: rgba(20, 5, 0, .45); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(560px, 100%); background: var(--bg); z-index: 50;
  box-shadow: -10px 0 40px rgba(0,0,0,.25); display: flex; flex-direction: column;
}
.drawer-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding: 18px 20px; border-bottom: 1px solid var(--border); background: var(--surface); }
.drawer-head h2 { font-size: 1.35rem; }
.drawer-head p { margin: 0 0 2px; }
.drawer-body { overflow-y: auto; padding: 18px 20px 40px; display: grid; gap: 16px; align-content: start; }
.section { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.section h3 { font-size: .95rem; margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.people li { display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; }
.people .raw { display: block; font-size: .78rem; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label { display: grid; gap: 4px; font-size: .82rem; font-weight: 600; color: var(--muted); }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .inline { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: .9rem; }
.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.form-actions .muted { font-size: .8rem; }
details.raw-answers summary { cursor: pointer; font-weight: 700; font-family: "Bricolage Grotesque", sans-serif; }
details.raw-answers .kv { margin-top: 12px; grid-template-columns: 1fr; gap: 2px; }
details.raw-answers dt { font-size: .78rem; margin-top: 8px; }
.wa { text-decoration: none; font-weight: 600; }

/* toasts */
.toasts { position: fixed; bottom: 16px; right: 16px; display: grid; gap: 10px; z-index: 60; max-width: calc(100% - 32px); }
.toast { background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.25); font-size: .9rem; animation: slidein .25s ease-out; cursor: pointer; max-width: 380px; }
.toast strong { color: var(--gold); }
.toast.err { background: var(--bad); color: #fff; }
@keyframes slidein { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 640px) {
  .brand { height: 34px; }
  .topbar-meta .event-line { display: none; }
  .live #live-text, .user-name { display: none; }
  .bar-row { grid-template-columns: 90px 1fr 56px; }
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dt { margin-top: 8px; }
  .form-grid { grid-template-columns: 1fr; }
  .money { grid-template-columns: 1fr; }
  .kpi .value { font-size: 1.35rem; }
  .kpi { padding: 12px 14px; }
}
