:root {
  --ink: #17202a;
  --muted: #657181;
  --line: #dce3ea;
  --paper: #f7f9fb;
  --white: #ffffff;
  --red: #b3262d;
  --red-dark: #7f1d1d;
  --gold: #c58a23;
  --teal: #217a7a;
  --blue: #285f9f;
  --green: #447344;
  --shadow: 0 18px 46px rgba(23, 32, 42, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(110deg, rgba(92, 17, 19, 0.94), rgba(127, 29, 29, 0.74) 52%, rgba(23, 32, 42, 0.62)),
    url("https://images.unsplash.com/photo-1517048676732-d65bc937f952?auto=format&fit=crop&w=1800&q=80") center/cover;
}

.auth-panel {
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.auth-panel h1 {
  margin: 0 0 12px;
  font-size: 30px;
}

.auth-panel p {
  margin: 0 0 20px;
  color: var(--muted);
}

.auth-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 10px;
}

.auth-form input {
  padding-left: 14px;
}

.auth-error {
  margin: 14px 0 0 !important;
  color: var(--red) !important;
  font-weight: 700;
}

.site-content[hidden],
.auth-gate[hidden] {
  display: none;
}

button,
input,
select {
  font: inherit;
}

.hero {
  min-height: 520px;
  color: var(--white);
  background:
    linear-gradient(110deg, rgba(92, 17, 19, 0.94), rgba(127, 29, 29, 0.72) 48%, rgba(23, 32, 42, 0.58)),
    url("https://images.unsplash.com/photo-1517048676732-d65bc937f952?auto=format&fit=crop&w=1800&q=80") center/cover;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 132px;
  background: linear-gradient(180deg, rgba(247, 249, 251, 0), var(--paper));
  pointer-events: none;
}

.topbar,
.hero-grid,
main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 26px 0;
}

.brand,
.nav-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  font-weight: 700;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
}

.nav-actions a {
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
  font-size: 14px;
}

.hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 48px;
  align-items: end;
  padding: 96px 0 120px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

.hero h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(42px, 7vw, 74px);
  line-height: 1.05;
  letter-spacing: 0;
}

.lede {
  max-width: 620px;
  margin: 24px 0 0;
  color: rgba(255, 255, 255, 0.84);
  font-size: 20px;
}

.metric-panel {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.metric-panel div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 22px 24px;
  background: rgba(23, 32, 42, 0.22);
}

.metric-panel strong {
  font-size: 34px;
  line-height: 1;
}

.metric-panel span {
  color: rgba(255, 255, 255, 0.78);
}

main {
  position: relative;
  margin-top: -26px;
  padding-bottom: 80px;
}

.controls {
  position: sticky;
  top: 12px;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(280px, 1.6fr) repeat(3, minmax(120px, 1fr)) 92px 92px;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.controls > * {
  min-width: 0;
}

.search-wrap {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

input,
select,
button {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
}

input {
  padding: 0 14px 0 40px;
}

select {
  padding: 0 12px;
}

button {
  cursor: pointer;
  font-weight: 700;
}

#resetFilters,
.dialog-close {
  border-color: var(--red);
  background: var(--red);
  color: var(--white);
}

.analytics,
.teams-section {
  padding-top: 58px;
}

.teams-section {
  padding-top: 34px;
}

.teams-section .controls {
  margin-bottom: 28px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.section-heading h2 {
  margin: 0;
  font-size: 30px;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.bar-chart {
  max-height: 320px;
  overflow: auto;
  padding-right: 6px;
}

.location-group + .location-group {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.location-group-title {
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--red-dark);
}

.chart-block {
  min-height: 338px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 10px 30px rgba(23, 32, 42, 0.06);
}

.block-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.block-title h3 {
  margin: 0;
  font-size: 18px;
}

.block-title span,
.result-count {
  color: var(--muted);
  font-size: 13px;
}

.bar-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) 34px;
  gap: 10px;
  align-items: center;
  margin: 12px 0;
  font-size: 14px;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f5;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--gold));
}

.donut-area {
  display: grid;
  justify-items: center;
  gap: 16px;
}

.donut {
  width: 180px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--red) 0deg, var(--gold) 0deg);
  position: relative;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 34px;
  border-radius: 50%;
  background: var(--white);
}

.legend {
  width: 100%;
  display: grid;
  gap: 9px;
}

.legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.legend-row i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
}

.word-cloud {
  min-height: 250px;
  display: flex;
  align-content: center;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.word-cloud button {
  width: auto;
  height: auto;
  padding: 6px 10px;
  border: 0;
  background: transparent;
  color: var(--blue);
  line-height: 1.1;
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.team-card {
  min-height: 244px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 8px 24px rgba(23, 32, 42, 0.05);
  text-align: left;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.team-card:hover {
  transform: translateY(-2px);
  border-color: rgba(179, 38, 45, 0.45);
  box-shadow: 0 16px 34px rgba(23, 32, 42, 0.1);
}

.card-top {
  display: flex;
  gap: 14px;
}

.team-avatar {
  flex: 0 0 58px;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: linear-gradient(145deg, #fff1df, #ffe1e1);
  color: var(--red-dark);
  font-weight: 800;
}

.team-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.team-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
  line-height: 1.25;
}

.meta-line,
.leader-line {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 16px 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef4f8;
  color: #29485f;
  font-size: 12px;
}

.goal-preview {
  margin: 0;
  color: #3d4752;
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty-state {
  padding: 42px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--white);
  text-align: center;
  color: var(--muted);
}

.team-dialog {
  width: min(860px, calc(100% - 28px));
  max-height: min(760px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.team-dialog::backdrop {
  background: rgba(23, 32, 42, 0.54);
}

.dialog-close {
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 1;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
}

.dialog-hero {
  min-height: 180px;
  padding: 34px 72px 30px 34px;
  background: linear-gradient(125deg, var(--red-dark), var(--red) 58%, #d89a32);
  color: var(--white);
}

.dialog-hero h2 {
  margin: 10px 0 12px;
  font-size: 30px;
  line-height: 1.18;
}

.dialog-body {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 24px;
  padding: 26px 34px 34px;
}

.detail-list {
  display: grid;
  gap: 14px;
  margin: 0;
}

.detail-list div {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.detail-list dt {
  color: var(--muted);
  font-size: 12px;
}

.detail-list dd {
  margin: 3px 0 0;
  font-weight: 700;
}

.detail-section h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.detail-section p {
  margin: 0 0 22px;
  white-space: pre-wrap;
}

.member-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

@media (max-width: 920px) {
  .hero-grid,
  .analytics-grid,
  .dialog-body {
    grid-template-columns: 1fr;
  }

  .controls {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .search-wrap {
    grid-column: 1 / -1;
  }

  .controls > #searchButton,
  .controls > #resetFilters {
    width: 100%;
  }
}

@media (max-width: 620px) {
  .topbar,
  .hero-grid,
  main {
    width: min(100% - 24px, 1180px);
  }

  .nav-actions {
    display: none;
  }

  .hero {
    min-height: 610px;
  }

  .hero-grid {
    padding: 70px 0 110px;
  }

  .hero h1 {
    font-size: 42px;
  }

  .lede {
    font-size: 17px;
  }

  .controls {
    position: static;
    grid-template-columns: 1fr;
  }

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

  .dialog-hero {
    padding: 58px 22px 24px;
  }

  .dialog-body {
    padding: 22px;
  }
}
