:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --line: #d9e0ea;
  --text: #172033;
  --muted: #667085;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --red: #dc2626;
  --green: #15803d;
  --shadow: 0 8px 24px rgba(20, 31, 53, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.topbar {
  display: grid;
  gap: 14px;
  padding: 16px 28px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-main {
  align-items: center;
  display: flex;
  gap: 20px;
  justify-content: space-between;
}

.topbar-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.tabbar {
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.tab {
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  color: var(--muted);
  font-weight: 700;
  padding: 10px 16px;
  text-decoration: none;
  white-space: nowrap;
}

.tab.active {
  background: var(--bg);
  border-color: var(--line);
  color: var(--blue-dark);
}

.user-label {
  color: var(--muted);
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 700;
}

h2 {
  font-size: 17px;
  font-weight: 700;
}

p,
dt {
  color: var(--muted);
}

.status {
  border-radius: 999px;
  font-weight: 700;
  padding: 8px 14px;
  white-space: nowrap;
}

.status-running {
  background: #dcfce7;
  color: var(--green);
}

.status-stopped {
  background: #fee2e2;
  color: var(--red);
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 20px;
  padding: 20px;
}

.full-span {
  grid-column: 1 / -1;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.controls {
  align-self: start;
}

.history {
  grid-column: 1 / -1;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  margin-bottom: 16px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

button,
.button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-weight: 700;
  padding: 8px 14px;
  text-decoration: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.primary:hover:not(:disabled) {
  background: var(--blue-dark);
}

.danger {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.meta {
  display: grid;
  gap: 12px;
  margin: 0;
}

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

.meta div {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.compact-meta div {
  align-content: start;
}

dt,
dd {
  margin: 0;
}

.mono {
  font-family: Consolas, "Courier New", monospace;
  overflow-wrap: anywhere;
}

.config-form {
  display: grid;
  gap: 14px;
}

.channel-add-form {
  margin-bottom: 14px;
}

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

.channel-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.channel-pill {
  align-items: center;
  background: #eef4ff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  display: inline-flex;
  gap: 8px;
  padding: 4px 4px 4px 12px;
}

.channel-pill span {
  color: var(--blue-dark);
  font-weight: 700;
}

.channel-pill button {
  border-radius: 999px;
  font-size: 12px;
  min-height: 28px;
  padding: 4px 10px;
}

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

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

.broadcaster-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  display: grid;
  gap: 12px;
  padding: 16px;
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.broadcaster-card:hover,
.broadcaster-card.active {
  border-color: var(--blue);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.12);
}

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

.broadcaster-card h3 {
  font-size: 18px;
  margin: 0;
}

.live-badge {
  background: #dcfce7;
  border-radius: 999px;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
}

.card-meta {
  display: grid;
  gap: 10px;
  margin: 0;
}

.card-meta div {
  display: grid;
  gap: 3px;
}

.card-meta dd {
  overflow-wrap: anywhere;
}

.notice {
  border-left: 4px solid var(--blue);
}

.notice.error {
  border-left-color: var(--red);
  color: var(--red);
  font-weight: 700;
}

.login-page {
  min-height: 100vh;
}

.login-shell {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-panel {
  max-width: 420px;
  width: 100%;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

input,
textarea {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  padding: 8px 10px;
}

textarea {
  resize: vertical;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

.nowrap {
  white-space: nowrap;
}

.empty {
  color: var(--muted);
  text-align: center;
}

@media (max-width: 900px) {
  .topbar-main {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .layout {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }
}
