/* BuxBox Adv - layout padrão BuxBox (modelo suporte.buxbox.org) */
:root {
  --blue-dark: #031633;
  --blue-mid: #0d6efd;
  --blue-soft: #0b5ed7;
  --blue-bg: #020b1a;
  --blue-light: #cfe2ff;
  --text-main: #f8f9ff;
  --text-soft: #b9c6ff;
  --accent: #20c997;
  --warn: #ffc107;
  --danger: #ff6b6b;
  --line: rgba(148, 193, 255, 0.22);
  --card: linear-gradient(145deg, rgba(3, 15, 36, 0.95), rgba(4, 33, 78, 0.92));
  --input: rgba(2, 11, 26, 0.75);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: dark; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #063970 0, #020b1a 45%, #00030a 100%) fixed;
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 14px;
}
a { color: var(--blue-light); }
button, input, select, textarea { font: inherit; color: inherit; }

.bg-blur { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: -1; }
.bg-pill { position: absolute; border-radius: 999px; filter: blur(70px); opacity: .35; }
.bg-pill--1 { width: 420px; height: 420px; background: #0d6efd; top: -80px; left: -40px; animation: drift1 16s ease-in-out infinite; }
.bg-pill--2 { width: 480px; height: 480px; background: #20c997; bottom: -140px; right: -80px; opacity: .25; animation: drift2 19s ease-in-out infinite; }
@keyframes drift1 { 0%,100% { translate: 0 0; } 50% { translate: 40px 30px; } }
@keyframes drift2 { 0%,100% { translate: 0 0; } 50% { translate: -50px -25px; } }
@media (prefers-reduced-motion: reduce) { .bg-pill { animation: none !important; } }

/* ---------- shell ---------- */
.shell {
  background: radial-gradient(circle at top left, rgba(13,110,253,0.22), transparent 55%),
              radial-gradient(circle at bottom right, rgba(4,206,172,0.12), transparent 60%),
              linear-gradient(135deg, rgba(3,22,51,0.96), rgba(3,15,36,0.98));
  border-radius: 26px;
  border: 1px solid rgba(148, 193, 255, 0.25);
  box-shadow: 0 32px 80px rgba(0,0,0,.75), 0 0 0 1px rgba(59,130,246,.25);
  backdrop-filter: blur(22px);
}
.app { max-width: 1320px; margin: 0 auto; padding: 20px 16px 40px; }
.app > .shell { padding: 18px 22px 24px; min-height: calc(100vh - 60px); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand__logo { width: 46px; height: 46px; object-fit: contain; filter: drop-shadow(0 0 12px rgba(13,110,253,.7)); }
.brand__name { font-weight: 700; letter-spacing: .04em; text-transform: uppercase; font-size: .9rem; color: var(--blue-light); }
.brand__domain { font-size: .8rem; color: var(--text-soft); }
.user-pill { display: flex; align-items: center; gap: 10px; font-size: .82rem; color: var(--text-soft); }
.user-pill strong { color: var(--blue-light); }

nav.menu { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
nav.menu a {
  padding: 8px 14px; border-radius: 999px; text-decoration: none; font-size: .84rem; color: var(--text-soft);
  border: 1px solid transparent;
}
nav.menu a:hover { border-color: var(--line); color: var(--blue-light); }
nav.menu a.ativo { background: rgba(13,110,253,.22); border-color: rgba(148,193,255,.5); color: var(--text-main); }

/* ---------- elementos ---------- */
h1 { font-size: 1.5rem; font-weight: 800; margin-bottom: 4px; }
h1 span.grad { background: linear-gradient(120deg, #4dabf7, #20c997); -webkit-background-clip: text; background-clip: text; color: transparent; }
h2 { font-size: 1.05rem; color: var(--blue-light); margin: 0 0 12px; }
.sub { color: var(--text-soft); margin-bottom: 18px; font-size: .9rem; }
.eyebrow { font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; color: var(--text-soft); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.kpi .valor { font-size: 1.45rem; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .valor.ok { color: var(--accent); }

.btn {
  border: none; border-radius: 999px; padding: 9px 18px; font-weight: 600; cursor: pointer; font-size: .85rem;
  background: linear-gradient(135deg, var(--blue-mid), var(--blue-soft)); color: #f8f9ff; text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  box-shadow: 0 10px 24px rgba(13,110,253,.35); transition: transform .15s, filter .15s;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.07); }
.btn:disabled { opacity: .5; cursor: wait; transform: none; }
.btn.sec { background: rgba(3,16,39,.9); border: 1px solid rgba(148,193,255,.5); box-shadow: none; color: var(--blue-light); }
.btn.ok { background: linear-gradient(135deg, #20c997, #12a37a); box-shadow: 0 10px 24px rgba(32,201,151,.3); }
.btn.perigo { background: rgba(80,10,20,.6); border: 1px solid rgba(255,107,107,.6); box-shadow: none; color: #ffc9c9; }
.btn.peq { padding: 5px 11px; font-size: .78rem; }
.acoes { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

label { display: block; font-size: .76rem; color: var(--text-soft); margin-bottom: 4px; letter-spacing: .02em; }
input, select, textarea {
  width: 100%; background: var(--input); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue-mid); box-shadow: 0 0 0 3px rgba(13,110,253,.25); }
.campos { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.campos .largo { grid-column: 1 / -1; }

.badge { font-size: .72rem; padding: 3px 9px; border-radius: 999px; border: 1px solid rgba(148,193,255,.5); color: var(--blue-light); background: rgba(7,31,76,.88); white-space: nowrap; }
.badge.ok { border-color: rgba(32,201,151,.65); color: var(--accent); background: rgba(4,206,172,.1); }
.badge.warn { border-color: rgba(255,193,7,.6); color: var(--warn); background: rgba(255,193,7,.08); }
.badge.err { border-color: rgba(255,107,107,.6); color: var(--danger); }

.aviso { border-radius: 12px; padding: 10px 14px; font-size: .85rem; margin-bottom: 14px; border: 1px solid rgba(255,193,7,.5); background: rgba(255,193,7,.07); color: #ffe69c; }
.aviso.info { border-color: rgba(148,193,255,.45); background: rgba(13,110,253,.1); color: var(--blue-light); }
.aviso.ok { border-color: rgba(32,201,151,.5); background: rgba(32,201,151,.08); color: #b5f5df; }

/* ---------- tabelas ---------- */
.tabela-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid rgba(148,193,255,.12); white-space: nowrap; }
th { background: rgba(3,16,39,.9); color: var(--text-soft); font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; position: sticky; top: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: rgba(13,110,253,.08); }
tr.clicavel { cursor: pointer; }
tfoot td { font-weight: 700; background: rgba(3,16,39,.7); }
td input { padding: 4px 6px; border-radius: 6px; text-align: right; min-width: 92px; }
td.neg { color: var(--danger); }

.tabs { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: none; border: 1px solid transparent; color: var(--text-soft); padding: 7px 14px; border-radius: 999px; cursor: pointer; }
.tabs button.ativo { background: rgba(13,110,253,.22); border-color: rgba(148,193,255,.5); color: var(--text-main); }

/* ---------- modal / toast ---------- */
.modal-fundo { position: fixed; inset: 0; background: rgba(0,3,10,.72); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { width: 100%; max-width: 980px; padding: 20px 22px; }
.modal header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 60; padding: 11px 16px; border-radius: 12px; background: rgba(3,22,51,.97); border: 1px solid rgba(32,201,151,.6); box-shadow: 0 14px 30px rgba(0,0,0,.6); max-width: 420px; }
.toast.err { border-color: rgba(255,107,107,.7); }

.vazio { text-align: center; color: var(--text-soft); padding: 30px 10px; }
.mini { font-size: .76rem; color: var(--text-soft); }
footer.rodape { margin-top: 26px; font-size: .74rem; color: var(--text-soft); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px 16px; }
.login { width: 100%; max-width: 440px; padding: 28px 26px; }
.login .brand { margin-bottom: 24px; }
.login form { display: grid; gap: 14px; }

@media (max-width: 640px) {
  .app { padding: 10px 8px 30px; }
  .app > .shell { padding: 14px 14px 20px; border-radius: 18px; }
  .brand__logo { width: 38px; height: 38px; }
  .modal-fundo { padding: 12px 8px; }
}

/* ---------- botão de tema ---------- */
.tema-btn {
  width: 34px; height: 34px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  background: rgba(3,16,39,.9); border: 1px solid rgba(148,193,255,.5); color: var(--blue-light); font-size: 16px; line-height: 1;
}
.tema-btn:hover { filter: brightness(1.15); }
.login .tema-btn { position: absolute; top: 18px; right: 18px; }
.login { position: relative; }
.obs-comp { white-space: normal; max-width: 240px; color: #ffe69c; }

/* =====================================================================
   TEMA CLARO  (html[data-theme="light"])
   ===================================================================== */
html[data-theme="light"] {
  color-scheme: light;
  --blue-light: #0b4fb3;
  --text-main: #10203a;
  --text-soft: #4f6283;
  --accent: #0f9d74;
  --warn: #b7791f;
  --danger: #c92a2a;
  --line: rgba(16, 60, 140, 0.16);
  --card: linear-gradient(145deg, #ffffff, #f4f8ff);
  --input: #ffffff;
}
html[data-theme="light"] body { background: radial-gradient(circle at top, #dbe9ff 0, #eef3fb 45%, #f7f9fc 100%) fixed; }
html[data-theme="light"] .bg-pill { opacity: .18; }
html[data-theme="light"] .shell {
  background: radial-gradient(circle at top left, rgba(13,110,253,0.08), transparent 55%),
              radial-gradient(circle at bottom right, rgba(32,201,151,0.07), transparent 60%),
              rgba(255,255,255,0.92);
  border-color: rgba(16,60,140,.14);
  box-shadow: 0 24px 60px rgba(16,32,58,.12), 0 0 0 1px rgba(13,110,253,.06);
}
html[data-theme="light"] .brand__logo { filter: drop-shadow(0 0 6px rgba(13,110,253,.35)); }
html[data-theme="light"] h1 span.grad { background: linear-gradient(120deg, #0b5ed7, #0f9d74); -webkit-background-clip: text; background-clip: text; }
html[data-theme="light"] nav.menu a.ativo,
html[data-theme="light"] .tabs button.ativo { background: rgba(13,110,253,.1); border-color: rgba(13,110,253,.35); color: #0b3d91; }
html[data-theme="light"] .card { box-shadow: 0 6px 18px rgba(16,32,58,.05); }
html[data-theme="light"] .btn { box-shadow: 0 8px 18px rgba(13,110,253,.22); }
html[data-theme="light"] .btn.sec,
html[data-theme="light"] .tema-btn { background: #fff; border-color: rgba(13,110,253,.35); color: #0b4fb3; box-shadow: none; }
html[data-theme="light"] .btn.ok { box-shadow: 0 8px 18px rgba(15,157,116,.22); }
html[data-theme="light"] .btn.perigo { background: #fff5f5; border-color: rgba(201,42,42,.45); color: #c92a2a; }
html[data-theme="light"] .badge { background: #eef4ff; border-color: rgba(13,110,253,.3); color: #0b4fb3; }
html[data-theme="light"] .badge.ok { background: #e9fbf4; border-color: rgba(15,157,116,.45); color: #0f7a5b; }
html[data-theme="light"] .badge.warn { background: #fff8e6; border-color: rgba(183,121,31,.45); color: #9a6412; }
html[data-theme="light"] .badge.err { background: #fff5f5; border-color: rgba(201,42,42,.45); color: #c92a2a; }
html[data-theme="light"] .aviso { background: #fff8e6; border-color: rgba(183,121,31,.4); color: #7a4f0e; }
html[data-theme="light"] .aviso.info { background: #eef4ff; border-color: rgba(13,110,253,.3); color: #0b3d91; }
html[data-theme="light"] .aviso.ok { background: #e9fbf4; border-color: rgba(15,157,116,.4); color: #0f6b50; }
html[data-theme="light"] th { background: #eef3fb; color: #4f6283; }
html[data-theme="light"] th, html[data-theme="light"] td { border-bottom-color: rgba(16,60,140,.09); }
html[data-theme="light"] tbody tr:hover { background: rgba(13,110,253,.05); }
html[data-theme="light"] tfoot td { background: #eef3fb; }
html[data-theme="light"] input, html[data-theme="light"] select, html[data-theme="light"] textarea { border-color: rgba(16,60,140,.22); }
html[data-theme="light"] .modal-fundo { background: rgba(16,32,58,.35); }
html[data-theme="light"] .toast { background: #fff; color: #10203a; box-shadow: 0 14px 30px rgba(16,32,58,.18); }
html[data-theme="light"] .obs-comp { color: #9a6412; }

/* ---------- login: links e redefinição ---------- */
.links-login { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: .82rem; }
.links-login a { color: var(--text-soft); text-decoration: none; }
.links-login a:hover { color: var(--blue-light); text-decoration: underline; }
.regras { list-style: none; font-size: .8rem; color: var(--text-soft); display: grid; gap: 3px; }
.regras li::before { content: "○ "; }
.regras li.ok { color: var(--accent); }
.regras li.ok::before { content: "● "; }
.contador { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--blue-light); }
.contador.fim { color: var(--danger); }
