:root {
  --bg: #090c11;
  --bg-2: #0c1016;
  --card: #11161e;
  --card-2: #151b25;
  --line: #1e2530;
  --line-2: #262f3c;
  --text: #e9eef5;
  --muted: #8b95a5;
  --muted-2: #5e6878;
  --gold: #f0b90b;
  --gold-2: #e0a800;
  --green: #2ecc71;
  --green-dim: #25a35a;
  --red: #ff5b5b;
  --blue: #4f8cff;
  --radius: 14px;
  --maxw: 1180px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #0f1620 0%, var(--bg) 60%);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 40px;
}
a { color: inherit; text-decoration: none; }
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.green { color: var(--green) !important; }
.center { text-align: center; }

/* ===== SVG icon helpers ===== */
.ico-wrap { display: flex; align-items: center; justify-content: center; width: 18px; height: 18px; }
.ico-wrap svg { width: 100%; height: 100%; }
.nav-ico { display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin-bottom: 1px; }
.nav-ico svg { width: 100%; height: 100%; }
.fab-ico { display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; }
.fab-ico svg { width: 100%; height: 100%; }
.qa-ico { display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; }
.qa-ico svg { width: 100%; height: 100%; }

/* ===== Brand ===== */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 36px; height: 36px; flex: 0 0 36px; filter: drop-shadow(0 0 8px rgba(240,185,11,.45)); }
.brand-logo svg { width: 100%; height: 100%; }
.brand-text { font-weight: 800; letter-spacing: .5px; font-size: 15px; color: var(--gold); display: flex; flex-direction: column; line-height: 1.1; }
.brand-text small { color: var(--muted); font-weight: 500; font-size: 9px; letter-spacing: .3px; }

/* ===== Top navbar ===== */
.topbar { position: sticky; top: 0; z-index: 40; background: rgba(9,12,17,.85); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 24px; height: 64px; }
.nav-links { display: flex; gap: 26px; margin-left: 18px; flex: 1; }
.nav-links a { color: var(--muted); font-weight: 600; font-size: 13.5px; padding: 6px 0; position: relative; }
.nav-links a:hover { color: var(--text); }
.nav-links a.active { color: var(--text); }
.nav-links a.active::after { content: ''; position: absolute; left: 0; right: 0; bottom: -22px; height: 2px; background: var(--gold); border-radius: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }

.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  color: #1a1300; border: none; font-weight: 700; font-size: 13px;
  padding: 10px 16px; border-radius: 10px; cursor: pointer; font-family: inherit;
  box-shadow: 0 6px 18px rgba(240,185,11,.28);
}
.btn-gold:active { transform: scale(.97); }
.btn-gold.big { padding: 13px 22px; font-size: 14px; }

.icon-btn { position: relative; background: var(--card); border: 1px solid var(--line); color: var(--text); width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 16px; display: grid; place-items: center; }
.badge-dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--red); border: 2px solid var(--card); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--gold), #b8860b); color: #1a1300; display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.avatar.sm { width: 34px; height: 34px; font-size: 12px; }

/* ===== Mobile topbar / menu ===== */
.mobile-topbar { display: none; align-items: center; justify-content: space-between; padding: 12px 16px; position: absolute; top: 0; left: 0; right: 0; z-index: 40; background: transparent; border-bottom: none; }
.mob-topbar-left { display: flex; align-items: center; gap: 10px; }
.mob-brand-name { font-size: 18px; font-weight: 800; color: var(--gold); letter-spacing: -.3px; }
.brand-center .brand-text { flex-direction: row; font-size: 14px; }
.menu-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 60; }
.menu-overlay.open { display: block; }
.menu-panel { position: absolute; left: 0; top: 0; bottom: 0; width: 70%; max-width: 280px; background: var(--bg-2); border-right: 1px solid var(--line); padding: 24px 18px; display: flex; flex-direction: column; gap: 6px; }
.menu-panel a { padding: 13px 14px; border-radius: 10px; color: var(--muted); font-weight: 600; }
.menu-panel a.active { background: var(--card); color: var(--gold); }

.page { padding-top: 22px; }

