[hidden] {
  display: none !important;
}

[data-role="membro"] [data-admin] {
  display: none !important;
}

.portal-login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 315px minmax(360px, 640px);
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 28px;
}

.portal-login-panel {
  padding: 32px;
}

.portal-login-panel h1 {
  margin: 4px 0 10px;
  color: #172033;
  font-size: clamp(42px, 5vw, 64px);
  line-height: 1;
}

.portal-login-panel h1 span {
  font-size: 0.72em;
}

.portal-login-panel p {
  color: #627083;
  margin: 0;
}

.portal-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

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

.portal-role-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.portal-role-toggle span {
  min-height: 54px;
  display: grid;
  place-items: center;
  border: 2px solid #ffd4e4;
  border-radius: 18px;
  background: #fffaf1;
  color: #627083;
  font-weight: 900;
}

.portal-role-toggle input:checked + span {
  border-color: #ff6fa8;
  background: #fff0f6;
  color: #e43e80;
}

.portal-field {
  display: grid;
  gap: 7px;
  font-weight: 800;
}

.portal-field span,
.portal-member-form span {
  color: #627083;
  font-size: 13px;
}

.portal-field input,
.portal-member-form input,
.portal-member-form select {
  width: 100%;
  min-height: 50px;
  border: 2px solid #ffd4e4;
  border-radius: 18px;
  background: #fffdf9;
  color: #172033;
  padding: 0 16px;
  outline: none;
  font: inherit;
}

.portal-primary,
.portal-save-btn,
.portal-clear-btn,
.portal-sidebar-logout,
.mini-btn {
  min-height: 46px;
  border: 0;
  border-radius: 16px;
  font-weight: 900;
  cursor: pointer;
  font: inherit;
}

.portal-primary,
.portal-save-btn {
  background: #ff6fa8;
  color: white;
  box-shadow: 0 10px 22px rgba(245, 68, 147, 0.22);
}

.portal-clear-btn,
.portal-sidebar-logout,
.mini-btn {
  border: 2px solid #ffd4e4;
  background: #fff0f6;
  color: #e43e80;
  padding: 0 14px;
}

.mini-btn {
  min-height: 34px;
  font-size: 13px;
}

.mini-btn.danger {
  background: #fff0f1;
  color: #cf294d;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: #cf294d;
  font-weight: 800;
}

.portal-sidebar-logout {
  width: 100%;
}

.portal-member-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.portal-member-form label {
  display: grid;
  gap: 7px;
  font-weight: 800;
}

.portal-member-form .wide {
  grid-column: span 2;
}

.portal-status-filter {
  margin-top: 10px;
}

.portal-member-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.portal-head-actions,
.portal-mobile-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.portal-action-btn {
  min-height: 48px;
  border: 0;
  border-radius: 16px;
  background: #ff6fa8;
  color: #fff;
  padding: 0 18px;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(245, 68, 147, 0.22);
  cursor: pointer;
}

.portal-notice {
  min-height: 20px;
  margin: 0 0 12px;
  color: #627083;
  font-weight: 800;
}

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

.portal-notice[data-type="success"] {
  color: #12925a;
}

.portal-notice[data-type="error"] {
  color: #cf294d;
}

.portal-inline-form,
.portal-week-form {
  margin: 14px 0 18px;
  border: 2px solid #ffc7de;
  border-radius: 22px;
  background: rgba(255, 253, 249, 0.96);
  padding: 18px;
  box-shadow: 0 14px 28px rgba(245, 68, 147, 0.10);
}

.portal-inline-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.portal-inline-form.avatar-only {
  grid-template-columns: minmax(260px, 1fr) auto;
}

.portal-inline-title,
.portal-inline-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.portal-inline-title strong {
  color: #172033;
  font-size: 18px;
}

.portal-inline-form label,
.portal-check-field,
.portal-week-form label {
  display: grid;
  gap: 7px;
  color: #627083;
  font-size: 13px;
  font-weight: 900;
}

.portal-inline-form input,
.portal-inline-form select,
.portal-week-form input,
.portal-week-form select {
  width: 100%;
  min-height: 48px;
  border: 2px solid #ffd4e4;
  border-radius: 16px;
  background: #fffdf9;
  color: #172033;
  padding: 0 14px;
  outline: none;
  font: inherit;
  font-weight: 800;
}

.portal-inline-form .wide {
  grid-column: span 2;
}

.portal-check-line {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 2px solid #ffd4e4;
  border-radius: 16px;
  background: #fffdf9;
  padding: 0 14px;
  color: #172033;
  font-weight: 900;
}

