/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f8f9fb;
  color: #1a1a2e;
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100dvh;
}
.hidden { display: none !important; }
button { cursor: pointer; font-family: inherit; }
input, textarea { font-family: inherit; }
ul { list-style: none; }

/* ===== DOMAIN COLORS ===== */
:root {
  --executing: #7B2D8E;
  --executing-bg: #f3e8f9;
  --executing-light: #d4a5e3;
  --influencing: #E97A2B;
  --influencing-bg: #fef0e4;
  --influencing-light: #f5c49a;
  --relationship: #0091AE;
  --relationship-bg: #e0f4f8;
  --relationship-light: #7dd1e3;
  --strategic: #5B8C2A;
  --strategic-bg: #eaf4dd;
  --strategic-light: #a8d475;
  --bg: #f8f9fb;
  --card: #ffffff;
  --border: #e8eaed;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
}

/* ===== LOGIN SCREEN ===== */
#login-screen {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: #0f0f1a;
}
.login-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(123,45,142,0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(0,145,174,0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 60% 80%, rgba(233,122,43,0.1) 0%, transparent 50%);
}
.login-card {
  position: relative; z-index: 1;
  text-align: center; padding: 48px 40px;
  width: 90%; max-width: 400px;
}
.login-logo { margin-bottom: 40px; }
.logo-mark {
  width: 64px; height: 64px; margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--executing), var(--relationship));
  border-radius: 16px; display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800; color: white; letter-spacing: -1px;
}
.login-card h1 {
  font-size: 28px; font-weight: 700; color: white; letter-spacing: -0.5px;
}
.login-subtitle {
  color: rgba(255,255,255,0.5); font-size: 14px; margin-top: 4px; font-weight: 400;
}
.input-group {
  display: flex; gap: 8px; background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 12px;
  padding: 4px 4px 4px 16px; transition: border-color 0.2s;
}
.input-group:focus-within {
  border-color: rgba(123,45,142,0.6);
  background: rgba(255,255,255,0.12);
}
#password-input {
  flex: 1; background: none; border: none; outline: none;
  color: white; font-size: 15px; padding: 10px 0;
}
#password-input::placeholder { color: rgba(255,255,255,0.3); }
#login-btn {
  background: linear-gradient(135deg, var(--executing), #5a2080);
  border: none; border-radius: 10px; padding: 10px 16px;
  color: white; display: flex; align-items: center; justify-content: center;
  transition: opacity 0.2s;
}
#login-btn:hover { opacity: 0.9; }
.login-error { color: #ef4444; font-size: 13px; margin-top: 12px; min-height: 20px; }

/* ===== HEADER ===== */
#header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 60px;
  background: rgba(255,255,255,0.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--executing), var(--relationship));
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; color: white;
}
.header-title { font-size: 16px; font-weight: 700; letter-spacing: -0.3px; }
.header-title-light { font-weight: 400; color: var(--text-secondary); }
.header-nav { display: flex; gap: 2px; }
.nav-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border: none; background: none;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
  color: var(--text-secondary); transition: all 0.2s;
}
.nav-btn:hover { background: rgba(0,0,0,0.04); color: var(--text); }
.nav-btn.active { background: var(--executing-bg); color: var(--executing); }
.nav-btn svg { flex-shrink: 0; }
.header-logout {
  background: none; border: none; color: var(--text-tertiary);
  padding: 8px; border-radius: var(--radius-sm); transition: all 0.2s;
}
.header-logout:hover { background: rgba(0,0,0,0.04); color: var(--text); }

/* ===== MAIN CONTENT ===== */
#content {
  max-width: 1200px; margin: 0 auto;
  padding: 24px 24px 100px;
}
.view { display: none; animation: fadeIn 0.3s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.view-header { margin-bottom: 24px; }
.view-header h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; }
.view-desc { color: var(--text-secondary); font-size: 14px; margin-top: 2px; }

/* ===== CARDS ===== */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card h3 { font-size: 16px; font-weight: 600; letter-spacing: -0.2px; }
.card-desc { color: var(--text-secondary); font-size: 13px; margin-top: 2px; margin-bottom: 16px; }

