* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0d1117;
  color: #e6edf3;
  min-height: 100vh;
}

header {
  text-align: center;
  padding: 2rem 1rem 1rem;
  border-bottom: 1px solid #21262d;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.subtitle {
  color: #8b949e;
  margin-top: 0.25rem;
  font-size: 0.95rem;
}

.search-bar {
  margin-top: 1.25rem;
  display: flex;
  justify-content: center;
}

.search-bar input {
  width: 100%;
  max-width: 400px;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  border: 1px solid #30363d;
  background: #21262d;
  color: #e6edf3;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-bar input:focus {
  border-color: #58a6ff;
}

.search-bar input::placeholder {
  color: #484f58;
}

.controls {
  margin-top: 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.control-select {
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  border: 1px solid #30363d;
  background: #21262d;
  color: #8b949e;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
}

.control-select:hover,
.control-select:focus {
  border-color: #58a6ff;
  color: #e6edf3;
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: #8b949e;
  cursor: pointer;
  user-select: none;
}

.toggle-label input {
  accent-color: #1f6feb;
  cursor: pointer;
}

.filters {
  display: flex;
  gap: 0.5rem;
}

.filter-btn {
  background: #21262d;
  color: #8b949e;
  border: 1px solid #30363d;
  padding: 0.4rem 1.2rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.filter-btn:hover {
  color: #e6edf3;
  border-color: #58a6ff;
}

.filter-btn.active {
  background: #1f6feb;
  color: #fff;
  border-color: #1f6feb;
}

/* Page navigation */
.page-nav {
  display: flex;
  justify-content: center;
  gap: 0;
  margin-top: 1rem;
}

.nav-btn {
  background: transparent;
  color: #8b949e;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.5rem 1.5rem;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-btn:hover {
  color: #e6edf3;
}

.nav-btn.active {
  color: #e6edf3;
  border-bottom-color: #58a6ff;
}

/* Releases controls (search, filters) */
.releases-controls {
  text-align: center;
  margin-bottom: 1.5rem;
}

.releases-controls .search-bar {
  margin-bottom: 1rem;
}

/* People search bar */
.people-search-bar {
  margin-bottom: 1rem;
}

.people-controls {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

/* People results grid */
.people-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}

.person-card {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
}

.person-card:hover {
  border-color: #58a6ff;
  transform: translateY(-2px);
}

.person-card-photo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  margin: 0 auto 0.75rem;
  background: #21262d;
}

.person-card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.person-card-photo .no-photo {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #484f58;
  font-size: 0.65rem;
}

.person-card-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #e6edf3;
  margin-bottom: 0.25rem;
}

.person-card-dept {
  font-size: 0.75rem;
  color: #8b949e;
}

/* Person profile header */
.person-profile {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 10px;
  padding: 1rem 1.5rem;
  margin-bottom: 1rem;
}

.profile-photo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: #21262d;
}

.profile-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-photo .no-photo {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #484f58;
  font-size: 0.6rem;
}

.profile-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: #e6edf3;
}

.profile-dept {
  font-size: 0.85rem;
  color: #8b949e;
}

.profile-count {
  font-size: 0.8rem;
  color: #58a6ff;
}

