:root {
  --portal-bg: #101217;
  --portal-surface: rgba(22, 26, 34, 0.94);
  --portal-surface-strong: rgba(32, 38, 49, 0.98);
  --portal-border: rgba(255, 255, 255, 0.08);
  --portal-text: #f3f4f6;
  --portal-muted: #b7bec9;
  --portal-accent: #e50914;
  --portal-accent-hover: #f6121d;
  --portal-ok: #7ee787;
  --portal-error: #ff8b8b;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Roboto", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(229, 9, 20, 0.16), transparent 28%),
    linear-gradient(180deg, #0a0c10 0%, var(--portal-bg) 100%);
  color: var(--portal-text);
}

.portal-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 60px;
}

.portal-header {
  margin-bottom: 28px;
}

.portal-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.portal-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.portal-lang {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--portal-surface-strong);
  border: 1px solid var(--portal-border);
}

.portal-lang-btn {
  border: 0;
  background: transparent;
  color: var(--portal-muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.portal-lang-btn:hover {
  color: var(--portal-text);
}

.portal-lang-btn.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--portal-accent), #ff6b35);
}

.portal-header-brand {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.portal-home-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--portal-text);
  background: var(--portal-surface-strong);
  border: 1px solid var(--portal-border);
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.portal-home-btn:hover,
.portal-home-btn:focus-visible {
  color: #fff;
  border-color: rgba(229, 9, 20, 0.45);
  background: rgba(229, 9, 20, 0.18);
}

.portal-home-btn i {
  font-size: 0.95rem;
}

.portal-header-tagline {
  margin: 0;
  padding-top: 0.15em;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--portal-muted);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.portal-header-lead {
  margin: 0;
  color: var(--portal-muted);
  line-height: 1.6;
  max-width: 62ch;
}

.portal-main {
  display: grid;
  gap: 24px;
}

.portal-card {
  padding: 24px;
  border: 1px solid var(--portal-border);
  border-radius: 22px;
  background: var(--portal-surface);
  backdrop-filter: blur(16px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
}

.portal-login-card {
  max-width: 520px;
}

.portal-login-hint {
  margin: 0;
  color: var(--portal-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.portal-captcha {
  margin-top: 4px;
}

.portal-captcha:empty {
  display: none;
}

.portal-device-uuid {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.06em;
  word-break: break-all;
}

.portal-card h2,
.portal-card h3 {
  margin: 0 0 16px;
}

.portal-form {
  display: grid;
  gap: 12px;
}

.portal-form label,
.portal-field-group label {
  font-size: 0.92rem;
  color: var(--portal-muted);
}

.portal-form input,
.portal-field-group input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--portal-border);
  border-radius: 14px;
  background: var(--portal-surface-strong);
  color: var(--portal-text);
  font: inherit;
}

.portal-form input:focus,
.portal-field-group input:focus {
  outline: none;
  border-color: rgba(229, 9, 20, 0.65);
  box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.16);
}

.portal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 18px;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  text-decoration: none;
  color: #fff;
  font: inherit;
  font-weight: 700;
  transition: transform 0.16s ease, opacity 0.16s ease, background 0.16s ease;
}

.portal-btn:hover {
  transform: translateY(-1px);
}

.portal-btn-primary {
  background: var(--portal-accent);
}

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

.portal-btn-ghost {
  background: rgba(255, 255, 255, 0.08);
}

.portal-btn-danger {
  background: rgba(229, 9, 20, 0.18);
}

.portal-btn-whatsapp {
  background: #1fa855;
}

.portal-btn-small {
  padding: 10px 12px;
  font-size: 0.92rem;
}

.portal-status {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--portal-text);
}

.portal-status.success {
  background: rgba(126, 231, 135, 0.12);
  color: var(--portal-ok);
}

.portal-status.error {
  background: rgba(255, 139, 139, 0.12);
  color: var(--portal-error);
}

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

