:root {
  --bg: #0a1020;
  --panel: rgba(13, 23, 45, 0.92);
  --panel-soft: rgba(15, 27, 51, 0.96);
  --line: rgba(63, 161, 255, 0.22);
  --line-strong: rgba(81, 189, 255, 0.4);
  --cyan: #63e9ff;
  --cyan-soft: #59cfff;
  --blue: #5886ff;
  --orange: #ff8a3d;
  --violet: #8b63ff;
  --text: #e8f3ff;
  --muted: #7f95b7;
  --shadow: 0 0 0 1px rgba(99, 233, 255, 0.03), 0 16px 50px rgba(2, 8, 23, 0.45);
  --nav-height: 56px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(55, 182, 255, 0.12), transparent 24%),
    radial-gradient(circle at top right, rgba(130, 94, 255, 0.1), transparent 28%),
    linear-gradient(180deg, #070d1a 0%, #09111f 100%);
}

.top-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-height);
  padding: 0 16px;
  background: rgba(10, 16, 32, 0.95);
  border-bottom: 1px solid rgba(99, 233, 255, 0.18);
  backdrop-filter: blur(12px);
}

.nav-brand h1 {
  margin: 0;
  font-size: 18px;
  color: var(--cyan);
  letter-spacing: 1px;
}

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

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid rgba(99, 233, 255, 0.25);
  background: rgba(18, 34, 63, 0.9);
  color: #87c8ff;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}

.nav-btn-primary {
  background: linear-gradient(135deg, var(--orange), #ff6b2c);
  border-color: transparent;
  color: #fff;
  font-weight: 700;
}

.nav-btn-menu {
  display: none;
}

.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(99, 233, 255, 0.12);
}

.filter-group {
  display: flex;
  gap: 8px;
}

.filter-btn {
  height: 32px;
  padding: 0 16px;
  border-radius: 6px;
  border: 1px solid rgba(99, 233, 255, 0.2);
  background: rgba(18, 34, 63, 0.8);
  color: #87c8ff;
  font-size: 13px;
  cursor: pointer;
}

.filter-btn.is-active {
  background: var(--cyan);
  color: #06111e;
  border-color: var(--cyan);
  font-weight: 700;
}

.filter-date {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hidden {
  display: none !important;
}

.filter-date input[type="date"] {
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid rgba(99, 233, 255, 0.2);
  background: rgba(18, 34, 63, 0.8);
  color: var(--text);
  font-size: 13px;
}

.filter-date span {
  color: var(--muted);
  font-size: 13px;
}

.filter-team {
  display: flex;
  align-items: center;
  gap: 8px;
}

#filter-team-label {
  color: var(--cyan);
  font-size: 13px;
  font-weight: 700;
}

