/* MegaPro — design system. "Sala de controle de broadcast": tinta escura + luz de sinal vermelha;
   no tema claro, papel de estúdio. Tokens por tema; componentes compartilhados (site + painel). */
:root {
  --font-display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Instrument Sans', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
  --r-sm: 8px; --r: 12px; --r-lg: 18px; --r-xl: 26px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}
:root, [data-theme="dark"] {
  --bg: #08080b; --bg-2: #0c0c11; --surface: #121218; --surface-2: #181821; --surface-3: #20202b; --field: #0d0d13;
  --line: rgba(255,255,255,.075); --line-strong: rgba(255,255,255,.15);
  --text: #f3f3f7; --text-2: #b7b8c6; --text-3: #8486a0;
  --accent: #ff3340; --accent-2: #ff6670; --accent-soft: rgba(255,51,64,.13); --accent-line: rgba(255,51,64,.4);
  --ok: #35d8a6; --ok-soft: rgba(53,216,166,.13);
  --warn: #f8ba4c; --warn-soft: rgba(248,186,76,.13);
  --bad: #ff5f6a; --bad-soft: rgba(255,95,106,.13);
  --info: #62acff; --info-soft: rgba(98,172,255,.13);
  --shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 18px 40px -22px rgba(0,0,0,.85);
  --shadow-pop: 0 30px 80px -20px rgba(0,0,0,.85), 0 0 0 1px rgba(255,255,255,.07);
  --page-glow-a: rgba(255,51,64,.10); --page-glow-b: rgba(98,118,255,.07);
  --grid-line: rgba(255,255,255,.028);
  --overlay: rgba(4,4,8,.66);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f1f0ed; --bg-2: #f9f8f6; --surface: #ffffff; --surface-2: #f6f5f2; --surface-3: #ecebe7; --field: #ffffff;
  --line: rgba(26,22,34,.09); --line-strong: rgba(26,22,34,.2);
  --text: #17151c; --text-2: #4b4a57; --text-3: #6c6b7a;
  --accent: #dc1f2c; --accent-2: #f04450; --accent-soft: rgba(220,31,44,.085); --accent-line: rgba(220,31,44,.32);
  --ok: #0a8f68; --ok-soft: rgba(10,143,104,.1);
  --warn: #a8700a; --warn-soft: rgba(212,140,16,.13);
  --bad: #cf2535; --bad-soft: rgba(207,37,53,.09);
  --info: #1a62c4; --info-soft: rgba(26,98,196,.09);
  --shadow: 0 1px 2px rgba(26,22,34,.05), 0 16px 34px -20px rgba(26,22,34,.22);
  --shadow-pop: 0 30px 70px -24px rgba(26,22,34,.4), 0 0 0 1px rgba(26,22,34,.08);
  --page-glow-a: rgba(220,31,44,.07); --page-glow-b: rgba(26,98,196,.05);
  --grid-line: rgba(26,22,34,.035);
  --overlay: rgba(24,20,32,.42);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--text); font: 400 15px/1.55 var(--font-body);
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 520px at 88% -8%, var(--page-glow-a), transparent 62%),
    radial-gradient(900px 520px at -8% 108%, var(--page-glow-b), transparent 60%),
    linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: auto, auto, 44px 44px, 44px 44px;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 650; letter-spacing: -.02em; line-height: 1.12; margin: 0; }
h1 { font-size: clamp(1.7rem, 2.4vw + 1rem, 2.35rem); }
h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
p { margin: 0; }
a { color: inherit; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.mono { font-family: var(--font-mono); font-feature-settings: 'zero' 1; letter-spacing: -.01em; }
.muted { color: var(--text-2); } .faint { color: var(--text-3); }
.small { font-size: 13px; } .xs { font-size: 12px; }
.tnum { font-variant-numeric: tabular-nums; }
.hide, [hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- ícones ---------- */
.ic { flex: none; display: inline-block; vertical-align: -0.18em; }

/* ---------- botões ---------- */
.btn {
  --h: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--h);
  padding: 0 16px; border-radius: var(--r); border: 1px solid var(--line-strong); background: var(--surface-2);
  color: var(--text); font-weight: 600; font-size: 14px; line-height: 1; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .18s var(--ease), border-color .18s var(--ease), transform .12s var(--ease), box-shadow .18s var(--ease), color .18s;
}
.btn:hover { background: var(--surface-3); border-color: var(--text-3); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn[disabled], .btn.is-busy { opacity: .55; pointer-events: none; }
.btn-primary {
  color: #fff; border-color: transparent;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 1px 0 rgba(255,255,255,.28) inset, 0 10px 24px -10px var(--accent);
}
.btn-primary:hover { background: linear-gradient(180deg, var(--accent-2), var(--accent)); filter: brightness(1.08); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-soft { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-2); }
[data-theme="light"] .btn-soft { color: var(--accent); }
.btn-danger { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn-sm { --h: 32px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-lg { --h: 48px; padding: 0 22px; font-size: 15px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-icon { width: var(--h); padding: 0; }
.btn .spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- campos ---------- */
.field { display: grid; gap: 6px; margin: 0 0 16px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.hint { font-size: 12px; color: var(--text-3); }
.input, .select, .textarea {
  width: 100%; height: 44px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--line-strong);
  background: var(--field); color: var(--text); outline: none; min-width: 0;
  transition: border-color .16s, box-shadow .16s, background .16s;
}
.textarea { height: auto; padding: 12px 14px; }
.input::placeholder { color: var(--text-3); }
.input:hover, .select:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.select {
  appearance: none; padding-right: 38px; cursor: pointer;
  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='%238486a0' 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 12px center;
}
.select option { background: var(--surface); color: var(--text); }
.input-group { position: relative; display: flex; gap: 8px; }
.input-group .input { flex: 1; }
.input.is-mono { font-family: var(--font-mono); font-size: 14px; }
.input-ico { position: relative; }
.input-ico > .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-ico > .input { padding-left: 40px; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.check { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-2); cursor: pointer; user-select: none; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }

/* interruptor */
.switch { position: relative; display: inline-flex; flex: none; width: 44px; height: 26px; cursor: pointer; }
.switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; z-index: 1; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line-strong); transition: background .2s var(--ease), border-color .2s; }
.switch .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--text-2); transition: transform .22s var(--ease), background .2s; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.switch input:checked + .track { background: var(--accent); border-color: transparent; }
.switch input:checked + .track::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- cartões, chips, avisos ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 22px; min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-title { font: 650 1.02rem/1.2 var(--font-display); letter-spacing: -.015em; }
.card-sub { font-size: 13px; color: var(--text-3); margin-top: 4px; }

.chip { display: inline-flex; align-items: center; gap: 7px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 22%, transparent); }
.chip.no-dot::before { display: none; }
.chip.ok { background: var(--ok-soft); color: var(--ok); } .chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); } .chip.info { background: var(--info-soft); color: var(--info); }
.chip.accent { background: var(--accent-soft); color: var(--accent-2); }
[data-theme="light"] .chip.accent { color: var(--accent); }
.chip.live::before { animation: tally 2.2s ease-in-out infinite; }
@keyframes tally { 0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 22%, transparent); } 50% { box-shadow: 0 0 0 6px color-mix(in srgb, currentColor 6%, transparent); } }

