@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500&display=swap');

:root {
  color-scheme: dark;
  --bg: #050505;
  --bg-2: #0b0b0c;
  --surface: rgba(255, 255, 255, 0.03);
  --surface-strong: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 31, 61, 0.16);
  --text: #f5f5f6;
  --muted: #8d8d96;
  --accent: #ff1f3d;
  --accent-2: #ff5a6e;
  --grad: linear-gradient(135deg, #ff1f3d 0%, #8f0016 100%);
  --grad-gold: linear-gradient(135deg, #fff1b8 0%, #f5c542 45%, #b8860b 100%);
  --success: #f5c542;
  --warning: #ffb020;
  --danger: #ff5a5a;
  --gold: #f5c542;
  --radius: 18px;
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.9);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(900px 520px at 8% -10%, rgba(255, 31, 61, 0.20), transparent 60%),
    radial-gradient(800px 500px at 105% 0%, rgba(143, 0, 22, 0.22), transparent 60%),
    radial-gradient(700px 500px at 50% 120%, rgba(255, 31, 61, 0.12), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: var(--accent-2); }

h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; font-weight: 700; }
.muted { color: var(--muted); }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.hidden { display: none !important; }

/* ---------- Header ---------- */

.header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.brand-logo {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--grad);
  display: grid; place-items: center;
  font-weight: 800; color: #fff; font-size: 14px;
  box-shadow: 0 8px 24px -8px rgba(255, 31, 61, 0.7);
}
img.brand-logo { object-fit: cover; padding: 0; font-size: 0; background: none; box-shadow: 0 8px 24px -8px rgba(255, 31, 61, 0.7); border: 1px solid rgba(255, 31, 61, 0.35); }
.brand-text { font-weight: 800; letter-spacing: -0.02em; }
.brand-text small { display: block; font-weight: 500; color: var(--muted); font-size: 0.72rem; letter-spacing: 0.02em; }

.header-right { display: flex; align-items: center; gap: 12px; }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--grad);
  display: grid; place-items: center;
  font-size: 0.8rem; font-weight: 700; color: #fff;
}
.user-chip .role { font-size: 0.72rem; color: var(--muted); }

.live-dot {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.75rem; color: var(--muted);
  padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border);
}
.live-dot::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger); box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.6);
}
.live-dot.on::before { background: var(--success); animation: pulse 1.8s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 31, 61, 0.6); }
  70% { box-shadow: 0 0 0 9px rgba(255, 31, 61, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 31, 61, 0); }
}

/* ---------- Ticker (top 1) ---------- */

.ticker {
  position: sticky;
  top: 69px;
  z-index: 40;
  overflow: hidden;
  background: linear-gradient(90deg, rgba(255, 31, 61, 0.22), rgba(0, 0, 0, 0.5), rgba(255, 31, 61, 0.22));
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.ticker-track {
  display: inline-flex;
  gap: 48px;
  padding: 10px 0;
  animation: scroll 38s linear infinite;
  will-change: transform;
}
.ticker:hover .ticker-track { animation-play-state: paused; }
.ticker-item { display: inline-flex; align-items: center; gap: 10px; font-size: 0.9rem; }
.ticker-item .crown { color: var(--gold); font-size: 1.05rem; }
.ticker-item strong { font-weight: 800; }
.ticker-item .valor { color: var(--success); font-weight: 700; }
@keyframes scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* ---------- Layout ---------- */

main, .auth-wrap { position: relative; z-index: 1; }

.container { width: min(1240px, 100%); margin: 0 auto; padding: 28px clamp(16px, 4vw, 40px) 60px; }

.page-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-title h1 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 800; }
.page-title p { margin: 4px 0 0; color: var(--muted); }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: 1fr 1.25fr; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .header { flex-wrap: wrap; }
  .ticker { top: 0; position: relative; }
  .user-chip .role { display: none; }
}

