/* ══════════════════════════════════════════════════════════════════════════
   YouTube Ads Tool — Dark UI Theme
   Watan Network
   ══════════════════════════════════════════════════════════════════════════ */

/* ── CSS Variables ────────────────────────────────────────────────────────── */
:root {
  --bg:           #0d1117;
  --surface:      #161b22;
  --surface2:     #21262d;
  --surface3:     #2d333b;
  --border:       #30363d;
  --border-muted: #21262d;
  --text:         #e6edf3;
  --text-muted:   #8b949e;
  --text-subtle:  #484f58;
  --accent:       #58a6ff;
  --green:        #238636;
  --green-hover:  #2ea043;
  --success:      #3fb950;
  --warning:      #d29922;
  --danger:       #f85149;
  --info:         #58a6ff;
  --radius:       6px;
  --radius-lg:    10px;
  --font-mono:    'JetBrains Mono', 'Fira Code', 'Consolas', 'Courier New', monospace;
  --font-ui:      -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --navbar-h:     52px;
}

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

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

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar        { width: 6px; height: 6px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }

/* ── Navbar ───────────────────────────────────────────────────────────────── */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--navbar-h);
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-logo-svg {
  height: 22px;
  width: auto;
  display: block;
  flex-shrink: 0;
  border-radius: 4px;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.brand-sep {
  color: var(--text-subtle);
}

.brand-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.icon-user {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ── Flash messages ───────────────────────────────────────────────────────── */
.flash-container {
  padding: 10px 16px 0;
  flex-shrink: 0;
}

.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.5;
}

.flash-danger,
.flash-error   { background: rgba(248, 81, 73,  0.12); border: 1px solid rgba(248, 81, 73,  0.35); color: #f85149; }
.flash-success { background: rgba(63, 185, 80,  0.12); border: 1px solid rgba(63, 185, 80,  0.35); color: #3fb950; }
.flash-info,
.flash-message { background: rgba(88, 166, 255, 0.12); border: 1px solid rgba(88, 166, 255, 0.35); color: #79c0ff; }
.flash-warning { background: rgba(210, 153, 34, 0.12); border: 1px solid rgba(210, 153, 34, 0.35); color: #d29922; }

/* ── Page wrapper ─────────────────────────────────────────────────────────── */
.page {
  height: calc(100vh - var(--navbar-h));
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Unauthenticated pages (login) — no navbar, full viewport height */
.page-anon {
  height: 100vh;
  overflow: auto;
}

/* ── Login ────────────────────────────────────────────────────────────────── */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.login-header {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo {
  margin-bottom: 18px;
  display: flex;
  justify-content: center;
}

.login-logo-svg {
  height: 52px;
  width: auto;
  display: block;
  border-radius: 9px;
  box-shadow: 0 4px 20px rgba(204, 0, 0, 0.35);
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}

.login-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.login-flashes {
  margin-bottom: 20px;
}

.login-flashes .flash:last-child {
  margin-bottom: 0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mt-form {
  margin-top: 4px;
}

/* ── Dashboard layout ─────────────────────────────────────────────────────── */
.dashboard {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: 100%;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: 300px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-section {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-muted);
}

.sidebar-section:last-child {
  border-bottom: none;
  margin-top: auto;
}

.sidebar-run {
  padding: 18px;
  margin-top: auto;
  border-top: 1px solid var(--border);
  border-bottom: none;
}

.section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Main area ────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 16px;
  gap: 14px;
  min-width: 0;
}

/* ── Panel header ─────────────────────────────────────────────────────────── */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
}

/* ── Terminal ─────────────────────────────────────────────────────────────── */
.terminal-panel {
  /* Fixed height so the review panel below it is reachable via .main scroll */
  height: 360px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.terminal {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.8;
  background: #010409;
  color: #c9d1d9;
  min-height: 0;
}

.log-line              { white-space: pre-wrap; word-break: break-all; }
.log-line.log-info     { color: #c9d1d9; }
.log-line.log-warning,
.log-line.log-warn     { color: #d29922; }
.log-line.log-error    { color: #f85149; }
.log-line.log-critical { color: #f85149; font-weight: 700; }
.log-line.log-debug    { color: var(--text-subtle); }

/* ── Reports panel ────────────────────────────────────────────────────────── */
.reports-panel {
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 220px;
}

.table-wrapper {
  overflow-y: auto;
  flex: 1;
}

.reports-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.reports-table th {
  padding: 8px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}

.reports-table td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-muted);
  color: var(--text);
}

.reports-table tbody tr:last-child td {
  border-bottom: none;
}

.reports-table tbody tr:hover td {
  background: var(--surface2);
}

td.empty {
  color: var(--text-muted);
  text-align: center;
  padding: 20px;
  font-style: italic;
  font-size: 12px;
}

.dl-link {
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.dl-link:hover {
  color: #79c0ff;
}

/* ── Form elements ────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 12px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.12);
}

.form-input::placeholder {
  color: var(--text-subtle);
}

.form-hint {
  display: block;
  font-size: 11px;
  color: var(--text-subtle);
  margin-top: 4px;
}

/* ── Radio buttons ────────────────────────────────────────────────────────── */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.radio-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}

.radio-label:hover {
  background: var(--surface2);
  border-color: var(--border);
}

.radio-label input[type="radio"] {
  display: none;
}

.radio-label:has(input:checked) {
  background: rgba(88, 166, 255, 0.07);
  border-color: rgba(88, 166, 255, 0.3);
}

.radio-dot {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border);
  margin-top: 3px;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}

.radio-label input[type="radio"]:checked ~ .radio-dot {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 3px var(--surface);
}

.radio-text strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.radio-text em {
  display: block;
  font-size: 11px;
  font-style: normal;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ── Checkboxes ───────────────────────────────────────────────────────────── */
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
  margin-bottom: 2px;
}

.checkbox-label:hover {
  background: var(--surface2);
  border-color: var(--border);
}

.checkbox-label input[type="checkbox"] {
  display: none;
}

.checkbox-box {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 2px solid var(--border);
  margin-top: 2px;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}

.checkbox-label input:checked ~ .checkbox-box {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox-label input:checked ~ .checkbox-box::after {
  content: '';
  position: absolute;
  left: 2px;
  top: -1px;
  width: 6px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.checkbox-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.checkbox-text em {
  display: block;
  font-size: 11px;
  font-style: normal;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ── Advanced details ─────────────────────────────────────────────────────── */
.advanced-details {
  cursor: default;
}

.advanced-summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 4px 0;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.advanced-summary::-webkit-details-marker {
  display: none;
}

.advanced-summary::before {
  content: '▸';
  font-size: 10px;
  transition: transform 0.15s;
}

.advanced-details[open] .advanced-summary::before {
  transform: rotate(90deg);
}

.advanced-summary:hover {
  color: var(--text);
}

.advanced-body {
  padding-top: 14px;
}

/* ── Status row ───────────────────────────────────────────────────────────── */
.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding: 6px 10px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border-muted);
}

.status-label {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}

.badge-idle    { background: var(--surface3); color: var(--text-muted); }
.badge-info    { background: rgba(88, 166, 255, 0.18);  color: #58a6ff; }
.badge-warning { background: rgba(210, 153, 34, 0.18);  color: #d29922; }
.badge-success { background: rgba(63, 185, 80, 0.18);   color: #3fb950; }
.badge-danger  { background: rgba(248, 81, 73, 0.18);   color: #f85149; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  margin-bottom: 12px;
  line-height: 1.6;
}

.alert code {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.3);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}

.alert-warning {
  background: rgba(210, 153, 34, 0.12);
  border: 1px solid rgba(210, 153, 34, 0.35);
  color: #d29922;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: background 0.12s, opacity 0.12s, color 0.12s, box-shadow 0.12s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.3;
}

.btn-primary {
  background: var(--green);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--green-hover);
  text-decoration: none;
  box-shadow: 0 0 0 3px rgba(35, 134, 54, 0.25);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover:not(:disabled) {
  background: var(--surface2);
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 4px 10px;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface2);
  color: var(--text);
  text-decoration: none;
}

.btn-danger {
  background: transparent;
  color: #e05252;
  border: 1px solid #e05252;
}

.btn-danger:hover:not(:disabled) {
  background: #e05252;
  color: #ffffff;
  text-decoration: none;
}

.btn-danger:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Smart Ad ─────────────────────────────────────────────────────────────── */

.smart-ad-label:has(input:checked) {
  background: rgba(88, 166, 255, 0.07);
  border-color: rgba(88, 166, 255, 0.3);
}

.smart-ad-label:has(input:checked) .checkbox-text {
  color: var(--accent);
}

.smart-ad-info {
  background: var(--bg);
}

.smart-phases {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.smart-phase {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.phase-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
}

.phase-1 .phase-dot { background: #f85149; }  /* red   — high density  */
.phase-2 .phase-dot { background: #d29922; }  /* amber — medium        */
.phase-3 .phase-dot { background: #3fb950; }  /* green — low density   */

.phase-text strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.phase-text em {
  display: block;
  font-size: 11px;
  font-style: normal;
  color: var(--text-muted);
  margin-top: 1px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   Review panel — video cards
═══════════════════════════════════════════════════════════════════════════ */

.review-panel {
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 16px;
}

.review-panel-header {
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.review-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.select-all-label {
  margin: 0;
  font-size: 13px;
}

/* Video card grid */
.video-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 16px;
}

/* Individual card */
.video-card {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
}

.video-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.video-card.card-selected {
  border-color: #388bfd;
  box-shadow: 0 0 0 1px #388bfd;
  background: rgba(56, 139, 253, 0.06);
}

.video-card.card-ineligible {
  opacity: 0.55;
  cursor: default;
}

.video-card.card-ineligible:hover {
  border-color: var(--border);
  box-shadow: none;
}

.video-card.card-applying {
  border-color: #d29922;
  box-shadow: 0 0 0 1px #d29922;
}

/* Thumbnail area */
.card-thumb-wrap {
  position: relative;
  background: #000;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.btn-preview {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0,0,0,0.75);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-preview:hover {
  background: rgba(0,0,0,0.92);
}

.card-embed {
  position: absolute;
  inset: 0;
}

.card-embed iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Card body */
.card-info {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.card-select-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.card-cb-label {
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  word-break: break-word;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.card-vid {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-muted);
}

.card-dur {
  font-size: 11px;
  color: var(--text-muted);
}

.card-studio-link {
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
  margin-left: auto;
}

.card-studio-link:hover {
  text-decoration: underline;
}

.card-ineligible-msg {
  font-size: 11px;
  color: #f85149;
  line-height: 1.4;
}

/* Break rows */
.card-breaks {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 2px;
}

.breaks-row {
  display: flex;
  gap: 6px;
  align-items: baseline;
  font-size: 11px;
}

.breaks-label {
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 100px;
}

.breaks-value {
  color: var(--text);
  font-family: var(--mono);
  word-break: break-all;
}

.breaks-value.suggested {
  color: #3fb950;
}

/* ── Admin page ───────────────────────────────────────────────────────────── */

.navbar-admin-link {
  margin-right: 8px;
}

.admin-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.admin-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.section-heading-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.user-count {
  font-size: 12px;
  color: var(--text-muted);
}

/* Table */
.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th {
  padding: 10px 14px;
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.admin-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.user-row-self {
  background: rgba(63, 185, 80, 0.04);
}

.cell-id {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  width: 40px;
}

.cell-name {
  font-weight: 500;
  white-space: nowrap;
}

.username-text {
  margin-right: 6px;
}

.cell-date {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.cell-del {
  width: 50px;
  text-align: center;
}

/* Role badge */
.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.role-admin {
  background: rgba(88, 166, 255, 0.15);
  color: #58a6ff;
}

.role-user {
  background: var(--surface2);
  color: var(--text-muted);
}

/* Inline change-password form */
.inline-pw-form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pw-input {
  width: 140px;
  padding: 5px 8px;
  font-size: 12px;
}

/* Delete ghost button */
.btn-danger-ghost {
  background: transparent;
  color: #e05252;
  border: 1px solid transparent;
  padding: 3px 8px;
  font-size: 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-danger-ghost:hover:not(:disabled) {
  background: rgba(224, 82, 82, 0.12);
  border-color: #e05252;
}

.btn-danger-ghost:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

/* Add user form */
.add-user-form {
  padding: 20px 18px;
}

.add-user-fields {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  align-items: end;
  gap: 14px;
  margin-bottom: 16px;
}

@media (max-width: 800px) {
  .add-user-fields {
    grid-template-columns: 1fr 1fr;
  }
  .inline-pw-form {
    flex-wrap: wrap;
  }
  .pw-input {
    width: 120px;
  }
}

.form-group-check {
  display: flex;
  align-items: center;
  padding-bottom: 4px;
}

.add-user-actions {
  display: flex;
  justify-content: flex-start;
}

/* ── Password generator ───────────────────────────────────────────────────── */

.pw-field-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.pw-field-row .form-input {
  flex: 1;
  min-width: 0;
}

.gen-pw-display {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 18px 16px;
  padding: 10px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  flex-wrap: wrap;
}

.gen-pw-label {
  color: var(--text-muted);
  white-space: nowrap;
}

.gen-pw-code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 14px;
  color: #3fb950;
  letter-spacing: 0.05em;
  word-break: break-all;
  flex: 1;
}

.copy-confirm {
  color: #3fb950;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

@keyframes gen-flash {
  0%   { border-color: #3fb950; box-shadow: 0 0 0 2px rgba(63,185,80,0.25); }
  100% { border-color: var(--border); box-shadow: none; }
}

.gen-pw-flash {
  animation: gen-flash 0.6s ease-out forwards;
}

/* ── URL auto-extraction flash ────────────────────────────────────────────── */

@keyframes extracted-flash {
  0%   { border-color: #3fb950; box-shadow: 0 0 0 3px rgba(63,185,80,0.20); }
  100% { border-color: var(--border); box-shadow: none; }
}

.input-extracted {
  animation: extracted-flash 0.7s ease-out forwards;
}

/* ══════════════════════════════════════════════════════════════════════════
   Activity Log page
   ══════════════════════════════════════════════════════════════════════════ */

.log-page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 24px 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.log-header-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.log-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.log-count {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
}

/* ── Filter bar ─────────────────────────────────────────────────────────── */
.log-filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}

.log-filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 130px;
}

.filter-group-search {
  min-width: 220px;
  flex: 1;
}

.filter-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.filter-select,
.filter-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  padding: 6px 10px;
  outline: none;
  transition: border-color 0.15s;
  height: 32px;
}

.filter-select:focus,
.filter-input:focus {
  border-color: var(--accent);
}

.filter-input::placeholder {
  color: var(--text-subtle);
}

.filter-actions {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  padding-bottom: 0;
}

/* ── Log table section ───────────────────────────────────────────────────── */
.log-table-section {
  /* inherits admin-table-wrap styles */
}

.log-table {
  width: 100%;
  table-layout: auto;
}

/* Column widths */
.log-table .col-time    { width: 90px;  white-space: nowrap; }
.log-table .col-user    { width: 110px; }
.log-table .col-source  { min-width: 200px; }
.log-table .col-mode    { width: 90px; }
.log-table .col-dry     { width: 60px;  text-align: center; }
.log-table .col-status  { width: 100px; }
.log-table .col-videos  { width: 65px;  text-align: right; }
.log-table .col-dur     { width: 80px;  text-align: right; white-space: nowrap; }
.log-table .col-job     { width: 80px; }

/* Row accent colours by status */
.log-row-done td:first-child       { border-left: 3px solid var(--success); }
.log-row-failed td:first-child     { border-left: 3px solid var(--danger); }
.log-row-cancelled td:first-child  { border-left: 3px solid var(--warning); }
.log-row-running td:first-child    { border-left: 3px solid var(--info); }

/* ── Cell details ───────────────────────────────────────────────────────── */
.log-ts {
  font-size: 12px;
  color: var(--text-muted);
  vertical-align: top;
  padding-top: 9px;
}

.log-ts-time {
  color: var(--text-subtle);
  font-size: 11px;
}

.log-username {
  font-weight: 600;
  color: var(--text);
}

/* Source cell — type badge + source ID stacked */
td.col-source {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 8px;
  padding-bottom: 8px;
  border: none;          /* override any table-cell border */
}

/* Fix: source cell is inside a table so use block display trick */
.log-table td.col-source {
  display: table-cell;   /* must stay table-cell */
  vertical-align: top;
}

.log-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 20px;
  text-transform: capitalize;
  color: var(--text-muted);
  background: var(--surface3);
  border: 1px solid var(--border);
  margin-bottom: 3px;
}

.log-type-playlist { color: #58a6ff; border-color: rgba(88,166,255,0.3); background: rgba(88,166,255,0.08); }
.log-type-channel  { color: #f0883e; border-color: rgba(240,136,62,0.3);  background: rgba(240,136,62,0.08); }
.log-type-videos   { color: #bc8cff; border-color: rgba(188,140,255,0.3); background: rgba(188,140,255,0.08); }

.log-source-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

/* Mode badge */
.log-mode-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: capitalize;
  background: var(--surface3);
  color: var(--text-muted);
}

.log-mode-preflight { color: #58a6ff; background: rgba(88,166,255,0.1); }
.log-mode-report    { color: #d29922; background: rgba(210,153,34,0.1); }
.log-mode-apply     { color: #3fb950; background: rgba(63,185,80,0.1); }

/* Dry run badge */
.log-dry-yes {
  background: rgba(210,153,34,0.12);
  color: var(--warning);
  border: 1px solid rgba(210,153,34,0.3);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 20px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.log-live {
  font-size: 10px;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Status badges */
.log-status {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

.log-status-done      { color: var(--success); background: rgba(63,185,80,0.10); }
.log-status-failed    { color: var(--danger);  background: rgba(248,81,73,0.10); }
.log-status-cancelled { color: var(--warning); background: rgba(210,153,34,0.10); }
.log-status-running   { color: var(--info);    background: rgba(88,166,255,0.10); }

/* Job ID */
.log-job-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-subtle);
}

/* Empty state */
.log-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.log-empty a {
  color: var(--accent);
  margin-left: 6px;
}

/* Responsive: collapse some columns on narrow screens */
@media (max-width: 900px) {
  .log-table .col-job,
  .log-table .col-dry { display: none; }
}

@media (max-width: 700px) {
  .log-filter-form { flex-direction: column; }
  .filter-group    { min-width: 100%; }
  .log-table .col-dur,
  .log-table .col-videos { display: none; }
}

/* ── Advanced settings — unit toggle ─────────────────────────────────────── */
.adv-unit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-muted);
}

.adv-unit-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.adv-unit-toggle {
  display: flex;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.adv-unit-btn {
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-ui);
  background: transparent;
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1.6;
  white-space: nowrap;
}

.adv-unit-btn:hover:not(.active) {
  background: var(--surface2);
  color: var(--text);
}

.adv-unit-btn.active {
  background: var(--accent);
  color: #fff;
  cursor: default;
}

/* ── Metadata controls (in review panel) ─────────────────────────────────── */
.meta-controls-wrap {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.meta-details {
  /* no extra padding — summary handles it */
}

.meta-summary {
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  padding: 10px 16px;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.meta-summary::-webkit-details-marker {
  display: none;
}

.meta-summary::before {
  content: '▸';
  font-size: 10px;
  transition: transform 0.15s;
  flex-shrink: 0;
}

.meta-details[open] .meta-summary::before {
  transform: rotate(90deg);
}

.meta-summary:hover {
  color: var(--text);
}

.meta-active-badge {
  font-size: 10px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: none;
}

.meta-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 16px 16px;
  border-top: 1px solid var(--border-muted);
}

.meta-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.meta-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 84px;
  flex-shrink: 0;
  padding-top: 7px;
}

.meta-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12px;
  font-family: var(--font-ui);
  padding: 5px 10px;
  outline: none;
  cursor: pointer;
  min-width: 190px;
  height: 30px;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238b949e'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.meta-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.12);
}

.meta-textarea {
  width: 100%;
  margin-top: 8px;
  font-size: 12px;
  font-family: var(--font-ui);
  resize: vertical;
  min-height: 66px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.meta-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.12);
}

.meta-tags-input {
  flex: 1;
  font-size: 12px;
  min-width: 200px;
  height: 30px;
}