.portal-check-line input {
  width: 18px;
  height: 18px;
  min-height: 0;
  border: 0;
  background: transparent;
  padding: 0;
  accent-color: #f54493;
  flex: 0 0 auto;
}

.rank-card {
  position: relative;
}

.up-badge {
  position: absolute;
  top: 9px;
  right: 12px;
  z-index: 5;
  min-width: 76px;
  display: grid;
  place-items: center;
  padding: 6px 10px;
  border: 2px solid #fff;
  border-radius: 14px;
  background: linear-gradient(135deg, #ff4e9b, #ffb335);
  box-shadow: 0 10px 18px rgba(245, 68, 147, 0.22);
  color: #fff;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  transform: rotate(2deg);
}

.up-badge b {
  font-size: 13px;
  letter-spacing: 0;
}

.up-badge span {
  margin-top: 2px;
  font-size: 10px;
  white-space: nowrap;
}

.portal-avatar-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.portal-avatar-tools .portal-upload-btn {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffd4e4;
  border-radius: 16px;
  background: #fff0f6;
  color: #e43e80;
  padding: 0 14px;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.portal-avatar-tools .portal-upload-btn input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.portal-avatar-preview {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #f7f7f7;
  overflow: hidden;
  flex: 0 0 auto;
}

.portal-avatar-preview img,
.portal-icon-choice img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.portal-icon-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
  gap: 10px;
}

.portal-icon-choice {
  width: 58px;
  height: 58px;
  border: 2px solid #ffd4e4;
  border-radius: 50%;
  background: #fff;
  padding: 3px;
  cursor: pointer;
  overflow: hidden;
}

.portal-icon-choice.active {
  border-color: #ff4f97;
  box-shadow: 0 0 0 4px rgba(255, 111, 168, 0.18);
}

.portal-week-meta {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(220px, 1fr);
  gap: 12px;
}

.portal-week-legend {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin: 12px 0;
  color: #627083;
  font-weight: 800;
}

.portal-week-list {
  display: grid;
  gap: 10px;
  max-height: min(58vh, 620px);
  overflow: auto;
  padding-right: 4px;
}

.portal-week-row {
  display: grid;
  grid-template-columns: minmax(190px, 1.4fr) repeat(6, minmax(92px, 1fr)) minmax(92px, .7fr);
  gap: 10px;
  align-items: end;
  border: 2px solid #ffd4e4;
  border-radius: 18px;
  padding: 12px;
  background: #fffaf1;
}

.portal-week-person {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.portal-week-person strong {
  display: block;
  color: #172033;
  font-size: 16px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-week-person span {
  color: #8d86a1;
  font-weight: 800;
}

.portal-week-total {
  min-height: 48px;
  border-radius: 16px;
  background: #e9f8ef;
  color: #14783f;
  display: grid;
  place-items: center;
  font-weight: 900;
}

.portal-week-total strong {
  font-size: 24px;
  line-height: 1;
}

.portal-week-total span {
  font-size: 12px;
}

.portal-week-row.is-inactive .portal-week-total {
  background: #ffe8ef;
  color: #bd2549;
}

.rank-warning {
  margin-top: 6px;
  color: #bd2549;
  font-size: 12px;
  font-weight: 900;
}

.empty-state {
  border: 2px dashed #ffd4e4;
  border-radius: 18px;
  color: #627083;
  padding: 24px;
  text-align: center;
  font-weight: 800;
}

.portal-mobile-shell {
  display: none;
}

@media (min-width: 851px) {
  #members.page.active {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 14px;
    overflow: hidden;
  }

  #members .page-head {
    margin-bottom: 0;
  }

  #members .ranking-panel {
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  #teamCardsDesktop.team-cards {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: auto;
  }
}

