:root {
  --bg: #f7f7f9;
  --surface: #ffffff;
  --surface-2: #f2f2f5;
  --border: #e6e6eb;
  --border-strong: #d4d4dc;
  --text: #16161a;
  --text-2: #5e5e6b;
  --text-3: #8d8d99;
  --brand: #e5194c;
  --brand-hover: #cc1242;
  --brand-soft: #fdecf0;
  --ok: #16a34a; --ok-soft: #e8f7ee;
  --warn: #b7791f; --warn-soft: #fdf4e3;
  --info: #2563eb; --info-soft: #e9f0fe;
  --bad: #dc2626; --bad-soft: #fdeceb;
  --shadow-sm: 0 1px 2px rgba(16, 16, 24, .05);
  --shadow: 0 1px 3px rgba(16, 16, 24, .06), 0 8px 24px rgba(16, 16, 24, .06);
  --radius: 12px;
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e11; --surface: #17171b; --surface-2: #1f1f24; --border: #2a2a31; --border-strong: #383841;
    --text: #f2f2f5; --text-2: #a5a5b2; --text-3: #73737f;
    --brand-soft: #3a1420; --ok-soft: #0f2a1b; --warn-soft: #2e2410; --info-soft: #132241; --bad-soft: #3a1414;
    --shadow-sm: none; --shadow: 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
button { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--text-2); }
.sprite { display: none; }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Botões */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 9px; border: 1px solid transparent; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, opacity .15s; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-danger-text { background: none; border: 0; color: var(--text-2); cursor: pointer; padding: 6px 8px; border-radius: 6px; font-size: 13px; font-weight: 500; }
.btn-danger-text:hover { color: var(--bad); background: var(--bad-soft); }
.icon-btn { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 0; background: none; cursor: pointer; color: var(--text-2); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.link { background: none; border: 0; color: var(--brand); font-weight: 600; font-size: 13px; cursor: pointer; padding: 0; }
.link:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Formulários */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > span { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--text); }
.field > span em { font-style: normal; font-weight: 500; color: var(--text-3); }
.hint { color: var(--text-3); font-size: 12px; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 9px; padding: 9px 12px; transition: border-color .15s, box-shadow .15s; }
textarea { resize: vertical; min-height: 96px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input-icon { position: relative; }
.input-icon .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 16px; height: 16px; }
.input-icon input { padding-left: 38px; height: 42px; }
.form-error { color: var(--bad); font-size: 13px; min-height: 0; margin: -4px 0 12px; }
.form-error:empty { display: none; }
.segmented { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 3px; }
.segmented button { flex: 1; height: 32px; border: 0; border-radius: 7px; background: none; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-2); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 500px at 50% -10%, var(--brand-soft), transparent 70%), var(--bg); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px 28px; box-shadow: var(--shadow); }
.auth-logo { border-radius: 14px; display: block; margin-bottom: 20px; }
.auth-card h1 { font-size: 22px; margin-bottom: 6px; }
.auth-card h1 span { color: var(--text-3); font-weight: 500; }
.auth-card > p { margin-bottom: 24px; }

