:root {
  color-scheme: dark;
  --bg: #080a0f;
  --surface: rgba(18, 22, 32, 0.97);
  --surface-alt: #141925;
  --surface-deep: #0b0f17;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #f4f5f7;
  --muted: #9da8bd;
  --accent: #ff304f;
  --accent-hover: #ff4764;
  --accent-glow: rgba(255, 48, 79, 0.25);
  --ok-bg: rgba(16, 185, 129, 0.14);
  --ok-border: rgba(52, 211, 153, 0.42);
  --ok-text: #a7f3d0;
  --err-bg: rgba(255, 48, 79, 0.14);
  --err-border: rgba(255, 92, 118, 0.5);
  --err-text: #fecdd3;
  --warn-bg: rgba(251, 191, 36, 0.13);
  --warn-border: rgba(251, 191, 36, 0.42);
  --warn-text: #fde68a;
  --radius: 16px;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
}

.skip-link:focus {
  left: 12px;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  position: relative;
  overflow-x: clip;
  display: flex;
  flex-direction: column;
}

.bg-orb {
  position: fixed;
  pointer-events: none;
  border-radius: 50%;
  filter: blur(95px);
  z-index: 0;
}

.bg-orb-top {
  width: 520px;
  height: 520px;
  top: -190px;
  left: -120px;
  background: radial-gradient(circle, rgba(255, 48, 79, 0.22), transparent 68%);
}

.bg-orb-bottom {
  width: 540px;
  height: 540px;
  bottom: -240px;
  right: -140px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.16), transparent 68%);
}

a {
  color: #fda4af;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #ffffff;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.9em;
}

.wrap {
  width: min(1140px, 92vw);
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 22px 52px rgba(0, 0, 0, 0.48);
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(8, 10, 15, 0.95);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 0;
  flex-wrap: wrap;
}

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

.brand:hover {
  text-decoration: none;
}

.brand-badge {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fda4af;
  background: rgba(255, 48, 79, 0.14);
  border: 1px solid rgba(255, 48, 79, 0.34);
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.nav {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.nav a {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
}

.nav a:hover {
  color: #ffffff;
  text-decoration: none;
}

.nav .nav-link-btn {
  padding: 7px 13px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-strong);
  color: #f4f5f7;
  font-weight: 600;
}

.nav .nav-link-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* Layout & Typography */
.main-wrap {
  flex: 1;
  padding: 34px 0 42px;
}

.card-panel {
  padding: 26px 26px 28px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #ff6b81;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(1.55rem, 2.8vw, 2.05rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

h2 {
  margin: 0 0 8px;
  font-size: clamp(1.2rem, 2vw, 1.45rem);
  line-height: 1.2;
}

h3 {
  margin: 0 0 6px;
  font-size: 1.08rem;
}

.lead,
.guide-sub,
.muted-copy {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.96rem;
}

.guide-logos {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: -6px 0 18px;
}

.guide-logo-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 6px 11px;
  border-radius: 9px;
  background: #f6f7f9;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.guide-logo-pill-dark {
  background: #0d0f15;
  border-color: rgba(255, 255, 255, 0.14);
}

.guide-logo-pill img {
  display: block;
  max-height: 22px;
  max-width: 78px;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* Login View */
.login-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 0.98fr);
  gap: 24px;
  align-items: start;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.86rem;
  font-weight: 700;
  color: #e2e8f0;
}

.field input,
.field textarea,
.pin-form input {
  width: 100%;
  background: var(--surface-deep);
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  color: #ffffff;
  font-family: inherit;
  font-size: 1rem;
  padding: 11px 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field textarea:focus,
.pin-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.field textarea {
  resize: vertical;
  min-height: 82px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 1rem;
}

.field-hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.pass-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.pass-wrap input {
  padding-right: 46px;
}

.btn-eye {
  position: absolute;
  right: 8px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 1.05rem;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
}

.btn-eye:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.94rem;
  border-radius: 10px;
  padding: 11px 18px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(255, 48, 79, 0.28);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-strong);
  color: #ffffff;
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.btn-ghost:hover:not(:disabled) {
  color: #ffffff;
  border-color: var(--border-strong);
}

.btn-danger-ghost {
  background: rgba(255, 48, 79, 0.12);
  border-color: rgba(255, 48, 79, 0.35);
  color: #fda4af;
}

.btn-danger-ghost:hover:not(:disabled) {
  background: rgba(255, 48, 79, 0.24);
  color: #ffffff;
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: 7px 13px;
  font-size: 0.85rem;
}

.btn-xs {
  padding: 5px 10px;
  font-size: 0.78rem;
  border-radius: 8px;
}

/* Alerts */
.alert {
  border-radius: 11px;
  padding: 11px 14px;
  font-size: 0.9rem;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
}

.alert[data-kind="error"] {
  background: var(--err-bg);
  border-color: var(--err-border);
  color: var(--err-text);
}

.alert[data-kind="success"] {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok-text);
}

.alert[data-kind="info"] {
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(96, 165, 250, 0.42);
  color: #dbeafe;
}