@media (min-width: 851px) {
  .portal-desktop-shell {
    display: block;
  }

  .portal-mobile-shell {
    display: none !important;
  }

  .portal-desktop-shell .brand-card {
    flex: 0 0 clamp(252px, 31vh, 302px);
    height: clamp(252px, 31vh, 302px);
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  .portal-desktop-shell .brand-card .mascot {
    height: clamp(244px, 30vh, 292px);
    margin: 0 auto;
  }

  .portal-desktop-shell .brand-card .logo {
    display: none;
  }

  .portal-desktop-shell .hero-title-with-logo {
    display: flex;
    align-items: center;
    margin-top: -4px;
    margin-bottom: 2px;
  }

  .portal-desktop-shell .hero-logo-frame {
    width: clamp(260px, 24vw, 390px);
    aspect-ratio: 676 / 290;
    display: inline-grid;
    place-items: center;
    overflow: hidden;
    flex: 0 0 auto;
  }

  .portal-desktop-shell .hero-logo-frame img {
    width: 100%;
    height: auto;
    display: block;
    transform: translateY(-27%);
  }

  .portal-desktop-shell .hero-title-with-logo .hero-candy {
    font-size: .75em;
  }

  #teamCardsDesktop .member-card-team {
    position: relative;
  }

  #teamCardsDesktop .portal-member-actions {
    position: absolute;
    right: 18px;
    bottom: 10px;
    z-index: 3;
    justify-content: flex-end;
    gap: 6px;
    margin: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease;
  }

  #teamCardsDesktop .member-card-team:hover .portal-member-actions {
    opacity: 1;
    pointer-events: auto;
  }

  #teamCardsDesktop .portal-member-actions.self-actions {
    opacity: 1;
    pointer-events: auto;
  }

  #teamCardsDesktop .portal-member-actions .mini-btn {
    min-height: 28px;
    border-radius: 10px;
    padding: 0 9px;
    font-size: 12px;
  }

  .portal-desktop-shell .desktop-rank-card {
    height: 400px;
    min-height: 400px;
    padding: 20px;
  }

  .portal-desktop-shell .desktop-rank-card .desktop-top-row {
    grid-template-columns: 34px 42px minmax(0, 1fr) 58px;
    gap: 10px;
    padding: 6px 0;
    min-height: 55px;
  }

  .portal-desktop-shell .desktop-rank-card .desktop-avatar {
    width: 42px;
    height: 42px;
  }

  .portal-desktop-shell .desktop-rank-card .desktop-medal {
    font-size: 20px;
  }

  .portal-desktop-shell .desktop-rank-card .desktop-medal span {
    width: 26px;
    height: 26px;
    font-size: 14px;
  }

  .portal-desktop-shell .desktop-rank-card .desktop-rank-info strong {
    font-size: 14px;
    line-height: 1.1;
  }

  .portal-desktop-shell .desktop-rank-card .desktop-rank-info small {
    font-size: 11px;
    margin-top: 1px;
  }

  .portal-desktop-shell .desktop-rank-card .desktop-bar {
    height: 8px;
    margin-top: 5px;
  }

  .portal-desktop-shell .desktop-rank-card .desktop-rank-score b {
    font-size: 20px;
  }

  .portal-desktop-shell .desktop-rank-card .desktop-rank-score small {
    font-size: 11px;
  }

  .portal-desktop-shell .desktop-rank-card .desktop-rank-btn {
    margin-top: 8px;
    padding: 9px 10px;
  }

  .portal-desktop-shell .health-graph .large-chart {
    width: min(100%, 960px);
    height: 210px;
    margin: 4px 0 0;
  }

  .portal-desktop-shell .health-graph .large-chart svg {
    width: 100%;
    height: 210px;
    margin-top: 0;
  }
}

