/* ===== Design Tokens ===== */
:root {
  --bg-primary: #0a0e17;
  --glass-bg: rgba(17, 24, 39, 0.65);
  --glass-border: rgba(255, 255, 255, 0.08);
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --success: #10b981;
  --danger: #ef4444;
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --radius-card: 16px;
  --radius-btn: 12px;
  --radius-input: 12px;
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 12px 40px rgba(59, 130, 246, 0.15);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

html {
  font-size: 15px;
  line-height: 1.6;
}

body {
  font-family: var(--font-stack);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== Background Glow ===== */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 20% 30%, rgba(59, 130, 246, 0.12) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 80% 70%, rgba(139, 92, 246, 0.1) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ===== Utility ===== */
.hidden {
  display: none !important;
}

.fade-out {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.fade-in {
  opacity: 1;
  transition: opacity 0.5s ease;
}

/* ===== Glass Card Base ===== */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-glass);
}

/* ===== Login Page ===== */
#login-page {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 48px 40px;
  text-align: center;
}

.login-card.shake {
  animation: shake 0.5s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-8px); }
  30% { transform: translateX(8px); }
  45% { transform: translateX(-6px); }
  60% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
  90% { transform: translateX(3px); }
}

/* Lock Icon (CSS) */
.lock-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 24px;
  position: relative;
}

.lock-icon::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 18px;
  border: 3px solid var(--accent-blue);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
}

.lock-icon::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 28px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  border-radius: 6px;
}

.login-title {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 32px;
  letter-spacing: 0.05em;
}

.form-group {
  margin-bottom: 16px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-input);
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font-stack);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.form-group input.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.btn-login {
  width: 100%;
  padding: 14px;
  margin-top: 8px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  border: none;
  border-radius: var(--radius-btn);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-stack);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}

.btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.35);
}

.btn-login:active {
  transform: translateY(0);
}

.status-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 32px;
  font-size: 12px;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
  50% { opacity: 0.8; box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

/* ===== Main Page ===== */
#main-page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  opacity: 0;
  display: none;
}

#main-page.visible {
  display: block;
}

/* Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  margin: 16px;
  border-radius: var(--radius-card);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  font-weight: 700;
}

.nav-logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  border-radius: 8px;
  position: relative;
}

.nav-logo-icon::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 3px;
}

.nav-time {
  font-size: 14px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.btn-logout {
  padding: 8px 20px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-btn);
  color: var(--danger);
  font-size: 13px;
  font-family: var(--font-stack);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.25);
  transform: translateY(-1px);
}

/* Bento Grid */
.bento-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  padding: 0 16px 32px;
  max-width: 1600px;
  margin: 0 auto;
}

@media (min-width: 640px) {
  .bento-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1024px) {
  .bento-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .chart-card {
    grid-column: span 2;
  }
}

@media (min-width: 1400px) {
  .bento-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .chart-card {
    grid-column: span 2;
  }

  .news-card {
    grid-row: span 2;
  }
}

/* Module Cards */
.module-card {
  position: relative;
  padding: 24px;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}

.module-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
}

.module-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-icon.news { background: rgba(59, 130, 246, 0.2); }
.card-icon.review { background: rgba(139, 92, 246, 0.2); }
.card-icon.holdings { background: rgba(16, 185, 129, 0.2); }
.card-icon.chart { background: rgba(245, 158, 11, 0.2); }
.card-icon.plan { background: rgba(236, 72, 153, 0.2); }

/* CSS Icons */
.icon-news,
.icon-review,
.icon-holdings,
.icon-chart,
.icon-plan {
  position: relative;
}

.icon-news::before {
  content: "";
  display: block;
  width: 14px;
  height: 16px;
  border: 2px solid var(--accent-blue);
  border-radius: 2px;
}

.icon-news::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 3px;
  width: 8px;
  height: 2px;
  background: var(--accent-blue);
  box-shadow: 0 4px 0 var(--accent-blue), 0 8px 0 var(--accent-blue);
}

.icon-review::before {
  content: "";
  display: block;
  width: 16px;
  height: 12px;
  border: 2px solid var(--accent-purple);
  border-radius: 2px;
}

.icon-review::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 2px;
  width: 12px;
  height: 2px;
  background: var(--accent-purple);
}

.icon-holdings::before {
  content: "";
  display: block;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 14px solid var(--success);
}

.icon-chart::before {
  content: "";
  display: block;
  width: 3px;
  height: 8px;
  background: #f59e0b;
  margin-left: 2px;
  box-shadow: 5px -4px 0 #f59e0b, 10px 2px 0 #f59e0b;
}

.icon-plan::before {
  content: "";
  display: block;
  width: 14px;
  height: 14px;
  border: 2px solid #ec4899;
  border-radius: 3px;
}

.icon-plan::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 5px;
  width: 6px;
  height: 3px;
  border-left: 2px solid #ec4899;
  border-bottom: 2px solid #ec4899;
  transform: rotate(-45deg);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
}

/* News Timeline */
.timeline {
  list-style: none;
}

.timeline-item {
  position: relative;
  padding-left: 24px;
  padding-bottom: 20px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 8px;
  bottom: -4px;
  width: 2px;
  background: rgba(59, 130, 246, 0.3);
}

.timeline-item:last-child::before {
  display: none;
}

.timeline-item::after {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  width: 10px;
  height: 10px;
  background: var(--accent-blue);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}

.timeline-date {
  font-size: 12px;
  color: var(--accent-blue);
  margin-bottom: 4px;
}

.timeline-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Review Tabs */
.tab-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab-btn {
  padding: 6px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 9999px;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font-stack);
  cursor: pointer;
  transition: all var(--transition);
}

.tab-btn.active {
  background: rgba(139, 92, 246, 0.2);
  border-color: var(--accent-purple);
  color: var(--text-primary);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.review-content {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.review-content p {
  margin-bottom: 8px;
}

/* Holdings Table */
.holdings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.holdings-table th {
  text-align: left;
  padding: 8px 12px;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 12px;
  border-bottom: 1px solid var(--glass-border);
}

.holdings-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

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

.text-up {
  color: var(--success);
}

.text-down {
  color: var(--danger);
}

/* Chart */
.chart-container {
  width: 100%;
  height: 280px;
  border-radius: 8px;
  overflow: hidden;
}

/* Plan Todo */
.todo-list {
  list-style: none;
}

.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.todo-item:last-child {
  border-bottom: none;
}

.todo-checkbox {
  width: 18px;
  height: 18px;
  border: 2px solid var(--glass-border);
  border-radius: 4px;
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.todo-checkbox.checked {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  border-color: transparent;
}

.todo-checkbox.checked::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 5px;
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.todo-text {
  font-size: 14px;
  color: var(--text-secondary);
  flex: 1;
}

.todo-text.done {
  text-decoration: line-through;
  opacity: 0.5;
}

.todo-priority {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 9999px;
  flex-shrink: 0;
}

.todo-priority.high {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.todo-priority.medium {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.todo-priority.low {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
}