:root {
  --bg: #f4f7f5;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-2: #0b5f59;
  --text: #1f2937;
  --muted: #6b7280;
  --danger: #b91c1c;
  --border: #d1d5db;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top right, #dff4ef 0%, var(--bg) 50%);
}
.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1rem;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.04);
}
h1, h2 { margin-top: 0; }
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}
label { font-weight: 600; display: block; margin-bottom: 0.25rem; }
input, textarea, select {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
}
textarea { min-height: 90px; resize: vertical; }
.btn {
  border: 0;
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  font-weight: 600;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-danger { background: var(--danger); color: #fff; }
.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  padding: 0.65rem;
  border-bottom: 1px solid var(--border);
}
.small { color: var(--muted); font-size: 0.9rem; }
.alert {
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.75rem;
}
.alert-error { background: #fee2e2; color: #7f1d1d; }
.alert-ok { background: #dcfce7; color: #14532d; }
@media (max-width: 780px) {
  .grid { grid-template-columns: 1fr; }
  .row { flex-direction: column; align-items: stretch; }
}

.split {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 1rem;
}
.topic-tree {
  list-style: none;
  margin: 0;
  padding-left: 1rem;
  border-left: 2px solid #cde8e3;
}
.topic-tree > li {
  margin: 0.45rem 0;
}
.topic-tree summary {
  cursor: pointer;
  font-weight: 700;
  color: #0b5f59;
  margin-bottom: 0.25rem;
}
.topic-tree details {
  background: #f8fcfb;
  border: 1px solid #d8eeea;
  border-radius: 10px;
  padding: 0.35rem 0.5rem;
}
.tree-leaf {
  padding: 0.2rem 0 0.4rem;
}
.pick {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 500;
  margin: 0.25rem 0;
}
.pick input[type="radio"] {
  width: 1rem;
  height: 1rem;
  accent-color: #0f766e;
}
.topic-path {
  display: inline-block;
  background: #e9f7f4;
  border: 1px solid #cde8e3;
  color: #0b5f59;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-weight: 600;
  font-size: 0.86rem;
}
@media (max-width: 980px) {
  .split { grid-template-columns: 1fr; }
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
  margin: 0.1rem 0.2rem 0.1rem 0;
  border: 1px solid transparent;
}
.badge-admin { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.badge-consumer { background: #dbeafe; color: #1e3a8a; border-color: #bfdbfe; }
.badge-active { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.badge-inactive { background: #f3f4f6; color: #374151; border-color: #d1d5db; }
.badge-key { background: #fef9c3; color: #854d0e; border-color: #fde68a; }
.admin-actions {
  display: grid;
  gap: 0.45rem;
  min-width: 250px;
}
.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem;
  align-items: center;
}
.inline-form input,
.inline-form select {
  margin: 0;
}
@media (max-width: 780px) {
  .inline-form { grid-template-columns: 1fr; }
}
.picker-collapse {
  border: 1px solid #d8eeea;
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  background: #f8fcfb;
}
.picker-collapse summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  list-style: none;
  margin: 0;
}
.picker-collapse summary::-webkit-details-marker {
  display: none;
}
.picker-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0b5f59;
}
.picker-collapse[open] summary {
  margin-bottom: 0.65rem;
}
.topic-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.45rem;
}
.topic-row > .pick {
  flex: 1;
  min-width: 0;
}
.topic-children {
  margin-left: auto;
  background: transparent;
  border: 0;
  padding: 0;
}
.topic-children > summary {
  list-style: none;
  cursor: pointer;
  width: 1.5rem;
  height: 1.5rem;
  border: 1px solid #cde8e3;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.15rem;
}
.topic-children > summary::-webkit-details-marker {
  display: none;
}
.topic-children > summary::before {
  content: '▸';
  font-size: 0.9rem;
  color: #0b5f59;
  line-height: 1;
}
.topic-children[open] > summary::before {
  content: '▾';
}
.topic-children > ul {
  margin-top: 0.4rem;
}
.topic-parent {
  display: block;
}
.topic-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}
.topic-row > .pick {
  flex: 1;
  min-width: 0;
}
.topic-expand {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.topic-toggle {
  width: 1.55rem;
  height: 1.55rem;
  border: 1px solid #cde8e3;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 1.55rem;
}
.topic-toggle::before {
  content: '▸';
  color: #0b5f59;
  font-size: 0.9rem;
  line-height: 1;
}
.topic-expand:checked + .topic-branch {
  display: block;
}
.topic-expand:checked + .topic-branch ~ * {
  display: none;
}
.topic-expand:checked ~ .topic-row .topic-toggle::before {
  content: '▾';
}
.topic-parent .topic-expand:checked ~ .topic-branch {
  display: block;
}
.topic-parent .topic-expand:not(:checked) ~ .topic-branch {
  display: none;
}
.topic-parent .topic-expand:checked ~ .topic-row .topic-toggle::before {
  content: '▾';
}
.topic-branch {
  margin-top: 0.45rem;
  margin-left: 1.8rem;
}
.topic-parent {
  display: block;
}
.topic-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}
.topic-row > .pick {
  flex: 1;
  min-width: 0;
  margin: 0;
}
.topic-expand {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.topic-toggle {
  width: 1.55rem;
  height: 1.55rem;
  border: 1px solid #cde8e3;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 1.55rem;
}
.topic-toggle::before {
  content: '▸';
  color: #0b5f59;
  font-size: 0.9rem;
  line-height: 1;
}
.topic-parent > .topic-expand:checked + .topic-row .topic-toggle::before {
  content: '▾';
}
.topic-parent > .topic-branch {
  display: none;
  margin-top: 0.4rem;
  margin-left: 1.45rem;
}
.topic-parent > .topic-expand:checked ~ .topic-branch {
  display: block;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.main-menu {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.main-menu a {
  text-decoration: none;
  color: #0b5f59;
  border: 1px solid #cde8e3;
  background: #f3fbf9;
  padding: 0.45rem 0.75rem;
  border-radius: 10px;
  font-weight: 600;
}
.main-menu a.active {
  background: #0f766e;
  border-color: #0f766e;
  color: #ffffff;
}
.topic-parent {
  display: block;
}
.topic-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}
.topic-row > .pick {
  flex: 1;
  min-width: 0;
  margin: 0;
}
.topic-expand {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.topic-toggle {
  width: 1.55rem;
  height: 1.55rem;
  border: 1px solid #cde8e3;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 1.55rem;
}
.topic-toggle::before {
  content: '▸';
  color: #0b5f59;
  font-size: 0.9rem;
  line-height: 1;
}
.topic-parent > .topic-expand:checked + .topic-row .topic-toggle::before {
  content: '▾';
}
.topic-parent > .topic-branch {
  display: none;
  margin-top: 0.4rem;
  margin-left: 1.45rem;
}
.topic-parent > .topic-expand:checked ~ .topic-branch {
  display: block;
}
@media (max-width: 780px) {
  .topbar { flex-direction: column; align-items: stretch; }
}
.filter-tabs {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.tab {
  text-decoration: none;
  color: #0b5f59;
  border: 1px solid #cde8e3;
  background: #f3fbf9;
  padding: 0.38rem 0.65rem;
  border-radius: 999px;
  font-weight: 600;
}
.tab.active {
  background: #0f766e;
  border-color: #0f766e;
  color: #fff;
}
.news-list {
  display: grid;
  gap: 0.8rem;
}
.news-item h3 {
  font-size: 1.1rem;
}
.news-excerpt {
  margin: 0;
  color: #1f2937;
  line-height: 1.45;
  max-width: 80ch;
}
.player-card {
  background: linear-gradient(180deg, #f9fffd 0%, #ffffff 100%);
}
.player-headline {
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: #0b5f59;
}
.player-progress {
  width: 100%;
  margin-bottom: 0.65rem;
  accent-color: #0f766e;
}
.player-controls {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.news-item.playing {
  border-color: #0f766e;
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.12);
}
@media (max-width: 780px) {
  .player-controls {
    width: 100%;
  }
  .player-controls .btn {
    flex: 1 1 calc(50% - 0.3rem);
  }
}
.admin-menu a {
  background: #eef6ff;
  border-color: #cfe1ff;
  color: #1d4ed8;
}
.admin-menu a.active {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #fff;
}
.token-edit-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
}
.token-edit-form textarea {
  min-height: 72px;
}
.token-edit-form .btn {
  grid-column: 1 / -1;
}
@media (max-width: 980px) {
  .token-edit-form {
    grid-template-columns: 1fr;
  }
}
.compact-card {
  padding: 0.85rem;
}
.compact-create-form {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 110px 32px;
  gap: 0.4rem;
  align-items: center;
}
.rss-list {
  display: grid;
  gap: 0.45rem;
}
.rss-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1.6fr) 72px minmax(0, 1.1fr) 32px;
  gap: 0.4rem;
  align-items: center;
}
.rss-row-delete {
  display: inline-flex;
  justify-content: flex-end;
  margin-top: -2.45rem;
}
.rss-label,
.rss-url,
.rss-status-select {
  margin: 0;
}
.rss-meta {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  overflow: hidden;
  white-space: nowrap;
}
.compact-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
}
.pager {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.85rem;
  flex-wrap: wrap;
}
@media (max-width: 980px) {
  .compact-create-form,
  .rss-row {
    grid-template-columns: 1fr;
  }
  .rss-row-delete {
    margin-top: 0;
    justify-content: flex-start;
  }
  .rss-meta {
    white-space: normal;
    flex-wrap: wrap;
  }
}
.rss-line {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}
.rss-row {
  display: grid;
  grid-template-columns: 150px minmax(340px, 1.7fr) 64px minmax(280px, 1.1fr) 32px;
  gap: 0.35rem;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}
.rss-row-delete {
  display: inline-flex;
  align-items: center;
  margin: 0;
}
.rss-label,
.rss-url,
.rss-status-select,
.rss-meta {
  min-width: 0;
}
.rss-meta {
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 980px) {
  .rss-line {
    display: block;
  }
  .rss-row {
    grid-template-columns: 1fr;
  }
  .rss-row-delete {
    margin-top: 0.35rem;
  }
}
.compact-create-form-rss {
  grid-template-columns: 160px minmax(0, 1fr) 72px 100px 32px;
}
.rss-filter-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}
.rss-row-lang {
  grid-template-columns: 140px minmax(300px, 1.5fr) 64px 64px minmax(260px, 1fr) 32px;
}
.rss-language {
  margin: 0;
  min-width: 0;
}
@media (max-width: 980px) {
  .compact-create-form-rss,
  .rss-row-lang {
    grid-template-columns: 1fr;
  }
}
.rss-filter-cards {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  align-items: center;
}
.filter-card {
  text-decoration: none;
  color: #0b5f59;
  border: 1px solid #cde8e3;
  background: #f3fbf9;
  padding: 0.45rem 0.75rem;
  border-radius: 12px;
  font-weight: 700;
  min-width: 56px;
  text-align: center;
}
.filter-card.active {
  background: #0f766e;
  border-color: #0f766e;
  color: #fff;
}

.rss-row-no-save {
  grid-template-columns: 140px minmax(300px, 1.6fr) 64px 64px minmax(260px, 1fr);
}
.compact-discovery-form {
  grid-template-columns: 180px minmax(0, 1fr) 72px 100px 32px;
}
.discovery-target-row {
  grid-template-columns: 150px minmax(260px, 1.2fr) 64px 64px minmax(240px, 1fr);
}
.candidate-card {
  border: 1px solid #dbe7e3;
  border-radius: 12px;
  padding: 0.75rem;
  background: #fbfefd;
}
.candidate-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
@media (max-width: 980px) {
  .compact-discovery-form,
  .discovery-target-row {
    grid-template-columns: 1fr;
  }
}


.pipeline-page {
  display: grid;
  gap: 1rem;
}

.pipeline-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

.pipeline-rail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  align-items: stretch;
  position: relative;
}

.pipeline-rail::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 12%;
  right: 12%;
  height: 3px;
  background: linear-gradient(90deg, #cde8e3 0%, #a7d9d2 50%, #cde8e3 100%);
  border-radius: 999px;
  transform: translateY(-50%);
  z-index: 0;
}

.pipeline-stage {
  position: relative;
  z-index: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 235px;
}

.pipeline-stage[data-stage="aggregator"] .stage-badge {
  background: #dff8f0;
  color: #0b5f59;
  border-color: #cde8e3;
}

.pipeline-stage[data-stage="filter"] .stage-badge {
  background: #e8f2ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.pipeline-stage[data-stage="decorator"] .stage-badge {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}

.stage-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  width: fit-content;
  padding: 0.24rem 0.7rem;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pipeline-stage h3 {
  margin: 0;
  font-size: 1.2rem;
}

.pipeline-stage p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.95rem;
}

.stage-summary {
  margin-top: auto;
  padding: 0.55rem 0.7rem;
  background: #f8fcfb;
  border: 1px solid #d8eeea;
  border-radius: 10px;
  color: #0b5f59;
  font-weight: 600;
  font-size: 0.82rem;
}

.pipeline-stage button {
  width: 100%;
  border: 1px solid #cde8e3;
  background: #f3fbf9;
  color: var(--text);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pipeline-stage button:hover {
  background: #eaf9f6;
  border-color: #9bd4cc;
}

.pipeline-stage button:focus-visible,
.modal-close:focus-visible,
.modal-save:focus-visible,
.modal-cancel:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.25);
  outline-offset: 2px;
}

.pipeline-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1rem;
}

.pipeline-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
}

.pipeline-modal-backdrop.open {
  display: flex;
}

.pipeline-modal {
  width: min(640px, 100%);
  background: white;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.18);
  overflow: hidden;
}

.pipeline-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: #f8fcfb;
}

.pipeline-modal-body {
  padding: 1rem 1.1rem 1.2rem;
}

.modal-close {
  border: 1px solid var(--border);
  background: white;
  border-radius: 10px;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  font-weight: 600;
}

.pipeline-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.pipeline-form-grid .full {
  grid-column: 1 / -1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
}

.modal-cancel,
.modal-save {
  border: 0;
  border-radius: 10px;
  padding: 0.7rem 1rem;
  font-weight: 700;
  cursor: pointer;
}

.modal-cancel {
  background: #f3f4f6;
  color: var(--text);
}

.modal-save {
  background: var(--accent);
  color: white;
}

@media (max-width: 900px) {
  .pipeline-grid {
    grid-template-columns: 1fr;
  }
  .pipeline-rail {
    grid-template-columns: 1fr;
  }
  .pipeline-rail::before {
    display: none;
  }
}
