:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --panel-2: #faf9f6;
  --ink: #18161d;
  --muted: #6c6877;
  --line: #e5e1d8;
  --brand: #5b4cf0;
  --brand-ink: #ffffff;
  --brand-soft: #ecebff;
  --ok: #0f8a5f;
  --ok-soft: #e2f5ec;
  --warn: #b45d07;
  --warn-soft: #fdf0e1;
  --bad: #c2362d;
  --bad-soft: #fbe6e4;
  --info: #2b6bd6;
  --info-soft: #e5eefc;
  --shadow: 0 1px 2px rgba(20, 16, 40, .05), 0 8px 24px rgba(20, 16, 40, .06);
  --radius: 16px;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --text: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111014; --panel: #1a1920; --panel-2: #212028; --ink: #f2f0f7; --muted: #a29eae; --line: #2e2c36;
    --brand: #8b80ff; --brand-ink: #0f0d1a; --brand-soft: #29264a;
    --ok: #3ccf91; --ok-soft: #12352a; --warn: #f2a54d; --warn-soft: #3a2a14; --bad: #ff7a70; --bad-soft: #3d1c1a;
    --info: #78a6ff; --info-soft: #1a2a48; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  }
}
:root[data-theme="dark"] {
  --bg: #111014; --panel: #1a1920; --panel-2: #212028; --ink: #f2f0f7; --muted: #a29eae; --line: #2e2c36;
  --brand: #8b80ff; --brand-ink: #0f0d1a; --brand-soft: #29264a;
  --ok: #3ccf91; --ok-soft: #12352a; --warn: #f2a54d; --warn-soft: #3a2a14; --bad: #ff7a70; --bad-soft: #3d1c1a;
  --info: #78a6ff; --info-soft: #1a2a48; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.02em; margin: 0; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 18px;
  padding: 12px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 9px; font: 700 19px var(--display); letter-spacing: -.02em; color: var(--ink); text-decoration: none; }