.portal-panel-head-small {
  margin-bottom: 12px;
}

.portal-muted {
  margin: 0;
  color: var(--portal-muted);
}

.portal-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.portal-summary-item {
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--portal-border);
}

.portal-summary-label {
  display: block;
  margin-bottom: 8px;
  color: var(--portal-muted);
  font-size: 0.88rem;
}

.portal-summary-item strong {
  font-size: 1.1rem;
}

#device-membership.is-expired,
#device-membership.is-critical {
  color: #ff8b8b;
}

.portal-expired-box {
  margin-bottom: 22px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(255, 139, 139, 0.2);
  background: rgba(255, 139, 139, 0.08);
}

.portal-whatsapp-fab {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  z-index: 40;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #1fa855;
  color: #fff;
  text-decoration: none;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.32);
  font-size: 1.35rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.portal-whatsapp-fab:hover,
.portal-whatsapp-fab:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.38);
}

.portal-expired-box p {
  margin: 0;
  line-height: 1.6;
}

.portal-playlists h3 {
  margin-bottom: 6px;
}

.portal-playlist-list {
  display: grid;
  gap: 12px;
  margin: 18px 0 20px;
}

.portal-playlist-item {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--portal-border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}

.portal-playlist-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.portal-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
}

.portal-modal[hidden] {
  display: none !important;
}

body.portal-modal-open {
  overflow: hidden;
}

.portal-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

.portal-modal-card {
  position: relative;
  width: min(560px, 100%);
  padding: 24px;
  border-radius: 22px;
  border: 1px solid var(--portal-border);
  background: var(--portal-surface-strong);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.portal-modal-card h3 {
  margin: 0 0 10px;
  font-size: 1.25rem;
}

.portal-modal-message {
  margin: 0 0 16px;
  color: var(--portal-muted);
  line-height: 1.6;
}

.portal-modal-body {
  margin-bottom: 18px;
}

.portal-modal-detail {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--portal-border);
}

.portal-modal-detail strong,
.portal-modal-detail span {
  overflow-wrap: anywhere;
}

.portal-modal-detail span {
  color: var(--portal-muted);
  font-size: 0.92rem;
}

.portal-modal-detail-label {
  color: var(--portal-muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.portal-modal-note {
  margin: 12px 0 0;
  color: var(--portal-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.portal-modal-form {
  display: grid;
  gap: 10px;
}

.portal-modal-form label {
  color: var(--portal-muted);
  font-size: 0.92rem;
}

.portal-modal-form input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--portal-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--portal-text);
  font: inherit;
}

.portal-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.portal-default-radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--portal-muted);
  font-size: 0.92rem;
}

.portal-default-radio input {
  accent-color: var(--portal-accent);
}

.portal-playlist-meta {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.portal-playlist-meta strong,
.portal-playlist-meta span {
  overflow-wrap: anywhere;
}

.portal-playlist-meta span {
  color: var(--portal-muted);
  font-size: 0.92rem;
}

.portal-form-inline {
  grid-template-columns: 200px minmax(0, 1fr) auto auto;
  align-items: end;
}

.portal-field-group {
  display: grid;
  gap: 8px;
}

.portal-field-group-wide {
  min-width: 0;
}

.portal-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 14px;
  color: var(--portal-muted);
}

.portal-empty {
  padding: 18px;
  border-radius: 16px;
  border: 1px dashed var(--portal-border);
  color: var(--portal-muted);
  text-align: center;
}

@media (max-width: 900px) {
  .portal-shell {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  .portal-summary-grid {
    grid-template-columns: 1fr;
  }

  .portal-header-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

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

  .portal-checkbox {
    padding-bottom: 0;
  }

  .portal-playlist-item {
    grid-template-columns: 1fr;
  }

  .portal-playlist-actions {
    justify-content: flex-start;
  }

  .portal-whatsapp-fab {
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
  }
}
