:root {
  color-scheme: dark;
  --bg: #07111f;
  --bg-2: #0b1729;
  --panel: rgba(15, 29, 49, 0.82);
  --panel-strong: #10213a;
  --text: #eef6ff;
  --muted: #91a4bc;
  --line: rgba(255, 255, 255, 0.12);
  --primary: #48e5b3;
  --primary-2: #4ea8ff;
  --warning: #ffd166;
  --danger: #ff6b7a;
  --ok: #4ade80;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  --radius: 24px;
  --radius-sm: 14px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(72, 229, 179, 0.22), transparent 34rem),
    radial-gradient(circle at top right, rgba(78, 168, 255, 0.2), transparent 28rem),
    linear-gradient(135deg, #07111f 0%, #0b1729 45%, #07111f 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(to bottom, black, transparent 80%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

code {
  padding: 0.15rem 0.38rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  color: #ddfff5;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1400px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 56px;
}

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(72, 229, 179, 0.9), rgba(78, 168, 255, 0.85));
  color: #061120;
  font-weight: 900;
  box-shadow: 0 18px 60px rgba(72, 229, 179, 0.22);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  letter-spacing: -0.02em;
}

.brand small {
  color: var(--muted);
  margin-top: 2px;
}

.top-actions,
.toolbar-actions,
.hero-links,
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.primary,
.secondary,
.ghost,
.link-button,
.icon-button {
  border: 0;
  border-radius: 999px;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 750;
  letter-spacing: -0.01em;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #04101c;
  box-shadow: 0 14px 38px rgba(72, 229, 179, 0.18);
}

.secondary {
  color: var(--text);
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--line);
}

.ghost,
.link-button {
  color: var(--text);
  background: rgba(255,255,255,0.04);
  border: 1px solid transparent;
}

.link-button {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.icon-button {
  width: 42px;
  padding: 0;
  color: var(--text);
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--line);
}

.primary:hover,
.secondary:hover,
.ghost:hover,
.link-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: stretch;
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(16, 33, 58, 0.82), rgba(15, 29, 49, 0.58));
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

.hero::after {
  content: "";
  position: absolute;
  right: -80px;
  top: -90px;
  width: 260px;
  height: 260px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(72, 229, 179, 0.2), transparent 70%);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 800px;
  margin-bottom: 14px;
  font-size: clamp(2.1rem, 5vw, 4.7rem);
  line-height: 0.95;
  letter-spacing: -0.075em;
}

h2 {
  margin-bottom: 4px;
  letter-spacing: -0.04em;
}

.hero-copy {
  max-width: 770px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.7;
}

.hero-links a {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  color: #dffdf5;
  background: rgba(72, 229, 179, 0.1);
  border: 1px solid rgba(72, 229, 179, 0.24);
  text-decoration: none;
  font-weight: 800;
}

.status-panel {
  display: grid;
  align-content: end;
  gap: 8px;
  min-height: 220px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(4, 15, 28, 0.55);
  position: relative;
  z-index: 1;
}

.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--warning);
  box-shadow: 0 0 24px var(--warning);
}

.status-dot.ok {
  background: var(--ok);
  box-shadow: 0 0 24px var(--ok);
}

.status-dot.error {
  background: var(--danger);
  box-shadow: 0 0 24px var(--danger);
}

.status-label {
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
}

.status-panel strong {
  font-size: 1.28rem;
}

.status-panel small {
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin: 18px 0;
}

.stat-card,
.table-card,
.notice {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  backdrop-filter: blur(18px);
}

.stat-card {
  padding: 20px;
}

.stat-card span,
.stat-card small {
  display: block;
  color: var(--muted);
}

.stat-card strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 2rem;
  letter-spacing: -0.06em;
}

.workspace {
  display: grid;
  gap: 16px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(9, 22, 39, 0.68);
  backdrop-filter: blur(18px);
}

.searchbox {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(520px, 100%);
  flex: 1;
  padding-left: 14px;
  color: var(--muted);
}

.searchbox input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.searchbox input::placeholder,
textarea::placeholder,
input::placeholder {
  color: rgba(145, 164, 188, 0.72);
}

.notice {
  padding: 14px 18px;
  color: #ffeeb2;
  background: rgba(255, 209, 102, 0.1);
  border-color: rgba(255, 209, 102, 0.24);
}

