:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #333;
  --text: #e0e0e0;
  --text-muted: #888;
  --accent: #e5a00d;
  --danger: #c0392b;
  --success: #27ae60;
  --running: #2980b9;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

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

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Nav */
.navbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.navbar .brand {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}
.nav-links { display: flex; gap: 1rem; }
.nav-user { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; color: var(--text-muted); }

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.4rem 1rem;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
}
.btn:hover { background: var(--border); }
.btn-primary { background: var(--accent); color: #000; border-color: var(--accent); }
.btn-primary:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-plex { background: #e5a00d; color: #000; border: none; padding: 0.6rem 1.5rem; font-size: 1rem; font-weight: 600; border-radius: 4px; cursor: pointer; }
.btn-link { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.9rem; padding: 0; }
.btn-link:hover { color: var(--text); }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.8rem; }

/* Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--accent); text-decoration: none; }
.card h2 { font-size: 1.05rem; color: var(--accent); margin-bottom: 0.4rem; }
.card p { color: var(--text-muted); font-size: 0.9rem; }

/* Media grid */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.media-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s;
}
.media-card:hover { border-color: var(--accent); }
.media-card img { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; }
.no-thumb {
  width: 100%;
  aspect-ratio: 2/3;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--text-muted);
}
.media-title { padding: 0.4rem 0.5rem 0.1rem; font-size: 0.85rem; font-weight: 500; }
.media-year { padding: 0 0.5rem 0.4rem; font-size: 0.75rem; color: var(--text-muted); }

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.9rem;
}
.data-table th, .data-table td {
  padding: 0.6rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th { color: var(--text-muted); font-weight: 500; }
.data-table td.path { font-size: 0.8rem; color: var(--text-muted); font-family: monospace; word-break: break-all; }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-queued { background: #444; color: #ccc; }
.badge-running { background: var(--running); color: #fff; }
.badge-completed, .badge-complete { background: var(--success); color: #fff; }
.badge-failed { background: var(--danger); color: #fff; }
.badge-skipped { background: #555; color: #aaa; }
.badge-already_exists { background: #2c7; color: #000; }
.badge-pending { background: #666; color: #ccc; }
.badge-partially_complete { background: #e67e22; color: #fff; }

/* Tags */
.tag {
  display: inline-block;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1rem 0.5rem;
  font-size: 0.8rem;
  margin-right: 0.3rem;
}

/* Forms */
fieldset { border: 1px solid var(--border); border-radius: 6px; padding: 0.75rem 1rem; margin-bottom: 1rem; }
legend { padding: 0 0.4rem; color: var(--text-muted); font-size: 0.9rem; }
label { display: block; margin-bottom: 0.5rem; cursor: pointer; }
label input[type=checkbox] { margin-right: 0.4rem; }

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-error { background: rgba(192,57,43,0.15); border: 1px solid var(--danger); color: #e74c3c; }

/* Login box */
.login-box {
  max-width: 400px;
  margin: 6rem auto;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2.5rem;
}
.login-box h1 { font-size: 2rem; color: var(--accent); margin-bottom: 0.5rem; }
.login-box p { color: var(--text-muted); margin-bottom: 1.5rem; }

/* Item detail */
.item-detail { display: grid; grid-template-columns: 1fr; gap: 2rem; }
.item-meta h1 { margin-bottom: 0.5rem; }
.item-meta .year { color: var(--text-muted); font-size: 0.85em; }
.summary { color: var(--text-muted); margin: 0.5rem 0 1rem; }

/* Job detail */
.job-paths { margin: 1rem 0; display: flex; flex-direction: column; gap: 0.4rem; }
.job-paths code { font-size: 0.85rem; color: var(--text-muted); }
#log-box { margin-top: 1rem; }
#log-box pre {
  background: #000;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  font-size: 0.82rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 600px;
  overflow-y: auto;
}

/* Meta row */
.meta-row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin: 0.5rem 0 1rem; color: var(--text-muted); font-size: 0.9rem; }
.filters { margin-bottom: 1rem; }

/* Pagination */
.pagination { margin-top: 1.5rem; display: flex; gap: 0.75rem; }

/* Misc */
.muted { color: var(--text-muted); }
h1 { font-size: 1.6rem; margin-bottom: 0.5rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.75rem; }
.children ul { list-style: none; display: flex; flex-direction: column; gap: 0.3rem; }
.children li a { color: var(--text); }
.children li a:hover { color: var(--accent); }
.request-form { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1.5rem; }

/* Search form */
.search-form { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.search-form input[type="text"] { flex: 1; min-width: 200px; padding: 0.45rem 0.75rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font-size: 0.95rem; }
.search-form input[type="text"]:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

/* Episode number badge */
.ep-num { font-size: 0.8rem; font-weight: 600; color: var(--accent); margin-right: 0.35rem; font-family: monospace; }

/* Utility */
.hidden { display: none !important; }

/* Toolbar */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.5rem; }
.toolbar h1 { margin-bottom: 0; }

/* Active button (current page, current per-page) */
.btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Pagination bar */
.pagination-bar { margin-top: 1.75rem; display: flex; flex-direction: column; gap: 0.75rem; }
.page-links { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.page-ellipsis { padding: 0 0.25rem; color: var(--text-muted); user-select: none; }
.page-controls { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; }
.jump-form { display: flex; gap: 0.35rem; align-items: center; }
.page-jump-input { width: 5rem; padding: 0.25rem 0.5rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font-size: 0.85rem; text-align: center; }
.per-page { display: flex; gap: 0.35rem; align-items: center; font-size: 0.85rem; color: var(--text-muted); }

/* Table thumbnail */
.thumb-cell { width: 48px; padding: 0.3rem 0.5rem; }
.table-thumb { width: 40px; height: 60px; object-fit: cover; border-radius: 3px; display: block; }
.table-thumb-placeholder { width: 40px; height: 60px; background: var(--surface2); border-radius: 3px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; color: var(--text-muted); }

/* Nav search */
.nav-search { display: flex; gap: 0.4rem; align-items: center; }
.nav-search input[type="text"] { padding: 0.3rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font-size: 0.85rem; width: 180px; }
.nav-search input[type="text"]:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

/* Global search results */
.search-hub { margin-bottom: 2rem; }
.search-hub-title { font-size: 1rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 0.5rem; border-bottom: 1px solid var(--border); padding-bottom: 0.4rem; }

/* Clean badge on media cards */
.clean-badge { background: var(--success); color: #fff; font-size: 0.7rem; font-weight: 600; padding: 0.15rem 0.4rem; text-align: center; }

/* Badge sizes */
.badge-xs { font-size: 0.65rem; padding: 0.1rem 0.35rem; margin-left: 0.4rem; }

/* Content type badges */
.badge-profanity { background: #e67e22; color: #fff; }
.badge-nudity { background: #8e44ad; color: #fff; }

/* Content report table */
.content-report { margin: 1.5rem 0; }
.report-time { font-family: monospace; font-size: 0.85rem; color: var(--text-muted); white-space: nowrap; }

/* Alert variants */
.alert { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert-error { background: rgba(231,76,60,0.15); border: 1px solid var(--danger); color: var(--danger); }
.alert-warn { background: rgba(230,126,34,0.12); border: 1px solid #e67e22; color: #e67e22; }

/* Progress steps */
.progress-steps { display: flex; flex-direction: column; gap: 1rem; margin: 0.5rem 0 1.5rem; }
.progress-step { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 0.9rem 1rem; }
.step-header { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.55rem; }
.step-icon { font-size: 1rem; width: 1.2rem; text-align: center; }
.step-name { font-weight: 500; flex: 1; }
.step-detail { font-size: 0.82rem; color: var(--text-muted); }

.step-bar-wrap {}
.step-bar { height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.step-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.4s ease; }

/* Indeterminate / running shimmer */
.step-bar-indeterminate { position: relative; }
.step-fill-indeterminate {
  position: absolute; height: 100%; width: 40%; background: var(--accent);
  border-radius: 4px; animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer {
  0%   { left: -40%; }
  100% { left: 100%; }
}

/* Step state colours */
.step-complete .step-icon { color: var(--success); }
.step-complete .step-fill { background: var(--success); }
.step-running  .step-icon { color: var(--accent); animation: spin 1.2s linear infinite; }
.step-skipped  .step-icon { color: var(--text-muted); }
.step-skipped  .step-fill { background: var(--border); }
.step-pending  .step-icon { color: var(--text-muted); }

@keyframes spin { to { transform: rotate(360deg); } }

/* Request actions & edit box */
.request-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 1rem 0; }
.edit-box { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1.2rem; margin: 0.5rem 0 1rem; }
.edit-box h3 { margin: 0 0 0.8rem; font-size: 1rem; }
.edit-box label { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; cursor: pointer; }
.edit-box-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }
.action-cell { white-space: nowrap; }

/* Audio track selector */
.select-input { width: 100%; padding: 0.5rem; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 4px; font-size: 0.9rem; }
.field-hint { font-size: 0.8rem; color: var(--text-muted); margin: 0.3rem 0 0; }