/* ===== STATS ROW ===== */
.stats-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); border: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
}
.stat-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.stat-icon.purple { background: var(--executing-bg); color: var(--executing); }
.stat-icon.orange { background: var(--influencing-bg); color: var(--influencing); }
.stat-icon.teal { background: var(--relationship-bg); color: var(--relationship); }
.stat-icon.green { background: var(--strategic-bg); color: var(--strategic); }
.stat-value { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }

/* ===== DASHBOARD ===== */
.dashboard-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin-bottom: 24px;
}
.chart-container { position: relative; max-height: 280px; margin-top: 8px; }
.chart-container-bar { max-height: 320px; }

/* Team Glance */
.team-glance { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.glance-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.glance-row:hover { background: var(--bg); }
.glance-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: white; flex-shrink: 0;
}
.glance-name {
  width: 130px; flex-shrink: 0; font-size: 13px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.glance-strengths { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.strength-pill {
  padding: 4px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 500; white-space: nowrap;
}
.pill-executing { background: var(--executing-bg); color: var(--executing); }
.pill-influencing { background: var(--influencing-bg); color: var(--influencing); }
.pill-relationship { background: var(--relationship-bg); color: var(--relationship); }
.pill-strategic { background: var(--strategic-bg); color: var(--strategic); }

/* ===== TEAM VIEW ===== */
.team-filter { margin-bottom: 20px; }
.team-filter input {
  width: 100%; max-width: 400px; padding: 10px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; outline: none; background: var(--card);
  transition: border-color 0.2s;
}
.team-filter input:focus { border-color: var(--executing); }
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }

.team-card {
  background: var(--card); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--border);
  transition: box-shadow 0.2s, transform 0.2s; cursor: pointer;
}
.team-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.team-card-header {
  padding: 20px 20px 16px; display: flex; align-items: center; gap: 14px;
}
.team-card-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 600; color: white; flex-shrink: 0;
}
.team-card-name { font-size: 16px; font-weight: 600; }
.team-card-role { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }
.team-card-domain-bar {
  display: flex; height: 3px; margin: 0 20px;
}
.team-card-domain-bar span { flex: 1; }
.team-card-strengths {
  padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 8px;
}
.strength-row {
  display: flex; align-items: center; gap: 10px;
}
.strength-rank {
  width: 22px; font-size: 11px; font-weight: 600;
  color: var(--text-tertiary); text-align: right; flex-shrink: 0;
}
.strength-name {
  flex: 1; font-size: 13px; font-weight: 500;
}
.strength-domain-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.team-card-expand {
  padding: 0 20px 16px; display: flex; flex-direction: column; gap: 6px;
  border-top: 1px solid var(--border); margin-top: 4px; padding-top: 12px;
}
.team-card-expand .strength-name { color: var(--text-secondary); }
.team-card-toggle {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 8px; background: none; border: none; border-top: 1px solid var(--border);
  color: var(--text-secondary); font-size: 12px; font-weight: 500;
  width: 100%; transition: background 0.15s;
}
.team-card-toggle:hover { background: var(--bg); }
.team-card-toggle svg { transition: transform 0.2s; }
.team-card.expanded .team-card-toggle svg { transform: rotate(180deg); }

