/* ===== Investment Dashboard — Navy+Gold Design System ===== */
:root {
  --navy: #0A1628;
  --navy-light: #1B2A4A;
  --navy-mid: #2E4057;
  --gold: #C5A55A;
  --gold-light: #D4BC7C;
  --cream: #FDFBF5;
  --cream-dark: #F5F0E6;
  --green: #2ECC71;
  --green-dark: #27AE60;
  --red: #E74C3C;
  --red-dark: #C0392B;
  --up: #10b981;
  --down: #ef4444;
  --orange: #F39C12;
  --blue: #3498DB;
  --gray: #7F8C8D;
  --gray-light: #BDC3C7;
  --gray-dark: #2C3E50;
  --accent: #F39C12;
  --text-dark: #2C3E50;
  --text-light: #7F8C8D;
  --font-th: 'Sarabun', sans-serif;
  --font-en: 'Inter', sans-serif;
  --font-display: 'Playfair Display', serif;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(10, 22, 40, 0.08);
  --shadow-lg: 0 8px 32px rgba(10, 22, 40, 0.12);
  --positive: #3fb950;
  --negative: #f85149;
  --gold-dim: rgba(197,165,90,0.25);
  --text-muted: #8b949e;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-th);
  background: var(--cream);
  color: var(--navy);
  line-height: 1.6;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ===== Auth Overlay ===== */
#auth-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}

.auth-card {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(197, 165, 90, 0.2);
  border-radius: var(--radius);
  padding: 48px 40px;
  max-width: 400px; width: 100%;
  text-align: center;
}

.auth-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--navy);
  font-family: var(--font-display);
  font-size: 28px; font-weight: 700;
  border-radius: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}

.auth-card h1 {
  font-family: var(--font-display);
  color: white; font-size: 24px; margin-bottom: 4px;
}

.auth-subtitle { color: var(--gold); font-size: 14px; margin-bottom: 32px; }

#auth-password {
  width: 100%; padding: 14px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  color: white; font-size: 16px;
  font-family: var(--font-en);
  outline: none; transition: border-color 0.2s;
}

#auth-password:focus { border-color: var(--gold); }
#auth-password::placeholder { color: rgba(255, 255, 255, 0.4); }

.btn-auth {
  width: 100%; margin-top: 16px; padding: 14px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--navy); font-weight: 700; font-size: 15px;
  border: none; border-radius: var(--radius-sm);
  cursor: pointer; transition: transform 0.15s, box-shadow 0.15s;
  font-family: var(--font-en);
}

.btn-auth:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(197, 165, 90, 0.4); }

.auth-error { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 20px; }

/* ===== Header ===== */
.header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: white; padding: 16px 24px;
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-lg);
}

.header-brand { display: flex; align-items: center; gap: 12px; }

.brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--navy);
  font-family: var(--font-display);
  font-size: 20px; font-weight: 700;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 700;
}

.brand-sub { font-size: 12px; color: var(--gold); opacity: 0.8; }

.header-actions { display: flex; gap: 8px; }

.btn-icon {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: white; width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}

.btn-icon:hover { background: rgba(255, 255, 255, 0.2); }

/* ===== Period Toggle ===== */
.period-toggle {
  display: flex;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 3px;
  gap: 2px;
}

.period-btn {
  padding: 6px 16px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-en);
  border-radius: 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}

.period-btn:hover { color: rgba(255, 255, 255, 0.9); }

.period-btn.active {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--navy);
}

.period-divider {
  width: 1px;
  background: rgba(255, 255, 255, 0.2);
  margin: 4px 4px;
}

.portfolio-btn {
  padding: 6px 14px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-en);
  border-radius: 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}