.alert { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface-2); font-size: 13.5px; color: var(--text-2); }
.alert > .ic { margin-top: 2px; color: var(--info); }
.alert.warn { background: var(--warn-soft); border-color: transparent; } .alert.warn > .ic { color: var(--warn); }
.alert.bad { background: var(--bad-soft); border-color: transparent; } .alert.bad > .ic { color: var(--bad); }
.alert.info { background: var(--info-soft); border-color: transparent; }
.alert.ok { background: var(--ok-soft); border-color: transparent; } .alert.ok > .ic { color: var(--ok); }
.alert b { color: var(--text); }

.kbd, code.inline { font-family: var(--font-mono); font-size: 12.5px; padding: 2px 7px; border-radius: 7px; background: var(--surface-3); color: var(--text); }
.codebox { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-family: var(--font-mono); font-size: 12.5px; background: var(--field); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; color: var(--text-2); word-break: break-all; }

/* ---------- tabelas ---------- */
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11.5px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .15s; }
.table tbody tr.is-click { cursor: pointer; }
.table tbody tr:hover { background: color-mix(in srgb, var(--text) 3.5%, transparent); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; z-index: 80; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 20px; background: var(--overlay); backdrop-filter: blur(7px); animation: fade .18s var(--ease); overflow-y: auto; }
.modal { width: min(540px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-pop); animation: pop .26s var(--ease); }
.modal.wide { width: min(760px, 100%); }
.modal, .modal-body { min-width: 0; } .modal-body { overflow-x: hidden; }
@media (max-width: 560px) { .modal-back { padding: 12px; } .modal-head { padding: 16px 16px 12px; } .modal-body { padding: 16px; } .modal-foot { padding: 12px 16px 16px; } .modal { max-height: calc(100vh - 24px); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 24px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 1.12rem; }
.modal-body { padding: 22px 24px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes tally { 0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 22%, transparent); } 50% { box-shadow: 0 0 0 6px color-mix(in srgb, currentColor 6%, transparent); } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.975); } }

/* ---------- toast / skeleton / vazio ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 120; display: grid; gap: 10px; max-width: min(420px, calc(100vw - 40px)); }
.toast { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow-pop); font-size: 14px; animation: toast-in .3s var(--ease); }
.toast > .ic { margin-top: 2px; } .toast.ok > .ic { color: var(--ok); } .toast.bad > .ic { color: var(--bad); } .toast.warn > .ic { color: var(--warn); }
.toast.out { opacity: 0; transform: translateY(8px); transition: .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.skeleton { border-radius: 8px; background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%); background-size: 220% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { to { background-position: -220% 0; } }
.empty { display: grid; place-items: center; gap: 10px; text-align: center; padding: 44px 16px; color: var(--text-3); }
.empty .ic { color: var(--text-3); opacity: .7; }
.empty b { color: var(--text-2); font-family: var(--font-display); font-weight: 650; font-size: 1.02rem; }

/* ---------- utilidades ---------- */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 16px; }
.gap-lg { gap: 22px; }
.right { margin-left: auto; }
.divider { height: 1px; background: var(--line); margin: 18px 0; border: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; } }

/* ---------- botão de tema (site + painel) ---------- */
.theme-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text-2); cursor: pointer; transition: .15s; flex: none; }
.theme-btn:hover { color: var(--text); border-color: var(--text-3); }
[data-theme="dark"] .theme-btn .i-moon, [data-theme="light"] .theme-btn .i-sun { display: none; }

/* ---------- barras de rolagem invisíveis (a rolagem continua funcionando) ---------- */
html, body, * { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { width: 0; height: 0; display: none; background: transparent; }
