* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f4f5f7;
  color: #1a1a1a;
}

.hidden { display: none !important; }

.view { width: 96%; max-width: 2200px; margin: 0 auto; padding: 24px; }

h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 10px; }

header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.header-actions { display: flex; gap: 8px; }
a.secondary {
  font: inherit; padding: 8px 14px; border-radius: 6px; border: none;
  background: #eceef1; color: #1a1a1a; cursor: pointer; white-space: nowrap;
  text-decoration: none; display: inline-flex; align-items: center;
}
a.secondary:hover { background: #dfe1e5; }

.panel {
  background: #fff; border: 1px solid #e2e3e6; border-radius: 8px;
  padding: 16px; margin-bottom: 24px;
}

.login-box {
  max-width: 320px; margin: 80px auto; background: #fff;
  border: 1px solid #e2e3e6; border-radius: 8px; padding: 24px;
  display: flex; flex-direction: column; gap: 12px;
}

label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #555; }

input[type="text"], input[type="password"], textarea {
  font: inherit; padding: 8px 10px; border: 1px solid #cfd1d5; border-radius: 6px;
  width: 100%; background: #fafafa;
}

textarea { resize: vertical; font-family: ui-monospace, monospace; font-size: 12px; }
textarea.prose-textarea { font-family: inherit; font-size: 14px; }

button {
  font: inherit; padding: 8px 14px; border-radius: 6px; border: none;
  background: #2563eb; color: #fff; cursor: pointer; white-space: nowrap;
}
button:hover { background: #1d4ed8; }
button.secondary { background: #eceef1; color: #1a1a1a; }
button.secondary:hover { background: #dfe1e5; }
button.danger { color: #b3261e; }
button.danger:hover { background: #fbe9e7; }

.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; }

.error { color: #b3261e; font-size: 13px; }
.hint { color: #777; font-size: 13px; }

.info-banner {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
}

.field-row { margin-bottom: 12px; }
.field-row label { margin-bottom: 4px; }

.copy-row { display: flex; gap: 6px; }
.copy-row input, .copy-row textarea { flex: 1; }
.copy-btn.copied { background: #16a34a; }

.channel-name { font-weight: 600; font-size: 16px; }
.channel-name-input { font-weight: 600; font-size: 16px; padding: 6px 8px; width: auto; flex: 1; }

.live-badge {
  background: #e11d2e; color: #fff; font: 600 11px/1 sans-serif;
  padding: 4px 8px; border-radius: 4px; letter-spacing: .04em;
}

.gallery { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 16px; }
.gallery-empty { color: #777; font-size: 13px; }
.gallery-item { position: relative; width: 72px; height: 41px; }
.gallery-item img {
  display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 4px;
  border: 2px solid #e2e3e6; background: #111; cursor: pointer;
}
.gallery-item.active img { border-color: #2563eb; }
.gallery-item .gallery-active-badge {
  position: absolute; bottom: 2px; left: 2px; z-index: 1;
  background: #2563eb; color: #fff; font: 600 9px/1 sans-serif;
  padding: 2px 4px; border-radius: 3px; letter-spacing: .03em;
  pointer-events: none;
}
.gallery-item .gallery-remove {
  position: absolute; top: -7px; right: -7px; width: 18px; height: 18px;
  border-radius: 50%; background: #b3261e; color: #fff; font-size: 12px;
  line-height: 16px; text-align: center; padding: 0; border: 2px solid #fff;
}
.gallery-item .gallery-remove:hover { background: #8f1e17; }

/* Channel list / picker */
.channel-row {
  display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit;
  background: #fff; border: 1px solid #e2e3e6; border-radius: 8px;
  padding: 14px 16px; margin-bottom: 10px; cursor: pointer;
}
.channel-row:hover { border-color: #2563eb; }
.channel-row-name { font-weight: 600; flex: 1; }
.channel-row-arrow { color: #999; }

/* Channel detail view */
.detail-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap;
}
.back-link { color: #2563eb; text-decoration: none; font-size: 14px; white-space: nowrap; }
.back-link:hover { text-decoration: underline; }

.detail-columns {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start;
}
@media (max-width: 760px) {
  .detail-columns { grid-template-columns: 1fr; }
}

.detail-col-left, .detail-col-right {
  display: flex; flex-direction: column; gap: 20px; min-width: 0;
}
.detail-col-left .panel, .detail-col-right .panel { margin-bottom: 0; }

.preview-panel { padding: 0; overflow: hidden; }
.preview-frame {
  position: relative; width: 100%; aspect-ratio: 16/9; background: #0b0b0d;
  color: #fff; display: flex; align-items: center; justify-content: center;
}
.preview-status-badge {
  position: absolute; top: 12px; left: 12px; z-index: 2;
  font: 600 11px/1 sans-serif; padding: 5px 9px; border-radius: 4px; letter-spacing: .04em;
}
.preview-status-badge.live-badge { background: #e11d2e; color: #fff; }
#detail-offline-badge { background: rgba(255, 255, 255, .15); color: #fff; }
#detail-viewer-badge { top: 12px; right: 12px; left: auto; background: rgba(0, 0, 0, .55); color: #fff; }

#detail-offline-info { width: 100%; max-width: 380px; padding: 24px; }
#detail-offline-info h3 { color: #fff; font-size: 17px; text-align: center; margin: 0 0 6px; }
#detail-offline-info .hint { text-align: center; color: #aaa; margin: 0 0 18px; }
#detail-offline-info label { color: #ccc; }
#detail-offline-info input { background: #1a1a1e; border-color: #333; color: #fff; }

.preview-iframe { width: 100%; height: 100%; border: 0; display: block; }

.outputs-panel-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px;
}
.outputs-panel-header h3 { margin: 0; }
.outputs-panel-header-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.add-output-type-row { display: flex; gap: 8px; flex-wrap: wrap; }
.add-output-type-row button { flex: 1; }

.brand-connect-btn { display: flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }

.privacy-notice { margin-top: 10px; }

.outputs-panel .output-row, .recordings-panel .output-row, .recording-toggle-panel .output-row {
  display: flex; align-items: center; gap: 12px; margin-bottom: 10px;
}
.recordings-panel .output-row { margin-bottom: 14px; }
.recording-toggle-panel .output-row { margin-bottom: 0; }
.recording-row { margin-bottom: 8px; }
.output-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.output-name { font-weight: 600; font-size: 14px; }
.output-url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.output-divider { border: none; border-top: 1px solid #e2e3e6; margin: 16px 0; }

.add-output-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { position: absolute; z-index: 1; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track {
  position: absolute; inset: 0; background: #cfd1d5; border-radius: 22px; transition: background .15s ease;
}
.switch-track::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  background: #fff; border-radius: 50%; transition: transform .15s ease;
}
.switch input:checked + .switch-track { background: #2563eb; }
.switch input:checked + .switch-track::before { transform: translateX(18px); }

.detail-extras { margin-top: 0; }
.detail-extras h3:not(:first-child) { margin-top: 18px; }

/* Stats page */
.stats-filters { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.stats-filters label { font-size: 13px; color: #555; }
.stats-filters select, .stats-filters input[type="date"] {
  font: inherit; padding: 8px 10px; border: 1px solid #cfd1d5; border-radius: 6px; background: #fafafa;
}
.stats-table-panel { overflow: hidden; }
.stats-table-scroll { overflow-x: auto; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.stats-table th, .stats-table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid #eceef1; }
.stats-table th { color: #555; font-weight: 600; }
.stats-table tbody tr:hover { background: #f8f9fb; }

/* Title & description popup */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .5);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-box {
  background: #fff; border-radius: 8px; padding: 20px; width: 100%; max-width: 420px;
  display: flex; flex-direction: column; gap: 12px;
}
.modal-box h3 { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