/* ===== KPI ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi-card { background: linear-gradient(180deg, var(--card-2), var(--card)); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.kpi-top { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.kpi-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.kpi-ico svg { width: 18px; height: 18px; }
.ico-gold  { background: rgba(240,185,11,.14); color: var(--gold); }
.ico-red   { background: rgba(255,91,91,.14);  color: var(--red); }
.ico-blue  { background: rgba(79,140,255,.16); color: var(--blue); }
.ico-green { background: rgba(46,204,113,.16); color: var(--green); }
.kpi-name { font-size: 10.5px; font-weight: 700; letter-spacing: .6px; color: var(--muted); }
.kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.kpi-chg { font-size: 11.5px; font-weight: 600; margin-top: 4px; }
.kpi-chg span { color: var(--muted-2); font-weight: 500; }
.kpi-chg.up { color: var(--green); }
.kpi-chg.down { color: var(--red); }

/* ===== Panels ===== */
.panel { background: linear-gradient(180deg, var(--card-2), var(--card)); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.panel-head h3 { font-size: 16px; font-weight: 700; }
.panel-sub { font-size: 12px; color: var(--muted); margin-top: 8px; }
.big-green { color: var(--green); font-size: 24px; font-weight: 800; margin: 2px 0 8px; }
.select-pill { background: var(--card); border: 1px solid var(--line-2); color: var(--muted); font-size: 12px; font-weight: 600; padding: 7px 12px; border-radius: 9px; cursor: pointer; white-space: nowrap; }
.select-pill.big { display: inline-block; margin-top: 8px; padding: 11px 18px; font-size: 13px; color: var(--text); }

.two-col { display: grid; grid-template-columns: 1.05fr .95fr; gap: 16px; }

/* Charts */
.chart-area { width: 100%; margin-top: 6px; position: relative; }
.chart-area svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-tip { position: absolute; background: var(--card); border: 1px solid var(--line-2); border-radius: 8px; padding: 5px 9px; font-size: 11px; font-weight: 600; pointer-events: none; transform: translate(-50%, -120%); white-space: nowrap; }
.chart-tip b { color: var(--green); display: block; }

/* Donut */
.donut-row { display: flex; align-items: center; gap: 18px; margin: 12px 0 16px; }
.donut { width: 150px; height: 150px; flex: 0 0 auto; position: relative; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.donut-center b { font-size: 22px; font-weight: 800; display: block; line-height: 1.1; }
.donut-center small { font-size: 9px; color: var(--muted); letter-spacing: 1.5px; margin-top: 3px; }
.legend { list-style: none; display: flex; flex-direction: column; gap: 10px; font-size: 13px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend b { color: var(--text); font-weight: 600; margin-left: auto; }
.dot { width: 9px; height: 9px; border-radius: 50%; }
.dot-green { background: var(--green); } .dot-red { background: var(--red); } .dot-grey { background: var(--muted-2); }

.best-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.best-box { background: var(--card); border: 1px solid var(--line); border-radius: 11px; padding: 13px; }
.best-box small { font-size: 11px; color: var(--muted); display: block; }
.best-box b { font-size: 19px; font-weight: 800; display: block; margin: 3px 0; }
.best-box span { font-size: 11px; color: var(--muted-2); }

/* ===== Trades table ===== */
.table-wrap { overflow-x: auto; margin-top: 6px; }
.trades-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.trades-table th { text-align: left; font-size: 10.5px; letter-spacing: .6px; color: var(--muted-2); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.trades-table td { padding: 13px 12px; border-bottom: 1px solid var(--line); font-weight: 500; white-space: nowrap; }
.trades-table tbody tr { cursor: pointer; }
.trades-table tbody tr:hover { background: var(--card); }
.trades-table tbody tr:last-child td { border-bottom: none; }
.dir-buy { color: var(--green); font-weight: 700; }
.dir-sell { color: var(--red); font-weight: 700; }
.pnl-up { color: var(--green); font-weight: 700; }
.pnl-down { color: var(--red); font-weight: 700; }

.trades-cards { display: none; flex-direction: column; gap: 10px; margin-top: 6px; }
.tc { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; }
.tc-pair { font-weight: 700; font-size: 14px; }
.tc-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.tc-right { margin-left: auto; text-align: right; }
.tc-date { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ===== Quick actions (old, desktop fallback) ===== */
.quick-actions { display: none; }
.qa-title { font-size: 15px; margin-bottom: 12px; }
.qa-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.qa-item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 6px; color: var(--muted); font-size: 11px; font-weight: 600; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 8px; font-family: inherit; }
.qa-item:first-child .qa-ico { color: var(--gold); }

/* ===== Mobile Hero (hidden on desktop) ===== */
.mob-hero { display: none; }
.mob-stats { display: none; }
.mob-quick-actions { display: none; }
.mob-spacer { display: none; }

/* ===== Trading Calendar ===== */
.cal-section { margin-bottom: 16px; }
.cal-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.cal-title { font-size: 17px; font-weight: 700; }
.cal-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.cal-nav { display: flex; align-items: center; gap: 10px; }
.cal-nav-btn { background: var(--card); border: 1px solid var(--line-2); color: var(--text); width: 34px; height: 34px; border-radius: 9px; font-size: 18px; cursor: pointer; display: grid; place-items: center; line-height: 1; }
.cal-nav-btn:hover { border-color: var(--gold); color: var(--gold); }
.cal-month-label { font-size: 15px; font-weight: 700; min-width: 130px; text-align: center; }

/* Monthly summary */
.cal-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.cal-sum-box { background: var(--card); border: 1px solid var(--line); border-radius: 11px; padding: 11px 13px; }
.cal-sum-box small { font-size: 10.5px; color: var(--muted); display: block; margin-bottom: 4px; font-weight: 600; letter-spacing: .3px; }
.cal-sum-box b { font-size: 18px; font-weight: 800; }

/* Grid */
.cal-grid-wrap { overflow-x: auto; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 4px; }
.cal-weekdays span { text-align: center; font-size: 11px; color: var(--muted-2); font-weight: 700; padding: 6px 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }

.cal-day {
  height: 76px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  padding: 8px 8px 6px;
  cursor: pointer;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative;
  transition: border-color .15s, transform .1s;
  min-width: 0;
}
.cal-day:hover { border-color: var(--gold); transform: scale(1.03); z-index: 2; }
.cal-day.empty { background: none; border-color: transparent; cursor: default; pointer-events: none; }
.cal-day.today { border-color: rgba(240,185,11,.5); }
.cal-day.today .cal-day-num { color: var(--gold); font-weight: 800; }
.cal-day.win  { background: rgba(46,204,113,.1); border-color: rgba(46,204,113,.28); }
.cal-day.loss { background: rgba(255,91,91,.09); border-color: rgba(255,91,91,.26); }
.cal-day.be   { background: rgba(139,149,165,.08); border-color: rgba(139,149,165,.22); }

.cal-day-num { font-size: 12px; font-weight: 600; color: var(--muted); line-height: 1; }
.cal-day.win  .cal-day-num { color: rgba(46,204,113,.8); }
.cal-day.loss .cal-day-num { color: rgba(255,91,91,.8); }

.cal-day-bottom { display: flex; flex-direction: column; gap: 2px; }
.cal-day-pnl   { font-size: 13px; font-weight: 800; line-height: 1; letter-spacing: -.2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-day.win  .cal-day-pnl { color: var(--green); }
.cal-day.loss .cal-day-pnl { color: var(--red); }
.cal-day.be   .cal-day-pnl { color: var(--muted); }
.cal-day-count { font-size: 10px; color: var(--muted-2); font-weight: 500; }

/* Legend */
.cal-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; }
.leg-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.leg-dot { width: 10px; height: 10px; border-radius: 3px; }
.leg-win  { background: rgba(46,204,113,.5); border: 1px solid rgba(46,204,113,.6); }
.leg-loss { background: rgba(255,91,91,.4);  border: 1px solid rgba(255,91,91,.5); }
.leg-be   { background: rgba(139,149,165,.3); border: 1px solid rgba(139,149,165,.4); }
.leg-none { background: var(--card); border: 1px solid var(--line); }

/* ===== Footer minimal ===== */
.footer { border-top: 1px solid var(--line); margin-top: 26px; padding: 20px 0; }
.foot-brand .copy { color: var(--muted-2); font-size: 12px; margin-top: 10px; }

/* ===== FAB + bottom nav (mobile) ===== */
.fab { display: none; position: fixed; right: 16px; bottom: calc(72px + env(safe-area-inset-bottom)); width: 48px; height: 48px; border-radius: 50%; border: none; background: linear-gradient(135deg, var(--gold), var(--gold-2)); color: #1a1300; font-size: 24px; font-weight: 700; cursor: pointer; z-index: 45; box-shadow: 0 6px 18px rgba(240,185,11,.5); }
.fab:active { transform: scale(.93); }
.bottom-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 44; background: var(--bg-2); border-top: 1px solid var(--line); justify-content: space-around; align-items: center; padding: 6px 2px calc(6px + env(safe-area-inset-bottom)); }
.nav-item { background: none; border: none; color: var(--muted-2); display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 9px; font-weight: 600; cursor: pointer; flex: 1; font-family: inherit; min-width: 0; }
.nav-item small { font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.nav-ico { width: 20px; height: 20px; }
.nav-item.active { color: var(--gold); }
.nav-spacer { visibility: hidden; }

/* ===== Sheet ===== */
.sheet-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 70; }
.sheet-overlay.open { opacity: 1; pointer-events: auto; }
.sheet { width: 100%; max-width: 500px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 20px 20px 0 0; padding: 10px 20px calc(env(safe-area-inset-bottom) + 24px); max-height: 92dvh; overflow-y: auto; overflow-x: hidden; transform: translateY(100%); transition: transform .3s cubic-bezier(.32,.72,0,1); box-sizing: border-box; }
.sheet-overlay.open .sheet { transform: translateY(0); }

/* Pair autocomplete */
.pair-wrap { position: relative; }
.pair-dropdown { display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--card); border: 1px solid var(--line-2); border-radius: 10px; z-index: 100; max-height: 200px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.pair-dropdown.show { display: block; }
.pair-option { padding: 11px 14px; font-size: 14px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.pair-option:last-child { border-bottom: none; }
.pair-option:hover, .pair-option.focused { background: var(--card-2); color: var(--gold); }
.pair-option small { font-size: 11px; color: var(--muted); font-weight: 500; }
.sheet-handle { width: 40px; height: 4px; border-radius: 999px; background: var(--line-2); margin: 0 auto 14px; }
.sheet-title { font-size: 17px; font-weight: 700; margin-bottom: 16px; }
.trade-form { display: flex; flex-direction: column; gap: 13px; }
.trade-form label { display: flex; flex-direction: column; gap: 6px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row > * { min-width: 0; }
.trade-form input, .trade-form select, .trade-form textarea { background: var(--card); border: 1px solid var(--line-2); border-radius: 10px; padding: 11px 13px; color: var(--text); font-size: 14px; font-family: inherit; resize: vertical; width: 100%; min-width: 0; box-sizing: border-box; }
.trade-form input[type=file] { padding: 9px 11px; font-size: 12px; color: var(--muted); }
.trade-form input:focus, .trade-form select:focus, .trade-form textarea:focus { outline: none; border-color: var(--gold); }
.form-actions { display: flex; gap: 12px; margin-top: 6px; }
.form-actions > * { flex: 1; padding: 13px; border-radius: 11px; font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit; }
.btn-ghost { background: var(--card); color: var(--text); border: 1px solid var(--line-2); }

/* Toast */
.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--card-2); border: 1px solid var(--gold); color: var(--text); padding: 12px 18px; border-radius: 12px; font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .3s; z-index: 80; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===================== RESPONSIVE ===================== */
/* Layar lebar menengah: rapikan grid, top-nav desktop masih muat (>=981px) */
@media (min-width: 981px) and (max-width: 1100px) {
  .two-col { grid-template-columns: 1fr; }
}

/* ===================== MOBILE (≤980px) ===================== */
@media (max-width: 980px) {
  .topbar { display: none; }
  .mobile-topbar { display: flex; }
  .two-col { grid-template-columns: 1fr; }
  .trades-table { display: none; }
  .table-wrap { overflow: visible; }
  .trades-cards { display: flex; }
  .fab { display: grid; place-items: center; }
  .bottom-nav { display: flex; }
  .page { padding-top: 0; }
  /* Non-dashboard pages: push content below transparent topbar */
  #page-trades, #page-analytics, #page-calendar, #page-goals,
  #page-reports, #page-insights, #page-account { padding-top: 56px; }
  .mob-spacer { display: block; height: calc(72px + env(safe-area-inset-bottom)); }
  body { padding-bottom: 0; }
  /* Keep container padding — full-bleed elements use negative margin */
  .container { padding: 0 16px; }

  /* ─── KPI grid hidden on mobile ─── */
  .kpi-grid { display: none; }

  /* ─── Mobile BG Wrap (hero + chart share one background) ─── */
  .mob-bg-wrap {
    display: block;
    position: relative;
    margin: 0 -16px;
    overflow: hidden;
  }
  /* dark overlay so text stays readable over photos */
  .mob-bg-overlay {
    display: block;
    position: absolute; inset: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,.35) 0%, rgba(0,0,0,.15) 50%, rgba(9,12,17,.85) 100%);
    pointer-events: none;
    z-index: 1;
  }
  .mob-hero, .mob-equity-chart { position: relative; z-index: 2; }

  /* ─── Mobile Hero ─── */
  .mob-hero {
    display: block;
    text-align: center;
    padding: 72px 16px 20px;
    background: none;
  }
  .mob-bal-label {
    font-size: 10px; font-weight: 700; letter-spacing: 1.5px;
    color: var(--muted); text-transform: uppercase; margin-bottom: 10px;
  }
  .mob-bal {
    font-size: 40px; font-weight: 900; letter-spacing: -1.5px; line-height: 1;
  }
  .mob-pnl-tag {
    font-size: 14px; font-weight: 700; margin-top: 10px; letter-spacing: -.1px;
  }

  /* ─── Equity chart: full-bleed inside bg-wrap on mobile ─── */
  .mob-equity-chart { display: block; width: 100%; }
  .mob-equity-chart svg, .mob-equity-chart canvas { display: block; width: 100% !important; }
  /* hide the original panel-equity on mobile (chart rendered in mob-equity-chart) */
  .panel-equity { display: none !important; }

  /* Hide chart tooltip on mobile (prevents overlap) */
  .chart-tip { display: none; }

  /* ─── Win rate panel: hidden on mobile dashboard ─── */
  .panel-winrate { display: none; }

  /* ─── Mobile Stat Strip ─── */
  .mob-stats {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 16px 0;
    margin: 0 -16px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    margin-bottom: 28px;
  }
  .mob-stat {
    display: flex; flex-direction: column; align-items: center; gap: 5px; flex: 1;
  }
  .mob-stat b { font-size: 16px; font-weight: 800; letter-spacing: -.3px; line-height: 1; }
  .mob-stat span { font-size: 9px; color: var(--muted); font-weight: 700; letter-spacing: .6px; text-transform: uppercase; }
  .mob-stat-div { width: 1px; height: 28px; background: var(--line); flex: 0 0 1px; }

  /* ─── Recent Trades: flat list, no panel box ─── */
  .panel-trades {
    background: none !important; border: none !important;
    border-radius: 0 !important; padding: 0 !important;
    margin-bottom: 4px !important;
  }
  .panel-trades .panel-head {
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 0;
  }
  .panel-trades .panel-head h3 { font-size: 16px; font-weight: 700; }
  .panel-trades { padding-bottom: 8px !important; }

  /* Trade rows */
  .tc {
    background: none; border: none; border-bottom: 1px solid var(--line);
    border-radius: 0; padding: 15px 0 15px 16px;
    position: relative; gap: 10px;
  }
  .tc:last-child { border-bottom: none; }
  .tc::before {
    content: '';
    position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    width: 3px; height: 28px; border-radius: 3px; background: var(--line-2);
  }
  .tc.tc-win::before { background: var(--green); }
  .tc.tc-loss::before { background: var(--red); }
  .tc-pair { font-size: 14px; font-weight: 700; }
  .tc-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
  .tc-right { margin-left: auto; text-align: right; }
  .tc-date { font-size: 11px; color: var(--muted-2); margin-top: 3px; }

  /* ─── Quick Actions ─── */
  .mob-quick-actions {
    display: block;
    padding: 24px 0 8px;
  }
  .mob-qa-label {
    font-size: 9px; font-weight: 700; letter-spacing: 1.2px;
    color: var(--muted-2); text-transform: uppercase; margin-bottom: 16px;
  }
  .mob-qa-row { display: flex; justify-content: space-between; gap: 10px; }
  .mob-qa-btn {
    flex: 1; background: var(--card); border: 1px solid var(--line);
    border-radius: 14px; padding: 14px 4px 12px;
    color: var(--muted); font-size: 11px; font-weight: 600;
    cursor: pointer; font-family: inherit;
    display: flex; flex-direction: column; align-items: center; gap: 9px;
    transition: border-color .15s, background .15s;
  }
  .mob-qa-btn:active { transform: scale(.96); }
  .mob-qa-ico { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; }
  .mob-qa-ico svg { width: 100%; height: 100%; }
  .mob-qa-btn:first-child { background: rgba(240,185,11,.08); border-color: rgba(240,185,11,.3); color: var(--gold); }

  /* Footer */
  .footer { display: none; }

  /* ─── Shared: page header ─── */
  .page-header { margin-bottom: 0; padding-top: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
  .page-title { font-size: 19px; }

  /* ============================================================
     TRADES PAGE — mobile flat
  ============================================================ */
  #page-trades .panel {
    background: none; border: none; border-radius: 0; padding: 0; margin-bottom: 0;
  }
  /* Toolbar strip */
  #page-trades .trades-toolbar {
    flex-direction: column; align-items: stretch; gap: 10px;
    padding: 14px 0; border-bottom: 1px solid var(--line);
  }
  .trades-search { width: 100%; background: var(--card); }
  .filter-chips { gap: 8px; }

  /* Trade list in trades page */
  #page-trades .trades-cards { flex-direction: column; gap: 0; margin-top: 0; }
  #page-trades .tc {
    background: none; border: none; border-bottom: 1px solid var(--line);
    border-radius: 0; padding: 15px 0 15px 16px; position: relative;
  }
  #page-trades .tc:last-child { border-bottom: none; }
  #page-trades .tc::before {
    content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    width: 3px; height: 28px; border-radius: 3px; background: var(--line-2);
  }
  #page-trades .tc.tc-win::before { background: var(--green); }
  #page-trades .tc.tc-loss::before { background: var(--red); }

  /* ============================================================
     ANALYTICS PAGE — mobile flat
  ============================================================ */
  #page-analytics .panel {
    background: none; border: none; border-radius: 0;
    padding: 0; margin-bottom: 0;
  }
  /* Equity curve section */
  #page-analytics .panel:first-of-type {
    margin: 0 -16px; padding: 0;
  }
  #page-analytics .panel:first-of-type .panel-head {
    padding: 18px 16px 4px;
  }
  #page-analytics .panel:first-of-type .panel-sub,
  #page-analytics .panel:first-of-type .big-green { padding: 0 16px; }
  #page-analytics .panel:first-of-type .chart-area { padding: 0; }

  /* Other analytics panels */
  #page-analytics .two-col { gap: 0; }
  #page-analytics .two-col .panel {
    padding: 20px 0; border-bottom: 1px solid var(--line);
  }
  #page-analytics .two-col .panel .panel-head h3 { font-size: 15px; margin-bottom: 12px; }

  /* Win/Loss donut panel */
  #page-analytics > .panel:last-of-type {
    padding: 20px 0 0;
  }
  .donut-row { flex-direction: column; align-items: center; gap: 16px; }
  .donut { width: 160px; height: 160px; }
  .donut-center b { font-size: 26px; }
  .legend { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 12px; }
  .best-row { gap: 10px; }
  .best-box { padding: 14px; border-radius: 12px; }
  .best-box b { font-size: 17px; }

  /* ============================================================
     CALENDAR PAGE — mobile flat
  ============================================================ */
  #page-calendar .panel {
    background: none; border: none; border-radius: 0; padding: 0; margin-bottom: 0;
  }
  .cal-summary { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 18px; }
  .cal-sum-box { border-radius: 10px; }
  .cal-header { padding-top: 6px; }

  /* ============================================================
     GOALS PAGE — mobile flat
  ============================================================ */
  #page-goals .two-col { gap: 0; }
  #page-goals .panel {
    background: none; border: none; border-radius: 0;
    padding: 20px 0; margin-bottom: 0; border-bottom: 1px solid var(--line);
  }
  #page-goals .panel:last-child { border-bottom: none; }
  #page-goals .panel .panel-head h3 { font-size: 16px; margin-bottom: 16px; }
  .goals-form input {
    background: var(--card-2); border: 1px solid var(--line-2);
    border-radius: 12px; padding: 13px 14px; font-size: 15px;
  }
  .goal-bar-wrap { height: 6px; border-radius: 6px; }

  /* ============================================================
     REPORTS PAGE — mobile flat
  ============================================================ */
  #page-reports .panel {
    background: none; border: none; border-radius: 0; padding: 0; margin-bottom: 0;
  }
  /* Override trades-table display:none for reports */
  #page-reports .trades-table { display: table; width: 100%; }
  #page-reports .trades-table th {
    font-size: 10px; letter-spacing: .5px; padding: 10px 0; color: var(--muted-2);
  }
  #page-reports .trades-table td {
    padding: 12px 0; border-bottom: 1px solid var(--line);
    font-size: 13px; white-space: normal;
  }
  #page-reports .trades-table tbody tr:last-child td { border-bottom: none; }

  /* ============================================================
     INSIGHTS PAGE — mobile flat
  ============================================================ */
  .insights-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0;
  }
  .insight-card {
    background: none; border: none; border-radius: 0;
    padding: 16px 0;
    border-bottom: 1px solid var(--line);
  }
  /* Every even card gets a left border as separator */
  .insight-card:nth-child(odd) { padding-right: 16px; }
  .insight-card:nth-child(even) { padding-left: 16px; border-left: 1px solid var(--line); }
  /* Last 2 cards — no bottom border */
  .insight-card:nth-last-child(-n+2) { border-bottom: none; }
  .insight-value { font-size: 18px; }

  /* Tips section */
  .tip-item { border-radius: 12px; }
}

