* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg: #0b1117;
  --panel: #121b24;
  --panel-soft: #172230;
  --border: #283747;
  --text: #e8eef5;
  --muted: #91a2b6;
  --field-bg: #0e1620;
  --field-border: #344456;
  --field-text: #f4f7fb;
  --button-bg: #1b2938;
  --button-hover: #243548;
  --button-border: #3a4c60;
  --primary: #11a37f;
  --primary-hover: #0d8f70;
  --danger: #d04437;
  --danger-hover: #b9382f;
  --ok: #36d399;
  --error: #ff6b5f;
  --log-bg: #060a0f;
  --log-text: #c9ffe9;
  --shadow: 0 12px 30px rgba(0, 0, 0, .24);
}

body.light {
  color-scheme: light;
  --bg: #eef4f8;
  --panel: #ffffff;
  --panel-soft: #f6fafc;
  --border: #d8e3ec;
  --text: #102033;
  --muted: #4f6379;
  --field-bg: #ffffff;
  --field-border: #c7d5e4;
  --field-text: #0f1f31;
  --button-bg: #f7fafc;
  --button-hover: #eaf2f8;
  --button-border: #b7c8d9;
  --primary: #0d8a7a;
  --primary-hover: #087567;
  --danger: #b42318;
  --danger-hover: #9f1f17;
  --ok: #087443;
  --error: #b42318;
  --log-bg: #101820;
  --log-text: #d7f5e8;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05);
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(37, 99, 235, .34), rgba(14, 165, 233, .16) 150px, transparent 330px),
    var(--bg);
}

body.light {
  background:
    linear-gradient(180deg, rgba(37, 99, 235, .18), rgba(14, 165, 233, .08) 150px, transparent 330px),
    var(--bg);
}

.shell {
  width: min(1420px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border-right: 1px solid var(--border);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--panel) 94%, transparent), color-mix(in srgb, var(--bg) 96%, transparent)),
    radial-gradient(circle at 20% 0%, color-mix(in srgb, var(--primary) 18%, transparent), transparent 42%);
}