.logo i { width: 28px; height: 28px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; color: var(--brand-ink); font-style: normal; font-size: 15px; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { padding: 7px 12px; border-radius: 10px; text-decoration: none; color: var(--muted); font-weight: 500; }
.nav a.on, .nav a:hover { background: var(--panel); color: var(--ink); }
.main { max-width: 1240px; margin: 0 auto; padding: 24px; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.pagehead p { margin: 4px 0 0; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 18px; }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- controles ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 11px; padding: 9px 14px; font: 600 14px var(--text); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; transition: transform .06s, background .15s;
}
.btn:hover { background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 9px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
label.f { display: grid; gap: 6px; font-weight: 600; font-size: 13px; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 11px; padding: 10px 12px; font: 15px var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); border-color: var(--brand); }
textarea { min-height: 180px; resize: vertical; line-height: 1.5; }
input[type=color] { padding: 3px; height: 42px; width: 64px; }
.check { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; background: var(--panel); }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.check.disabled { opacity: .55; cursor: not-allowed; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.b-rascunho { background: var(--panel-2); color: var(--muted); }
.b-aguardando_aprovacao { background: var(--info-soft); color: var(--info); }
.b-ajustes { background: var(--warn-soft); color: var(--warn); }
.b-aprovado { background: var(--brand-soft); color: var(--brand); }
.b-publicando { background: var(--info-soft); color: var(--info); }
.b-publicado { background: var(--ok-soft); color: var(--ok); }
.b-parcial, .b-erro { background: var(--bad-soft); color: var(--bad); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

.alert { border-radius: 14px; padding: 14px 16px; border: 1px solid var(--line); background: var(--panel); }
.alert.warn { background: var(--warn-soft); border-color: transparent; }
.alert.bad { background: var(--bad-soft); border-color: transparent; }
.alert.ok { background: var(--ok-soft); border-color: transparent; }
.alert.info { background: var(--info-soft); border-color: transparent; }
code.copy { display: block; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); border: 1px dashed var(--line); font-size: 13px; word-break: break-all; }

/* ---------- calendário ---------- */
.cal-layout { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.cal { overflow: hidden; }
.cal-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.cal-head h2 { flex: 1; }
.cal-head h2::first-letter { text-transform: uppercase; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-dow { padding: 8px 10px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); }
.cal-day { min-height: 118px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.out { background: var(--panel-2); }
.cal-day.out .num { opacity: .4; }
.cal-day:hover { background: color-mix(in srgb, var(--brand-soft) 50%, transparent); }
.num { font-size: 13px; font-weight: 600; color: var(--muted); padding: 2px 4px; }
.today .num { background: var(--brand); color: var(--brand-ink); border-radius: 8px; width: max-content; }
.chip { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 8px; font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; overflow: hidden; }
.chip span.t { font-weight: 600; flex: none; }
.chip span.n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip img { width: 20px; height: 20px; border-radius: 5px; object-fit: cover; flex: none; }
.chip.s-publicado { opacity: .7; }
.chip.s-erro, .chip.s-parcial { border-color: var(--bad); }
.chip.s-ajustes { border-color: var(--warn); }
.side-list { display: grid; gap: 8px; }
.side-item { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 12px; border: 1px solid var(--line); cursor: pointer; background: var(--panel); }
.side-item:hover { background: var(--panel-2); }
.side-item img, .side-item .ph { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex: none; background: var(--panel-2); }

/* ---------- clientes ---------- */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.ccard { padding: 16px; display: grid; gap: 10px; cursor: pointer; transition: transform .1s; }
.ccard:hover { transform: translateY(-2px); }
.avatar { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; color: #fff; font: 700 18px var(--display); flex: none; }
.netrow { display: flex; gap: 6px; flex-wrap: wrap; }
.net { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); }
a.net { color: var(--ink); text-decoration: none; }
a.net:hover { border-color: var(--brand); color: var(--brand); }
.net.on { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.acc { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.acc img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }

/* ---------- editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 22px; align-items: start; }
.drop { border: 2px dashed var(--line); border-radius: 14px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; background: var(--panel-2); }
.drop.over { border-color: var(--brand); background: var(--brand-soft); }
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; }
.thumb { position: relative; width: 104px; }
.thumb img { width: 104px; height: 104px; object-fit: cover; border-radius: 12px; display: block; border: 1px solid var(--line); }
.thumb .pos { position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,.65); color: #fff; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 1px 6px; }
.thumb .tools { display: flex; justify-content: space-between; margin-top: 4px; }
.thumb .tools button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 15px; padding: 2px 6px; border-radius: 6px; }
.thumb .tools button:hover { background: var(--panel-2); color: var(--ink); }
.thumb.uploading img { opacity: .4; }
.counter { font-size: 12px; color: var(--muted); text-align: right; }
.counter.over { color: var(--bad); font-weight: 600; }

/* prévia estilo Instagram */
.phone { position: sticky; top: 76px; }
.ig { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); }
.ig-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.ig-head .avatar { width: 32px; height: 32px; border-radius: 50%; font-size: 14px; }
.ig-media { position: relative; background: #000; aspect-ratio: var(--ratio, 1); display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.ig-media::-webkit-scrollbar { display: none; }
.ig-media img { flex: 0 0 100%; width: 100%; height: 100%; object-fit: cover; scroll-snap-align: center; }
.ig-empty { width: 100%; display: grid; place-items: center; color: #8a8696; font-size: 14px; aspect-ratio: 1; background: var(--panel-2); }
.ig-icons { display: flex; gap: 14px; padding: 10px 12px 2px; font-size: 20px; }
.ig-dots { display: flex; gap: 4px; justify-content: center; padding-top: 8px; }
.ig-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.ig-dots i.on { background: var(--brand); }
.ig-cap { padding: 6px 12px 14px; font-size: 14px; white-space: pre-wrap; word-wrap: break-word; max-height: 260px; overflow: auto; }
.ig-cap b { margin-right: 6px; }

.targets { display: grid; gap: 8px; }
.target { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); }
.target .err { color: var(--bad); font-size: 13px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .panel { width: 100%; max-width: 380px; padding: 28px; display: grid; gap: 16px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--bad); color: #fff; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.modal-bg { position: fixed; inset: 0; background: rgba(10, 8, 20, .45); display: grid; place-items: center; padding: 16px; z-index: 40; }
.modal { width: 100%; max-width: 460px; padding: 22px; display: grid; gap: 14px; }

@media (max-width: 980px) {
  .cal-layout, .editor { grid-template-columns: 1fr; }
  .phone { position: static; }
}
@media (max-width: 680px) {
  .main { padding: 16px; }
  .topbar { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .cal-day { min-height: 74px; padding: 3px; }
  .chip span.n, .chip span.t { display: none; }
  .chip { padding: 3px; justify-content: center; }
  .cal-dow { padding: 6px 4px; font-size: 11px; text-align: center; }
  h1 { font-size: 23px; }
}
