/* penta.css */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: #1a1a1a;
  min-height: 100vh;
}

/* ── Header ────────────────────────────────────────────────────────────── */
header {
  background: #1a1a2e;
  color: white;
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.back-btn {
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: color 0.15s;
  flex-shrink: 0;
}
.back-btn:hover { color: white; }

header h1 {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ── Main layout ───────────────────────────────────────────────────────── */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ── Card ──────────────────────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 8px rgba(0,0,0,0.04);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

/* ── Header auth ───────────────────────────────────────────────────────── */
.header-auth {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  font-size: 0.82rem;
}

.header-auth-email {
  color: rgba(255,255,255,0.7);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-auth a, .header-auth button {
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}
.header-auth a:hover, .header-auth button:hover { background: rgba(255,255,255,0.22); }

/* ── Lock Overlay ─────────────────────────────────────────────────────── */
#lockOverlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(240,242,245,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lock-card {
  background: white;
  border-radius: 12px;
  padding: 2.5rem 2rem;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  max-width: 420px;
  width: 90%;
}
.lock-icon  { font-size: 2.5rem; margin-bottom: 1rem; }
.lock-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.5rem; color: #1a1a2e; }
.lock-body  { font-size: 0.88rem; color: #555; margin-bottom: 1.5rem; line-height: 1.6; }
.lock-btn-sub {
  display: inline-block;
  background: #2e7d32;
  color: white;
  padding: 0.65rem 1.75rem;
  border-radius: 5px;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
}
.lock-hint { margin-top: 0.85rem; font-size: 0.82rem; color: #aaa; }

/* ── Group filter ──────────────────────────────────────────────────────── */
.penta-group-filter {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 0.75rem 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.penta-group-filter label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #888;
  white-space: nowrap;
}

.group-filter-select {
  padding: 0.45rem 0.65rem;
  border: 1px solid #d5d5d5;
  border-radius: 5px;
  font-size: 0.88rem;
  color: #1a1a1a;
  background: white;
  cursor: pointer;
  min-width: 180px;
}
.group-filter-select:focus {
  outline: none;
  border-color: #4a6fa5;
  box-shadow: 0 0 0 3px rgba(74,111,165,0.14);
}

/* ── Person selectors grid ─────────────────────────────────────────────── */
.persons-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.person-slot {
  background: white;
  border-top: 3px solid var(--person-color, #ccc);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 0.75rem 1rem;
  min-width: 160px;
  flex: 1 1 160px;
  max-width: 220px;
}

.person-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--person-color, #888);
  margin-bottom: 0.4rem;
}

.person-select {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: 1px solid #d5d5d5;
  border-radius: 5px;
  font-size: 0.85rem;
  color: #1a1a1a;
  background: white;
  cursor: pointer;
}
.person-select:focus {
  outline: none;
  border-color: #4a6fa5;
  box-shadow: 0 0 0 3px rgba(74,111,165,0.14);
}

/* ── Best-person suggestion panel ──────────────────────────────────────── */
.best-panel {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  margin-bottom: 1.25rem;
  overflow: hidden;
  border: 1px solid #e0e0e0;
}

.best-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  background: #f7f8fa;
  border-bottom: 1px solid #e0e0e0;
  font-weight: 600;
  font-size: 0.88rem;
  color: #333;
}

.best-panel-close {
  background: none;
  border: none;
  color: #999;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 0.2rem;
  line-height: 1;
}
.best-panel-close:hover { color: #333; }

.best-list {
  padding: 0.4rem 0;
  max-height: 280px;
  overflow-y: auto;
}

.best-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: background 0.12s;
}
.best-item:hover { background: #f0f4ff; }

.best-name {
  color: #1a1a2e;
  font-size: 0.9rem;
}

.best-score {
  color: #2a7a2a;
  font-size: 0.8rem;
  font-weight: 600;
  margin-left: 1rem;
  white-space: nowrap;
}

.best-empty {
  padding: 0.75rem 1rem;
  color: #888;
  font-size: 0.85rem;
}

/* ── Penta main layout ─────────────────────────────────────────────────── */
.penta-main {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  align-items: flex-start;
}

/* ── Bodygraph SVG ─────────────────────────────────────────────────────── */
.penta-bodygraph-wrap {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 1rem;
  flex: 0 0 auto;
}

#pentaBodygraph svg {
  width: 480px;
  height: auto;
  display: block;
}

/* ── Roles ─────────────────────────────────────────────────────────────── */
.penta-roles-wrap {
  flex: 1 1 260px;
  min-width: 220px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 1rem 1.25rem;
}

.penta-roles-wrap h3 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #888;
  margin-bottom: 0.75rem;
}

.roles-grid {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.role-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.3rem 0.5rem;
  border-radius: 5px;
  min-height: 2rem;
}
.role-row:nth-child(odd) { background: #f7f8fa; }

.role-name {
  font-size: 0.78rem;
  color: #555;
  min-width: 80px;
  flex-shrink: 0;
}

.role-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.role-chip {
  display: inline-block;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.role-empty {
  color: #bbb;
  font-size: 0.8rem;
}

/* ── Mobile ────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  header { padding: 1rem; }

  main { padding: 1rem; }

  .person-slot {
    min-width: 140px;
    max-width: 100%;
  }

  .penta-bodygraph-wrap { width: 100%; display: flex; justify-content: center; }
  #pentaBodygraph svg { width: 100%; }

  .role-name {
    min-width: 60px;
    font-size: 0.7rem;
  }
}
