:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #edf3f8;
  --muted: #8fa1ad;
  --line: #253541;
  --surface: #0b1117;
  --panel: #121b23;
  --panel-2: #17232d;
  --panel-3: #1d2b36;
  --accent: #14b8a6;
  --accent-dark: #0f766e;
  --danger: #ef4444;
  --danger-dark: #b91c1c;
  --shadow: 0 18px 40px rgb(0 0 0 / 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  color: var(--ink);
  background: var(--surface);
  display: grid;
  grid-template-columns: 244px 1fr;
  overflow: hidden;
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #04201d;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 800;
}

button:hover {
  background: #2dd4bf;
}

.sidebar {
  background: #080d12;
  border-right: 1px solid var(--line);
  color: #fff;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  font-size: 22px;
  font-weight: 900;
  margin: 0 8px 18px;
}

.nav {
  background: transparent;
  color: #9eb0bd;
  text-align: left;
  min-height: 42px;
}

.nav.active,
.nav:hover {
  background: var(--panel-3);
  color: #fff;
}

.nav.subtle {
  margin-top: auto;
}

.shell {
  padding: 28px;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
}

.hidden {
  display: none !important;
}

.login-card,
.panel,
.form-page,
.form-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.login-card {
  width: min(420px, 100%);
  padding: 24px;
  margin: 10vh auto;
}

.topbar,
.form-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

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

.form-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.topbar-actions select {
  width: 180px;
}

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

h1 {
  margin-bottom: 4px;
}

h2 {
  font-size: 18px;
  margin-bottom: 14px;
}

h3 {
  margin-bottom: 8px;
}

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

.helper-text {
  color: var(--muted);
  font-size: 12px;
  margin: 2px 0 0;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  font-weight: 750;
  color: #c9d5dd;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #0d151c;
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 2px solid rgb(20 184 166 / 0.18);
}

textarea {
  resize: vertical;
}

.match-grid,
.card-grid {
  display: grid;
  gap: 16px;
}

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

.card-grid {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.match-card,
.media-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  overflow: visible;
  box-shadow: var(--shadow);
}

.match-card {
  padding: 16px;
}

.match-league {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
  min-height: 30px;
  padding-right: 36px;
}

.league-logo,
.team-logo,
.channel-logo,
.thumb {
  object-fit: cover;
  background: var(--panel-3);
}

.league-logo {
  width: 26px;
  height: 26px;
  border-radius: 50%;
}

.teams {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin: 18px 0;
}

.team {
  display: grid;
  justify-items: center;
  gap: 9px;
  text-align: center;
  min-width: 0;
}

.team strong,
.match-league span,
.media-card h3 {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-league span {
  min-width: 0;
}

.team strong {
  width: 100%;
}

.team-logo {
  width: 58px;
  height: 58px;
  border-radius: 50%;
}

.versus {
  min-width: 42px;
  padding: 8px 9px;
  border-radius: 6px;
  background: rgb(20 184 166 / 0.13);
  color: #5eead4;
  text-align: center;
  font-weight: 900;
}

.match-meta,
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.match-meta span,
.pill-row span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  background: #0d151c;
}

.media-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.poster,
.banner-image {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--panel-3);
}

.channel-card {
  padding: 16px;
  align-items: center;
  text-align: center;
}

.channel-logo {
  width: 88px;
  height: 88px;
  border-radius: 18px;
  margin-bottom: 12px;
}

.placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 900;
}

.media-body {
  padding: 14px;
}

.media-body p,
.match-card p {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.kebab {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
}

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: #0d151c;
  color: var(--ink);
  line-height: 1;
}

.icon-button:hover {
  background: var(--panel-3);
}

.menu {
  display: none;
  position: absolute;
  top: 40px;
  right: 0;
  min-width: 130px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d151c;
  box-shadow: var(--shadow);
}

.menu.open {
  display: grid;
}

.menu button {
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 9px 10px;
}

.menu button:hover {
  background: var(--panel-3);
}

.menu .menu-danger {
  color: #fca5a5;
}

.ghost {
  background: var(--panel-3);
  color: var(--ink);
}

.ghost:hover {
  background: #263946;
}

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

.danger:hover {
  background: var(--danger);
}

.empty-state {
  border: 1px dashed var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 30px;
  color: var(--muted);
}

.empty-state.compact {
  padding: 16px;
}

.form-page {
  padding: 0;
  border: 0;
  background: transparent;
}

.form-section {
  padding: 20px;
  margin-bottom: 16px;
}

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

.section-title,
.link-summary,
.row-actions,
.form-actions,
.actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-title,
.link-summary,
.form-actions,
.actions {
  justify-content: space-between;
}

.links-list {
  display: grid;
  gap: 10px;
}

.link-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #0d151c;
}

.link-summary strong,
.link-summary span {
  display: block;
  overflow-wrap: anywhere;
}

.link-summary span {
  color: var(--muted);
  margin-top: 4px;
}

.form-actions {
  padding: 4px 0 20px;
}

.check {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
}

.check input {
  width: auto;
}

.error {
  color: #fca5a5;
  min-height: 20px;
}

dialog {
  width: min(720px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgb(0 0 0 / 0.62);
}

dialog form {
  padding: 24px;
}

@media (max-width: 1120px) {
  .match-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  body {
    grid-template-columns: 1fr;
    height: auto;
    overflow: auto;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 12px;
    height: auto;
  }

  .brand {
    margin: 0 8px 0 0;
    font-size: 18px;
    white-space: nowrap;
  }

  .shell {
    padding: 16px;
    height: auto;
    overflow: visible;
  }

  .topbar,
  .topbar-actions,
  .form-head-actions,
  .form-page-head,
  .grid,
  .match-grid,
  .section-title,
  .link-summary,
  .form-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .topbar-actions select {
    width: 100%;
  }
}
