:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #090d18;
  color: #f4f6fb;
  --bg: #090d18;
  --surface: #111827;
  --surface-2: #151e30;
  --surface-3: #1b263b;
  --line: #26344d;
  --line-soft: #1c283c;
  --text: #f4f6fb;
  --muted: #8e9ab0;
  --muted-2: #68758c;
  --accent: #8b7cff;
  --accent-soft: #29254d;
  --cyan: #4ed6c8;
  --success: #4dd5a4;
  --danger: #ff7f96;
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% -5%, #20234d 0, transparent 29rem),
    radial-gradient(circle at 92% 5%, #123e48 0, transparent 22rem),
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .025;
  background-image: linear-gradient(#fff 1px, transparent 1px), linear-gradient(90deg, #fff 1px, transparent 1px);
  background-size: 44px 44px;
}

a { color: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 72px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 10px max(24px, calc((100% - 1340px) / 2));
  border-bottom: 1px solid #ffffff12;
  background: #090d18e8;
  backdrop-filter: blur(18px);
}

.brand-mark {
  width: fit-content;
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
}

.brand-mark img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 12px;
  background: #19223a;
  padding: 3px;
}

.brand-mark span,
.user-menu span {
  display: grid;
  gap: 1px;
}

.brand-mark b { font-size: 15px; letter-spacing: -.01em; }
.brand-mark small { color: var(--muted); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: #111827b8;
}

.main-nav a {
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

.main-nav a:hover,
.main-nav a.active {
  color: var(--text);
  background: var(--surface-3);
}

.user-menu {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 15px;
}

.user-menu span { text-align: right; }
.user-menu b { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.user-menu small { max-width: 180px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 11px; }
.user-menu > a { color: var(--muted); font-size: 13px; text-decoration: none; }
.user-menu > a:hover { color: var(--text); }

.app-shell {
  position: relative;
  width: min(100%, 1388px);
  min-height: calc(100vh - 72px);
  margin: 0 auto;
  padding: 46px 24px 72px;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin: 0 0 26px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 14px currentColor;
}

h1 {
  margin: 8px 0 0;
  font-size: clamp(28px, 3.2vw, 44px);
  line-height: 1.06;
  letter-spacing: -.04em;
}

h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -.015em;
}

h3 { margin: 0; }

p, small { color: var(--muted); }
p { line-height: 1.58; }

.tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.tiles article {
  min-height: 124px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: linear-gradient(145deg, #151e30, #101726);
  box-shadow: 0 12px 34px #0002;
}

.tiles strong {
  font-size: clamp(28px, 3vw, 38px);
  line-height: 1;
  letter-spacing: -.04em;
}

.tiles span { color: var(--muted); font-size: 13px; }

.card {
  margin: 16px 0;
  padding: 24px;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background: #111827e8;
  box-shadow: 0 18px 55px #0003;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.panel-head p {
  max-width: 720px;
  margin: 7px 0 0;
  font-size: 13px;
}

.narrow { width: min(100%, 440px); }

.auth-shell .card {
  position: relative;
  overflow: hidden;
  padding: 34px;
  border-color: #33415e;
}

.auth-shell .card::after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  right: -90px;
  top: -90px;
  border-radius: 50%;
  background: #8b7cff26;
  filter: blur(4px);
}

label {
  display: grid;
  gap: 7px;
  margin: 14px 0;
  color: #dce2ed;
  font-size: 13px;
  font-weight: 600;
}

input,
textarea,
select {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: #0b1220;
  color: var(--text);
  padding: 11px 12px;
  font: inherit;
  transition: border-color .18s, box-shadow .18s, background .18s;
}

input:hover,
textarea:hover,
select:hover { border-color: #3b4b6b; }

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px #8b7cff20;
}

textarea { resize: vertical; }

button,
.action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #8b7cff, #6e63eb);
  color: white;
  font: inherit;
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  transition: transform .16s, filter .16s, border-color .16s;
}

button:hover,
.action:hover { filter: brightness(1.08); transform: translateY(-1px); }