.card {
  position: relative;
  border-color: rgba(255, 31, 61, 0.14);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

.stat { padding: 20px; }
.stat .label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.stat .value { font-size: 1.8rem; font-weight: 800; margin-top: 6px; letter-spacing: -0.02em; }
.stat .value.money { background: var(--grad-gold); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat::after {
  content: ''; position: absolute; right: -40px; top: -40px; width: 120px; height: 120px; border-radius: 50%;
  background: var(--grad); opacity: 0.12; filter: blur(10px);
}

/* ---------- Forms ---------- */

label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field { margin-bottom: 14px; }
input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 31, 61, 0.2);
}
select option { background: var(--bg-2); color: var(--text); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .row { grid-template-columns: 1fr; } }

.form-error { color: var(--danger); font-size: 0.88rem; min-height: 1.2em; margin: 6px 0 0; }

.segmented {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px;
  background: var(--surface-strong); border: 1px solid var(--border); border-radius: 14px; margin-bottom: 18px;
}
.segmented button {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600;
  padding: 10px; border-radius: 10px; cursor: pointer; transition: all .2s;
}
.segmented button.active { background: var(--grad); color: #fff; box-shadow: 0 8px 20px -10px rgba(255, 31, 61, 0.7); }

.class-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.class-option {
  cursor: pointer; border: 1px solid var(--border); border-radius: 14px; padding: 14px;
  background: var(--surface-strong); transition: all .2s; position: relative;
}
.class-option input { position: absolute; opacity: 0; pointer-events: none; }
.class-icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  color: var(--accent-2);
  background: rgba(255, 31, 61, 0.1);
  border: 1px solid rgba(255, 31, 61, 0.25);
}
.class-icon svg { width: 22px; height: 22px; }
.class-option:has(input:checked) .class-icon { background: var(--grad); color: #fff; border-color: transparent; }
.class-option strong { display: block; margin-top: 6px; font-size: 0.95rem; }
.class-option small { color: var(--muted); font-size: 0.75rem; }
.class-option:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(255, 31, 61, 0.2); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; font-size: 0.92rem;
  border: 1px solid transparent; border-radius: 12px; padding: 11px 18px;
  cursor: pointer; color: #fff; background: var(--grad);
  transition: transform .15s, box-shadow .2s, opacity .2s;
  box-shadow: 0 10px 25px -12px rgba(255, 31, 61, 0.7);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 14px 30px -12px rgba(255, 31, 61, 1); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface-strong); color: var(--text); border-color: var(--border); box-shadow: none; }