.table-card {
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.table-header p {
  margin: 0;
  color: var(--muted);
}

.badge,
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: #ddfff5;
  border: 1px solid rgba(72, 229, 179, 0.22);
  background: rgba(72, 229, 179, 0.1);
  font-size: 0.78rem;
  font-weight: 850;
}

.badge.warn {
  color: #ffeeb2;
  border-color: rgba(255, 209, 102, 0.24);
  background: rgba(255, 209, 102, 0.1);
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 15px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(255,255,255,0.03);
}

tr:hover td {
  background: rgba(255,255,255,0.025);
}

.channel-main {
  display: grid;
  gap: 4px;
}

.channel-main strong {
  display: flex;
  align-items: center;
  gap: 8px;
}

.channel-main small,
.stream-cell small {
  color: var(--muted);
}

.stream-cell {
  display: grid;
  gap: 5px;
  max-width: 480px;
}

.stream-url {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #dfefff;
}

.row-actions,
.order-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.row-actions button,
.order-actions button {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(255,255,255,0.06);
  font-weight: 800;
}

.row-actions .danger {
  color: #ffd4d9;
  border-color: rgba(255, 107, 122, 0.25);
  background: rgba(255, 107, 122, 0.1);
}

.empty-state {
  padding: 36px 24px 48px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  display: block;
  color: var(--text);
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.modal-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(3, 8, 16, 0.72);
  backdrop-filter: blur(16px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(780px, 100%);
  max-height: min(900px, calc(100vh - 40px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #0c192d;
  box-shadow: 0 28px 120px rgba(0, 0, 0, 0.55);
  padding: 24px;
}

.modal.small {
  width: min(520px, 100%);
}

.modal.wide {
  width: min(1040px, 100%);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 18px;
}

.muted {
  color: var(--muted);
  line-height: 1.65;
}

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

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

.form-grid label {
  display: grid;
  gap: 7px;
  color: #d7e7f7;
  font-weight: 800;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 14px;
  color: var(--text);
  background: rgba(255,255,255,0.06);
  outline: 0;
}

input,
select {
  min-height: 46px;
  padding: 0 13px;
}

textarea {
  resize: vertical;
  min-height: 92px;
  padding: 12px 13px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(72, 229, 179, 0.7);
  box-shadow: 0 0 0 4px rgba(72, 229, 179, 0.11);
}

.checkbox-row {
  grid-auto-flow: column;
  grid-template-columns: auto 1fr;
  align-items: center;
  justify-content: start;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
}

.checkbox-row input {
  width: 18px;
  min-height: 18px;
}

.form-actions {
  justify-content: flex-end;
  margin-top: 8px;
}

.code-block {
  max-height: 60vh;
  overflow: auto;
  margin: 0;
  padding: 18px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 18px;
  background: #06101e;
  color: #d9fff5;
  font-size: 0.92rem;
  line-height: 1.55;
}

.import-box {
  display: grid;
  gap: 12px;
}

.toast {
  position: fixed;
  z-index: 30;
  right: 24px;
  bottom: 24px;
  max-width: 420px;
  padding: 14px 16px;
  border: 1px solid rgba(72, 229, 179, 0.24);
  border-radius: 16px;
  color: #ddfff5;
  background: rgba(10, 23, 40, 0.95);
  box-shadow: var(--shadow);
}

.toast.error {
  color: #ffd4d9;
  border-color: rgba(255, 107, 122, 0.32);
}

@media (max-width: 980px) {
  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
    border-radius: 22px;
  }

  .hero {
    grid-template-columns: 1fr;
    padding: 26px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .searchbox {
    width: 100%;
    min-width: 0;
    min-height: 46px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1400px);
    padding-top: 14px;
  }

  .top-actions,
  .toolbar-actions,
  .hero-links,
  .form-actions {
    width: 100%;
  }

  .top-actions > *,
  .toolbar-actions > *,
  .hero-links > *,
  .form-actions > * {
    flex: 1 1 auto;
    justify-content: center;
  }

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

  h1 {
    font-size: clamp(2.2rem, 15vw, 3.2rem);
  }

  .modal {
    padding: 18px;
  }
}