/* Guide Steps */
.steps-list {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.steps-list li {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
  background: var(--surface-alt);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  contain: layout style;
}

.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 48, 79, 0.16);
  border: 1px solid rgba(255, 48, 79, 0.45);
  color: #ff8598;
  font-weight: 800;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.steps-list li > div > strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.steps-list p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.copy-inline {
  margin-top: 8px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.inline-feedback {
  font-size: 0.8rem;
  color: #86efac;
}

.guide-tip {
  background: rgba(255, 255, 255, 0.04);
  border-left: 3px solid var(--accent);
  padding: 11px 14px;
  border-radius: 0 10px 10px 0;
  font-size: 0.87rem;
  color: var(--muted);
}

.guide-tip strong {
  color: var(--text);
}

/* Dashboard View */
.dash-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.device-header-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.device-main {
  flex: 1;
  min-width: 260px;
}

.device-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.device-title-row .eyebrow {
  margin: 0;
}

.status-pill {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.status-pill.status-active {
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  color: var(--ok-text);
}

.status-pill.status-trial {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
}

.status-pill.status-blocked {
  background: var(--err-bg);
  border: 1px solid var(--err-border);
  color: var(--err-text);
}

.device-codes-bar {
  display: grid;
  grid-template-columns: 1.45fr 0.85fr 1fr 1.25fr;
  gap: 12px;
}

#dev-mac {
  white-space: nowrap;
}

.code-chip {
  background: var(--surface-deep);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px 13px;
}

.code-chip small {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 3px;
}

.code-chip strong {
  font-size: 0.96rem;
  color: #ffffff;
  word-break: break-word;
}

.code-val-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sync-notice {
  margin: 12px 0 0;
  font-size: 0.84rem;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 10px #34d399;
  flex-shrink: 0;
}

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

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr);
  gap: 22px;
  align-items: start;
}

.dash-col-main {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.empty-box {
  background: var(--surface-deep);
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  padding: 22px 18px;
  text-align: center;
}

.empty-box strong {
  display: block;
  margin-bottom: 4px;
}

.empty-box p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.playlists-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pl-card {
  background: var(--surface-alt);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 13px;
  padding: 15px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  contain: layout style;
}

.pl-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pl-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pl-name {
  font-size: 1.04rem;
  font-weight: 800;
  color: #ffffff;
}

.type-pill {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.16);
  border: 1px solid rgba(96, 165, 250, 0.36);
  color: #bfdbfe;
}

.type-pill.is-m3u {
  background: rgba(168, 85, 247, 0.16);
  border-color: rgba(192, 132, 252, 0.38);
  color: #e9d5ff;
}

.protected-pill {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
}

.pl-meta {
  font-size: 0.84rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 3px;
  word-break: break-all;
}

.pl-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.delete-confirm-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(255, 48, 79, 0.12);
  border: 1px solid rgba(255, 48, 79, 0.35);
  font-size: 0.84rem;
  color: var(--err-text);
}

/* Editor Tabs */
.editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.mode-tab {
  background: var(--surface-deep);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.14s ease;
}

.mode-tab:hover {
  color: #ffffff;
  border-color: var(--border-strong);
}

.mode-tab.is-active {
  background: rgba(255, 48, 79, 0.16);
  border-color: var(--accent);
  color: #ffffff;
}

.mode-pane {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-mode-note {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(59, 130, 246, 0.11);
  border: 1px solid rgba(96, 165, 250, 0.3);
  color: #dbeafe;
  font-size: 0.85rem;
}

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

.editor-actions .btn-primary {
  flex: 1;
}

/* PIN Card */
.pin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.pin-row .muted-copy {
  margin-bottom: 0;
}

.pin-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pin-form input {
  width: 120px;
  text-align: center;
  letter-spacing: 0.18em;
  font-weight: 800;
}

/* Footer */
.footer {
  padding: 20px 0 32px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.85rem;
}

.footer p {
  margin: 0;
  max-width: 680px;
}

.footer-nav {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.footer-nav a {
  color: var(--muted);
}

.footer-nav a:hover {
  color: #ffffff;
}

@media (max-width: 920px) {
  .login-layout,
  .dash-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 560px) {
  .card-panel {
    padding: 20px 18px 22px;
  }

  .device-codes-bar {
    grid-template-columns: 1fr;
  }

  .editor-actions {
    flex-direction: column;
  }

  .pin-form {
    width: 100%;
  }

  .pin-form input {
    flex: 1;
  }
}

.license-bar-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  border-color: rgba(16, 185, 129, 0.34);
  background: linear-gradient(120deg, rgba(16, 185, 129, 0.08), rgba(14, 18, 27, 0.96));
}

.lic-headline {
  margin: 4px 0 4px;
  font-size: 1.15rem;
}

.license-bar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn-emerald {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #031b13;
  box-shadow: 0 8px 22px rgba(16, 185, 129, 0.25);
}

.btn-emerald:hover:not(:disabled) {
  filter: brightness(1.07);
  transform: translateY(-1px);
}

.mode-tabs {
  flex-wrap: wrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(4, 6, 11, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-card {
  width: min(490px, 100%);
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
}

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

.pix-qr-box {
  width: fit-content;
  margin: 14px auto;
  padding: 12px;
  border-radius: 14px;
  background: #ffffff;
}

.pix-qr-box img {
  width: 210px;
  height: 210px;
  display: block;
}

.pix-modal-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.pix-poll-msg {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ok-text);
}

a:focus-visible,
.btn:focus-visible,
.mode-tab:focus-visible,
.btn-eye:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
  .topbar {
    background: rgba(8, 10, 15, 0.88);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
  }

  .modal-backdrop {
    background: rgba(4, 6, 11, 0.84);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
  }
}

@media (hover: none), (max-width: 820px) {
  .bg-orb {
    display: none;
  }

  .surface,
  .btn-primary,
  .btn-emerald {
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

