:root {
  --bg: #0d0e12; --panel: #15171d; --panel2: #1c1f27; --panel3: #242833;
  --line: #2a2e3a; --text: #ecedf2; --muted: #8d92a3; --faint: #5d6274;
  --accent: #4f8cff; --accent-ink: #fff;
  --yt: #ff5a52; --ig: #ec4fa5; --cr: #f2a93b; --vsl: #a37bff;
  --ok: #3ecf8e; --warn: #f2a93b; --bad: #ff5d5d;
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--panel3); border-radius: 8px; border: 2px solid var(--bg); }

#app { display: grid; grid-template-columns: 216px 1fr; height: 100vh; }
#nav { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; }
.brand { font-weight: 700; font-size: 15px; letter-spacing: -.01em; padding: 4px 10px 18px; display: flex; align-items: center; gap: 9px; }
.brand i { width: 22px; height: 22px; border-radius: 7px; background: conic-gradient(from 200deg, var(--yt), var(--ig), var(--vsl), var(--accent), var(--cr), var(--yt)); }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--muted); cursor: pointer; border: 0; background: none; text-align: left; width: 100%; }
.nav-item:hover { background: var(--panel2); color: var(--text); }
.nav-item.on { background: var(--panel3); color: var(--text); font-weight: 600; }
.nav-item svg { width: 17px; height: 17px; flex: none; }
.nav-item .count { margin-left: auto; font-size: 11.5px; background: var(--bad); color: #fff; border-radius: 20px; padding: 0 7px; font-weight: 600; }
.nav-foot { margin-top: auto; padding: 10px; font-size: 12px; color: var(--faint); }

#main { overflow: auto; padding: 26px 30px 60px; min-width: 0; }
.head { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.head h1 { margin: 0; font-size: 23px; letter-spacing: -.02em; }
.head p { margin: 3px 0 0; color: var(--muted); }
.head .sp { flex: 1; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 12px; font-weight: 600; }

.btn { border: 1px solid var(--line); background: var(--panel2); padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 550; white-space: nowrap; }
.btn:hover { background: var(--panel3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--panel2); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: default; }

input[type=text], input[type=password], input[type=date], input[type=datetime-local], input[type=number], input[type=search], input[type=url], select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; width: 100%; outline: none; color-scheme: dark;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 5px; font-weight: 550; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }
.hint { font-size: 12px; color: var(--faint); margin-top: 5px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 14px; }
.empty { color: var(--faint); text-align: center; padding: 28px 10px; }
.empty b { display: block; color: var(--muted); margin-bottom: 4px; font-size: 14.5px; }

.cat { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; color: var(--c); }
.cat::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.c-youtube { --c: var(--yt); } .c-instagram { --c: var(--ig); } .c-criativo { --c: var(--cr); } .c-vsl { --c: var(--vsl); }

.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; padding: 2px 8px; border-radius: 20px; background: var(--panel3); color: var(--muted); white-space: nowrap; }
.chip.late { background: #3a1719; color: var(--bad); }
.chip.soon { background: #3a2c12; color: var(--warn); }
.chip.ok { background: #12301f; color: var(--ok); }

/* Painel */
.tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 22px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; cursor: pointer; position: relative; overflow: hidden; }
.tile::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--c); }
.tile:hover { border-color: var(--c); }
.tile .num { font-size: 40px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; margin: 8px 0 2px; }
.tile .num small { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-left: 6px; }
.tile .sub { color: var(--muted); font-size: 12.5px; }
.tile .next { margin-top: 10px; }
.cols2 { grid-template-columns: 1.5fr 1fr; align-items: start; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-top: 1px solid var(--line); cursor: pointer; border-radius: 6px; }
.list-row:first-of-type { border-top: 0; }
.list-row:hover { background: var(--panel2); }
.list-row .t { flex: 1; min-width: 0; }
.list-row .t b { display: block; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pipe { display: flex; flex-direction: column; gap: 9px; }
.pipe-row { display: grid; grid-template-columns: 96px 1fr 28px; gap: 10px; align-items: center; font-size: 12.5px; color: var(--muted); }
.pipe-bar { height: 8px; border-radius: 6px; background: var(--panel3); overflow: hidden; display: flex; }
.pipe-bar span { background: var(--c); }
.pipe-row b { color: var(--text); text-align: right; }

/* Kanban */
.filters { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pill { border: 1px solid var(--line); background: none; padding: 5px 12px; border-radius: 20px; cursor: pointer; color: var(--muted); font-size: 12.5px; font-weight: 550; }
.pill:hover { color: var(--text); }
.pill.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.board { display: grid; grid-template-columns: repeat(6, minmax(215px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 60vh; }
.col.over { border-color: var(--accent); background: #161b28; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 10px; font-weight: 600; font-size: 13px; }
.col-head .n { color: var(--faint); font-weight: 500; }
.col-head button { margin-left: auto; }
.kcard { background: var(--panel2); border: 1px solid var(--line); border-left: 3px solid var(--c); border-radius: 9px; padding: 10px 11px; margin-bottom: 8px; cursor: grab; }
.kcard:hover { border-color: var(--faint); border-left-color: var(--c); }
.kcard.dragging { opacity: .4; }
.kcard .title { font-weight: 550; margin: 5px 0 8px; overflow-wrap: anywhere; }
.kcard .meta { display: flex; gap: 5px; flex-wrap: wrap; }

/* Calendário */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line); gap: 1px; }
.cal .dow { background: var(--panel); padding: 8px 10px; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.cal .day { background: var(--panel); min-height: 108px; padding: 7px; }
.cal .day.out { background: var(--bg); }
.cal .day .d { font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.cal .day.today .d { color: var(--accent-ink); background: var(--accent); display: inline-block; padding: 0 7px; border-radius: 20px; font-weight: 600; }
.ev { display: block; width: 100%; text-align: left; border: 0; background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--text); border-left: 3px solid var(--c); border-radius: 5px; padding: 3px 6px; font-size: 11.5px; margin-bottom: 3px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev.pub { border-left-style: dashed; opacity: .85; }
.legend { display: flex; gap: 16px; color: var(--muted); font-size: 12.5px; margin-top: 12px; flex-wrap: wrap; }

/* Ideias e Radar */
.cards3 { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.idea { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px; display: flex; flex-direction: column; gap: 8px; }
.idea h3 { margin: 0; font-size: 14.5px; line-height: 1.35; }
.idea .hook { color: var(--text); font-style: italic; border-left: 2px solid var(--line); padding-left: 9px; }
.idea p { margin: 0; color: var(--muted); font-size: 12.5px; }
.idea .acts { display: flex; gap: 6px; margin-top: auto; padding-top: 6px; flex-wrap: wrap; }
.vid .thumb { aspect-ratio: 16/9; background: var(--panel3) center/cover; border-radius: 8px; position: relative; }
.vid .thumb .badge { position: absolute; left: 7px; top: 7px; background: var(--ok); color: #04130b; font-weight: 700; font-size: 11.5px; padding: 1px 8px; border-radius: 20px; }
.vid .stats { display: flex; gap: 10px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab { border: 0; background: none; padding: 9px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 550; margin-bottom: -1px; }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.toolbar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar .field { margin: 0; }
.comp-list { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.comp { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--panel); border-radius: 20px; padding: 5px 6px 5px 12px; cursor: pointer; }
.comp.on { border-color: var(--accent); background: #161b28; }
.comp button { border: 0; background: none; color: var(--faint); cursor: pointer; padding: 0 5px; font-size: 15px; }
.comp button:hover { color: var(--bad); }
.notice { background: #1a2032; border: 1px solid #2c3a5e; border-radius: 10px; padding: 12px 14px; color: #b9c6e8; margin-bottom: 16px; }
.notice.err { background: #2a1516; border-color: #5a2628; color: #ffb4b4; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; margin-right: 7px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
.overlay { position: fixed; inset: 0; background: rgba(4, 5, 8, .68); display: flex; justify-content: flex-end; z-index: 20; }
.sheet { width: min(760px, 100%); background: var(--panel); border-left: 1px solid var(--line); height: 100%; display: flex; flex-direction: column; animation: slide .16s ease-out; }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.sheet-head { padding: 18px 22px 0; }
.sheet-head .top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.sheet-head input.title { font-size: 19px; font-weight: 650; border: 0; background: none; padding: 4px 0; letter-spacing: -.01em; }
.sheet-body { padding: 4px 22px 30px; overflow: auto; flex: 1; }
.sheet .tabs { margin: 12px 0 18px; }
textarea.script { min-height: 46vh; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
.block { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.block h3 { margin: 0 0 12px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.status-line { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
progress { width: 100%; height: 6px; accent-color: var(--accent); }

.conn { display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.on { background: var(--ok); }
.settings { max-width: 760px; }

#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--panel3); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 30px #0008; max-width: 520px; }
.toast.err { border-color: #6b2c2e; color: #ffb4b4; }

@media (max-width: 1100px) { .tiles { grid-template-columns: repeat(2, 1fr); } .cols2 { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  #nav { order: 2; flex-direction: row; padding: 6px; border-right: 0; border-top: 1px solid var(--line); overflow-x: auto; }
  .brand, .nav-foot, .nav-item span { display: none; }
  .nav-item { justify-content: center; padding: 11px; }
  #main { padding: 18px 16px 40px; }
  .tiles { grid-template-columns: 1fr; }
  .row { flex-direction: column; gap: 0; }
  .cal .day { min-height: 70px; padding: 4px; }
}

/* Menu do botão direito */
.ctx { position: fixed; z-index: 40; min-width: 190px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 5px; box-shadow: 0 12px 40px #000a; }
.ctx button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.ctx button:hover { background: var(--panel3); }
.ctx button.danger { color: var(--bad); }
.ctx hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }
.ctx-label { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; padding: 5px 10px 2px; }
.kcard.archived { opacity: .6; }
.kcard input.rename { margin: 4px 0 7px; padding: 4px 7px; font-weight: 550; }

/* Confirmação */
.overlay.ask { justify-content: center; align-items: center; z-index: 60; }
.ask-box { background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: min(420px, calc(100% - 32px)); box-shadow: 0 20px 60px #000b; }
.ask-box p { margin: 0 0 18px; font-size: 14.5px; }
.ask-acts { display: flex; justify-content: flex-end; gap: 8px; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }

/* Comando com IA e Gravar hoje */
.jarvis { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: stretch; background: linear-gradient(135deg, #171c2e, var(--panel)); border: 1px solid #2c3a5e; border-radius: var(--radius); padding: 12px; margin-bottom: 18px; }
.jarvis textarea { min-height: 54px; resize: none; }
.jarvis-last { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); }
.today-row { display: flex; gap: 14px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--c); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; }
.today-row .t { flex: 1; min-width: 0; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.today-row .t b { font-size: 14.5px; font-weight: 600; overflow-wrap: anywhere; }
.today-row .hook { color: var(--muted); font-style: italic; font-size: 13px; }
.today-row .meta, .today-row .acts { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.today-row .acts { flex: none; }
@media (max-width: 760px) { .today-row { flex-direction: column; align-items: stretch; } .jarvis { grid-template-columns: 1fr; } }

/* Raio-x do vídeo */
.md h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin: 22px 0 8px; }
.md p { margin: 0 0 10px; line-height: 1.6; }
.md ul { margin: 0 0 10px; padding-left: 20px; }
.md li { margin-bottom: 6px; line-height: 1.55; }
.md blockquote { margin: 0 0 10px; padding: 8px 12px; border-left: 3px solid var(--line); background: var(--panel2); border-radius: 0 8px 8px 0; font-style: italic; }

/* Inteligência */
.stats-row { display: flex; gap: 26px; flex-wrap: wrap; }
.stat b { display: block; font-size: 22px; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 12px; }
.md table { border-collapse: collapse; width: 100%; margin: 0 0 12px; font-size: 13px; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; vertical-align: top; }
.md th { background: var(--panel2); color: var(--muted); font-weight: 600; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* Roteirista */
.rot-msgs { display: flex; flex-direction: column; gap: 14px; max-width: 860px; margin: 0 auto 18px; }
.rot-user { align-self: flex-end; max-width: 82%; background: #1b2540; border: 1px solid #2c3a5e; border-radius: 14px 14px 4px 14px; padding: 10px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.rot-ai { background: var(--panel); border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; padding: 6px 18px 14px; }
.rot-ai .acts { display: flex; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.rot-ai .md code, .sheet code { background: var(--panel3); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.rot-composer { position: sticky; bottom: -60px; padding-bottom: 60px; max-width: 860px; margin: 0 auto; background: linear-gradient(transparent, var(--bg) 18px); padding-top: 18px; }
.rot-composer textarea { background: var(--panel); border-radius: 12px 12px 0 0; border-bottom: 0; resize: none; font-size: 14.5px; }
.rot-bar { display: flex; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 12px 12px; padding: 8px; }

/* Login */
#login { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-box { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 26px; }