body.light .sidebar {
  background:
    linear-gradient(180deg, #ffffff 0%, #f3f8fb 58%, #eef5f9 100%),
    radial-gradient(circle at 0% 0%, rgba(13, 138, 122, .18), transparent 34%);
  box-shadow: 8px 0 28px rgba(29, 54, 78, .07);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #4b71f5);
  color: white;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: 0 12px 26px color-mix(in srgb, var(--primary) 26%, transparent);
}

body.light .brand-mark {
  background: linear-gradient(135deg, #0d8a7a, #3b82f6);
  box-shadow: 0 12px 28px rgba(13, 138, 122, .22);
}

.brand h1 {
  font-size: 16px;
}

.brand p {
  margin: 2px 0 0;
  font-size: 11px;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  justify-content: flex-start;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  text-align: left;
  color: var(--muted);
  font-size: 14px;
  position: relative;
  overflow: hidden;
  transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease, color .16s ease;
}

body.light .nav-item {
  background: rgba(255, 255, 255, .66);
}

.nav-item svg {
  width: 28px;
  height: 28px;
  padding: 5px;
  border-radius: 8px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  background: color-mix(in srgb, currentColor 12%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08);
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}

.nav-item:hover {
  transform: translateX(2px);
  color: var(--text);
  border-color: color-mix(in srgb, #60a5fa 48%, var(--button-border));
}

.nav-item:hover svg {
  transform: scale(1.06);
  background: rgba(96, 165, 250, .14);
}

.nav-item.is-active {
  color: #ffffff;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, .95), rgba(14, 165, 233, .88)),
    var(--button-bg);
  border-color: rgba(59, 130, 246, .9);
  box-shadow:
    0 0 0 1px rgba(96, 165, 250, .16) inset,
    0 12px 28px rgba(37, 99, 235, .26),
    0 0 28px rgba(14, 165, 233, .24);
}

.nav-item.is-active svg {
  background: rgba(255, 255, 255, .18);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .24),
    0 0 18px rgba(255, 255, 255, .18);
}

body.light .nav-item::before {
  content: "";
  width: 4px;
  align-self: stretch;
  margin: -7px 0 -7px -10px;
  border-radius: 6px;
  background: var(--nav-accent, var(--primary));
  opacity: .55;
}

body.light .nav-item[data-view="dashboard"] {
  --nav-accent: #0d9488;
}

body.light .nav-item[data-view="channels"] {
  --nav-accent: #2563eb;
}

body.light .nav-item[data-view="movies"] {
  --nav-accent: #d97706;
}

body.light .nav-item[data-view="series"] {
  --nav-accent: #7c3aed;
}

body.light .nav-item[data-view="epg-sync"] {
  --nav-accent: #0ea5e9;
}

body.light .nav-item[data-view="cleanup"] {
  --nav-accent: #dc2626;
}

body.light .nav-item[data-view="xui-db"] {
  --nav-accent: #0891b2;
}

body.light .nav-item[data-view="config"] {
  --nav-accent: #475569;
}

body.light .nav-item.is-active {
  color: #ffffff;
  background:
    linear-gradient(135deg, #1d4ed8, #0ea5e9 72%, #22d3ee),
    #2563eb;
  border-color: #60a5fa;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, .28) inset,
    0 14px 28px rgba(37, 99, 235, .28),
    0 0 32px rgba(14, 165, 233, .28);
}

body.light .nav-item.is-active::before {
  opacity: 1;
  background: #bfdbfe;
}

.sidebar-footer {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.sidebar-footer button {
  min-height: 38px;
  padding: 7px 10px;
}

.content-shell {
  min-width: 0;
  padding: 24px;
}

.login-shell {
  --login-bg: #050b16;
  --login-panel: rgba(9, 17, 31, .88);
  --login-border: rgba(96, 165, 250, .34);
  --login-text: #eaf6ff;
  --login-muted: #a6b8d1;
  --login-field: rgba(7, 14, 27, .92);
  --login-field-border: rgba(96, 165, 250, .32);
  --login-blue: #2563eb;
  --login-cyan: #22d3ee;
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  isolation: isolate;
  color: var(--login-text);
  background:
    radial-gradient(circle at 18% 0%, rgba(34, 211, 238, .20), transparent 34%),
    radial-gradient(circle at 88% 18%, rgba(37, 99, 235, .26), transparent 36%),
    linear-gradient(180deg, #0a1220 0%, var(--login-bg) 72%);
}

.login-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(rgba(34, 211, 238, .08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(96, 165, 250, .07) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, transparent 0%, #000 18%, #000 82%, transparent 100%);
}

.login-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(120deg, rgba(34, 211, 238, .14), transparent 34%),
    linear-gradient(300deg, rgba(37, 99, 235, .18), transparent 38%),
    linear-gradient(180deg, rgba(255, 255, 255, .18), transparent 18%);
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  position: relative;
  overflow: hidden;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(15, 27, 46, .95), var(--login-panel)),
    linear-gradient(135deg, rgba(34, 211, 238, .14), rgba(37, 99, 235, .08));
  border-color: var(--login-border);
  box-shadow:
    0 24px 70px rgba(0, 0, 0, .46),
    0 0 48px rgba(37, 99, 235, .18),
    inset 0 1px 0 rgba(255, 255, 255, .06);
  backdrop-filter: blur(18px);
}

.login-card::before {
  display: none;
}

.login-card h1 {
  font-size: 34px;
  color: var(--login-text);
  text-shadow: 0 0 18px rgba(34, 211, 238, .28);
}

.login-card p {
  font-size: 15px;
  line-height: 1.45;
  color: var(--login-muted);
}

.login-card label {
  color: var(--login-muted);
}

.login-card input {
  color: var(--login-text);
  background: var(--login-field);
  border-color: var(--login-field-border);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .02);
}

.login-card input:focus {
  border-color: rgba(34, 211, 238, .78);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, .13);
}

.login-card .field-icon,
.login-card .icon-button {
  color: #93b4df;
}

.login-card .icon-button:hover {
  color: var(--login-cyan);
  background: rgba(34, 211, 238, .08);
}

.login-card .primary {
  color: #f8fbff;
  background: linear-gradient(135deg, var(--login-blue), #0891b2);
  border-color: rgba(125, 211, 252, .55);
  box-shadow:
    0 14px 32px rgba(37, 99, 235, .32),
    inset 0 1px 0 rgba(255, 255, 255, .16);
}

.login-card .primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.login-card.is-loading {
  border-color: rgba(34, 211, 238, .76);
}

.login-card.is-loading .primary {
  opacity: .86;
  cursor: wait;
}

.login-progress {
  display: grid;
  gap: 8px;
  opacity: 0;
  transform: translateY(-6px);
  max-height: 0;
  overflow: hidden;
  transition: opacity .22s ease, transform .22s ease, max-height .22s ease;
}

.login-progress.is-active {
  opacity: 1;
  transform: translateY(0);
  max-height: 56px;
}

.operation-progress {
  display: grid;
  gap: 8px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-4px);
  transition: opacity .2s ease, transform .2s ease, max-height .2s ease;
}

.operation-progress.is-active {
  max-height: 54px;
  opacity: 1;
  transform: translateY(0);
  margin-top: 2px;
}

.operation-progress-label {
  color: color-mix(in srgb, #0ea5e9 72%, var(--text));
  font-size: 13px;
  font-weight: 800;
}

.operation-progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, #0ea5e9 36%, var(--border));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--field-bg) 86%, #0ea5e9), var(--field-bg));
}

.operation-progress-bar {
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, #38bdf8, #2563eb, #22d3ee, transparent);
  box-shadow: 0 0 20px rgba(14, 165, 233, .42);
  animation: operation-progress-scan 1.05s ease-in-out infinite;
}

@keyframes operation-progress-scan {
  0% {
    transform: translateX(-115%);
  }

  100% {
    transform: translateX(250%);
  }
}

.progress-label {
  font-size: 13px;
  font-weight: 700;
  color: #a5f3fc;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(7, 14, 27, .94);
  border: 1px solid rgba(34, 211, 238, .32);
}

.progress-bar {
  width: 46%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, #60a5fa, var(--login-cyan), transparent);
  animation: login-progress-scan 1.05s ease-in-out infinite;
}

@keyframes login-progress-scan {
  0% {
    transform: translateX(-110%);
  }

  100% {
    transform: translateX(245%);
  }
}

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

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

.theme-toggle {
  width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
}

.theme-toggle svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle .theme-sun {
  display: none;
}

.theme-toggle.is-light .theme-sun {
  display: block;
}

.theme-toggle.is-light .theme-moon {
  display: none;
}

h1, h2, p {
  margin: 0;
}

h1 {
  font-size: 28px;
}

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

p {
  color: var(--muted);
  margin-top: 5px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, .75fr);
  gap: 16px;
}

.view-panel {
  display: none;
}

.view-panel.is-active {
  display: block;
}

.sync-kind {
  margin: -4px 0 14px;
  font-weight: 700;
  color: color-mix(in srgb, var(--primary) 74%, var(--text));
}

body[data-sync-view="channels"] .vod-only {
  display: none;
}

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

body.light .panel {
  border-color: #d5e2ed;
  box-shadow: 0 16px 34px rgba(21, 45, 70, .08);
}

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

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

.secondary-metrics {
  margin-top: 12px;
}

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

.metric-card {
  min-height: 112px;
  display: grid;
  align-content: space-between;
  gap: 12px;
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--metric-color, var(--border)) 42%, var(--border));
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--metric-color, var(--primary)) 28%, var(--panel-soft)), var(--field-bg) 76%),
    linear-gradient(180deg, color-mix(in srgb, var(--metric-color, var(--primary)) 22%, transparent), transparent);
  box-shadow:
    0 16px 32px color-mix(in srgb, var(--metric-color, var(--primary)) 16%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, .08);
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--metric-color) 72%, white), var(--metric-color));
  box-shadow: 0 0 22px color-mix(in srgb, var(--metric-color) 42%, transparent);
}