/* Person back button */
.person-back-btn {
  margin-bottom: 1rem;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.loading {
  text-align: center;
  padding: 4rem;
  color: #8b949e;
  font-size: 1.1rem;
}

.error {
  text-align: center;
  padding: 2rem;
  color: #f85149;
  background: #1c0a0a;
  border: 1px solid #f8514933;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.movie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.movie-card {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  transition: border-color 0.2s, transform 0.2s;
}

.movie-card:hover {
  border-color: #58a6ff;
  transform: translateY(-2px);
}

.movie-poster {
  width: 130px;
  min-height: 195px;
  flex-shrink: 0;
  background: #21262d;
}

.movie-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.movie-poster .no-poster {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #484f58;
  font-size: 0.8rem;
}

.movie-info {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.movie-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.movie-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}

.own-btn {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid #30363d;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.own-btn .check {
  color: transparent;
  font-size: 0.8rem;
  line-height: 1;
}

.own-btn:hover {
  border-color: #3fb950;
}

.own-btn:hover .check {
  color: #3fb95066;
}

.own-btn.owned {
  border-color: #3fb950;
  background: #3fb950;
}

.own-btn.owned .check {
  color: #fff;
}

.movie-card.owned {
  opacity: 0.55;
}

.movie-card.owned:hover {
  opacity: 1;
}

.movie-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.rating {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.rating-star {
  color: #f0c040;
}

.rating-good { color: #3fb950; }
.rating-mid { color: #d29922; }
.rating-bad { color: #f85149; }

.badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 10px;
  background: #1f6feb22;
  color: #58a6ff;
  border: 1px solid #1f6feb44;
  white-space: nowrap;
}

.plex-badge {
  background: #e5a00d22;
  color: #e5a00d;
  border-color: #e5a00d44;
}

.movie-cast {
  font-size: 0.8rem;
  color: #8b949e;
  line-height: 1.5;
}

.movie-cast strong {
  color: #c9d1d9;
  font-weight: 500;
}

.movie-synopsis {
  font-size: 0.78rem;
  color: #8b949e;
  line-height: 1.5;
}

.synopsis-toggle {
  color: #58a6ff;
  cursor: pointer;
  font-size: 0.75rem;
  user-select: none;
}

.synopsis-toggle:hover {
  text-decoration: underline;
}

.movie-synopsis.collapsed .synopsis-text {
  display: none;
}

.synopsis-text {
  display: block;
  margin-top: 0.25rem;
}

.movie-streaming {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.provider {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  color: #c9d1d9;
  background: #21262d;
  padding: 0.2rem 0.5rem 0.2rem 0.2rem;
  border-radius: 4px;
  border: 1px solid #30363d;
}

.provider img {
  width: 18px;
  height: 18px;
  border-radius: 3px;
}

.no-streaming {
  font-size: 0.75rem;
  color: #484f58;
  font-style: italic;
}

.movie-torrents {
  display: flex;
  flex-wrap: wrap;
}

.torrent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.torrent-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  color: #c9d1d9;
  background: #21262d;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  border: 1px solid #30363d;
  text-decoration: none;
  transition: all 0.2s;
}

.torrent-link:hover {
  border-color: #a371f7;
  background: #a371f711;
}

.torrent-quality {
  font-weight: 600;
  color: #a371f7;
}

.torrent-size {
  color: #8b949e;
}

.torrent-seeds {
  font-weight: 600;
}

.seeds-good { color: #3fb950; }
.seeds-ok { color: #d29922; }
.seeds-low { color: #f85149; }

.torrent-item {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.qbit-btn {
  min-width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid #30363d;
  background: #21262d;
  color: #c9d1d9;
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.3rem;
  transition: all 0.2s;
  line-height: 1;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.qbit-btn:hover:not(:disabled) {
  border-color: #3fb950;
  color: #3fb950;
}

.qbit-btn.qbit-downloading {
  border-color: #1f6feb;
  color: #58a6ff;
  background:
    linear-gradient(#1f6feb33, #1f6feb33) left / var(--prog, 0%) 100% no-repeat,
    #21262d;
}

.qbit-btn.qbit-done {
  background: #23862e;
  border-color: #3fb950;
  color: #fff;
}

.qbit-btn.qbit-paused {
  border-color: #d29922;
  color: #d29922;
}

.qbit-btn.qbit-error {
  background: #8b1a1a;
  border-color: #f85149;
  color: #fff;
}

.qbit-btn.sending {
  color: #8b949e;
}

.qbit-btn:disabled {
  cursor: default;
}

.movie-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}

.movie-date {
  font-size: 0.75rem;
  color: #484f58;
}

.imdb-link {
  font-size: 0.7rem;
  font-weight: 700;
  color: #0d1117;
  background: #f5c518;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  text-decoration: none;
  transition: opacity 0.2s;
}

.imdb-link:hover {
  opacity: 0.8;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
  padding: 1rem;
}

.page-btn {
  background: #21262d;
  color: #e6edf3;
  border: 1px solid #30363d;
  padding: 0.5rem 1.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
  background: #30363d;
  border-color: #58a6ff;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#page-info {
  color: #8b949e;
  font-size: 0.85rem;
}

footer {
  text-align: center;
  padding: 2rem 1rem;
  color: #484f58;
  font-size: 0.8rem;
  border-top: 1px solid #21262d;
}

footer a {
  color: #58a6ff;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* Upgrades page */
.upgrades-empty {
  text-align: center;
  padding: 4rem;
  color: #3fb950;
  font-size: 1.1rem;
}

.upgrades-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.upgrade-card {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: border-color 0.2s, opacity 0.3s, transform 0.3s;
}

.upgrade-card:hover {
  border-color: #58a6ff;
}

.upgrade-info {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

.upgrade-title {
  font-size: 1rem;
  font-weight: 600;
  color: #e6edf3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upgrade-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.upgrade-quality-badge {
  background: #f8514922;
  color: #f85149;
  border-color: #f8514944;
}

.upgrade-size {
  font-size: 0.8rem;
  color: #8b949e;
}

.upgrade-options {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.upgrade-label {
  font-size: 0.8rem;
  color: #8b949e;
  white-space: nowrap;
}

.upgrade-btns {
  display: flex;
  gap: 0.4rem;
}

.upgrade-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  color: #c9d1d9;
  background: #21262d;
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
  border: 1px solid #30363d;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.upgrade-btn:hover:not(:disabled) {
  border-color: #3fb950;
  background: #3fb95011;
}

.upgrade-btn.sending {
  color: #8b949e;
  cursor: default;
}

.upgrade-btn:disabled {
  cursor: default;
}

.upgrade-btn.upgrade-error {
  border-color: #f85149;
  background: #8b1a1a;
  color: #fff;
}

.upgrades-actions {
  display: flex;
  justify-content: center;
  padding: 1.5rem;
}

/* Duplicates page */
.duplicates-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.duplicate-group {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  transition: border-color 0.2s;
}

.duplicate-group:hover {
  border-color: #58a6ff;
}

.duplicate-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.duplicate-title {
  font-size: 1rem;
  font-weight: 600;
  color: #e6edf3;
}

.duplicate-wasted {
  font-size: 0.8rem;
  color: #f85149;
  white-space: nowrap;
}

.duplicate-copies {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.duplicate-copy {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 6px;
  font-size: 0.8rem;
}

.duplicate-copy.duplicate-keep {
  border-color: #3fb95044;
  background: #3fb95008;
}

.duplicate-res-badge {
  flex-shrink: 0;
}

.duplicate-size {
  color: #e6edf3;
  font-weight: 600;
  white-space: nowrap;
  min-width: 60px;
}

.duplicate-codecs {
  color: #8b949e;
  white-space: nowrap;
}

.duplicate-path {
  color: #484f58;
  font-size: 0.7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.duplicate-keep-label {
  font-size: 0.7rem;
  color: #3fb950;
  font-weight: 600;
  white-space: nowrap;
}

.duplicate-delete-btn {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: #f85149;
  background: #f8514911;
  border: 1px solid #f8514944;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.duplicate-delete-btn:hover:not(:disabled) {
  background: #f8514933;
  border-color: #f85149;
}

.duplicate-delete-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Storage page */
.storage-summary {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 2rem;
  justify-content: center;
}

.storage-stat {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 10px;
  padding: 1.25rem 2rem;
  text-align: center;
  min-width: 160px;
}

.storage-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #e6edf3;
}

.storage-stat-label {
  font-size: 0.8rem;
  color: #8b949e;
  margin-top: 0.25rem;
}

.storage-heading {
  font-size: 1.1rem;
  font-weight: 600;
  color: #e6edf3;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #21262d;
}

.storage-drives,
.storage-quality {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.storage-bar-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.storage-bar-label {
  font-size: 0.8rem;
  color: #8b949e;
  min-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}

.storage-bar-label.quality-label {
  min-width: 80px;
}

.storage-bar {
  flex: 1;
  height: 20px;
  background: #21262d;
  border-radius: 4px;
  overflow: hidden;
}

.storage-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.bar-green { background: #3fb950; }
.bar-yellow { background: #d29922; }
.bar-red { background: #f85149; }

.storage-bar-info {
  font-size: 0.75rem;
  color: #8b949e;
  white-space: nowrap;
  min-width: 180px;
}

@media (max-width: 480px) {
  .movie-grid {
    grid-template-columns: 1fr;
  }

  .movie-card {
    flex-direction: row;
  }

  .movie-poster {
    width: 100px;
    min-height: 150px;
  }

  .upgrade-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .upgrade-options {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  .duplicate-header {
    flex-direction: column;
    gap: 0.25rem;
  }

  .duplicate-copy {
    flex-wrap: wrap;
  }

  .duplicate-path {
    flex-basis: 100%;
  }

  .storage-summary {
    flex-direction: column;
    align-items: center;
  }

  .storage-bar-row {
    flex-wrap: wrap;
  }

  .storage-bar-label {
    min-width: 100%;
  }

  .storage-bar-info {
    min-width: auto;
  }
}
