/* Speedy Media · Ads — mesma linguagem visual do Speedy Media OS */
@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap");

:root {
  --background: #111214;
  --panel: #181a1d;
  --panel-strong: #1f2227;
  --line: rgba(255, 255, 255, 0.1);
  --line-soft: rgba(255, 255, 255, 0.06);
  --text: #f7f7f8;
  --subtle: #a3a7ae;
  --faint: #6f737a;
  --primary: #e01e37;
  --primary-dark: #ad1024;
  --primary-soft: rgba(224, 30, 55, 0.16);
  --success: #27d17f;
  --warning: #f7b733;
  --danger: #ff5a6e;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
  color-scheme: dark;
  color: var(--text);
  background: var(--background);
  font-family: "Manrope", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--background); }
body { min-width: 320px; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
.tabular { font-variant-numeric: tabular-nums; }

.app-shell {
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 0%, rgba(224, 30, 55, 0.22), transparent 31rem),
    linear-gradient(180deg, #151619 0%, #111214 34%, #0d0e10 100%);
}
.page-wrap {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 56px;
  display: flex; flex-direction: column; gap: 22px;
}

/* ----------------------------------------------------------- topo */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand-line {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--subtle); font-size: .82rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; text-decoration: none;
}
.brand-line span {
  width: 10px; height: 10px; border-radius: 50%; background: var(--primary);
  box-shadow: 0 0 0 8px var(--primary-soft), 0 0 28px rgba(224, 30, 55, .6);
}
.brand-line b { color: #fff; font-weight: 800; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.user-chip { color: var(--subtle); font-size: .78rem; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; padding: 14px 0 0; flex-wrap: wrap; }
.kicker {
  display: inline-flex; align-items: center; gap: 7px;
  color: #ff6577; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em;
}
h1 { margin-top: 10px; font-size: clamp(2rem, 5vw, 3.6rem); line-height: 1; letter-spacing: -.035em; }
.hero p { margin-top: 12px; color: var(--subtle); font-size: .95rem; }
.hero p b { color: #fff; font-weight: 700; }
.back-link {
  display: inline-flex; align-items: center; gap: 6px; color: var(--subtle);
  font-size: .8rem; font-weight: 700; text-decoration: none; margin-bottom: 4px;
}
.back-link:hover { color: #fff; }

/* ----------------------------------------------------------- botões */
.primary-btn, .ghost-btn, .danger-btn {
  min-height: 40px; border-radius: 8px; padding: 0 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: .82rem; font-weight: 800; color: #fff; text-decoration: none;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}
.primary-btn { border: 0; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); box-shadow: 0 14px 34px rgba(224, 30, 55, .25); }
.ghost-btn { border: 1px solid var(--line); background: rgba(255, 255, 255, .06); }
.danger-btn { border: 1px solid rgba(224, 30, 55, .35); background: var(--primary-soft); color: #ff7788; }
.primary-btn:hover, .ghost-btn:hover { transform: translateY(-1px); }
.ghost-btn:hover { border-color: rgba(255, 255, 255, .2); }
button:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; padding: 0;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .04); color: #fff; border-radius: 8px;
}
.link-btn { border: 0; background: none; padding: 0; color: #ff7182; font-size: .8rem; font-weight: 700; }
.link-btn:hover { text-decoration: underline; }
.icon { width: 16px; height: 16px; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ----------------------------------------------------------- superfícies */
.surface {
  background: linear-gradient(180deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .03));
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset;
}
.panel { padding: 18px 18px 16px; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head h2 { font-size: 1.05rem; letter-spacing: -.01em; }
.panel-head p { color: var(--subtle); font-size: .78rem; margin-top: 4px; }
.section-label {
  color: var(--subtle); font-size: .72rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .08em; margin: 6px 0 -8px;
}

/* ----------------------------------------------------------- período */
.period-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px; }
.segmented { display: flex; gap: 3px; padding: 3px; border-radius: 9px; background: rgba(0, 0, 0, .25); border: 1px solid var(--line-soft); flex-wrap: wrap; }
.segmented button {
  min-height: 32px; padding: 0 11px; border: 0; border-radius: 7px; background: transparent;
  color: var(--subtle); font-size: .76rem; font-weight: 800; white-space: nowrap;
}
.segmented button:hover { color: #fff; }
.segmented button.active { background: var(--primary-soft); color: #ff8a98; box-shadow: inset 0 0 0 1px rgba(224, 30, 55, .35); }
.date-inputs { display: flex; align-items: center; gap: 6px; color: var(--subtle); font-size: .78rem; }
.date-inputs input, .field, select.field {
  min-height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #1d1f23; color: #fff; outline: 0; font-size: .82rem;
}
.field:focus, .date-inputs input:focus { border-color: rgba(224, 30, 55, .75); box-shadow: 0 0 0 3px var(--primary-soft); }
.period-meta { margin-left: auto; color: var(--subtle); font-size: .76rem; text-align: right; }
.period-meta b { color: #fff; }

/* ----------------------------------------------------------- KPIs */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.kpi { padding: 16px 16px 14px; position: relative; overflow: hidden; min-height: 112px; display: flex; flex-direction: column; }
.kpi > span { color: var(--subtle); font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.kpi strong { display: block; margin: 8px 0 auto; font-size: clamp(1.3rem, 2.1vw, 1.75rem); font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
.kpi.highlight { border-color: rgba(224, 30, 55, .3); }
.kpi.highlight::after {
  content: ""; position: absolute; width: 110px; height: 110px; border-radius: 50%;
  background: var(--primary-soft); right: -38px; top: -48px; box-shadow: 0 0 40px rgba(224, 30, 55, .18);
}
.kpi .sub { color: var(--faint); font-size: .72rem; margin-top: 8px; }
.delta { display: inline-flex; align-items: center; gap: 4px; font-size: .74rem; font-weight: 800; margin-top: 8px; }
.delta small { color: var(--faint); font-weight: 600; }
.delta.good { color: var(--success); }
.delta.bad { color: var(--danger); }
.delta.flat { color: var(--subtle); }

/* ----------------------------------------------------------- gráfico */
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; height: 260px; overflow: visible; }
.chart-wrap .grid line { stroke: rgba(255, 255, 255, .07); }
.chart-wrap .axis text { fill: var(--faint); font-size: 11px; font-family: inherit; }
.chart-wrap .bar { fill: var(--primary); transition: opacity .12s; }
.chart-wrap .bar.dim { opacity: .35; }
.chart-wrap .bar-zero { fill: rgba(255, 255, 255, .08); }
.chart-wrap .hit { fill: transparent; cursor: crosshair; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 150px;
  padding: 9px 11px; border-radius: 8px; background: #0c0d0f; border: 1px solid var(--line);
  box-shadow: var(--shadow); font-size: .76rem; transform: translate(-50%, -100%); white-space: nowrap;
}
.chart-tip b { display: block; font-size: .95rem; margin-top: 3px; }
.chart-tip span { color: var(--subtle); }
.chart-empty { height: 260px; display: grid; place-items: center; color: var(--subtle); font-size: .85rem; }

/* ----------------------------------------------------------- tabelas */
.table-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search {
  min-height: 36px; min-width: 220px; border: 1px solid var(--line); background: rgba(255, 255, 255, .035);
  border-radius: 8px; display: flex; align-items: center; gap: 8px; padding: 0 10px; color: var(--subtle);
}
.search input { border: 0; outline: 0; background: transparent; color: #fff; min-width: 0; width: 100%; font-size: .82rem; }
.table-scroll { overflow-x: auto; margin: 0 -18px -16px; border-top: 1px solid var(--line); }
table.data { width: 100%; border-collapse: collapse; font-size: .8rem; }
table.data th, table.data td { padding: 11px 14px; text-align: right; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; padding-left: 18px; }
table.data th:last-child, table.data td:last-child { padding-right: 18px; }
table.data th {
  color: var(--subtle); font-size: .66rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  background: rgba(255, 255, 255, .025); position: sticky; top: 0; user-select: none;
}
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover, table.data th.sorted { color: #fff; }
table.data th.sorted::after { content: " ↓"; color: #ff7182; }
table.data th.sorted.asc::after { content: " ↑"; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr:hover { background: rgba(255, 255, 255, .03); }
table.data tbody tr.selected { background: rgba(224, 30, 55, .07); box-shadow: inset 3px 0 0 var(--primary); }
table.data tfoot td { font-weight: 800; color: #fff; background: rgba(255, 255, 255, .025); border-bottom: 0; }
.name-cell { min-width: 230px; max-width: 420px; white-space: normal !important; }
.name-cell strong { display: block; font-weight: 700; line-height: 1.3; }
.name-cell small { display: block; color: var(--faint); font-size: .72rem; margin-top: 3px; line-height: 1.3; }
.muted { color: var(--faint); }
.rank { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 8px; border-radius: 6px; background: rgba(255, 255, 255, .06); color: var(--subtle); font-size: .68rem; font-weight: 800; vertical-align: middle; }
.rank.top { background: var(--primary-soft); color: #ff8a98; }
.more-row td { text-align: center !important; padding: 12px !important; }
.empty-row td { text-align: center !important; color: var(--subtle); padding: 28px !important; }
.spend-bar { display: block; height: 3px; margin-top: 6px; border-radius: 99px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.spend-bar i { display: block; height: 100%; background: var(--primary); border-radius: 99px; }

/* ----------------------------------------------------------- etiquetas */
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px;
  font-size: .68rem; font-weight: 800; border: 1px solid var(--line); background: rgba(255, 255, 255, .05); color: var(--subtle);
}
.pill.ok { color: var(--success); border-color: rgba(39, 209, 127, .3); background: rgba(39, 209, 127, .08); }
.pill.warn { color: var(--warning); border-color: rgba(247, 183, 51, .3); background: rgba(247, 183, 51, .08); }
.pill.bad { color: var(--danger); border-color: rgba(255, 90, 110, .3); background: rgba(255, 90, 110, .08); }
.pill.red { color: #ff8a98; border-color: rgba(224, 30, 55, .35); background: var(--primary-soft); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ----------------------------------------------------------- grid admin */
.two-col { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.stack { display: grid; gap: 14px; }
.list { display: grid; }
.list-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 11px 0; border-top: 1px solid var(--line-soft);
}
.list-row:first-child { border-top: 0; }
.list-row strong { font-size: .84rem; font-weight: 700; }
.list-row small { display: block; color: var(--faint); font-size: .72rem; margin-top: 3px; }
.row-actions { display: flex; align-items: center; gap: 6px; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.form-row .field { flex: 1; min-width: 160px; }
.note { color: var(--subtle); font-size: .76rem; line-height: 1.5; }
.callout {
  padding: 12px 14px; border-radius: 8px; border: 1px solid rgba(247, 183, 51, .22);
  background: rgba(247, 183, 51, .07); color: #ecd795; font-size: .78rem; line-height: 1.5;
}
.callout.red { border-color: rgba(224, 30, 55, .3); background: var(--primary-soft); color: #ffb3bd; }
.copy-box { display: flex; gap: 8px; margin-top: 10px; }
.copy-box input { flex: 1; min-width: 0; font-size: .74rem; }

/* ----------------------------------------------------------- login */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(420px, 100%); padding: 32px; border-radius: 16px; background: rgba(24, 26, 29, .94); box-shadow: var(--shadow); }
.auth-card h1 { font-size: 2.1rem; margin: 34px 0 8px; }
.auth-card > p { color: var(--subtle); font-size: .88rem; line-height: 1.5; margin-bottom: 18px; }
.auth-card label { display: grid; gap: 7px; margin-top: 12px; }
.auth-card label span { color: var(--subtle); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.auth-card .field { width: 100%; min-height: 44px; }
.auth-card .primary-btn { width: 100%; margin-top: 20px; min-height: 44px; }
.auth-foot { display: flex; justify-content: space-between; margin-top: 16px; }
.form-error { margin-top: 12px; color: #ff8a98; font-size: .82rem; }
.form-ok { margin-top: 12px; color: var(--success); font-size: .82rem; }

/* ----------------------------------------------------------- estados */
.loading { min-height: 50vh; display: grid; place-items: center; color: var(--subtle); }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .12); border-top-color: var(--primary); animation: spin .8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { opacity: .55; pointer-events: none; transition: opacity .15s; }
.empty-state { padding: 46px 20px; text-align: center; }
.empty-state h2 { font-size: 1.2rem; margin-bottom: 8px; }
.empty-state p { color: var(--subtle); font-size: .88rem; max-width: 520px; margin: 0 auto; line-height: 1.55; }
.toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 100; padding: 12px 16px; border-radius: 9px;
  background: #0c0d0f; border: 1px solid var(--line); box-shadow: var(--shadow); font-size: .84rem; max-width: 360px;
}
.toast.error { border-color: rgba(224, 30, 55, .45); color: #ffb3bd; }
.footer-note { color: var(--faint); font-size: .72rem; text-align: center; margin-top: 8px; }

@media (max-width: 980px) { .two-col { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .page-wrap { width: calc(100% - 24px); padding-top: 16px; }
  .period-meta { margin-left: 0; text-align: left; width: 100%; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { min-height: 98px; padding: 13px; }
  .kpi strong { font-size: 1.2rem; }
  .kpi > span { font-size: .62rem; }
  .delta small { display: none; }
  .user-chip { display: none; }
  .search { min-width: 0; width: 100%; }
  .table-tools { width: 100%; }
  .chart-wrap svg, .chart-empty { height: 210px; }
}