.metric-card::after {
  content: "";
  position: absolute;
  inset: auto 14px 14px auto;
  width: 62px;
  height: 62px;
  border-radius: 999px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--metric-color, var(--primary)) 52%, white), color-mix(in srgb, var(--metric-color, var(--primary)) 24%, transparent));
  box-shadow:
    0 16px 34px color-mix(in srgb, var(--metric-color, var(--primary)) 22%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, .38);
  opacity: .72;
}

.metric-card:nth-child(1) {
  --metric-color: #2563eb;
}

.metric-card:nth-child(2) {
  --metric-color: #d97706;
}

.metric-card:nth-child(3) {
  --metric-color: #7c3aed;
}

.metric-card:nth-child(4) {
  --metric-color: #0891b2;
}

.secondary-metrics .metric-card:nth-child(1) {
  --metric-color: #0284c7;
}

.secondary-metrics .metric-card:nth-child(2) {
  --metric-color: #ea580c;
}

.secondary-metrics .metric-card:nth-child(3) {
  --metric-color: #9333ea;
}

.secondary-metrics .metric-card:nth-child(4) {
  --metric-color: #059669;
}

.epg-metrics .metric-card:nth-child(1) {
  --metric-color: #0ea5e9;
}

.epg-metrics .metric-card:nth-child(2) {
  --metric-color: #14b8a6;
}