@media (max-width: 850px) {
  .decor {
    display: none;
  }

  body {
    overflow-x: hidden;
    overflow-y: auto;
  }

  .portal-login {
    min-height: 100vh;
    display: block;
    padding: 12px;
  }

  .portal-login-brand {
    display: none;
  }

  .portal-login-panel {
    border-radius: 34px;
    padding: 24px 18px;
  }

  .portal-login-panel h1 {
    font-size: clamp(36px, 10vw, 58px);
  }

  .portal-desktop-shell {
    display: none !important;
  }

  .portal-mobile-shell {
    display: block;
  }

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

  .portal-member-form .wide {
    grid-column: auto;
  }

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

  .portal-member-actions .mini-btn {
    flex: 1 1 auto;
  }

  .portal-mobile-shell .up-badge {
    top: 8px;
    right: 10px;
    min-width: 62px;
    padding: 5px 8px;
    border-radius: 12px;
  }

  .portal-mobile-shell .up-badge b {
    font-size: 11px;
  }

  .portal-mobile-shell .up-badge span {
    font-size: 8px;
    max-width: 76px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .portal-mobile-shell .top5-header h2 {
    font-size: clamp(29px, 8.2vw, 34px);
    line-height: 1.05;
    white-space: nowrap;
  }

  .portal-mobile-shell .top-member {
    display: grid;
    grid-template-columns: 34px 64px minmax(0, 1fr) 66px;
    align-items: center;
    gap: 10px;
    min-height: 92px;
    padding: 14px 0;
    border-bottom: 2px solid #ffe4f0;
  }

  .portal-mobile-shell .top-member:last-child {
    border-bottom: 0;
  }

  .portal-mobile-shell .top-pos {
    display: grid;
    place-items: center;
    min-width: 0;
    font-size: 24px;
    font-weight: 900;
    color: #f54493;
  }

  .portal-mobile-shell .top-pos span {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #ffeaf4;
  }

  .portal-mobile-shell .top-avatar {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: 50%;
    background: #f7f7f7;
  }

  .portal-mobile-shell .top-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  .portal-mobile-shell .top-avatar span {
    font-size: 26px;
    font-weight: 900;
    color: #172033;
  }

  .portal-mobile-shell .top-info {
    min-width: 0;
  }

  .portal-mobile-shell .top-info strong {
    display: inline-block;
    max-width: calc(100% - 52px);
    overflow: hidden;
    color: #172033;
    font-size: clamp(20px, 5.7vw, 32px);
    line-height: 1.05;
    text-overflow: ellipsis;
    vertical-align: bottom;
    white-space: nowrap;
  }

  .portal-mobile-shell .top-info span {
    margin-left: 6px;
    color: #8b7d9b;
    font-size: clamp(14px, 3.6vw, 20px);
    white-space: nowrap;
  }

  .portal-mobile-shell .top-bar {
    height: 12px;
    overflow: hidden;
    margin-top: 7px;
    border-radius: 999px;
    background: #fff0f6;
  }

  .portal-mobile-shell .top-bar i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #ffc94d, #ff8f3f);
  }

  .portal-mobile-shell .top-score {
    min-width: 0;
    color: #f54493;
    text-align: right;
    font-weight: 900;
  }

  .portal-mobile-shell .top-score strong {
    display: block;
    font-size: clamp(26px, 7vw, 40px);
    line-height: 1;
  }

  .portal-mobile-shell .top-score span {
    display: block;
    margin-top: 2px;
    font-size: clamp(15px, 4vw, 22px);
    line-height: 1;
  }

  .portal-mobile-shell .member-card-team {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 0;
    padding: 16px;
  }

  .portal-mobile-shell .member-card-team .member-left {
    grid-column: 1;
    grid-row: 1;
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    align-items: center;
    gap: 14px;
    min-width: 0;
    width: 100%;
  }

  .portal-mobile-shell .member-card-team .member-avatar {
    width: 56px;
    height: 56px;
  }

  .portal-mobile-shell .member-card-team .member-info {
    min-width: 0;
  }

  .portal-mobile-shell .member-card-team .member-name {
    overflow: hidden;
    font-size: clamp(24px, 7vw, 36px);
    line-height: 1.05;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .portal-mobile-shell .member-card-team .member-id {
    font-size: clamp(16px, 4.5vw, 24px);
    line-height: 1.15;
  }

  .portal-mobile-shell .member-card-team .member-role {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    max-width: 96px;
    color: #172033;
    font-size: clamp(16px, 4.5vw, 22px);
    line-height: 1.15;
    text-align: right;
  }

  .portal-mobile-shell .member-card-team .portal-member-actions {
    grid-column: 1 / -1;
    display: flex;
    width: 100%;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
  }

  .portal-mobile-shell .member-card-team .portal-member-actions .mini-btn {
    flex: 0 0 auto;
    min-height: 34px;
    border-radius: 14px;
    padding: 0 12px;
    font-size: clamp(12px, 3.4vw, 15px);
    line-height: 1;
  }

  .portal-mobile-search {
    margin: 12px 0 14px;
  }

  .portal-mobile-actions,
  .portal-head-actions {
    width: 100%;
    justify-content: stretch;
  }

  .portal-mobile-actions select,
  .portal-head-actions select,
  .portal-action-btn {
    width: 100%;
  }

  .portal-inline-form,
  .portal-inline-form.mobile {
    grid-template-columns: 1fr;
    border-radius: 28px;
    padding: 16px;
  }

  .portal-inline-form .wide {
    grid-column: auto;
  }

  .portal-avatar-tools,
  .portal-inline-actions,
  .portal-inline-title {
    align-items: stretch;
  }

  .portal-avatar-tools .portal-clear-btn,
  .portal-inline-actions button,
  .portal-inline-title button {
    width: 100%;
  }

  .portal-week-form,
  .portal-week-form.mobile {
    border-radius: 28px;
    padding: 16px;
  }

  .portal-week-meta,
  .portal-week-row {
    grid-template-columns: 1fr;
  }

  .portal-week-list {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .portal-week-person strong {
    white-space: normal;
  }

  .portal-week-total {
    min-height: 68px;
  }

  .rank-info {
    line-height: 1.25;
  }
}
