/* ===== APP LAYOUT ===== */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.app-header {
  position: sticky; top: 0; z-index: 50;
  border-bottom: 1px solid var(--border);
  background: rgba(8,8,8,0.95);
  backdrop-filter: blur(12px);
  padding: 0.75rem var(--pad);
  display: flex; align-items: center; gap: 1rem;
}
.app-header-brand {
  font-family: var(--font-display); font-weight: 700;
  font-size: 1rem; color: var(--text); text-decoration: none; letter-spacing: -0.02em;
}
.app-nav { display: flex; gap: 0.25rem; flex: 1; margin-left: 1rem; }
.app-nav a {
  padding: 0.4rem 0.75rem; border-radius: 6px;
  color: var(--muted); text-decoration: none; font-size: 0.875rem;
  transition: all 0.15s;
}
.app-nav a:hover { color: var(--text); background: var(--surface-2); }
.app-nav a.active { color: var(--green); background: var(--green-dim); }
.app-header-right { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.45rem 1rem; border-radius: 6px; font-size: 0.875rem; font-weight: 500; cursor: pointer; transition: all 0.15s; text-decoration: none; border: none; }
.btn-primary { background: var(--green); color: #000; }
.btn-primary:hover { opacity: 0.85; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-danger { background: rgba(255,77,77,0.1); color: var(--red); border: 1px solid var(--red); }
.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.8rem; }

/* ===== MAIN CONTENT ===== */
.app-main { flex: 1; padding: 2rem var(--pad); max-width: var(--max-w); margin: 0 auto; width: 100%; }

.page-header { margin-bottom: 2.5rem; }
.page-header-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
}
.page-eyebrow {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--green);
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.page-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.page-subtitle { color: var(--muted); font-size: 0.875rem; margin-top: 0.4rem; }
.page-actions { display: flex; gap: 0.75rem; align-items: center; margin-top: 0.75rem; }

/* ===== SECTION HEADER (inside dashboard) ===== */
.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.section-title-sm {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
}

/* ===== STAT CARDS — PREMIUM POLISH ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 2.5rem; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem 1.75rem;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.15s;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--green);
  opacity: 0.6;
  border-radius: 16px 16px 0 0;
}
.stat-card:hover { border-color: rgba(0,212,126,0.35); transform: translateY(-1px); }
.stat-card--pnl-positive::before { background: var(--green); opacity: 1; }
.stat-card--pnl-negative::before { background: var(--red); opacity: 1; }

.stat-label {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.6rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1;
}
.stat-value--positive { color: var(--green); }
.stat-value--negative { color: var(--red); }
.stat-sub { font-size: 0.78rem; color: var(--muted); margin-top: 0.5rem; }

/* ===== TABLE ===== */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.data-table td { padding: 0.9rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; color: var(--text); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }

/* ===== ACCOUNT CARDS — PREMIUM ===== */
.account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.25rem; margin-bottom: 2rem; }

.account-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  position: relative;
}
.account-card:hover {
  border-color: rgba(255,255,255,0.12);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  transform: translateY(-2px);
}
.account-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.account-card-header-left { flex: 1; min-width: 0; }
.account-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.account-broker { font-size: 0.78rem; color: var(--muted); margin-top: 0.2rem; }

.status-badge {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.3rem 0.7rem;
  border-radius: 100px;
  flex-shrink: 0;
  border: 1px solid transparent;
}
.status-eval { background: var(--amber-dim); color: var(--amber); border-color: rgba(245,166,35,0.2); }
.status-funded { background: var(--green-dim); color: var(--green); border-color: rgba(0,212,126,0.2); }

.account-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1.25rem; }
.metric { }
.metric-label {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.3rem;
  font-weight: 500;
}
.metric-value {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.metric-value.positive { color: var(--green); }
.metric-value.negative { color: var(--red); }
.metric-value.warning { color: var(--amber); }

/* ===== DRAWDOWN INDICATOR ===== */
.dd-section { }
.dd-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.dd-label {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}
.dd-pct {
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-display);
}
.dd-pct--safe { color: var(--green); }
.dd-pct--warning { color: var(--amber); }
.dd-pct--danger { color: var(--red); }