.epg-metrics .metric-card:nth-child(3) {
  --metric-color: #22c55e;
}

.epg-metrics .metric-card:nth-child(4) {
  --metric-color: #ef4444;
}

body.light .metric-card {
  border-color: color-mix(in srgb, var(--metric-color) 36%, #d8e3ec);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--metric-color) 22%, white), #ffffff 68%),
    linear-gradient(180deg, color-mix(in srgb, var(--metric-color) 12%, transparent), transparent),
    #ffffff;
  box-shadow:
    0 18px 36px color-mix(in srgb, var(--metric-color) 16%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, .82);
}

.metric-card.compact {
  min-height: 84px;
}

.metric-label {
  color: color-mix(in srgb, var(--metric-color, var(--muted)) 76%, var(--text));
  font-size: 13px;
  font-weight: 800;
  position: relative;
  z-index: 1;
}

.metric-card strong {
  color: color-mix(in srgb, var(--metric-color, var(--text)) 82%, var(--text));
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0;
  position: relative;
  z-index: 1;
  text-shadow: 0 8px 22px color-mix(in srgb, var(--metric-color, var(--primary)) 18%, transparent);
}

.metric-card.compact strong {
  font-size: 24px;
}

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

.run-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.compact-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.compact-field {
  align-self: start;
}

.compact-field select {
  min-height: 38px;
}

.list-grid {
  align-items: start;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

input, select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--field-border);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  background: var(--field-bg);
  color: var(--field-text);
}

body.light input,
body.light select {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .72);
}

.input-wrap {
  position: relative;
  display: block;
}

.secret-wrap {
  position: relative;
  display: block;
}

.input-wrap input {
  padding-left: 42px;
}

.input-wrap input[name="password"],
.secret-wrap input {
  padding-right: 48px;
}

.field-icon,
.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.field-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.icon-button {
  position: absolute;
  right: 6px;
  top: 50%;
  width: 36px;
  min-height: 32px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.icon-button:hover {
  background: var(--button-hover);
  color: var(--text);
}

.icon-button .eye-closed {
  display: none;
}

.icon-button.is-visible .eye-open {
  display: none;
}

.icon-button.is-visible .eye-closed {
  display: block;
}

input:focus, select:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent);
  outline-offset: 1px;
}

select[multiple] {
  min-height: 154px;
}

.sync-actions {
  margin: 14px 0 18px;
}

.check-list {
  min-height: 180px;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--field-border);
  border-radius: 6px;
  padding: 8px;
  background: var(--field-bg);
}

.list-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.mini-button {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12px;
  background: color-mix(in srgb, var(--button-bg) 82%, var(--primary));
}

.check-row {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--field-text);
  cursor: pointer;
}

.check-row:hover {
  background: var(--button-hover);
}

.check-row input {
  width: 18px;
  min-height: 18px;
  flex: 0 0 auto;
  accent-color: var(--primary);
}

.check-empty {
  padding: 10px;
  color: var(--muted);
}