.btn.success { background: linear-gradient(135deg, #8f0016, #ff1f3d); box-shadow: 0 10px 25px -12px rgba(255, 31, 61, 0.7); }
.btn.sm { padding: 7px 12px; font-size: 0.8rem; border-radius: 10px; }

/* ---------- Badges / lists ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.72rem; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); white-space: nowrap;
}
.badge.disponivel { color: #f5f5f6; background: rgba(255, 255, 255, 0.07); border-color: rgba(255, 255, 255, 0.18); }
.badge.em_andamento { color: var(--warning); background: rgba(251, 191, 36, 0.1); border-color: rgba(251, 191, 36, 0.3); }
.badge.concluida { color: #fff; background: rgba(255, 31, 61, 0.22); border-color: rgba(255, 31, 61, 0.5); }

.list { display: grid; gap: 12px; max-height: 620px; overflow: auto; padding-right: 4px; }
.list::-webkit-scrollbar { width: 6px; }
.list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }

.ficha {
  position: relative;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  border-radius: 16px;
  padding: 16px 18px;
  transition: transform .2s, border-color .2s;
  animation: enter .45s cubic-bezier(.2,.8,.2,1);
}
.ficha:hover { transform: translateY(-2px); border-color: rgba(255, 31, 61, 0.55); }
.ficha.leaving { animation: leave .35s forwards; }
.ficha .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.ficha h3 { font-size: 1rem; font-weight: 700; }
.ficha .meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; margin: 12px 0; font-size: 0.85rem; }
.ficha .meta span { color: var(--muted); }
.ficha .meta b { font-weight: 600; color: var(--text); }
.ficha .actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.ficha .valor-tag { color: var(--success); font-weight: 800; }

@keyframes enter { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes leave { to { opacity: 0; transform: translateX(-20px) scale(.96); } }

.empty {
  text-align: center; padding: 40px 16px; color: var(--muted);
  border: 1px dashed var(--border); border-radius: 16px;
}
.empty .icon { font-size: 2rem; margin-bottom: 6px; }

/* ---------- Upload ---------- */

.dropzone {
  border: 1.5px dashed var(--border); border-radius: 16px; padding: 22px; text-align: center;
  cursor: pointer; transition: all .2s; background: var(--surface-strong); position: relative;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent-2); background: rgba(255, 31, 61, 0.06); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone img { max-height: 180px; border-radius: 12px; margin-top: 10px; }

.ocr-result {
  margin-top: 12px; padding: 12px 14px; border-radius: 12px;
  background: rgba(255, 31, 61, 0.08); border: 1px solid rgba(255, 31, 61, 0.3); font-size: 0.9rem;
}
.ocr-result .big { font-size: 1.3rem; font-weight: 800; }
.ocr-result pre {
  white-space: pre-wrap; max-height: 120px; overflow: auto; font-size: 0.72rem; margin: 8px 0 0; color: var(--muted);
}

/* ---------- Tables ---------- */

.table-wrap { overflow: auto; border-radius: 14px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); background: var(--surface-strong); position: sticky; top: 0; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: var(--surface-strong); }
td.money, th.money { text-align: right; font-variant-numeric: tabular-nums; }
td.money { color: var(--success); font-weight: 700; }
tfoot td { font-weight: 800; background: var(--surface-strong); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.tabs button {
  font: inherit; font-weight: 600; font-size: 0.88rem; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  padding: 9px 16px; border-radius: 999px; transition: all .2s;
}
.tabs button.active { color: #fff; background: var(--grad); border-color: transparent; }

.feed { display: grid; gap: 8px; max-height: 620px; overflow: auto; }
.feed-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  padding: 10px 14px; border-radius: 12px; background: var(--surface-strong); border: 1px solid var(--border);
  font-size: 0.86rem; animation: enter .4s ease;
}
.feed-item .time { color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.event-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 12px var(--accent-2); }
.event-dot.money { background: var(--success); box-shadow: 0 0 12px var(--success); }
.event-dot.warn { background: var(--warning); box-shadow: 0 0 12px var(--warning); }

/* ---------- Ranking ---------- */

.rank-row {
  display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center;
  padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-strong);
}
.rank-row .pos { font-weight: 800; color: var(--muted); text-align: center; }
.rank-row.first { border-color: rgba(250, 204, 21, 0.5); background: linear-gradient(90deg, rgba(250, 204, 21, 0.12), transparent); }
.rank-row.first .pos { color: var(--gold); }

/* ---------- Toast ---------- */

.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 10px; z-index: 100; }
.toast {
  min-width: 260px; max-width: 360px; padding: 14px 16px; border-radius: 14px;
  background: var(--surface-strong); border: 1px solid var(--border); box-shadow: var(--shadow);
  backdrop-filter: blur(16px); font-size: 0.9rem; animation: enter .35s ease;
  border-left: 3px solid var(--accent-2);
}
.toast.ok { border-left-color: var(--success); }
.toast.err { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--gold); }

/* ---------- Auth ---------- */

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(460px, 100%); padding: 30px; }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand .brand-logo { margin: 0 auto 14px; width: 104px; height: 104px; font-size: 18px; border-radius: 26px; }
.auth-brand h1 { font-size: 1.6rem; font-weight: 800; }

/* ---------- Modal ---------- */

.modal-bg {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(6px);
  display: grid; place-items: center; z-index: 80; padding: 16px;
}
.modal { width: min(560px, 100%); max-height: 90vh; overflow: auto; }