.btn-tiktok { height: 46px; background: #111114; color: #fff; font-size: 15px; }
.btn-tiktok:hover { background: #26262b; }
@media (prefers-color-scheme: dark) { .btn-tiktok { background: #fff; color: #111114; } .btn-tiktok:hover { background: #e9e9ee; } }
.ic-fill { fill: currentColor; stroke: none; width: 20px; height: 20px; }
.auth-note { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 14px; font-size: 12px; color: var(--text-3); }
.auth-note .ic { width: 14px; height: 14px; }
.auth-alt { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.auth-alt summary { cursor: pointer; font-size: 13px; color: var(--text-2); text-align: center; list-style: none; }
.auth-alt summary::-webkit-details-marker { display: none; }
.auth-alt summary:hover { color: var(--text); }
.auth-alt[open] summary { margin-bottom: 16px; }
.auth-card .form-error { margin: 0 0 14px; }

/* Estrutura */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 24px; padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand img { border-radius: 9px; }
.brand strong { display: block; font-size: 14px; }
.brand small { display: block; color: var(--text-3); font-size: 12px; margin-top: -2px; }
.nav { display: grid; gap: 2px; }
.nav button { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border: 0; border-radius: 8px; background: none; cursor: pointer; font-weight: 500; color: var(--text-2); text-align: left; }
.nav button:hover { background: var(--surface-2); color: var(--text); }
.nav button.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.count:empty { display: none; }
.sidebar-foot { margin-top: auto; display: grid; gap: 10px; }
.conn { display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 10px; background: var(--surface-2); font-size: 12px; color: var(--text-2); }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.conn.on .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.conn.off .dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }

.main { padding: 28px 36px 48px; min-width: 0; width: 100%; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.topbar h2 { font-size: 22px; }
.topbar p { margin-top: 2px; }

.banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; margin-bottom: 20px; border: 1px solid var(--warn); background: var(--warn-soft); border-radius: var(--radius); }
.banner p { color: var(--text-2); font-size: 13px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h3 { font-size: 15px; }
.pad { padding: 16px 20px 0; }
.pad-x { padding: 0 20px 12px; font-size: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.kpi { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.kpi span { display: block; color: var(--text-2); font-size: 13px; font-weight: 500; }
.kpi strong { display: block; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi-ic { position: absolute; top: 16px; right: 16px; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }

/* Listas */
.upcoming, .top { list-style: none; margin: 0; padding: 0; }
.upcoming li, .top li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.upcoming li:first-child, .top li:first-child { border-top: 0; }
.date-chip { flex: none; width: 48px; text-align: center; border: 1px solid var(--border); border-radius: 9px; padding: 4px 0; background: var(--surface-2); }
.date-chip b { display: block; font-size: 16px; line-height: 1.2; }
.date-chip small { display: block; font-size: 10px; text-transform: uppercase; color: var(--text-3); font-weight: 600; letter-spacing: .04em; }
.li-main { min-width: 0; flex: 1; }
.li-main strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.li-main small { color: var(--text-3); font-size: 12px; }
.rank { flex: none; width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; background: var(--surface-2); font-size: 12px; font-weight: 700; color: var(--text-2); }
.li-num { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; }
.empty { padding: 28px 12px; text-align: center; color: var(--text-3); }
.empty strong { display: block; color: var(--text-2); margin-bottom: 4px; }

/* Tabela */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; padding: 12px 20px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 14px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .right { text-align: right; }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sortable th[data-sort] { cursor: pointer; user-select: none; }
.sortable th[data-sort]:hover { color: var(--text); }
.sortable th.sorted { color: var(--brand); }
.sortable th.sorted::after { content: " ↓"; }
.sortable th.sorted.asc::after { content: " ↑"; }
.cell-title { max-width: min(640px, 36vw); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.cell-sub { display: block; color: var(--text-3); font-size: 12px; }
.bar { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.bar i { display: block; height: 6px; width: 56px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar span { min-width: 64px; text-align: right; }
.nowrap { white-space: nowrap; }
.bar i b { display: block; height: 100%; background: var(--brand); border-radius: 3px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 12px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-scheduled { color: var(--info); background: var(--info-soft); }
.b-sending, .b-sent { color: var(--warn); background: var(--warn-soft); }
.b-published { color: var(--ok); background: var(--ok-soft); }
.b-failed { color: var(--bad); background: var(--bad-soft); }
.b-canceled { color: var(--text-3); background: var(--surface-2); }
.tag { display: inline-block; font-size: 12px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 8px; }
.err-line { display: block; color: var(--bad); font-size: 12px; margin-top: 4px; max-width: 360px; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(10, 10, 14, .45); backdrop-filter: blur(2px); animation: fade .15s ease-out; }
.modal-card { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 22px 24px; box-shadow: var(--shadow); animation: rise .18s ease-out; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h3 { font-size: 17px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* Toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: grid; gap: 8px; }
.toast { min-width: 240px; max-width: 360px; padding: 12px 14px; border-radius: 10px; background: var(--text); color: var(--bg); font-size: 13px; font-weight: 500; box-shadow: var(--shadow); animation: rise .18s ease-out; }
.toast.bad { background: var(--bad); color: #fff; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* Barra inferior (celular) */
.tabbar { display: none; }

@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 20px 16px 96px; }
  .topbar { flex-direction: column; align-items: stretch; }
  .topbar .btn { width: 100%; }
  .kpi strong { font-size: 22px; }
  .kpis { gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-ic { display: none; }
  .table th, .table td { padding: 12px 14px; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--surface); border-top: 1px solid var(--border); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar button { flex: 1; display: grid; justify-items: center; gap: 2px; border: 0; background: none; padding: 6px 0; font-size: 11px; font-weight: 600; color: var(--text-3); cursor: pointer; }
  .tabbar button.active { color: var(--brand); }
  .toasts { left: 16px; right: 16px; bottom: 80px; }
  .toast { max-width: none; }
}
