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

:root {
  --red: #E74C3C;
  --red-dark: #c0392b;
  --orange: #F39C12;
  --orange-light: #f5b041;
  --bg-dark: #1a1a2e;
  --bg-card: #16213e;
  --bg-card-hover: #1b2a4a;
  --bg-input: #0f1729;
  --text-primary: #e8e8e8;
  --text-secondary: #a0a0b0;
  --text-muted: #6c6c80;
  --border: #2a2a4a;
  --success: #2ecc71;
  --warning: #f39c12;
  --danger: #e74c3c;
  --radius: 8px;
  --radius-lg: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* ===== Header ===== */
header {
  background: linear-gradient(135deg, var(--bg-card) 0%, #1a1a3e 100%);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
}

.logo-icon { font-size: 1.5rem; }
.logo-text {
  background: linear-gradient(135deg, var(--red), var(--orange));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

nav { display: flex; gap: 0.25rem; }

.nav-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  border-radius: var(--radius);
  transition: all 0.2s;
}

.nav-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }
.nav-btn.active { color: var(--orange); background: rgba(243,156,18,0.1); }

/* ===== Buttons ===== */
.btn {
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: white;
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}
.btn-outline:hover { border-color: var(--orange); color: var(--orange); }

.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }

/* ===== Main Content ===== */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.page { display: none; }
.page.active { display: block; }
.hidden { display: none !important; }

/* ===== Generator Inputs ===== */
.generator-inputs {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.generator-inputs h2 {
  margin-bottom: 1rem;
  font-size: 1.25rem;
  color: var(--orange);
}

.input-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.input-group { display: flex; flex-direction: column; gap: 0.35rem; }
.input-group label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input, select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--orange);
}

/* ===== Plan Cards Grid ===== */
.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
}

.plan-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s;
}

.plan-card:hover {
  transform: translateY(-2px);
  border-color: var(--orange);
}

.plan-card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.plan-card-header h3 {
  font-size: 1.1rem;
  margin-bottom: 0.2rem;
}

.plan-card-header .strategy-badge {
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-safe { background: rgba(46,204,113,0.15); color: var(--success); }
.badge-balanced { background: rgba(243,156,18,0.15); color: var(--orange); }
.badge-yield { background: rgba(231,76,60,0.15); color: var(--red); }

.plan-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: rgba(0,0,0,0.2);
}

.stat { text-align: center; }
.stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--orange);
}
.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.plan-allocations {
  padding: 0.75rem 1.25rem;
  max-height: 250px;
  overflow-y: auto;
}

.alloc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  font-size: 0.85rem;
}

.alloc-row:last-child { border-bottom: none; }

.alloc-asset {
  font-weight: 600;
  min-width: 60px;
}

.alloc-details {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.alloc-apr {
  color: var(--success);
  font-weight: 500;
}

.alloc-amount { color: var(--text-primary); }

.plan-card-actions {
  padding: 0.75rem 1.25rem;
  display: flex;
  gap: 0.5rem;
  border-top: 1px solid var(--border);
}

.plan-card-actions .btn { flex: 1; justify-content: center; }

/* ===== Customize Modal ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 800px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-sm { max-width: 400px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 1.1rem; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 1.25rem; }

.customize-stats {
  display: flex;
  gap: 2rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: rgba(0,0,0,0.2);
  border-radius: var(--radius);
}

.customize-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.customize-table th {
  text-align: left;
  padding: 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.customize-table td {
  padding: 0.5rem;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.customize-table input[type="number"] {
  width: 100px;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
}

.customize-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.add-product-select {
  flex: 1;
  padding: 0.5rem;
}

/* ===== Dashboard ===== */
.subscription-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.sub-header {
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.sub-header h3 { font-size: 1.1rem; }

.sub-stats {
  display: flex;
  gap: 2rem;
  padding: 0.75rem 1.25rem;
  background: rgba(0,0,0,0.2);
}

.sub-items { padding: 0.5rem 1.25rem; overflow-x: auto; }

.sub-item {
  display: grid;
  grid-template-columns: 100px 80px 1fr 80px 110px 110px;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  gap: 0.5rem;
  font-size: 0.9rem;
}

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

.status-badge {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.25rem;
}

.status-active { background: var(--success); }
.status-expiring { background: var(--warning); }
.status-expired { background: var(--danger); }

.sub-actions {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

/* ===== Auth ===== */
.auth-toggle {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.auth-toggle a {
  color: var(--orange);
  text-decoration: none;
}
.auth-toggle a:hover { text-decoration: underline; }

.error-text {
  color: var(--danger);
  font-size: 0.85rem;
  padding: 0.5rem 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-info span { color: var(--text-secondary); font-size: 0.9rem; }

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.plan-card { animation: fadeIn 0.3s ease-out; }
.plan-card:nth-child(2) { animation-delay: 0.1s; }
.plan-card:nth-child(3) { animation-delay: 0.2s; }

.stat-value { transition: all 0.3s ease; }

/* ===== Loading ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: var(--text-muted);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 0.5rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .header-inner { flex-wrap: wrap; height: auto; padding: 0.75rem 0; gap: 0.5rem; }
  nav { order: 3; width: 100%; justify-content: center; }
  .plans-grid { grid-template-columns: 1fr; }
  .input-grid { grid-template-columns: 1fr 1fr; }
  .plan-stats { grid-template-columns: repeat(3, 1fr); }
  .sub-item { grid-template-columns: 60px 1fr 60px 80px 30px; font-size: 0.8rem; }
  .customize-stats { flex-direction: column; gap: 0.5rem; }
  .modal-content { width: 95%; }
}

@media (max-width: 480px) {
  .input-grid { grid-template-columns: 1fr; }
  main { padding: 1rem; }
  .sub-item { grid-template-columns: 1fr 1fr; }
}