/* ===== DOMAINS VIEW ===== */
.domains-content { display: flex; flex-direction: column; gap: 24px; }
.domain-section {
  background: var(--card); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--border);
}
.domain-section-header {
  padding: 20px 24px; display: flex; align-items: center; gap: 14px;
}
.domain-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: white;
}
.domain-section-title { font-size: 18px; font-weight: 600; }
.domain-section-desc { font-size: 13px; color: var(--text-secondary); margin-top: 1px; }
.domain-strengths-grid {
  padding: 0 24px 24px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px;
}
.domain-strength-card {
  padding: 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); transition: box-shadow 0.2s;
}
.domain-strength-card:hover { box-shadow: var(--shadow); }
.domain-strength-name { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.domain-strength-people {
  display: flex; flex-wrap: wrap; gap: 4px;
}
.person-chip {
  padding: 2px 8px; border-radius: 12px;
  font-size: 11px; font-weight: 500;
}
.person-chip.top5 { font-weight: 600; }

/* ===== MATRIX VIEW ===== */
.matrix-legend {
  display: flex; gap: 16px; margin-bottom: 16px; flex-wrap: wrap;
}
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.legend-dot { width: 12px; height: 12px; border-radius: 3px; }
.matrix-wrapper {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  padding: 0;
}
.matrix-table table {
  border-collapse: collapse; font-size: 11px; width: 100%;
  min-width: 900px;
}
.matrix-table th, .matrix-table td {
  padding: 6px 8px; text-align: center; border: 1px solid var(--border);
}
.matrix-table th {
  background: var(--bg); font-weight: 600; position: sticky; top: 0; z-index: 2;
}
.matrix-table th.name-col {
  text-align: left; position: sticky; left: 0; z-index: 3; background: var(--bg);
  min-width: 110px;
}
.matrix-table td.name-cell {
  text-align: left; font-weight: 500; position: sticky; left: 0;
  background: white; z-index: 1; white-space: nowrap;
}
.matrix-cell {
  width: 28px; height: 28px; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600; color: white;
}
.matrix-cell.top5 { opacity: 1; }
.matrix-cell.top10 { opacity: 0.65; }
.matrix-cell.rest { opacity: 0.15; }

/* ===== LEADERSHIP VIEW ===== */
.leader-partnership {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
  margin-bottom: 24px;
}
.leader-profile {
  background: var(--card); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow); border: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.leader-profile::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
}
.leader-profile.brian::before { background: linear-gradient(90deg, var(--relationship), var(--executing)); }
.leader-profile.sam::before { background: linear-gradient(90deg, var(--executing), var(--influencing)); }
.leader-profile-header { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.leader-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: white; flex-shrink: 0;
}
.leader-name { font-size: 20px; font-weight: 700; }
.leader-role { font-size: 13px; color: var(--text-secondary); }
.leader-strengths-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.leader-insight { font-size: 14px; line-height: 1.7; color: var(--text); }
.leader-insight p { margin-bottom: 10px; }
.leader-insight strong { color: var(--text); }

.synergy-card {
  background: var(--card); border-radius: var(--radius);
  padding: 28px; box-shadow: var(--shadow); border: 1px solid var(--border);
  margin-bottom: 24px;
  background: linear-gradient(135deg, rgba(123,45,142,0.03), rgba(0,145,174,0.03));
}
.synergy-card h3 { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.synergy-card .card-desc { margin-bottom: 20px; }
.synergy-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.synergy-item {
  padding: 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: white;
}
.synergy-item h4 { font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--executing); }
.synergy-item p { font-size: 13px; line-height: 1.6; color: var(--text-secondary); }

