:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1a1d21;
  --muted: #6b7280;
  --line: #e6e8ec;
  --brand: #ff0033;
  --brand2: #2563eb;
  --ok: #16a34a;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--ink); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; margin: 16px 0; }
.spacer { flex: 1; }
a { color: var(--brand2); text-decoration: none; }

button, .btn {
  font: inherit; cursor: pointer; border: 1px solid var(--line);
  background: #fff; color: var(--ink); padding: 10px 16px; border-radius: 10px;
  transition: .15s; font-weight: 600;
}
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.ghost { background: #fff; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.big { padding: 14px 22px; font-size: 16px; margin-top: 12px; }
.icon-btn { background: none; border: none; font-size: 22px; padding: 4px 8px; }

/* ===== LOGIN ===== */
.login-screen { position: fixed; inset: 0; display: grid; place-items: center;
  background: linear-gradient(135deg, #eef1f6, #e3e8f0); }
.login-card { background: var(--card); padding: 36px 32px; border-radius: var(--radius);
  box-shadow: var(--shadow); width: 340px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login-card h1 { margin: 6px 0 0; font-size: 22px; }
.login-card p { margin: 0; }
.login-logo { width: 56px; height: 56px; margin: 0 auto; object-fit: contain; }
.login-card input { padding: 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; }
.error-msg { color: var(--brand); font-size: 13px; min-height: 16px; }

/* ===== APP SHELL ===== */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 230px; background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; padding: 6px 8px 18px; }
.brand img { width: 34px; height: 34px; object-fit: contain; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 10px;
  color: var(--ink); font-weight: 600; }
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: #fff0f2; color: var(--brand); }
.nav-item .ic { font-size: 18px; }
.sidebar-foot { padding-top: 12px; border-top: 1px solid var(--line); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 12px 22px;
  background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar #menuToggle { display: none; }
.channel-switch { display: flex; align-items: center; gap: 8px; }
.channel-switch select, .period select, select { padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 9px; font: inherit; background: #fff; }
.content { padding: 22px; max-width: 1100px; width: 100%; }

.view-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; flex-wrap: wrap; gap: 10px; }
.view-head h2 { margin: 0; font-size: 22px; }
.note { background: #fff8e6; border: 1px solid #f3e2b3; color: #7a5d00; padding: 10px 14px;
  border-radius: 10px; font-size: 13px; margin: 8px 0 18px; }

/* ===== CARDS / STATS ===== */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card h3 { margin: 0 0 6px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin: 14px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat .sub { font-size: 12px; color: var(--muted); }

.channel-header { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.channel-header img { width: 56px; height: 56px; border-radius: 50%; }
.channel-header .ch-title { font-weight: 700; font-size: 18px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }
.list-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.list-row:last-child { border-bottom: none; }

/* ===== VIDEOS ===== */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 600; font-size: 14px; }
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.video-grid, .frames-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.video-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.video-card .thumb { position: relative; aspect-ratio: 16/9; background: #000; }
.video-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-card .dur { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.8); color: #fff; font-size: 12px; padding: 2px 6px; border-radius: 5px; }
.video-card .priv { position: absolute; left: 6px; top: 6px; font-size: 11px; padding: 2px 7px; border-radius: 5px; background: #fff; font-weight: 700; }
.priv.private { background: #ffe1e1; color: #b40000; }
.priv.unlisted { background: #fff0d6; color: #8a5a00; }
.priv.public { background: #e1f5e6; color: var(--ok); }
.video-card .body { padding: 10px 12px; }
.video-card .vtitle { font-weight: 600; font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.video-card .vmeta { color: var(--muted); font-size: 12px; margin-top: 6px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ===== ASSISTENTE ===== */
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 34px; text-align: center; cursor: pointer; transition: .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: #fff7f8; }
.progress { margin-top: 14px; background: var(--line); border-radius: 999px; height: 22px; position: relative; overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--brand2); transition: width .2s; }
.progress .pct { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 700; }

.frames-grid img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 10px; cursor: pointer; border: 3px solid transparent; }
.frames-grid img.sel { border-color: var(--brand); }

.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.row label, .block { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 600; }
.block { display: block; margin-bottom: 12px; }
.row input, .block input, .block textarea, .block select { padding: 10px; border: 1px solid var(--line); border-radius: 9px; font: inherit; color: var(--ink); width: 100%; }
.titles-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.title-opt { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 600; }
.title-opt:hover { border-color: var(--brand2); }
.title-opt.sel { border-color: var(--brand); background: #fff0f2; }

.cover-editor { display: grid; grid-template-columns: 1fr 280px; gap: 18px; align-items: start; }
@media (max-width: 820px) { .cover-editor { grid-template-columns: 1fr; } }
#coverCanvas { width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); background: #000; }

.ai-cover-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.cover-suggest { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.cover-chip { padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; font-weight: 700; font-size: 13px; }
.cover-chip:hover { border-color: var(--brand2); }
.cover-chip.sel { border-color: var(--brand); background: #fff0f2; }
.cover-chip .hl { color: #d97700; }
.cover-loading { display: inline-block; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink); }
.check input { width: auto; }

/* ===== CONEXOES ===== */
.channels-list { margin-top: 18px; display: flex; flex-direction: column; gap: 12px; }
.ch-item { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); }
.ch-item img { width: 44px; height: 44px; border-radius: 50%; }
.ch-item .grow { flex: 1; }
.ch-item .badge { font-size: 11px; background: var(--ok); color: #fff; padding: 2px 8px; border-radius: 999px; }

/* ===== TOAST ===== */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 10px; box-shadow: var(--shadow); z-index: 50; font-size: 14px; }
.toast.err { background: var(--brand); }
.toast.ok { background: var(--ok); }

/* ===== RESPONSIVO ===== */
@media (max-width: 820px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 20; transform: translateX(-100%); transition: .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .topbar #menuToggle { display: block; }
}
