/* Saturn Ads — painel. Escuro, sóbrio e sem fonte externa: a CSP do servidor
   é default-src 'self', então tudo aqui é CSS próprio. */

:root {
  --bg: #0d0f13;
  --surface: #14171d;
  --surface-2: #1a1e26;
  --surface-3: #20252f;
  --line: #262c36;
  --line-strong: #333a46;
  --text: #e6e9ef;
  --muted: #99a1ae;
  --accent: #f2a63b;
  --accent-ink: #2a1c05;
  --ok: #4bb971;
  --bad: #e2565f;
  --warn: #d9a13a;
  --radius: 10px;
  --shadow: 0 18px 40px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* display: flex nos nossos blocos venceria o [hidden] do navegador. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 10;
  background: var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: 0 0 var(--radius) 0;
}
.skip:focus { left: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- estrutura ---------- */

.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100%; }

.sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh;
  display: flex; flex-direction: column; gap: 22px;
  padding: 22px 18px;
  background: var(--surface); border-right: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; letter-spacing: .14em; }
.brand-text { font-weight: 500; color: var(--muted); }
.brand-text strong { color: var(--text); font-weight: 700; }
.brand-mark {
  width: 24px; height: 24px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffd9a0, var(--accent) 58%, #a66a16);
  display: grid; place-items: center; position: relative;
}
.brand-mark i {
  position: absolute; inset: 50% -5px auto -5px; height: 3px;
  background: rgba(255, 255, 255, .55); border-radius: 2px; transform: rotate(-18deg);
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 9px 11px; border-radius: 8px;
  color: var(--muted); font-weight: 500; text-decoration: none;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--surface-3); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav-count { font-size: .75rem; color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.sidebar-note { color: var(--muted); font-size: .8rem; line-height: 1.4; }
.sidebar-buttons { display: flex; gap: 8px; }

.main { min-width: 0; padding: 26px 30px 70px; }
.topbar { margin-bottom: 22px; }
.topbar-note { color: var(--muted); margin-top: 6px; max-width: 70ch; font-size: .9rem; }
.view { display: flex; flex-direction: column; gap: 16px; }

/* ---------- blocos ---------- */

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px;
}
.card > h3 { margin-bottom: 12px; }

.bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.bar.sticky {
  position: sticky; bottom: 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
}
.bar-note { color: var(--muted); font-size: .85rem; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.grow { flex: 1 1 220px; }
.live { color: var(--ok); }

.empty { text-align: center; padding: 42px 20px; display: grid; gap: 10px; justify-items: center; }
.empty p { color: var(--muted); max-width: 56ch; }

.notice { border-radius: 8px; padding: 12px 14px; font-size: .9rem; line-height: 1.5; border: 1px solid var(--line); background: var(--surface-2); }
.notice.bad { border-color: rgba(226, 86, 95, .5); background: rgba(226, 86, 95, .12); }
.notice code { background: rgba(0, 0, 0, .35); padding: 1px 5px; border-radius: 4px; }

/* ---------- botões ---------- */

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 15px; border-radius: 8px; cursor: pointer;
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--line-strong);
  font: inherit; font-weight: 500; text-decoration: none;
}
.button:hover:not(:disabled) { background: #272d38; text-decoration: none; }
.button:disabled { opacity: .5; cursor: not-allowed; }
.button.primary { background: var(--accent); color: var(--accent-ink); border-color: #c9862b; font-weight: 600; }
.button.primary:hover:not(:disabled) { background: #ffb752; }
.button.ghost { background: transparent; }
.button.danger { color: #ffb4b8; border-color: rgba(226, 86, 95, .45); background: rgba(226, 86, 95, .1); }
.button.danger:hover:not(:disabled) { background: rgba(226, 86, 95, .2); }
.button.small { padding: 6px 11px; font-size: .85rem; }
.button.active { background: var(--accent); color: var(--accent-ink); border-color: #c9862b; }

.segmented { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.segmented .button { border-color: transparent; background: transparent; }
.segmented .button.active { background: var(--accent); color: var(--accent-ink); }

/* ---------- formulários ---------- */

.field { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: var(--muted); font-weight: 500; }
.field > input, .field > select, .field > .input-unit > input, select {
  font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 9px 11px; width: 100%;
}
.field > input:focus, .field > select:focus, .input-unit > input:focus { border-color: var(--accent); outline: none; }
.field > input[type=file] { padding: 7px 9px; color: var(--muted); }
.hint { color: var(--muted); font-weight: 400; font-size: .78rem; line-height: 1.4; }
.hint.bad { color: var(--bad); }

.input-unit { display: flex; align-items: center; gap: 8px; }
.input-unit em { font-style: normal; color: var(--muted); font-size: .8rem; white-space: nowrap; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px 18px; align-items: start; }
.form-row { display: flex; gap: 14px; align-items: end; flex-wrap: wrap; }

.check { display: flex; gap: 10px; align-items: start; font-size: .9rem; cursor: pointer; padding: 4px 0; }
.check input { width: 17px; height: 17px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.check small { display: block; color: var(--muted); font-size: .78rem; line-height: 1.4; margin-top: 2px; }
.check-list {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 2px 18px;
  max-height: 232px; overflow-y: auto;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
.radios { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 10px; }

.group { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 16px; display: grid; gap: 10px; }
.group > legend { padding: 0 6px; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.days { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-check { cursor: pointer; }
.chip-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip-check span {
  display: inline-block; padding: 7px 12px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line-strong); color: var(--muted); font-size: .85rem;
}
.chip-check input:checked + span { background: var(--accent); border-color: #c9862b; color: var(--accent-ink); font-weight: 600; }
.chip-check input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.rules-section { display: grid; gap: 12px; }

/* ---------- entrar ---------- */

.login { display: grid; place-items: center; padding: 6vh 0; }
.login-card { width: min(100%, 400px); display: grid; gap: 16px; box-shadow: var(--shadow); }

/* ---------- tabelas ---------- */

.table-card { padding: 0; overflow: hidden; }
.table-card > h3 { padding: 16px 18px 0; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .74rem; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.table td small.mono { display: block; color: var(--muted); font-size: .72rem; margin-top: 2px; }
.table .bar-column { width: 34%; min-width: 90px; }
.table .right { text-align: right; }
.states { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .74rem; font-weight: 600;
  background: var(--surface-3); color: var(--muted); border: 1px solid var(--line-strong); white-space: nowrap;
}
.badge.ok { color: #9ee7b6; background: rgba(75, 185, 113, .14); border-color: rgba(75, 185, 113, .4); }
.badge.warn { color: #f0ce8e; background: rgba(217, 161, 58, .14); border-color: rgba(217, 161, 58, .4); }
.badge.off { color: #c9ced8; background: transparent; }
.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .18em; font-size: .85rem; background: var(--bg);
  border: 1px dashed var(--line-strong); border-radius: 6px; padding: 3px 8px;
}
.code-input { letter-spacing: .3em; text-transform: uppercase; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.15rem; text-align: center; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 16px 0 0; padding: 14px; background: var(--bg); border-radius: 8px; }
.facts dt { font-size: .7rem; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 3px 0 0; font-size: .85rem; word-break: break-all; }

/* ---------- criativos ---------- */

.creative-form { display: grid; gap: 16px; }
.creative-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.creative { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.preview { width: 100%; aspect-ratio: 16 / 9; object-fit: contain; background: #05070a; display: block; }
.preview.missing { display: grid; place-items: center; color: var(--muted); font-size: .85rem; border-bottom: 1px solid var(--line); }
.creative-body { padding: 14px 16px 16px; display: grid; gap: 9px; }
.creative-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.creative-actions .button { cursor: pointer; }

.progress-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.progress { flex: 1 1 200px; height: 9px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .15s linear; }
.progress-label { font-size: .85rem; color: var(--muted); min-width: 16ch; }

/* ---------- campanhas ---------- */

.campaign-list { display: grid; gap: 12px; }
.campaign { display: grid; gap: 8px; }
.campaign-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.campaign-summary { font-size: .92rem; }
.campaign-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* ---------- relatório ---------- */

.total { display: flex; align-items: baseline; gap: 14px; justify-content: space-between; }
.total span { color: var(--muted); font-size: .9rem; }
.total strong { font-size: 2.4rem; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.meter { display: block; height: 7px; background: var(--bg); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, #8a5f16, var(--accent)); }

/* ---------- modal e aviso ---------- */

.modal {
  border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); color: var(--text);
  width: min(94vw, 680px); max-height: 88vh; padding: 22px 24px; box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(5, 7, 10, .72); }
.modal form { display: grid; gap: 14px; }
.modal h2 { margin-bottom: 2px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding-top: 4px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  max-width: min(92vw, 520px); padding: 12px 18px; border-radius: 10px;
  background: var(--surface-3); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  font-size: .92rem;
}
.toast.bad { background: #3a1b1f; border-color: rgba(226, 86, 95, .6); }
.toast.ok { border-color: rgba(75, 185, 113, .45); }

[aria-busy=true] { opacity: .75; }

/* ---------- telas estreitas ---------- */

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px 18px; border-right: none; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; }
  .nav-item.active { box-shadow: inset 0 -2px 0 var(--accent); }
  .sidebar-foot { margin: 0; flex-direction: row; align-items: center; gap: 14px; flex: 1 1 100%; justify-content: space-between; }
  .main { padding: 20px 16px 60px; }
  .table-card { overflow-x: auto; }
  .table { min-width: 680px; }
}

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