.epg-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.epg-summary-card {
  min-height: 72px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, #0ea5e9 24%, var(--border));
  border-radius: 8px;
  background:
    linear-gradient(135deg, color-mix(in srgb, #0ea5e9 18%, var(--panel-soft)), var(--field-bg));
}

body.light .epg-summary-card {
  background: linear-gradient(135deg, color-mix(in srgb, #0ea5e9 14%, white), #ffffff);
  box-shadow: 0 12px 26px rgba(14, 165, 233, .10);
}

.epg-summary-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.epg-summary-card strong {
  color: color-mix(in srgb, #0ea5e9 76%, var(--text));
  font-size: 24px;
}

.epg-preview {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--field-border);
  border-radius: 8px;
  background: var(--field-bg);
}

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.epg-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.epg-table th,
.epg-table td {
  padding: 10px 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 76%, transparent);
  text-align: left;
  vertical-align: top;
}

.epg-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: var(--panel-soft);
}

.epg-table small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.epg-table .match-high td {
  background: color-mix(in srgb, var(--ok) 10%, transparent);
}

.epg-table .match-medium td {
  background: color-mix(in srgb, #f59e0b 10%, transparent);
}

.epg-table .match-low td,
.epg-table .match-unmatched td {
  background: color-mix(in srgb, var(--error) 7%, transparent);
}

.check-inline {
  min-height: 38px;
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.check-inline input {
  width: 18px;
  min-height: 18px;
  flex: 0 0 auto;
  accent-color: var(--primary);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

button {
  min-height: 38px;
  border: 1px solid var(--button-border);
  border-radius: 6px;
  padding: 8px 14px;
  background: var(--button-bg);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

body.light button {
  box-shadow: 0 8px 18px rgba(35, 62, 90, .06);
}

button:hover {
  background: var(--button-hover);
}

.primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

body.light .primary {
  background: linear-gradient(135deg, #0d8a7a, #0ea5a0);
  border-color: #0d8a7a;
  box-shadow: 0 12px 24px rgba(13, 138, 122, .22);
}

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

.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

body.light .danger {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  border-color: #dc2626;
  box-shadow: 0 12px 24px rgba(220, 38, 38, .18);
}

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

.stop-button {
  background: color-mix(in srgb, var(--danger) 16%, var(--button-bg));
  border-color: color-mix(in srgb, var(--danger) 55%, var(--button-border));
  color: var(--text);
}

body.light .stop-button {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #9a3412;
}

.stop-button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--danger) 30%, var(--button-bg));
}

button:disabled {
  opacity: .48;
  cursor: not-allowed;
}

button:disabled:hover {
  background: var(--button-bg);
}

.status {
  min-height: 22px;
  margin-top: 12px;
  font-weight: 700;
}

.status.ok {
  color: var(--ok);
}

.status.error {
  color: var(--error);
}

.toast {
  position: fixed;
  right: 32px;
  top: 96px;
  z-index: 20;
  max-width: min(460px, calc(100vw - 32px));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border: 1px solid color-mix(in srgb, var(--ok) 68%, white);
  border-radius: 8px;
  background: linear-gradient(135deg, #0f9f75, #16b889);
  color: #ffffff;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 20px 60px rgba(15, 159, 117, .36), 0 12px 30px rgba(0, 0, 0, .34);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-12px);
  transition: opacity .2s ease, transform .2s ease;
}

.toast-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(255, 255, 255, .18);
  color: #ffffff;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: linear-gradient(135deg, #c9372c, #e05346);
  border-color: color-mix(in srgb, var(--error) 74%, white);
  box-shadow: 0 20px 60px rgba(201, 55, 44, .34), 0 12px 30px rgba(0, 0, 0, .34);
}

.logs-panel {
  margin-top: 16px;
}

body[data-sync-view="dashboard"] .logs-panel,
body[data-sync-view="config"] .logs-panel,
body[data-sync-view="xui-db"] .logs-panel,
body[data-sync-view="epg-sync"] .logs-panel {
  display: none;
}

.logs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

pre {
  margin: 0;
  min-height: 320px;
  max-height: 520px;
  overflow: auto;
  padding: 14px;
  border-radius: 6px;
  background: var(--log-bg);
  color: var(--log-text);
  white-space: pre-wrap;
  font: 13px/1.5 Consolas, "Courier New", monospace;
}

pre.has-error {
  border: 1px solid #ef4444;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .side-nav,
  .sidebar-footer {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-shell {
    padding: 16px;
  }

  .grid,
  .fields,
  .run-grid,
  .dashboard-grid,
  .epg-summary,
  .compact-grid {
    grid-template-columns: 1fr;
  }

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

  .top-actions {
    width: 100%;
    flex-wrap: wrap;
  }
}
