:root {
  --bg: #0e0e12;
  --bg-2: #16161d;
  --bg-3: #1f1f29;
  --line: #2a2a36;
  --txt: #ececf1;
  --muted: #9a9ab0;
  --accent: #e0245e;
  --accent-2: #ff5c8a;
  --ok: #2ecc71;
  --warn: #f1c40f;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--txt);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
}
a { cursor: pointer; color: inherit; text-decoration: none; }
.hidden { display: none !important; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 16px 12px;
  position: sticky; top: 0; height: 100vh;
}
.brand { font-size: 20px; font-weight: 800; margin: 4px 8px 18px; }
.brand span { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-item { padding: 10px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.nav-item:hover { background: var(--bg-3); color: var(--txt); }
.nav-item.active { background: linear-gradient(90deg, rgba(224,36,94,.25), transparent); color: #fff; }
.refresh-btn {
  margin-top: 12px; padding: 11px; border: none; border-radius: 10px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 700; cursor: pointer;
}
.refresh-btn:active { transform: scale(.98); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(14,14,18,.9); backdrop-filter: blur(6px); z-index: 20;
}
.topbar h1 { font-size: 19px; margin: 0; flex-shrink: 0; }
.topbar-tools { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.menu-toggle { display: none; background: var(--bg-3); border: 1px solid var(--line); color: var(--txt); border-radius: 8px; padding: 6px 10px; font-size: 18px; cursor: pointer; }
.view { padding: 22px; }

/* Inputs */
input, select, textarea, .btn {
  background: var(--bg-3); color: var(--txt);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 12px; font-size: 14px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.btn { cursor: pointer; font-weight: 600; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: linear-gradient(90deg, var(--accent), var(--accent-2)); border: none; color: #fff; }
.btn.danger { border-color: #6d2233; color: #ff8aa6; }
.btn.small { padding: 6px 10px; font-size: 13px; }

/* Cards grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.card {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; transition: transform .12s, border-color .12s;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); }
.card-thumb {
  position: relative; aspect-ratio: 16/10; background: #000 center/cover no-repeat;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.card-thumb .ph { font-size: 38px; opacity: .35; }
.badge {
  position: absolute; top: 8px; left: 8px; font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px; backdrop-filter: blur(4px);
}
.badge.seen { background: rgba(46,204,113,.85); color: #06281a; }
.badge.in_progress { background: rgba(241,196,15,.9); color: #3a2f00; }
.badge.new { background: rgba(224,36,94,.9); color: #fff; }
.badge.type { left: auto; right: 8px; background: rgba(0,0,0,.6); color:#fff; }
.fav-star { position: absolute; bottom: 8px; right: 8px; font-size: 20px; cursor: pointer; filter: drop-shadow(0 1px 2px #000); }
.card-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-title { font-size: 14px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-sub { font-size: 12px; color: var(--muted); }
.card-actions { margin-top: auto; display: flex; gap: 6px; }
.card-actions .btn { flex: 1; text-align: center; }
.card-actions .del-btn { flex: 0 0 auto; }

.progress-line { height: 4px; background: var(--bg-3); border-radius: 999px; overflow: hidden; }
.progress-line > i { display: block; height: 100%; background: var(--accent-2); }

/* Toolbar filters */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar input { flex: 1; min-width: 160px; }

/* Dashboard stats */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 14px; margin-bottom: 24px; }
.stat { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat .n { font-size: 28px; font-weight: 800; }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* Producer chips */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 9px 15px; cursor: pointer; font-weight: 600; display: flex; gap: 8px; align-items: center;
}
.chip:hover { border-color: var(--accent); }
.chip .count { background: var(--bg-3); border-radius: 999px; padding: 1px 8px; font-size: 12px; color: var(--muted); }

/* Tables / lists */
.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
}
.row .grow { flex: 1; min-width: 180px; }
.row .muted { color: var(--muted); font-size: 13px; }
.switch { cursor: pointer; }
.pl-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-left: 6px; }
.pl-badge.on { background: rgba(46,204,113,.2); color: #2ecc71; border: 1px solid #2ecc71; }
.pl-badge.off { background: var(--bg-3); color: var(--muted); border: 1px solid var(--line); }

/* Forms block */
.panel { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.panel h3 { margin: 0 0 12px; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.form-row input { flex: 1; min-width: 200px; }
textarea { width: 100%; min-height: 130px; font-family: ui-monospace, monospace; resize: vertical; }

.empty { color: var(--muted); text-align: center; padding: 50px 10px; }
.tag { background: var(--bg-3); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px; }

/* Player modal */
.player-modal { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.player-content { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); width: min(1280px, 100%); max-height: 94vh; overflow: hidden; position: relative; display: flex; }
.player-main { flex: 1; min-width: 0; overflow-y: auto; }
.player-close { position: absolute; top: 10px; right: 12px; z-index: 5; background: rgba(0,0,0,.6); color: #fff; border: none; font-size: 18px; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; }

/* Right suggestions panel */
.player-suggest { width: 300px; flex-shrink: 0; border-left: 1px solid var(--line); background: var(--bg); overflow-y: auto; padding: 16px; max-height: 94vh; }
.player-suggest h3 { margin: 0 0 2px; font-size: 16px; }
.suggest-sub { margin: 0 0 14px; color: var(--muted); font-size: 12px; }
.suggest-list { display: flex; flex-direction: column; gap: 10px; }
.suggest-card { display: flex; gap: 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px; cursor: pointer; transition: border-color .12s, transform .12s; }
.suggest-card:hover { border-color: var(--accent); transform: translateX(-2px); }
.suggest-card.next { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.suggest-thumb { width: 64px; height: 64px; flex-shrink: 0; border-radius: 8px; background: #000 center/cover no-repeat; display: flex; align-items: center; justify-content: center; font-size: 24px; }
.suggest-info { min-width: 0; display: flex; flex-direction: column; gap: 3px; justify-content: center; }
.suggest-title { font-size: 13px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.suggest-prod { font-size: 11px; color: var(--muted); }
.suggest-flag { font-size: 10px; font-weight: 700; color: var(--accent-2); text-transform: uppercase; }
#video { width: 100%; background: #000; aspect-ratio: 16/9; display: block; }
.player-meta { padding: 16px 20px 22px; }
.player-meta h2 { margin: 0 0 10px; }
.player-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.player-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.player-status { color: var(--muted); font-size: 13px; margin-top: 12px; }

/* Login */
.login-overlay { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 200; }
.login-box { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 30px; width: min(360px, 92%); display: flex; flex-direction: column; gap: 12px; }
.login-box h2 { margin: 0 0 6px; text-align: center; }
.login-box button { padding: 11px; border: none; border-radius: 9px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 700; cursor: pointer; }
.login-error { color: var(--accent-2); font-size: 13px; min-height: 16px; margin: 0; text-align: center; }

/* Toast */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--bg-3); border: 1px solid var(--line); padding: 12px 18px; border-radius: 10px; z-index: 300; box-shadow: 0 8px 30px rgba(0,0,0,.5); }

/* Responsive */
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: block; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .player-content { flex-direction: column; overflow-y: auto; }
  .player-suggest { width: 100%; border-left: none; border-top: 1px solid var(--line); max-height: none; }
}