/* ===================== ACCOUNT PAGE ===================== */
.acc-section { padding: 18px 0; }
.acc-avatar-row { display: flex; align-items: center; gap: 16px; }
.acc-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), #b8860b);
  color: #1a1300; display: grid; place-items: center;
  font-weight: 900; font-size: 22px; flex: 0 0 64px;
}
.acc-name { font-size: 18px; font-weight: 800; }
.acc-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.acc-divider { height: 1px; background: var(--line); margin: 4px 0; }
.acc-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  color: var(--muted-2); text-transform: uppercase;
  margin: 18px 0 12px;
}
.acc-form { display: flex; flex-direction: column; }
.acc-field {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 0; border-bottom: 1px solid var(--line); gap: 12px;
}
.acc-field span { font-size: 14px; font-weight: 500; color: var(--text); flex: 0 0 auto; }
.acc-field input, .acc-field select {
  background: none; border: none; outline: none;
  color: var(--muted); font-size: 14px; font-family: inherit;
  text-align: right; flex: 1; min-width: 0;
}
.acc-field select { cursor: pointer; }
.acc-field input::placeholder { color: var(--muted-2); }
.acc-field input:focus, .acc-field select:focus { color: var(--text); }
.acc-danger-btn {
  width: 100%; padding: 13px; border-radius: 12px; border: 1px solid rgba(255,91,91,.4);
  background: rgba(255,91,91,.08); color: var(--red); font-size: 14px; font-weight: 700;
  cursor: pointer; font-family: inherit; margin-top: 4px;
}
.acc-danger-btn:active { transform: scale(.98); }
.acc-logout-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 13px; border-radius: 12px;
  border: 1px solid rgba(255,91,91,.3);
  background: rgba(255,91,91,.06); color: var(--red);
  font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.acc-logout-btn:active { transform: scale(.98); }