.screen {
  min-height: 100vh;
  padding: 18px 28px 10px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.screen-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(99, 233, 255, 0.12);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid rgba(99, 233, 255, 0.25);
  background: rgba(18, 34, 63, 0.9);
  color: #87c8ff;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}

.nav-btn-primary {
  background: linear-gradient(135deg, var(--orange), #ff6b2c);
  border-color: transparent;
  color: #fff;
  font-weight: 700;
}

.brand-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-vision {
  margin: 8px 0 0;
  font-size: 14px;
  color: rgba(99, 233, 255, 0.7);
  letter-spacing: 1px;
}

.brand h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 1px;
  color: var(--cyan);
  text-shadow: 0 0 14px rgba(99, 233, 255, 0.35);
}

.brand-tag {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  border-radius: 8px;
  color: #62cfff;
  background: rgba(37, 68, 102, 0.65);
  font-size: 12px;
  letter-spacing: 1px;
  font-weight: 700;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.tool {
  height: 28px;
  padding: 0 14px;
  border-radius: 4px;
  border: 1px solid rgba(99, 233, 255, 0.18);
  background: rgba(18, 34, 63, 0.96);
  color: #87c8ff;
  font-size: 12px;
}

.tool.is-active {
  background: rgba(24, 86, 120, 0.9);
  color: var(--cyan);
}

.tool-date {
  min-width: 112px;
}

.clock {
  min-width: 210px;
  text-align: right;
  padding-top: 10px;
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 4px;
  font-size: 24px;
}

.metric-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.metric-card,
.panel {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.metric-card::before,
.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(99, 233, 255, 0.05), transparent 32%);
}

.metric-card {
  padding: 14px 18px 18px;
  min-height: 92px;
}

.metric-label {
  color: var(--cyan);
  font-size: 12px;
  letter-spacing: 1px;
  text-align: center;
  font-weight: 700;
}

.metric-value {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 10px;
  margin-top: 8px;
}

.metric-value strong {
  font-size: 34px;
  line-height: 1;
  font-weight: 900;
}

.metric-value span {
  font-size: 14px;
  color: var(--muted);
  font-weight: 700;
}

.metric-card.orange strong {
  color: var(--orange);
  text-shadow: 0 0 18px rgba(255, 138, 61, 0.28);
}

.metric-card.cyan strong {
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(99, 233, 255, 0.28);
}

.metric-card.light strong {
  color: #ffffff;
}

.board-grid {
  display: grid;
  grid-template-columns: 1.05fr 1.05fr 1.05fr 1.05fr;
  gap: 18px;
  margin-top: 14px;
}

.panel {
  padding: 12px 14px 16px;
  max-height: 520px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.gallery-panel {
  overflow: hidden;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.panel-title h2 {
  margin: 0;
  font-size: 16px;
  color: var(--cyan);
}

.panel-sub {
  margin-left: auto;
  color: #f0a54d;
  font-size: 12px;
}

.panel-btn {
  height: 28px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid rgba(99, 233, 255, 0.3);
  background: transparent;
  color: var(--cyan);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.panel-btn:hover {
  background: rgba(99, 233, 255, 0.1);
  border-color: var(--cyan);
}

.panel-mark {
  width: 4px;
  height: 22px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--cyan), #4da4ff);
  box-shadow: 0 0 12px rgba(99, 233, 255, 0.5);
}

.team-ranking {
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  padding-right: 4px;
  flex: 1;
}

.team-ranking::-webkit-scrollbar {
  width: 4px;
}

.team-ranking::-webkit-scrollbar-track {
  background: rgba(102, 122, 166, 0.1);
  border-radius: 2px;
}

.team-ranking::-webkit-scrollbar-thumb {
  background: rgba(99, 233, 255, 0.3);
  border-radius: 2px;
}

.team-ranking::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 233, 255, 0.5);
}

.member-ranking {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  padding-right: 4px;
  flex: 1;
}

.member-ranking::-webkit-scrollbar {
  width: 4px;
}

.member-ranking::-webkit-scrollbar-track {
  background: rgba(102, 122, 166, 0.1);
  border-radius: 2px;
}

.member-ranking::-webkit-scrollbar-thumb {
  background: rgba(99, 233, 255, 0.3);
  border-radius: 2px;
}

.member-ranking::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 233, 255, 0.5);
}

.rank-row {
  display: grid;
  gap: 8px;
}

.rank-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.rank-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.rank-index {
  color: #f3f7ff;
  font-size: 14px;
}

.rank-value {
  color: var(--cyan);
  font-weight: 700;
}

.rank-value small {
  color: var(--muted);
  margin-left: 4px;
}

.rank-row.active {
  background: rgba(99, 233, 255, 0.08);
  border-radius: 8px;
}

.team-name-link {
  cursor: pointer;
  transition: color 0.2s;
}

.team-name-link:hover {
  color: var(--cyan);
  text-decoration: underline;
}

.progress-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: rgba(102, 122, 166, 0.22);
  overflow: hidden;
}

.progress-bar {
  display: block;
  height: 100%;
  border-radius: 999px;
}

.team-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.team-tab {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(99, 233, 255, 0.16);
  background: rgba(20, 34, 61, 0.85);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.team-tab.active {
  color: #06111e;
  background: var(--cyan);
  box-shadow: 0 0 16px rgba(99, 233, 255, 0.34);
}

.member-card {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--panel-soft);
  border: 1px solid rgba(99, 233, 255, 0.08);
}

