/* Emphatiq Performance Dashboard — client-facing light theme
   Premium wealth-management aesthetic: calm, confident, generous whitespace. */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-page:    #fafafa;
  --bg-card:    #ffffff;
  --border:     #e5e7eb;
  --border-light: #f0f1f3;
  --text-primary:   #0a0a0a;
  --text-secondary: #525252;
  --text-muted:     #a3a3a3;
  --green:      #15803d;
  --green-bg:   #f0fdf4;
  --red:        #b91c1c;
  --red-bg:     #fef2f2;
  --blue:       #1d4ed8;
  --blue-light: #eff6ff;
  --radius:     10px;
  --radius-sm:  6px;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-card-hover: 0 4px 12px rgba(0,0,0,0.08);
  --font-sans: -apple-system, "SF Pro Display", "Inter", "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", "Consolas", monospace;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Top bar ────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 16px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.topbar-logo {
  width: 28px;
  height: 28px;
  background: var(--text-primary);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar-logo svg {
  width: 16px;
  height: 16px;
  fill: white;
}

.topbar-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.topbar-spacer { flex: 1; }

.account-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
}

.account-btn {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.account-btn:hover {
  background: #f5f5f5;
  color: var(--text-primary);
}

.account-btn.active {
  background: var(--text-primary);
  color: white;
  border-color: var(--text-primary);
}

/* ── Main layout ────────────────────────────────────────────── */
.page-content {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* ── Skeleton loading ───────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position: 600px 0; }
}

.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
}

/* ── Hero ───────────────────────────────────────────────────── */
.hero {
  padding: 56px 0 40px;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.hero.visible { opacity: 1; }

.hero-nav-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.hero-nav {
  font-size: 64px;
  font-weight: 300;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin-bottom: 16px;
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.hero-holder {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-secondary);
}

.hero-asof {
  font-size: 13px;
  color: var(--text-muted);
}

.hero-delta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  padding: 4px 10px;
  border-radius: 20px;
}

.hero-delta.positive {
  color: var(--green);
  background: var(--green-bg);
}

.hero-delta.negative {
  color: var(--red);
  background: var(--red-bg);
}

.hero-delta.neutral {
  color: var(--text-muted);
  background: #f5f5f5;
}

/* ── Card ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.card-body {
  padding: 20px 24px 24px;
}

/* ── Returns table ──────────────────────────────────────────── */
.returns-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.returns-table th {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: right;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.returns-table th:first-child,
.returns-table th:nth-child(2) {
  text-align: left;
}

.returns-table td {
  text-align: right;
  padding: 12px 12px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.returns-table td:first-child {
  text-align: left;
  font-weight: 600;
  font-size: 13px;
}

.returns-table td:nth-child(2) {
  text-align: left;
  color: var(--text-secondary);
  font-size: 12px;
}

.returns-table tbody tr:last-child td { border-bottom: none; }

.returns-table tbody tr:hover td {
  background: #fafafa;
}

.pnl-positive { color: var(--green); font-weight: 500; }
.pnl-negative { color: var(--red); font-weight: 500; }
.pnl-neutral  { color: var(--text-muted); }

.return-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

.return-badge.positive { color: var(--green); background: var(--green-bg); }
.return-badge.negative { color: var(--red);   background: var(--red-bg);   }
.return-badge.neutral  { color: var(--text-muted); background: #f5f5f5; }

.table-footer {
  padding: 12px 12px 0;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-light);
  margin-top: 4px;
}

/* ── Chart ──────────────────────────────────────────────────── */
.card-header {
  flex-wrap: wrap;
  gap: 12px;
}

.chart-controls {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.period-btn {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.period-btn:hover {
  background: #f5f5f5;
  color: var(--text-primary);
}

.period-btn.active {
  background: var(--text-primary);
  color: white;
  border-color: var(--text-primary);
}

.chart-wrapper {
  position: relative;
  height: 300px;
  padding-top: 20px;
}

.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 260px;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}

/* ── Account Info ───────────────────────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.info-row {
  display: flex;
  flex-direction: column;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

.info-row:nth-child(odd)  { padding-right: 32px; }
.info-row:nth-child(even) { padding-left: 32px; border-left: 1px solid var(--border-light); }

.info-row:nth-last-child(1),
.info-row:nth-last-child(2) { border-bottom: none; }

.info-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.info-value {
  font-size: 13px;
  color: var(--text-primary);
}

/* ── Footer ─────────────────────────────────────────────────── */
.page-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 32px 0 20px;
}

/* ── Error state ────────────────────────────────────────────── */
.error-panel {
  padding: 48px 32px;
  text-align: center;
}

.error-panel h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.error-panel p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.auth-id {
  display: inline-block;
  margin-top: 16px;
  padding: 12px 16px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text-primary);
  background: #f5f5f5;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: left;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Auth gate ──────────────────────────────────────────────── */
.auth-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 60px);
  padding: 48px 24px;
}

.auth-gate-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 56px 48px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.04);
}

.auth-gate-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.auth-gate-sub {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 28px;
}

.auth-signin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  color: white;
  background: var(--text-primary);
  border: 1px solid var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.05s;
}

.auth-signin:hover { opacity: 0.92; }
.auth-signin:active { transform: translateY(1px); }

/* ── Signed-in user controls ────────────────────────────────── */
.auth-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 16px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}

.auth-user {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.auth-signout {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.auth-signout:hover {
  background: #f5f5f5;
  color: var(--text-primary);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 720px) {
  .topbar { padding: 0 16px; }
  .page-content { padding: 0 16px 64px; }

  .hero { padding: 36px 0 28px; }
  .hero-nav { font-size: 44px; }

  .card-body { padding: 16px 16px 20px; }
  .card-header { padding: 16px 16px 0; }

  .info-grid { grid-template-columns: 1fr; }
  .info-row:nth-child(odd)  { padding-right: 0; }
  .info-row:nth-child(even) { padding-left: 0; border-left: none; }
  .info-row:nth-last-child(2) { border-bottom: 1px solid var(--border-light); }

  .returns-table th:nth-child(2),
  .returns-table td:nth-child(2),
  .returns-table th:nth-child(3),
  .returns-table td:nth-child(3),
  .returns-table th:nth-child(4),
  .returns-table td:nth-child(4) {
    display: none;
  }

  .chart-wrapper { height: 240px; }

  .account-btn { padding: 5px 9px; font-size: 12px; }
}

@media (max-width: 480px) {
  .hero-nav { font-size: 36px; }
  .hero-meta { gap: 10px; }
  .topbar-name { display: none; }
}