/* Background templates */
.bg-templates { display: flex; gap: 10px; flex-wrap: wrap; padding: 10px 0 14px; }
.bg-swatch { width: 44px; height: 44px; border-radius: 10px; border: 2px solid transparent; cursor: pointer; transition: transform .15s, border-color .15s; flex-shrink: 0; }
.bg-swatch:hover { transform: scale(1.1); }
.bg-swatch.active { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(240,185,11,.25); }
.acc-field-upload { align-items: center; }
.upload-btn { display: inline-block; padding: 7px 16px; border-radius: 8px; background: var(--card-2); border: 1px solid var(--line-2); color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.upload-btn:hover { background: var(--line-2); }

@media (max-width: 980px) {
  #page-account .page-header { padding-bottom: 0; border-bottom: none; }
  .acc-section { padding: 14px 0; }
  .acc-avatar { width: 56px; height: 56px; font-size: 18px; flex: 0 0 56px; }
  .acc-name { font-size: 16px; }
}

@media (max-width: 640px) {
  /* Calendar full-bleed on mobile */
  #page-calendar .panel { margin-left: -16px !important; margin-right: -16px !important; padding: 0 !important; border: none !important; background: none !important; }
  .cal-header { padding: 16px 16px 12px; }
  .cal-summary { padding: 0 16px 14px; }
  .cal-legend { padding: 10px 16px; }
  .cal-sum-box b { font-size: 15px; }

  .cal-grid-wrap { padding: 0 4px; overflow-x: hidden; }
  .cal-weekdays { gap: 2px; padding: 0 4px; }
  .cal-weekdays span { font-size: 9px; font-weight: 700; color: var(--muted); text-align: center; }
  .cal-grid { gap: 2px; }

  .cal-day { height: auto; aspect-ratio: 1 / 1.3; border-radius: 7px; padding: 5px 3px 4px; }
  .cal-day-num { font-size: 10px; font-weight: 700; margin-bottom: 3px; }
  .cal-day-pnl { font-size: 9px; font-weight: 800; letter-spacing: -.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .cal-day-bottom { gap: 1px; }
  .cal-day-count { display: none; }
}

@media (max-width: 380px) {
  .mob-bal { font-size: 34px; }
  .mob-stat b { font-size: 14px; }
  .container { padding: 0 12px; }
  .mob-hero { margin: 0 -12px; }
  .panel-equity { margin: 0 -12px 0 !important; }
  .mob-stats { margin: 0 -12px; }
}

/* ===================== SPA PAGE VIEWS ===================== */
.page-view { display: none; }
.page-view.active { display: block; }

/* Page header row */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; gap: 12px;
}
.page-title { font-size: 22px; font-weight: 800; }

/* ===================== TRADES PAGE ===================== */
.trades-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.trades-search {
  flex: 1; min-width: 180px;
  background: var(--card); border: 1px solid var(--line-2);
  border-radius: 10px; padding: 10px 14px; color: var(--text);
  font-size: 13px; font-family: inherit;
}
.trades-search:focus { outline: none; border-color: var(--gold); }
.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: var(--card); border: 1px solid var(--line-2);
  color: var(--muted); font-size: 12px; font-weight: 600;
  padding: 7px 14px; border-radius: 20px; cursor: pointer;
  font-family: inherit; transition: all .15s;
}
.chip:hover { border-color: var(--gold); color: var(--text); }
.chip.active { background: var(--gold); border-color: var(--gold); color: #1a1300; }

/* ===================== GOALS PAGE ===================== */
.goals-form {
  display: flex; flex-direction: column; gap: 14px;
}
.goals-form label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 11.5px; color: var(--muted); font-weight: 600;
}
.goals-form input {
  background: var(--card); border: 1px solid var(--line-2);
  border-radius: 10px; padding: 11px 13px; color: var(--text);
  font-size: 14px; font-family: inherit;
}
.goals-form input:focus { outline: none; border-color: var(--gold); }