.member-badge {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: #d7e7ff;
  font-weight: 700;
}

.member-badge.top-1,
.member-badge.top-2,
.member-badge.top-3 {
  background: transparent;
  font-size: 18px;
}

.member-name {
  font-weight: 700;
}

.member-score {
  color: var(--cyan);
  font-size: 28px;
  font-weight: 800;
}

.member-score small {
  margin-left: 4px;
  font-size: 12px;
  color: var(--muted);
}

.activity-ticker {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 10px;
  overflow-y: auto;
  padding-right: 4px;
  flex: 1;
}

.activity-ticker::-webkit-scrollbar {
  width: 4px;
}

.activity-ticker::-webkit-scrollbar-track {
  background: rgba(102, 122, 166, 0.1);
  border-radius: 2px;
}

.activity-ticker::-webkit-scrollbar-thumb {
  background: rgba(99, 233, 255, 0.3);
  border-radius: 2px;
}

.activity-ticker::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 233, 255, 0.5);
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--panel-soft);
  border: 1px solid rgba(99, 233, 255, 0.08);
  animation: tickerFadeIn 0.5s ease;
}

@keyframes tickerFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.activity-text {
  flex: 1;
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

.activity-text .team-name {
  color: var(--cyan);
  font-weight: 600;
}

.activity-text .member-name {
  color: var(--text);
  font-weight: 600;
}

.activity-text .sport-name {
  color: var(--orange);
  font-weight: 600;
}

.activity-text .calorie-value {
  color: var(--orange);
  font-weight: 700;
}

.activity-time {
  color: var(--muted);
  font-size: 11px;
  flex-shrink: 0;
}

.activity-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--muted);
  font-size: 14px;
}

.gallery-grid {
  column-count: 2;
  column-gap: 10px;
  overflow: hidden;
  flex: 1;
}

.gallery-card {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(180deg, #29354d 0%, #162136 100%);
  border: 1px solid rgba(99, 233, 255, 0.08);
  break-inside: avoid;
  margin-bottom: 10px;
  display: inline-block;
  width: 100%;
}

.gallery-card .loading-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: rgba(99, 233, 255, 0.5);
  font-size: 12px;
  letter-spacing: 1px;
  pointer-events: none;
}

.gallery-card .loading-placeholder .loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(99, 233, 255, 0.15);
  border-top-color: rgba(99, 233, 255, 0.6);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.gallery-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.3s;
}

.gallery-card img.loaded {
  opacity: 1;
}

.gallery-fallback {
  display: grid;
  place-items: center;
  height: 100%;
  color: rgba(232, 243, 255, 0.36);
  font-size: 14px;
  letter-spacing: 1px;
}

.screen-footer {
  padding-top: 12px;
  text-align: center;
}

.screen-footer p {
  margin: 12px 0 0;
  color: #4e7299;
  font-size: 12px;
}

.screen-footer a {
  color: #4e7299;
  text-decoration: none;
}

.screen-footer a:hover {
  color: var(--cyan);
}

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

  .panel {
    min-height: 420px;
  }
}

@media (max-width: 900px) {
  .metric-cards,
  .board-grid {
    grid-template-columns: 1fr;
  }

  .screen-header {
    flex-direction: column;
  }

  .clock {
    text-align: left;
  }
}