.portfolio-btn:hover { color: rgba(255, 255, 255, 0.85); }
.portfolio-btn.active {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* ===== Ticker Bar ===== */
.ticker-bar {
  background: var(--navy);
  padding: 8px 24px;
  display: flex; gap: 24px; overflow-x: auto;
  border-bottom: 1px solid rgba(197, 165, 90, 0.2);
}

.ticker-item {
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap; font-size: 13px; color: rgba(255, 255, 255, 0.7);
  font-family: var(--font-en);
}

.ticker-label { font-weight: 600; color: var(--gold); }
.ticker-value { color: white; }
.ticker-change { font-weight: 600; padding: 2px 6px; border-radius: 4px; font-size: 12px; }
.ticker-change.up { background: rgba(46, 204, 113, 0.2); color: var(--green); }
.ticker-change.down { background: rgba(231, 76, 60, 0.2); color: var(--red); }
.ticker-status {
  margin-left: auto; font-size: 11px; color: rgba(255,255,255,0.45);
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
  font-family: var(--font-en);
}
.ticker-loading { color: rgba(255,255,255,0.3); font-style: italic; }
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  display: inline-block; animation: livePulse 2s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(46,204,113,0.5); }
  50% { opacity: 0.7; box-shadow: 0 0 6px 2px rgba(46,204,113,0.3); }
}
.ticker-flash { animation: tickFlash 0.6s ease-out; }
@keyframes tickFlash {
  0% { background: rgba(197,165,90,0.25); }
  100% { background: transparent; }
}

/* ===== Tabs ===== */
.tabs {
  background: white;
  padding: 0 24px;
  display: flex; gap: 0; overflow-x: auto;
  border-bottom: 2px solid var(--cream-dark);
  position: sticky; top: 72px; z-index: 99;
}

.tab {
  padding: 14px 20px;
  background: none; border: none;
  color: var(--gray);
  font-size: 14px; font-weight: 600;
  font-family: var(--font-en);
  cursor: pointer; white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  margin-bottom: -2px;
}

.tab:hover { color: var(--navy); }
.tab.active { color: var(--gold); border-bottom-color: var(--gold); }

/* ===== Content ===== */
.content { padding: 24px; max-width: 1400px; margin: 0 auto; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--gray);
  font-size: 13px;
  border-top: 1px solid var(--cream-dark);
  margin-top: 40px;
}

.footer-note { font-size: 11px; margin-top: 4px; }

/* ===== Data Timestamps ===== */
.data-timestamp {
  font-size: 12px;
  color: var(--gray);
  font-style: italic;
  padding: 4px 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ts-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ts-live { background: #22C55E; box-shadow: 0 0 4px #22C55E; }
.ts-stale { background: #F59E0B; }
.ts-closed { background: #9CA3AF; }

/* ===== Loading State ===== */
.loading {
  text-align: center; padding: 40px;
  color: var(--gray); font-size: 14px;
}

.loading::before {
  content: '';
  display: block; width: 32px; height: 32px;
  border: 3px solid var(--cream-dark);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Period Badge ===== */
.period-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: middle;
}

/* ===== Spinner ===== */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ===== Today Button Style ===== */
.today-btn { border: 1px solid #3B82F6; color: #93B5F8 !important; background: none; }
.today-btn:hover { background: rgba(59, 130, 246, 0.15); color: #fff !important; }
.today-btn.active { background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%); color: #fff !important; border-color: transparent; }

/* ===== Card Subtitle ===== */
.card-subtitle { font-size:12px; color:var(--gray); margin:-8px 0 12px; }

/* ===== Tabular Nums (Bloomberg Standard) ===== */
.kpi-value,
.ticker-value,
.ticker-change,
.rank-score-text,
.broker-dive-pnl,
.rec-pnl,
.buy-plan-amount-inline strong {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .header { padding: 12px 16px; flex-wrap: wrap; gap: 10px; }
  .brand-title { font-size: 15px; }
  .period-toggle { order: 3; width: 100%; justify-content: center; flex-wrap: wrap; }
  .period-btn { padding: 5px 12px; font-size: 12px; }
  .portfolio-btn { padding: 4px 10px; font-size: 11px; }
  .period-divider { height: 1px; width: auto; margin: 2px 0; flex-basis: 100%; background: none; }
  .ticker-bar { padding: 8px 16px; gap: 16px; }
  .tabs { padding: 0 12px; }
  .tab { padding: 12px 14px; font-size: 13px; }
  .content { padding: 16px; }
  .auth-card { padding: 32px 24px; }
}

@media (max-width: 480px) {
  /* Base mobile overrides handled in components.css */
}
