:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --line: #dde3ea;
  --text: #1d2630;
  --muted: #617284;
  --primary: #0b7a75;
  --danger: #b6252a;
  --warn: #b06d00;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #eef4ff 0%, var(--bg) 220px);
}

.topbar {
  padding: 20px 24px;
  background: #0a3348;
  color: #fff;
}

.topbar h1 {
  margin: 0;
  font-size: 1.4rem;
}

.topbar p {
  margin: 6px 0 0;
  opacity: 0.85;
}

.topnav {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.topnav a {
  color: #d8e4ef;
  text-decoration: none;
  border: 1px solid rgba(216, 228, 239, 0.35);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.9rem;
}

.topnav a:hover {
  background: rgba(255, 255, 255, 0.12);
}

.topnav a.active {
  background: #fff;
  color: #0a3348;
  border-color: #fff;
}

.container {
  width: min(1200px, 95vw);
  margin: 18px auto 40px;
  display: grid;
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}

.flash {
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 600;
  border: 1px solid var(--line);
}

.flash-success {
  background: #e6f7ef;
  color: #215f3e;
  border-color: #bce4cc;
}

.flash-error {
  background: #fbe9ea;
  color: #7f2024;
  border-color: #f1c0c2;
}

h2,
h3,
h4 {
  margin: 0 0 10px;
}

h4 {
  margin-top: 12px;
}

.grid-form {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.grid-form.compact {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

label {
  display: grid;
  gap: 4px;
  font-size: 0.9rem;
  color: var(--muted);
}

input,
select,
button {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #c9d4df;
  font-size: 0.95rem;
}

button {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  cursor: pointer;
}

button:hover {
  filter: brightness(1.06);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
}

.btn-small {
  padding: 4px 8px;
  font-size: 0.82rem;
}

.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid #d8b3b5;
  background: #fff4f4;
  color: var(--danger);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0;
}

.icon-btn:hover {
  background: #ffe9ea;
}

.inline-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.actions {
  display: flex;
  align-items: end;
}

.row-space {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.series-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-top: 12px;
}

.series-accordion > summary,
.season-accordion > summary {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  list-style: none;
}

.series-accordion > summary::-webkit-details-marker,
.season-accordion > summary::-webkit-details-marker {
  display: none;
}

.series-title {
  font-weight: 700;
}

.series-summary-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.series-cover-wrap {
  width: 34px;
  height: 46px;
  border-radius: 6px;
  overflow: hidden;
  background: #dfe8f3;
  border: 1px solid #c7d3e0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

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

.series-cover-fallback {
  color: #4d6278;
  font-weight: 700;
  font-size: 0.9rem;
}

.series-cover-wrap.has-cover .series-cover-fallback {
  display: none;
}

.series-content,
.season-content {
  margin-top: 10px;
}

.season-accordion {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  margin-top: 10px;
  background: #fafcff;
}

.add-season-block {
  margin: 10px 0;
}

.migration-box {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.domain-migration-progress {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.inline-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.pill {
  display: inline-block;
  background: #eef3f8;
  border: 1px solid #d4dee8;
  border-radius: 999px;
  padding: 4px 10px;
  color: #435564;
  font-size: 0.85rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 6px;
  vertical-align: top;
  font-size: 0.9rem;
}

th {
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.break {
  word-break: break-all;
}

.progress-cell {
  min-width: 220px;
}

.progress-wrap {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e8eef5;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #1e9f9a, #0b7a75);
}

.progress-cell small {
  color: var(--muted);
}

.status {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: lowercase;
}

.status-present,
.status-completed {
  background: #e7f8ec;
  color: #1e633f;
}

.status-missing,
.status-queued,
.status-downloading {
  background: #fff2da;
  color: var(--warn);
}

.status-resolving {
  background: #e7f1ff;
  color: #245c9e;
}

.status-not_in_sonarr,
.status-failed {
  background: #fde7e7;
  color: var(--danger);
}

.loc-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: help;
}

.loc-sonarr {
  background: #e7f1ff;
  color: #245c9e;
}

.loc-download_dir {
  background: #e7f8ec;
  color: #1e633f;
}

.loc-unknown {
  background: #fde7e7;
  color: var(--danger);
}

.source-url-input,
.new-source-url,
.new-season-url,
.new-season-number {
  width: 100%;
}

.toast-root {
  position: fixed;
  top: 16px;
  right: 16px;
  display: grid;
  gap: 8px;
  z-index: 1000;
}

.toast {
  min-width: 240px;
  max-width: min(92vw, 420px);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  transform: translateY(-12px) scale(0.98);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.toast.show {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.toast-success {
  background: #e6f7ef;
  border-color: #bce4cc;
  color: #215f3e;
}

.toast-error {
  background: #fbe9ea;
  border-color: #f1c0c2;
  color: #7f2024;
}

.toast-info {
  background: #e7f1ff;
  border-color: #bfd8fb;
  color: #1f4e8a;
}

@media (max-width: 900px) {
  .inline-actions {
    flex-wrap: wrap;
  }
  .row-space {
    flex-direction: column;
    align-items: flex-start;
  }
  .table-wrap {
    overflow-x: auto;
  }
}
