:root {
  /* Tema claro estilo Meta Ads Manager */
  --bg: #f0f2f5;
  --surface: #ffffff;
  --border: #dadde1;
  --border-soft: #e9ebee;
  --text: #1c1e21;
  --muted: #65676b;
  --link: #216fdb;
  --accent: #0866ff;
  --accent-hover: #0b5fd8;
  --green: #31a24c;
  --red: #e41e3f;
  --row-hover: #f5f6f7;
  --row-off: #fafafa;
  --header-bg: #ffffff;
  --shadow: 0 1px 2px rgba(0,0,0,.1);
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ---- Login ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 32px 28px; width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.12);
}
.login-logo { font-size: 26px; font-weight: 800; text-align: center; color: var(--accent); }
.login-sub { text-align: center; color: var(--muted); margin: -6px 0 8px; font-size: 13px; }
.login-card input, .login-card button {
  height: 46px; border-radius: 8px; border: 1px solid var(--border); padding: 0 14px; font-size: 15px;
}
.login-card input { background: var(--surface); color: var(--text); }
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(8,102,255,.2); }
.login-card button { background: var(--accent); color: #fff; border: none; font-weight: 600; cursor: pointer; }
.login-card button:hover { background: var(--accent-hover); }
.login-error { color: var(--red); font-size: 13px; min-height: 16px; text-align: center; }

/* ---- Topbar ---- */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20; flex-wrap: wrap;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.meta-mark { display: inline-flex; align-items: center; }
.topbar h1 { font-size: 17px; font-weight: 700; margin: 0; }
.account-pill, .date-pill {
  display: inline-flex; align-items: center; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; height: 36px; padding: 0 4px;
}
.account-pill select, .date-pill select {
  border: none; background: transparent; color: var(--text); font-size: 13px;
  font-weight: 600; padding: 0 8px; height: 34px; cursor: pointer; outline: none; max-width: 260px;
}
.updated { color: var(--muted); font-size: 12px; }
.icon-btn {
  height: 36px; width: 36px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 8px; cursor: pointer; font-size: 16px; color: var(--muted);
}
.icon-btn:hover { background: var(--row-hover); }
.ghost-btn {
  height: 36px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 8px; padding: 0 14px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text);
}
.ghost-btn:hover { background: var(--row-hover); }

/* ---- Tabstrip ---- */
.tabstrip { display: flex; align-items: center; padding: 0 16px; background: var(--bg); gap: 6px; padding-top: 12px; }
.tab {
  background: var(--surface); border: 1px solid var(--border); border-bottom: none;
  border-radius: 8px 8px 0 0; padding: 9px 16px; font-weight: 700; font-size: 13px;
  color: var(--text); box-shadow: var(--shadow);
}
.tab .num, #tab-count { color: var(--muted); font-weight: 500; }
.spacer { flex: 1; }

/* ---- Tabela ---- */
.table-card {
  margin: 0 16px 32px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 0 var(--radius) var(--radius) var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
thead th {
  text-align: left; color: var(--muted); font-size: 12px; font-weight: 600;
  padding: 10px 14px; background: var(--header-bg); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; white-space: nowrap;
}
th.num, td.num { text-align: right; }
th.col-toggle, td.col-toggle { width: 64px; text-align: center; }
th.col-status, td.col-status { width: 120px; }

tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tbody tr:hover { background: var(--row-hover); }
tbody tr.is-off { background: var(--row-off); }
tbody tr.is-off:hover { background: var(--row-hover); }

.camp-name { color: var(--link); font-weight: 500; cursor: default; }
.camp-name-wrap { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Status Veiculacao */
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.on { background: var(--green); }
.dot.off { background: #bcc0c4; }
.status.on { color: var(--text); }
.status.off { color: var(--muted); }

/* Toggle switch estilo Meta */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: #bcc0c4; border-radius: 22px; transition: .2s; }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider:before { transform: translateX(16px); }
.switch input:disabled + .slider { opacity: .5; cursor: wait; }

/* Celula de orcamento (valor + periodicidade) */
.budget { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.budget-main { display: inline-flex; align-items: center; gap: 6px; }
.budget-value { font-weight: 500; }
.budget-period { color: var(--muted); font-size: 11px; }
.budget-input {
  width: 84px; height: 30px; text-align: right; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 0 8px; font-size: 13px;
}
.budget-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(8,102,255,.2); }
.budget-save {
  height: 30px; border: none; border-radius: 6px; background: var(--accent); color: #fff;
  padding: 0 10px; cursor: pointer; font-size: 12px; font-weight: 600;
}
.budget-save:hover { background: var(--accent-hover); }
.budget-save:disabled { opacity: .5; cursor: wait; }
.budget-edit-btn {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 13px; padding: 2px 4px; visibility: hidden;
}
tr:hover .budget-edit-btn { visibility: visible; }
.budget-cbo { color: var(--muted); font-style: italic; font-size: 12px; }
.dash { color: var(--muted); }

/* Rodape de totais */
tfoot td {
  padding: 12px 14px; border-top: 2px solid var(--border); font-weight: 600;
  background: var(--surface); position: sticky; bottom: 0;
}
tfoot .foot-label { color: var(--text); font-weight: 700; }
tfoot .foot-sub { display: block; color: var(--muted); font-weight: 400; font-size: 11px; }

.empty, .loading { text-align: center; color: var(--muted); padding: 36px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #242526; color: #fff; padding: 12px 18px; border-radius: 8px;
  font-size: 14px; z-index: 60; box-shadow: 0 8px 30px rgba(0,0,0,.35); max-width: 90vw;
}
.toast.ok { background: #1f7a34; }
.toast.err { background: #b31228; }

@media (max-width: 720px) {
  .table-card { margin: 0 8px 24px; }
  .updated { display: none; }
}
