/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f0f13;
  --surface:   #1a1a24;
  --surface2:  #22222f;
  --border:    #2e2e40;
  --text:      #e2e2f0;
  --text-dim:  #8888a8;
  --accent:    #6c63ff;
  --accent-h:  #574fd6;
  --red:       #ff5555;
  --green:     #50fa7b;
  --radius:    10px;
  --font:      -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.5; }

a { color: inherit; text-decoration: none; cursor: pointer; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--radius); border: none;
  font-size: 14px; font-weight: 500; cursor: pointer; transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-h); }
.btn-ghost    { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface2); color: var(--text); }
.btn-full     { width: 100%; margin-top: 10px; }

/* ── Login page ───────────────────────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

.login-wrap { width: 100%; max-width: 380px; padding: 16px; }

.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 40px 32px; text-align: center;
}

.login-logo  { font-size: 48px; margin-bottom: 8px; }
.login-title { font-size: 24px; font-weight: 700; margin-bottom: 24px; }

.login-hint  { color: var(--text-dim); font-size: 14px; margin-bottom: 20px; line-height: 1.6; }

.code-input {
  width: 100%; padding: 14px; margin-bottom: 4px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 24px; text-align: center; letter-spacing: 8px;
  outline: none; transition: border-color .15s;
}
.code-input:focus { border-color: var(--accent); }

.login-error { color: var(--red); font-size: 13px; margin-top: 14px; min-height: 18px; }

/* ── Dashboard layout ─────────────────────────────────────────────────────── */
.dashboard-body { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  font-size: 17px; font-weight: 700;
  border-bottom: 1px solid var(--border);
}

.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: block; padding: 9px 12px; border-radius: 8px;
  color: var(--text-dim); font-size: 14px; cursor: pointer;
  transition: background .12s, color .12s;
}
.nav-item:hover  { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; font-weight: 500; }

.sidebar-footer { padding: 12px 8px; border-top: 1px solid var(--border); }

.main { flex: 1; overflow-y: auto; }

.main-inner { padding: 32px; max-width: 960px; }

.section-title { font-size: 20px; font-weight: 700; margin-bottom: 20px; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}

.placeholder-card {
  background: var(--surface); border: 1px dashed var(--border);
  border-radius: var(--radius); padding: 40px;
  color: var(--text-dim); text-align: center; font-size: 14px;
}

/* ── Layout helpers ───────────────────────────────────────────────────────── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.section-header .section-title { margin-bottom: 0; }
.mb-16 { margin-bottom: 16px; }
.text-dim { color: var(--text-dim); font-size: 14px; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.input {
  width: 100%; padding: 10px 12px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 14px; outline: none; transition: border-color .15s;
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--text-dim); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: start; }
.form-error { color: var(--red); font-size: 13px; margin-top: 10px; }

/* ── Buttons extra ────────────────────────────────────────────────────────── */
.btn-sm   { padding: 6px 12px; font-size: 13px; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #cc3333; }

/* ── Dot status ───────────────────────────────────────────────────────────── */
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
.dot-green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot-red   { background: var(--red);   box-shadow: 0 0 6px var(--red); }

/* ── Source cards ─────────────────────────────────────────────────────────── */
.source-list { display: flex; flex-direction: column; gap: 10px; }

.source-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}

.source-row {
  display: flex; align-items: flex-start; gap: 14px; padding: 16px;
}

.source-info { flex: 1; min-width: 0; }
.source-title { font-weight: 600; font-size: 15px; margin-bottom: 3px; }
.source-url   { font-size: 12px; color: var(--text-dim); margin-bottom: 5px;
                white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-meta  { font-size: 12px; color: var(--text-dim); }

.source-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: flex-start; }

/* ── Source expanded videos ───────────────────────────────────────────────── */
.source-videos {
  border-top: 1px solid var(--border);
  background: var(--surface2);
}

.video-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.video-row:last-child { border-bottom: none; }

.video-title {
  flex: 1; min-width: 0; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.video-title:hover { color: var(--accent); }
.video-dur { flex-shrink: 0; }

/* ── Cookies ──────────────────────────────────────────────────────────────── */
.cookies-status-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

.cookies-steps {
  margin: 0 0 16px 18px;
  padding: 0;
  display: flex; flex-direction: column; gap: 8px;
  font-size: 13px; line-height: 1.6; color: var(--text-dim);
}
.cookies-steps li { padding-left: 4px; }
.cookies-steps b  { color: var(--text); }

.cookies-code {
  display: inline; font-family: monospace; font-size: 12px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px; color: var(--text); white-space: nowrap;
}

.cookies-notes {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--surface2); border-radius: var(--radius);
  padding: 14px 16px; margin-top: 16px;
}
.cookies-note-item {
  display: flex; gap: 10px; font-size: 13px; color: var(--text-dim); line-height: 1.5;
}
.cookies-note-item span { flex-shrink: 0; }
.cookies-note-item b { color: var(--text); }