.direct-reports-section { margin-bottom: 32px; }
.direct-reports-section > h3 {
  font-size: 18px; font-weight: 700; margin-bottom: 4px;
}
.direct-reports-section > p { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }
.report-cards { display: flex; flex-direction: column; gap: 16px; }
.report-card {
  background: var(--card); border-radius: var(--radius);
  padding: 20px 24px; box-shadow: var(--shadow); border: 1px solid var(--border);
}
.report-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.report-card-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; color: white; flex-shrink: 0;
}
.report-card-name { font-size: 15px; font-weight: 600; }
.report-card-sub { font-size: 12px; color: var(--text-secondary); }
.report-card-strengths { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.report-tips { display: flex; flex-direction: column; gap: 8px; }
.report-tip {
  display: flex; gap: 10px; font-size: 13px; line-height: 1.6;
  color: var(--text-secondary);
}
.report-tip-icon { flex-shrink: 0; font-size: 16px; margin-top: 1px; }
.report-tip strong { color: var(--text); }

@media (max-width: 768px) {
  .leader-partnership { grid-template-columns: 1fr; }
  .synergy-grid { grid-template-columns: 1fr; }
}

/* ===== CHAT VIEW ===== */
.chat-container {
  display: flex; flex-direction: column;
  height: calc(100dvh - 160px); max-height: 700px;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  overflow: hidden;
}
.chat-header-info {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.chat-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--executing), var(--relationship));
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.chat-header-info h3 { font-size: 15px; font-weight: 600; }
.chat-header-info p { font-size: 12px; color: var(--text-secondary); }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
}
.chat-message { display: flex; flex-direction: column; }
.chat-message.user { align-items: flex-end; }
.chat-message .message-content {
  max-width: 85%; padding: 12px 16px;
  border-radius: 16px; font-size: 14px; line-height: 1.6;
}
.chat-message.assistant .message-content {
  background: var(--bg); border-bottom-left-radius: 4px;
}
.chat-message.user .message-content {
  background: var(--executing); color: white; border-bottom-right-radius: 4px;
}
.chat-message .message-content p { margin-bottom: 8px; }
.chat-message .message-content p:last-child { margin-bottom: 0; }
.chat-message .message-content ul { padding-left: 18px; list-style: disc; margin: 8px 0; }
.chat-message .message-content li { margin-bottom: 4px; }
.chat-message .message-content strong { font-weight: 600; }
.typing-indicator {
  display: flex; gap: 4px; padding: 12px 16px;
  background: var(--bg); border-radius: 16px; border-bottom-left-radius: 4px;
  width: fit-content;
}
.typing-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--text-tertiary);
  animation: typingBounce 1.4s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}
.chat-input-area { border-top: 1px solid var(--border); padding: 12px 16px; }
.chat-suggestions {
  display: flex; gap: 8px; margin-bottom: 10px;
  overflow-x: auto; padding-bottom: 4px;
}
.suggestion-chip {
  padding: 6px 14px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--bg);
  font-size: 12px; color: var(--text-secondary); white-space: nowrap;
  transition: all 0.2s;
}
.suggestion-chip:hover { border-color: var(--executing); color: var(--executing); background: var(--executing-bg); }
.chat-input-row { display: flex; gap: 8px; align-items: flex-end; }
#chat-input {
  flex: 1; resize: none; border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 14px; font-size: 14px;
  outline: none; background: var(--bg); min-height: 42px; max-height: 120px;
  transition: border-color 0.2s;
}
#chat-input:focus { border-color: var(--executing); }
#chat-send {
  background: var(--executing); border: none; border-radius: 10px;
  padding: 10px 14px; color: white; display: flex; align-items: center;
  justify-content: center; transition: opacity 0.2s; flex-shrink: 0;
}
#chat-send:hover { opacity: 0.9; }
#chat-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== MOBILE NAV ===== */
.mobile-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(255,255,255,0.92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  justify-content: space-around; z-index: 100;
}
.mobile-nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 12px; border: none; background: none;
  font-size: 10px; font-weight: 500; color: var(--text-tertiary);
  border-radius: var(--radius-sm); transition: all 0.2s;
}
.mobile-nav-btn.active { color: var(--executing); }
.mobile-nav-btn svg { width: 22px; height: 22px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .header-nav { display: none; }
  .mobile-nav { display: flex; }
  #content { padding: 16px 16px 100px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 18px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .team-grid { grid-template-columns: 1fr; }
  .view-header h2 { font-size: 20px; }
  .glance-name { width: 90px; font-size: 12px; }
  .glance-strengths { gap: 4px; }
  .strength-pill { font-size: 10px; padding: 3px 8px; }
  .domain-strengths-grid { grid-template-columns: 1fr; }
  .chat-container { height: calc(100dvh - 180px); }
  .chat-suggestions { display: none; }
  .login-card { padding: 32px 24px; }
}
@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .stat-card { padding: 12px; gap: 10px; }
  .stat-icon { width: 36px; height: 36px; font-size: 16px; }
  .stat-value { font-size: 16px; }
  .stat-label { font-size: 11px; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