.dd-bar { height: 5px; background: rgba(255,255,255,0.06); border-radius: 4px; overflow: hidden; }
.dd-bar-fill { height: 100%; border-radius: 4px; transition: width 0.4s ease; }
.dd-safe { background: var(--green); }
.dd-warning { background: var(--amber); }
.dd-danger { background: var(--red); }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.4rem; text-transform: uppercase; letter-spacing: 0.05em; }
.form-control {
  width: 100%; padding: 0.6rem 0.85rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-family: var(--font-body);
  font-size: 0.9rem; transition: border-color 0.15s;
}
.form-control:focus { outline: none; border-color: var(--green); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.form-error { color: var(--red); font-size: 0.8rem; margin-top: 0.3rem; }

/* ===== FILTER BAR ===== */
.filter-bar { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.5rem; }
.filter-bar select, .filter-bar input { padding: 0.45rem 0.75rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 0.85rem; }

/* ===== RESULT BADGES ===== */
.result-win { color: var(--green); font-weight: 600; }
.result-loss { color: var(--red); font-weight: 600; }
.result-breakeven { color: var(--amber); font-weight: 600; }

/* ===== EMPTY STATES — PREMIUM ===== */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  border-style: dashed;
}
.empty-state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: var(--surface-2);
  border-radius: 16px;
  margin-bottom: 1.25rem;
  font-size: 1.75rem;
}
.empty-state h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}
.empty-state p { font-size: 0.875rem; color: var(--muted); max-width: 320px; margin: 0 auto 1.5rem; line-height: 1.6; }
.empty-state .btn { margin-top: 0.5rem; }

/* ===== TOAST ===== */
.toast-container { position: fixed; bottom: 2rem; right: 2rem; z-index: 999; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
  padding: 0.75rem 1.25rem; border-radius: 10px; font-size: 0.875rem;
  display: flex; align-items: center; gap: 0.5rem;
  animation: slideUp 0.2s ease-out;
}
.toast-success { background: var(--green-dim); color: var(--green); border: 1px solid var(--green); }
.toast-error { background: rgba(255,77,77,0.12); color: var(--red); border: 1px solid var(--red); }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ===== DELETE MODAL ===== */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 2rem; max-width: 420px; width: 90%;
}
.modal h3 { font-family: var(--font-display); font-size: 1.1rem; margin-bottom: 0.75rem; }
.modal p { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.5rem; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; }

/* ===== LOADING ===== */
.skeleton { background: var(--surface-2); border-radius: 6px; animation: shimmer 1.5s infinite; }
@keyframes shimmer { 0% { opacity: 0.5; } 50% { opacity: 1; } 100% { opacity: 0.5; } }

/* ===== AUTH PAGES ===== */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 2rem; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 2.5rem; width: 100%; max-width: 420px; }
.auth-logo { display: flex; align-items: center; gap: 0.5rem; text-decoration: none; margin-bottom: 2rem; }
.auth-logo-text { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; color: var(--text); }
.auth-title { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; color: var(--text); }
.auth-subtitle { color: var(--muted); font-size: 0.9rem; margin-bottom: 2rem; }
.auth-footer { text-align: center; margin-top: 1.5rem; font-size: 0.875rem; color: var(--muted); }
.auth-footer a { color: var(--green); text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }
.auth-forgot { color: var(--muted) !important; }
.auth-footer-sep { margin: 0 0.4rem; }
.auth-info-banner {
  background: rgba(0, 212, 126, 0.08);
  border: 1px solid rgba(0, 212, 126, 0.3);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--green);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header-inner { flex-direction: column; }
  .page-actions { margin-top: 0; }
}
@media (max-width: 600px) {
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .account-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
  .stat-card { padding: 1.1rem 1.25rem; }
  .stat-value { font-size: 1.5rem; }
  /* Nav: wrap labels so they don't overflow */
  .app-nav a { font-size: 0.8rem; padding: 0.35rem 0.5rem; }
  /* Tables: horizontal scroll, fixed layout */
  .data-table { display: block; overflow-x: auto; white-space: nowrap; }
  .data-table th, .data-table td { white-space: nowrap; }
  /* Buttons: ensure min tap height 44px on mobile */
  .btn { min-height: 44px; padding: 0.55rem 1rem; }
  /* Filter bar: stack vertically */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar select { width: 100%; }
  /* Page header: reduce spacing */
  .app-main { padding: 1rem var(--pad); }
  .page-header { margin-bottom: 1.25rem; }
  /* Account metrics: 2 columns on mobile */
  .account-metrics { grid-template-columns: 1fr 1fr; }
}