/* ── Shared link style ────────────────────────────────────────────────────── */
.accent-link  { color: var(--accent); text-decoration: none; }
.accent-link:hover { text-decoration: underline; }
.cookies-link { color: var(--accent); text-decoration: none; }
.cookies-link:hover { text-decoration: underline; }

/* ── Upload ───────────────────────────────────────────────────────────────── */
.upload-dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 28px 20px; transition: border-color .15s, background .15s;
}
.upload-dropzone:hover { border-color: var(--accent); background: rgba(108,99,255,.05); }
.upload-dropzone.hasfile { border-style: solid; border-color: var(--accent); background: rgba(108,99,255,.06); }

.upload-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}

.upload-file-list { display: flex; flex-direction: column; gap: 6px; }

.upload-file-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  cursor: pointer; transition: border-color .12s;
}
.upload-file-row:hover   { border-color: var(--accent); }
.upload-file-row.selected { border-color: var(--accent); background: rgba(108,99,255,.08); }

.upload-check {
  width: 20px; height: 20px; border-radius: 5px; flex-shrink: 0; margin-top: 1px;
  border: 2px solid var(--border); background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; transition: all .12s;
}
.upload-check.checked { background: var(--accent); border-color: var(--accent); }

.upload-file-info { flex: 1; min-width: 0; }

.upload-field { margin-bottom: 12px; }
.upload-label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 5px; }
.upload-textarea { resize: vertical; min-height: 72px; }

.upload-progress-list { display: flex; flex-direction: column; gap: 12px; }

.upload-progress-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.upload-progress-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 8px;
}
.upload-progress-title {
  flex: 1; min-width: 0; font-size: 14px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.progress-bar-wrap { display: flex; align-items: center; gap: 10px; }
.progress-bar  { flex: 1; height: 6px; background: var(--surface2); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }

.upload-history-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.upload-history-row:last-child { border-bottom: none; }

/* ── Status ───────────────────────────────────────────────────────────────── */
.status-top-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
@media (max-width: 640px) { .status-top-grid { grid-template-columns: 1fr; } }

.status-card-title { font-weight: 600; margin-bottom: 14px; }

.status-monitor-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 15px; }

.status-meta-list { display: flex; flex-direction: column; gap: 8px; }
.status-meta-row  { display: flex; justify-content: space-between; font-size: 13px; gap: 12px; }
.status-meta-row span:last-child { text-align: right; }

.status-disk-bar-wrap { display: flex; align-items: center; gap: 10px; }
.status-disk-bar  { flex: 1; height: 8px; background: var(--surface2); border-radius: 99px; overflow: hidden; }
.status-disk-fill { height: 100%; border-radius: 99px; transition: width .4s; }

.status-counts-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px;
}
.status-count-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }

/* ── Filter tabs ──────────────────────────────────────────────────────────── */
.filter-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.filter-tab  {
  padding: 5px 12px; border-radius: 99px; border: 1px solid var(--border);
  background: transparent; color: var(--text-dim); font-size: 13px; cursor: pointer;
  transition: all .15s;
}
.filter-tab:hover  { background: var(--surface2); color: var(--text); }
.filter-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Video table ──────────────────────────────────────────────────────────── */
.video-table { display: flex; flex-direction: column; gap: 2px; }

.vt-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  transition: border-color .12s;
}
.vt-row:hover { border-color: var(--accent); }

.vt-main  { flex: 1; min-width: 0; }
.vt-title {
  display: block; font-size: 14px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px;
}
.vt-title:hover { color: var(--accent); }
.vt-meta  { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; }

.vt-right   { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.vt-actions { display: flex; gap: 6px; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 500; white-space: nowrap; flex-shrink: 0;
}
.badge-green  { background: rgba(80,250,123,.15); color: var(--green); }
.badge-red    { background: rgba(255,85,85,.15);  color: var(--red); }
.badge-yellow { background: rgba(255,184,108,.15); color: #ffb86c; }
.badge-blue   { background: rgba(108,99,255,.15);  color: #8be9fd; }
.badge-dim    { background: var(--surface2); color: var(--text-dim); }