.skeleton { background: linear-gradient(90deg, var(--surface), var(--surface-strong), var(--surface)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 14px; height: 110px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (max-width: 600px) {
  .brand-text small { display: none; }
  .ficha .meta { grid-template-columns: 1fr; }
  .toasts { left: 16px; right: 16px; }
  .toast { min-width: 0; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Cifrões subindo (fundo) ---------- */

.money-rain {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.money-rain span {
  position: absolute;
  bottom: -12%;
  color: rgba(245, 197, 66, 0.3);
  font-weight: 800;
  line-height: 1;
  user-select: none;
  text-shadow: 0 0 18px rgba(245, 197, 66, 0.45);
  animation: rise linear infinite;
  will-change: transform, opacity;
}

.money-rain svg { display: block; width: 100%; height: auto; overflow: visible; }

.hint {
  font-size: 0.84rem; color: var(--muted); line-height: 1.7;
  padding: 12px 14px; border-radius: 12px;
  background: rgba(255, 31, 61, 0.06); border: 1px dashed rgba(255, 31, 61, 0.3);
}
.hint b { color: var(--text); font-weight: 600; }

/* ---------- Ícones (SVG de linha) ---------- */

.ico { width: 1.1em; height: 1.1em; flex-shrink: 0; vertical-align: -0.2em; }

.h-ico {
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--accent-2); vertical-align: -4px; margin-right: 2px;
}
.h-ico .ico { width: 20px; height: 20px; }

.btn .ico { width: 16px; height: 16px; }

.empty .icon { display: flex; justify-content: center; margin-bottom: 10px; color: var(--accent-2); }
.empty .icon .ico { width: 34px; height: 34px; opacity: 0.85; }

.drop-ico { display: flex; justify-content: center; color: var(--accent-2); }
.drop-ico .ico { width: 36px; height: 36px; }

.ticker-item .ico { width: 16px; height: 16px; }
.ticker-item .crown { display: inline-flex; color: var(--gold); }
.ticker-item .crown .ico { width: 18px; height: 18px; }

.rank-row .pos { display: flex; justify-content: center; align-items: center; }
.rank-row .pos .ico { width: 18px; height: 18px; color: var(--gold); }

/* ---------- Operadores e solicitações ---------- */

.class-picker-3 { grid-template-columns: repeat(3, 1fr); }
.class-picker-3 .class-option small { font-size: 0.7rem; line-height: 1.35; }
@media (max-width: 520px) {
  .class-picker-3 { grid-template-columns: 1fr; }
}

.ticker-sep { color: var(--gold); font-size: 0.7rem; align-self: center; opacity: 0.8; }

.badge.pendente { color: var(--warning); background: rgba(255, 176, 32, 0.1); border-color: rgba(255, 176, 32, 0.35); }
.badge.aceita { color: #fff; background: rgba(255, 31, 61, 0.18); border-color: rgba(255, 31, 61, 0.45); }
.badge.recusada { color: var(--danger); background: rgba(255, 90, 90, 0.08); border-color: rgba(255, 90, 90, 0.4); }
.badge.cancelada { color: var(--muted); background: transparent; }

.operador-box {
  margin-top: 10px; padding: 10px 12px; border-radius: 12px; font-size: 0.84rem;
  background: rgba(255, 176, 32, 0.07); border: 1px solid rgba(255, 176, 32, 0.25);
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.operador-box.ok { background: rgba(255, 31, 61, 0.07); border-color: rgba(255, 31, 61, 0.3); }
.operador-box.bad { background: rgba(255, 90, 90, 0.06); border-color: rgba(255, 90, 90, 0.3); }

.op-list { display: grid; gap: 8px; max-height: 300px; overflow: auto; margin-bottom: 14px; }
.op-option {
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-strong);
  transition: border-color .2s, box-shadow .2s;
}
.op-option input { width: auto; accent-color: #ff1f3d; margin: 0; }
.op-option:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(255, 31, 61, 0.15); }
.op-option strong { display: block; font-size: 0.95rem; }
.op-option small { color: var(--muted); font-size: 0.78rem; }

.sol-card {
  border: 1px solid rgba(255, 176, 32, 0.3); background: rgba(255, 176, 32, 0.04);
}

@keyframes rise {
  0% { transform: translateY(0) rotate(0deg) scale(0.9); opacity: 0; }
  10% { opacity: 1; }
  50% { transform: translateY(-55vh) rotate(12deg) scale(1); }
  90% { opacity: 0.7; }
  100% { transform: translateY(-120vh) rotate(-18deg) scale(1.1); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .money-rain { display: none; }
}