.muted {
  border-color: var(--line);
  background: #172135;
  color: #dce2ef;
}

.notice {
  width: min(100%, 700px);
  margin: 0 auto 18px;
  padding: 13px 15px;
  border: 1px solid #665cad;
  border-radius: 12px;
  background: #262347;
}

.row { display: flex; gap: 10px; }
.row input { flex: 1; }
.compact input { min-width: 150px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.scroll {
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: #0c1321;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #121b2c;
  color: #8e9ab0;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .05em;
  text-transform: uppercase;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .15s; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #182237; }

td a,
.back { color: #b8afff; text-decoration: none; }
td a:hover,
.back:hover { color: #d2cdff; }

.platform-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  background: #151f32;
  color: #cbd3e2;
  font-size: 11px;
  font-weight: 750;
  text-transform: capitalize;
}

.video-cell {
  display: grid;
  gap: 5px;
  min-width: 190px;
}

.video-cell > span:first-child {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #e7ebf4;
  font-size: 12px;
}

.video-link {
  width: fit-content;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
}

.video-link:hover { color: #8bf3e8; }
.video-link.unavailable { color: var(--muted-2); font-weight: 500; }

.video-actions {
  min-width: min(100%, 330px);
  display: grid;
  justify-items: end;
  gap: 10px;
}

.url-form {
  display: flex;
  gap: 7px;
  width: 100%;
}

.url-form input {
  flex: 1;
  padding: 9px 10px;
  font-size: 12px;
}

.url-form button {
  padding: 9px 11px;
}

.tag {
  display: inline-flex;
  margin: 3px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #d5d0ff;
  font-size: 12px;
}

.video-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.publication-cover {
  width: 116px;
  height: 150px;
  flex: 0 0 116px;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #0d1524;
}

.publication-cover.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 30px;
  font-weight: 800;
}

.metrics {
  grid-template-columns: repeat(4, 1fr);
  margin: 16px 0;
}

.metrics article { min-height: 112px; }
.metrics small { display: block; margin-top: 7px; }
.up { color: var(--success); }
.down { color: var(--danger); }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 18px 0;
}

.detail-grid div {
  padding: 15px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: #0d1524;
}

.detail-grid span { display: block; color: var(--muted); font-size: 11px; }
.detail-grid b { display: block; margin-top: 7px; font-size: 20px; }

code {
  color: #d8d3ff;
  word-break: break-all;
}

th[tabindex] { cursor: pointer; user-select: none; white-space: nowrap; }
th[tabindex]::after { content: " ↕"; opacity: .35; }
th.sort-asc::after { content: " ↑"; opacity: 1; }
th.sort-desc::after { content: " ↓"; opacity: 1; }

.table-tools {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px auto auto;
  gap: 9px;
  align-items: center;
  margin: 18px 0 12px;
}

.table-tools button { white-space: nowrap; }
.table-count { color: var(--muted); font-size: 12px; text-align: right; }
tr[hidden] { display: none; }

@media (max-width: 900px) {
  .topbar { grid-template-columns: 1fr auto; }
  .main-nav { order: 3; grid-column: 1 / -1; justify-self: center; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 700px) {
  .topbar { padding: 10px 15px; gap: 12px; }
  .brand-mark span, .user-menu span { display: none; }
  .app-shell { padding: 30px 14px 60px; }
  .page-head, .panel-head, .video-head { display: block; }
  .card { padding: 18px; border-radius: 15px; }
  .tiles, .grid { grid-template-columns: 1fr 1fr; }
  .metrics, .detail-grid { grid-template-columns: 1fr 1fr; }
  .row { display: grid; }
  .table-tools { grid-template-columns: 1fr; }
  .table-count { text-align: left; }
  .video-actions { justify-items: start; margin-top: 18px; }
}

@media (max-width: 440px) {
  .tiles, .metrics, .detail-grid { grid-template-columns: 1fr; }
  .main-nav { width: 100%; }
  .main-nav a { flex: 1; text-align: center; }
}
