:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f1f3f6;
  --border: #e3e6eb;
  --text: #15181d;
  --muted: #6a717d;
  --accent: #5b5bf0;
  --accent-soft: #ececfe;
  --ok: #1f9d55;
  --ok-soft: #e3f6ea;
  --warn: #b7791f;
  --warn-soft: #fdf3e1;
  --danger: #d64545;
  --yt: #ff0033;
  --tt: #111111;
  --ig: #e1306c;
  --fb: #1877f2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --panel: #171a20;
    --panel-2: #1e222a;
    --border: #2a2f39;
    --text: #e8eaee;
    --muted: #9198a5;
    --accent: #8b8bff;
    --accent-soft: #23243f;
    --ok: #4ccb7f;
    --ok-soft: #173325;
    --warn: #e9b44c;
    --warn-soft: #382c14;
    --tt: #e8eaee;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
}
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* Layout */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh;
}
.brand { font-weight: 700; font-size: 15px; padding: 0 8px; display: flex; align-items: center; gap: 8px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-size: 11px;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { text-decoration: none; padding: 8px 10px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 0 4px; }
.main { padding: 28px 32px 60px; min-width: 0; max-width: 1280px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Cards */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); gap: 8px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 500; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* Buttons & inputs */
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--panel); color: var(--text);
  padding: 7px 12px; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

label.field { display: flex; flex-direction: column; gap: 5px; font-weight: 500; font-size: 13px; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
input, textarea, select {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; width: 100%;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.search { max-width: 260px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab { padding: 9px 12px; text-decoration: none; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--text); border-color: var(--accent); }
.count { background: var(--panel-2); border-radius: 99px; padding: 0 7px; font-size: 11px; margin-left: 4px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.pf { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; color: #fff; font-size: 11px; font-weight: 800; flex: none; }
.pf.youtube { background: var(--yt); }
.pf.tiktok { background: #111; box-shadow: inset -2px 0 0 #25f4ee, inset 2px 0 0 #fe2c55; }
.pf.instagram { background: linear-gradient(45deg, #f9ce34, #ee2a7b 50%, #6228d7); }
.pf.facebook { background: var(--fb); }
.pf.lg { width: 36px; height: 36px; border-radius: 9px; font-size: 15px; }

.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; background: var(--accent); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }

/* Video grid */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 22px; text-align: center;
  color: var(--muted); margin-bottom: 16px; background: var(--panel); cursor: pointer;
}
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.vcard { text-decoration: none; overflow: hidden; display: flex; flex-direction: column; }
.vcard:hover { border-color: var(--accent); }
.thumb { aspect-ratio: 9 / 16; background: var(--panel-2); position: relative; display: grid; place-items: center; color: var(--muted); }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.thumb .dur { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.7); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 4px; }
.thumb .storage { position: absolute; left: 6px; top: 6px; }
.vcard .meta { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.vcard .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dots { display: flex; gap: 4px; flex-wrap: wrap; }
.dot { width: 18px; height: 18px; border-radius: 5px; font-size: 9px; opacity: .25; }
.dot.on { opacity: 1; }

/* Lists */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.list-row .name { font-weight: 600; }
.progress { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; min-width: 80px; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 10px; }

/* Video detail */
.detail { display: grid; grid-template-columns: 320px 1fr; gap: 20px; align-items: start; }
.player { aspect-ratio: 9 / 16; background: #000; border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; color: #888; }
.player video { width: 100%; height: 100%; object-fit: contain; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; }
.platform-group + .platform-group { border-top: 1px solid var(--border); }
.platform-label { display: flex; align-items: center; gap: 8px; padding: 12px 16px 4px; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* Profiles */
.profile-card .card-head { border-bottom: 1px solid var(--border); }
.profile-grid { display: grid; gap: 16px; }
.link-bar { padding: 10px 16px; border-top: 1px solid var(--border); }
.link-bar .pf { width: 16px; height: 16px; font-size: 9px; border-radius: 4px; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 12, 16, .5); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--panel); border-radius: 14px; border: 1px solid var(--border); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: min(720px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--panel); }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.platform-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.platform-pick label { border: 1px solid var(--border); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; font-weight: 500; font-size: 12px; }
.platform-pick input { display: none; }
.platform-pick label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.step { display: flex; gap: 12px; }
.step-num { width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }
.step-body { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.note { background: var(--panel-2); border-radius: 10px; padding: 10px 12px; font-size: 12px; color: var(--muted); }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.google-btn { background: #fff; color: #1f1f1f; border: 1px solid #dadce0; font-weight: 600; }
.google-btn:hover { background: #f7f8f8; }
.google-g { font-weight: 800; background: conic-gradient(#ea4335 0 25%, #fbbc05 0 50%, #34a853 0 75%, #4285f4 0); -webkit-background-clip: text; background-clip: text; color: transparent; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* Login */
body.locked .app { grid-template-columns: 1fr; }
body.locked .sidebar { display: none; }
body.locked .main { max-width: none; min-height: 100vh; display: grid; place-items: center; }
.login { width: min(360px, 100%); }
.login .brand { padding: 0; margin-bottom: 4px; }

/* Toasts */
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: rise .2s ease-out; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* Responsive */
@media (max-width: 900px) {
  .detail, .grid-2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .player { max-width: 320px; }
}
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 10px 12px; }
  .nav { flex-direction: row; }
  .nav a, .brand { white-space: nowrap; }
  .sidebar-foot { display: none; }
  .main { padding: 20px 16px 60px; }
  .platform-pick { grid-template-columns: repeat(2, 1fr); }
}