.goal-item { margin-bottom: 18px; }
.goal-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 8px; }
.goal-target { color: var(--muted); font-size: 12px; }
.goal-bar-wrap {
  width: 100%; height: 8px; background: var(--line);
  border-radius: 99px; overflow: hidden;
}
.goal-bar { height: 100%; border-radius: 99px; transition: width .4s ease; }
.goal-pct { font-size: 11px; font-weight: 700; margin-top: 5px; }

/* ===================== INSIGHTS PAGE ===================== */
.insights-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
.insight-card {
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px;
}
.insight-label { font-size: 10.5px; font-weight: 700; letter-spacing: .6px; color: var(--muted); margin-bottom: 8px; }
.insight-value { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.insight-sub { font-size: 11px; color: var(--muted-2); }
.insight-empty { text-align: center; }

.tips-list { list-style: none; display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.tip-item {
  background: var(--card); border: 1px solid var(--line-2);
  border-radius: 10px; padding: 12px 14px;
  font-size: 13px; color: var(--text); line-height: 1.5;
  padding-left: 36px; position: relative;
}
.tip-item::before {
  content: "💡";
  position: absolute; left: 12px; top: 11px; font-size: 14px;
}

@media (max-width: 980px) {
  .insights-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .insights-grid { grid-template-columns: 1fr; }
  .trades-toolbar { flex-direction: column; align-items: stretch; }
  .filter-chips { justify-content: flex-start; }
  .page-title { font-size: 18px; }
}

/* ===== DESKTOP REDESIGN v38 ===== */

/* Mobile-first: sidebar & topbar hidden */
.desk-sidebar { display: none; }
.desk-topbar  { display: none; }

/* On mobile, desk-content is just a normal block container */
.desk-content { display: block; width: 100%; }

/* ── Desktop ≥981px ── */
@media (min-width: 981px) {
  body {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    min-height: 100vh;
    padding-bottom: 0;
    background: var(--bg);
  }

  /* Fixed left sidebar */
  .desk-sidebar {
    display: flex;
    flex-direction: column;
    width: 220px;
    min-width: 220px;
    min-height: 100vh;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    background: var(--card);
    border-right: 1px solid var(--line);
    z-index: 50;
    overflow: hidden;
  }

  /* Content area fills remaining width */
  .desk-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    min-height: 100vh;
    margin-left: 220px;
    background: radial-gradient(1200px 600px at 60% -10%, #0f1620 0%, var(--bg) 60%);
  }

  /* Container fills full width on desktop */
  .desk-content .container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0 28px 28px;
  }

  /* Sidebar logo area */
  .desk-sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px 16px;
    border-bottom: 1px solid var(--line);
  }
  .desk-logo-mark {
    width: 36px; height: 36px; flex: 0 0 36px;
    filter: drop-shadow(0 0 8px rgba(240,185,11,.45));
  }
  .desk-logo-mark svg, .desk-logo-mark .brand-logo svg { width: 100%; height: 100%; }
  .desk-logo-text {
    font-size: 20px; font-weight: 900; color: var(--gold);
    letter-spacing: 2px;
  }

  /* Sidebar nav */
  .desk-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 12px 10px;
    gap: 2px;
    overflow-y: auto;
  }
  .desk-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 13.5px;
    font-weight: 600;
    transition: background .15s, color .15s;
    cursor: pointer;
  }
  .desk-nav-item:hover {
    background: rgba(255,255,255,.04);
    color: var(--text);
  }
  .desk-nav-item.active {
    background: rgba(240,185,11,.10);
    color: var(--gold);
  }
  .desk-nav-ico {
    width: 18px; height: 18px; flex: 0 0 18px;
    display: flex; align-items: center; justify-content: center;
  }
  .desk-nav-ico svg { width: 100%; height: 100%; }
  .desk-nav-divider {
    height: 1px;
    background: var(--line);
    margin: 8px 4px;
  }

  /* Sidebar footer */
  .desk-sidebar-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
  }
  .desk-user-avatar {
    width: 34px; height: 34px; border-radius: 50%; flex: 0 0 34px;
    background: linear-gradient(135deg, var(--gold), #b8860b);
    color: #1a1300; display: grid; place-items: center;
    font-weight: 800; font-size: 12px;
  }
  .desk-user-info { min-width: 0; }
  .desk-user-name {
    font-size: 13px; font-weight: 700; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .desk-user-sub {
    font-size: 11px; color: var(--muted); margin-top: 1px;
  }

  /* ── Desktop topbar ── */
  .desk-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 24px;
    background: rgba(14,19,25,.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 40;
  }
  .desk-topbar-left { display: flex; align-items: center; gap: 12px; }
  .desk-topbar-right { display: flex; align-items: center; gap: 12px; }
  .desk-page-title {
    font-size: 17px; font-weight: 800; color: var(--text);
    letter-spacing: -.2px;
  }

  /* Hide old topbar, mobile elements on desktop */
  .topbar { display: none !important; }
  .mobile-topbar { display: none !important; }
  .menu-overlay { display: none !important; }
  .fab { display: none !important; }
  .bottom-nav { display: none !important; }
  .mob-spacer { display: none !important; }
  .mob-bg-wrap { display: none !important; }
  .mob-stats { display: none !important; }
  .mob-quick-actions { display: none !important; }

  /* Page area */
  .page { padding-top: 0; }
  .container { max-width: 1280px; }

  /* ── KPI grid: 5 cards on desktop ── */
  .kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    margin-bottom: 18px;
  }

  /* 5th KPI card color */
  .ico-blue2 {
    background: rgba(79,140,255,.16);
    color: var(--blue);
  }

  /* ── Analytics 3-column row ── */
  .three-col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }

  /* ── Dashboard best row: 4 columns ── */
  .desk-four-col {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }

  /* ── Chip-select for trades toolbar ── */
  .chip-select {
    background: var(--card);
    border: 1px solid var(--line-2);
    color: var(--muted);
    font-size: 12px; font-weight: 600;
    padding: 7px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-family: inherit;
    outline: none;
  }
  .chip-select:focus { border-color: var(--gold); }

  .chip-btn {
    padding: 7px 16px;
    border-radius: 20px;
    font-size: 12px; font-weight: 600;
  }

  /* ── Date range controls ── */
  .date-range-controls {
    display: flex;
    gap: 6px;
  }

  /* ── Calendar desktop layout ── */
  .desk-cal-layout {
    display: flex;
    gap: 16px;
  }
  .desk-cal-main { flex: 1; min-width: 0; }

  /* ── Page header right slot ── */
  .page-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  /* ── footer stays visible desktop ── */
  .footer { display: block; }

  /* ── Adjust sheet to be centered modal on desktop ── */
  .sheet-overlay { align-items: center; }
  .sheet {
    border-radius: 18px;
    max-height: 88vh;
    width: 460px;
    transform: translateY(40px) scale(.97);
    opacity: 0;
    transition: transform .28s cubic-bezier(.32,.72,0,1), opacity .25s;
  }
  .sheet-overlay.open .sheet {
    transform: translateY(0) scale(1);
    opacity: 1;
  }

  /* 2-col layout at 981-1100 */
  .kpi-grid { grid-template-columns: repeat(5,1fr); }
}

/* ── Between 981-1140: compress 5-card KPI ── */
@media (min-width: 981px) and (max-width: 1140px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .three-col { grid-template-columns: 1fr 1fr; }
}

/* ── desk-only helper ── */
@media (max-width: 980px) {
  .desk-only { display: none !important; }
  .desk-topbar { display: none; }
  .desk-sidebar { display: none; }
  .desk-four-col { grid-template-columns: 1fr 1fr; }
  .three-col { grid-template-columns: 1fr; }
  .chip-select { display: none; }
  .chip-btn { display: none; }
  .desk-cal-layout { display: block; }
  .ico-blue2 {
    background: rgba(79,140,255,.16);
    color: var(--blue);
  }
}