@media (max-width: 768px) {
  .screen {
    padding: 12px 10px 8px;
  }

  .screen-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

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

  .brand-tag {
    display: none;
  }

  .clock {
    font-size: 16px;
    min-width: auto;
    letter-spacing: 2px;
  }

  .nav-btn-primary {
    height: 32px;
    padding: 0 12px;
    font-size: 13px;
  }

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

  .filter-date {
    width: 100%;
  }

  .filter-date input[type="date"] {
    flex: 1;
  }

  .metric-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .metric-card {
    padding: 10px 6px;
    min-height: 72px;
  }

  .metric-label {
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
  }

  .metric-value {
    gap: 4px;
    margin-top: 6px;
  }

  .metric-value strong {
    font-size: 18px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }

  .metric-value span {
    font-size: 11px;
    flex-shrink: 0;
  }

  .board-grid {
    gap: 12px;
  }

  .panel {
    min-height: auto;
    padding: 10px 12px 14px;
  }

  .panel-title h2 {
    font-size: 14px;
  }

  .panel-mark {
    height: 16px;
    width: 3px;
  }

  .donut-chart {
    width: 180px;
    height: 180px;
  }

  .donut-chart::after {
    inset: 42px;
  }

  .gallery-panel {
    display: none;
  }

  .member-score {
    font-size: 20px;
  }

  .rank-value {
    font-size: 14px;
  }

  .screen-footer p {
    font-size: 11px;
  }
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  width: 90%;
  max-width: 800px;
  max-height: 85vh;
  background: linear-gradient(180deg, #1a2a4a 0%, #0f1b33 100%);
  border: 1px solid rgba(99, 233, 255, 0.2);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(99, 233, 255, 0.15);
  flex-wrap: wrap;
  gap: 10px;
}

.modal-header h3 {
  margin: 0;
  color: var(--cyan);
  font-size: 18px;
  white-space: nowrap;
}

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

#modal-search {
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid rgba(99, 233, 255, 0.2);
  background: rgba(18, 34, 63, 0.8);
  color: var(--text);
  font-size: 13px;
  width: 180px;
}

#modal-search::placeholder {
  color: var(--muted);
}

.modal-btn {
  height: 32px;
  padding: 0 16px;
  border-radius: 6px;
  border: 1px solid rgba(99, 233, 255, 0.3);
  background: transparent;
  color: var(--cyan);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.modal-btn:hover {
  background: rgba(99, 233, 255, 0.1);
  border-color: var(--cyan);
}

.export-btn {
  border-color: rgba(240, 165, 77, 0.4);
  color: #f0a54d;
}

.export-btn:hover {
  background: rgba(240, 165, 77, 0.1);
  border-color: #f0a54d;
}

.close-btn {
  border-color: rgba(220, 38, 38, 0.4);
  color: #dc2626;
}

.close-btn:hover {
  background: rgba(220, 38, 38, 0.1);
  border-color: #dc2626;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.modal-body::-webkit-scrollbar {
  width: 4px;
}

.modal-body::-webkit-scrollbar-track {
  background: rgba(102, 122, 166, 0.1);
  border-radius: 2px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: rgba(99, 233, 255, 0.3);
  border-radius: 2px;
}

.modal-table {
  width: 100%;
  border-collapse: collapse;
}

.modal-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--cyan);
  font-size: 13px;
  border-bottom: 1px solid rgba(99, 233, 255, 0.15);
  position: sticky;
  top: 0;
  background: #1a2a4a;
}

.modal-table td {
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
  border-bottom: 1px solid rgba(99, 233, 255, 0.06);
}

.modal-table tr:hover td {
  background: rgba(99, 233, 255, 0.05);
}

.modal-table .rank-cell {
  color: var(--cyan);
  font-weight: 700;
  width: 60px;
}

.modal-table .score-cell {
  color: var(--orange);
  font-weight: 700;
}

@media (max-width: 768px) {
  .modal-content {
    width: 96%;
    max-height: 90vh;
    border-radius: 8px;
  }

  .modal-header {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 14px;
    gap: 10px;
  }

  .modal-header h3 {
    font-size: 16px;
    text-align: center;
  }

  .modal-actions {
    justify-content: center;
  }

  #modal-search {
    width: 100%;
    flex: 1;
  }

  .modal-btn {
    padding: 0 12px;
    font-size: 12px;
    height: 30px;
  }

  .modal-body {
    padding: 10px 8px;
  }

  .modal-table th {
    padding: 8px 6px;
    font-size: 12px;
  }

  .modal-table td {
    padding: 8px 6px;
    font-size: 12px;
  }

  .modal-table .rank-cell {
    width: 40px;
    text-align: center;
  }
}

.image-viewer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  cursor: pointer;
}

.image-viewer-container {
  position: relative;
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-viewer-close {
  position: absolute;
  top: -40px;
  right: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.image-viewer-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.image-viewer-img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
}
