/* ═══════════════════════════════════════════════════════════════════
   TRADETRACKER — MOBILE RESPONSIVE OVERRIDES
   Only affects screens ≤ 768px. Desktop layout is untouched.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Ensure viewport meta is respected ── */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* ════════════════════════════════════════
   BREAKPOINT: ≤ 768px  (tablets & phones)
   ════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── App wrapper ── */
  .app {
    padding: 16px 14px;
  }

  /* ── Header: relative so hamburger can break out to the absolute left ── */
  header {
    position: relative;
    margin-bottom: 18px;
    padding-bottom: 16px;
    gap: 6px;
    flex-wrap: wrap;
    align-items: flex-start;     /* rows stack from the top */
  }

  /* ── .logo: full-width row 1, logo+h1 centred visually.
         The hamburger inside is pulled left via absolute positioning. ── */
  .logo {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    flex: 1 0 100%;              /* own full-width row */
    gap: 8px;
    padding-left: 0;
    min-height: 44px;            /* stable height for hamburger reference */
  }

  /* Hamburger button: pinned to top-left of row 1 */
  .hamburger-btn {
    position: absolute !important;
    left: 0 !important;
    top: 8px !important;
    transform: none !important;
    z-index: 10 !important;
    flex-shrink: 0;
  }

  /* PNG logo: slightly larger than before for clear visibility */
  .logo img {
    height: 38px !important;
    width: auto !important;
    flex-shrink: 0;
    padding: 0;
    margin: 0;
  }

  /* Logo: hide subtitle on very small screens */
  .logo span {
    display: none;
  }

  /* h1 title */
  .logo h1 {
    font-size: 20px;
    line-height: 1;
    white-space: nowrap;
  }

  .logo-mark {
    width: 28px;
    height: 28px;
  }

  /* Header nav: row 2 — sits below the logo row, no left offset needed */
  .header-nav {
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
    padding-left: 0;
  }

  /* Calendar toggle: take full width on mobile */
  .cal-view-toggle {
    flex: 1;
    min-width: 0;
    gap: 4px !important;
    padding: 3px !important;
  }

  .cal-view-btn {
    padding: 7px 14px !important;
    font-size: 11px !important;
    flex: 1 !important;
    text-align: center !important;
    min-width: 72px !important;
  }

  /* DAS import button: compact */
  .btn.btn-das {
    padding: 7px 10px;
    font-size: 11px;
  }

  /* Hide the user badge from the top bar on mobile — it lives in the sidebar instead */
  .user-dropdown {
    display: none !important;
  }

  /* ── Month navigation ── */
  .month-nav {
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
  }

  .month-title {
    font-size: 22px;
    min-width: 0;
    flex: 1;
  }

  .account-size-wrap {
    width: auto;
    max-width: 200px;
    justify-content: flex-start;
    order: 10; /* push below nav buttons */
  }

  /* ── Stats bar: 2 columns ── */
  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
  }

  .stat-card {
    padding: 12px 14px;
  }

  .stat-value {
    font-size: 18px;
  }

  /* ── Calendar grid ── */
  .weekday {
    padding: 8px 4px;
    font-size: 9px;
    letter-spacing: 1px;
  }

  .day-cell {
    min-height: 68px;
    padding: 6px 5px;
  }

  .day-num {
    font-size: 10px;
    margin-bottom: 4px;
  }

  .day-pnl {
    font-size: 12px;
    margin-bottom: 2px;
  }

  /* Hide tags & streak badges on small cells */
  .tag {
    display: none;
  }

  .streak-badge {
    display: none;
  }

  .day-note-icon {
    font-size: 10px;
    bottom: 4px;
    right: 4px;
  }

  /* Week recap cell: tighter */
  .week-recap-pnl {
    font-size: 12px;
  }

  .week-recap-num {
    font-size: 9px;
  }

  .week-recap-trades {
    font-size: 8px;
  }

  /* ── Analysis grid: single column ── */
  .analysis-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 14px;
  }

  .analysis-card {
    padding: 14px;
  }

  /* ── Weekday performance ── */
  .weekday-perf {
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
  }

  .wd-item {
    padding: 8px 4px;
  }

  .wd-name {
    font-size: 8px;
    letter-spacing: 0.5px;
  }

  .wd-val {
    font-size: 11px;
  }

  /* ── Equity chart wrap ── */
  .equity-wrap {
    margin-top: 14px;
    padding: 14px;
  }

  /* ── Annual view ── */
  .year-nav {
    gap: 10px;
    margin-bottom: 18px;
    flex-wrap: wrap;
  }

  .year-title {
    font-size: 28px;
    letter-spacing: -1px;
  }

  .year-pills {
    gap: 5px;
    flex-wrap: wrap;
  }

  .year-pill {
    font-size: 11px;
    padding: 4px 10px;
  }

  /* Annual stats: 3 cols → 2 cols */
  .annual-stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 18px;
  }

  .annual-stat {
    padding: 10px 12px;
  }

  /* Months grid: 1 column */
  .months-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Monthly summary row: 6 cols → 4 cols */
  .monthly-summary-row {
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    margin-top: 14px;
  }

  .msr-item {
    padding: 8px 4px;
  }

  .msr-pnl {
    font-size: 10px;
  }

  /* ── Analytics view ── */
  .analysis-view-header {
    margin-bottom: 16px;
  }

  .analysis-view-title {
    font-size: 22px;
    letter-spacing: -0.5px;
  }

  /* Filter bar: wraps naturally */
  .av-filter-bar {
    gap: 6px;
    row-gap: 8px;
  }

  .av-flt-select {
    min-width: 70px;
    font-size: 10px;
    padding: 5px 22px 5px 8px;
  }

  /* Summary: 2x2 grid */
  .av-summary {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
  }

  .av-sum-card {
    padding: 12px 12px;
  }

  .av-sum-value {
    font-size: 17px;
  }

  /* Gap/price card grids: 2 cols */
  .av-gap-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Tables: single column */
  .av-tables {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .av-table-card {
    padding: 14px;
    overflow-x: hidden;
  }

  /* Analytics rows: hide win rate column on tiny screens */
  .av-row {
    grid-template-columns: 1fr auto auto;
    gap: 6px;
  }

  .av-row-wr {
    display: none;
  }

  /* Meta row: scrollable horizontally */
  .av-meta-section {
    overflow-x: auto;
  }

  /* ── Side panel (day detail) ── */
  .side-panel {
    width: 100vw;
  }

  .sp-header {
    padding: 16px 16px 12px;
  }

  .sp-date {
    font-size: 16px;
  }

  .sp-pnl-badge {
    font-size: 17px;
  }

  .sp-body {
    padding: 16px;
    gap: 16px;
  }

  .ticker-card {
    padding: 12px 14px;
  }

  .ticker-sym {
    font-size: 14px;
  }

  .ticker-pnl {
    font-size: 14px;
  }

  /* Trade rows: compact */
  .trade-row {
    padding: 10px 12px;
    gap: 8px;
  }

  .trade-pnl {
    font-size: 13px;
  }

  /* ── Chart modal: full-screen on mobile ── */
  .chart-modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .chart-modal {
    max-width: 100%;
    width: 100%;
    border-radius: 16px 16px 0 0;
    /* Full height: no black gap above when trades collapse */
    height: 92vh;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
  }

  .cm-header {
    padding: 14px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .cm-header-left {
    gap: 10px;
    flex-wrap: wrap;
  }

  .cm-sym {
    font-size: 17px;
  }

  .cm-interval-btns {
    flex-wrap: wrap;
    gap: 3px;
  }

  .cm-interval-btn {
    padding: 4px 8px;
    font-size: 9px;
  }

  .cm-body {
    padding: 14px 16px;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    flex: 1 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
  }

  /* Give the chart a fixed height on mobile so the canvas never
     overflows its container and lands on top of the trades row */
  .cm-chart-area {
    flex: none !important;
    height: 240px !important;
    min-height: 0 !important;
    overflow: hidden !important;
    position: relative !important;
  }

  canvas#chartModalCanvas {
    width: 100% !important;
    height: 100% !important;
  }

  .cm-trades-row {
    gap: 5px;
  }

  .cm-trade-pill {
    padding: 5px 8px;
    font-size: 10px;
  }

  /* ── DAS Import modal ── */
  .das-modal {
    padding: 20px 16px;
    border-radius: 14px;
    max-height: 95vh;
  }

  .das-modal-header {
    margin-bottom: 16px;
  }

  .das-title {
    font-size: 18px;
  }

  .das-dropzone {
    padding: 28px 16px;
  }

  .das-dropzone-icon {
    font-size: 28px;
  }

  .das-dropzone-text {
    font-size: 13px;
  }

  .broker-selector-row {
    gap: 10px;
    flex-direction: column;
    align-items: flex-start;
  }

  .broker-selector {
    min-width: 0;
    width: 100%;
  }

  .das-merge-opts {
    flex-direction: column;
  }

  .merge-opt {
    min-width: 0;
    width: 100%;
  }

  .das-actions {
    flex-wrap: wrap;
    gap: 8px;
  }

  .das-actions .btn {
    flex: 1;
    min-width: 100px;
    text-align: center;
    justify-content: center;
  }

  /* ── Day note modal ── */
  .modal {
    padding: 20px 16px;
    width: calc(100vw - 24px);
    max-width: 100%;
    border-radius: 14px;
  }

  .modal-date {
    font-size: 17px;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .form-group.full {
    grid-column: span 1;
  }

  .modal-actions {
    flex-wrap: wrap;
    gap: 6px;
  }

  .modal-actions .btn {
    flex: 1;
    min-width: 80px;
    justify-content: center;
  }

  /* ── Analysis panel offset fix ── */
  #panelAnalysis {
    padding: 0 14px 24px;
    margin: -16px auto 0;
  }

  /* ── Upgrade wall ── */
  .fg-wall-card {
    padding: 32px 20px;
  }

  /* ── User dropdown menu: prevent overflow ── */
  .user-dropdown-menu {
    right: 0;
    left: auto;
    max-width: calc(100vw - 28px);
  }

  /* ── Import limits banner ── */
  .import-limit-banner,
  .import-limit-wrap {
    font-size: 11px;
  }
}

/* ════════════════════════════════════════
   BREAKPOINT: ≤ 480px  (small phones)
   ════════════════════════════════════════ */
@media (max-width: 480px) {

  .app {
    padding: 12px 10px;
  }

  header {
    margin-bottom: 14px;
    padding-bottom: 14px;
  }

  /* Hide logo subtitle (already hidden at 768 in most cases) */
  .logo span {
    display: none;
  }

  .logo h1 {
    font-size: 18px;
  }

  /* Header nav: stack toggle and buttons */
  .header-nav {
    gap: 5px;
  }

  .cal-view-toggle {
    width: 100%;
    justify-content: stretch;
  }

  .cal-view-btn {
    flex: 1;
    text-align: center;
    padding: 5px 6px;
    font-size: 9px;
  }

  .btn.btn-das {
    flex: 1;
    text-align: center;
    font-size: 10px;
    padding: 7px 8px;
  }

  /* Stats: 2x3 compact */
  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .stat-card {
    padding: 10px 10px;
  }

  .stat-value {
    font-size: 16px;
  }

  .stat-label {
    font-size: 9px;
  }

  /* Calendar cells: very compact */
  .day-cell {
    min-height: 56px;
    padding: 4px 4px;
  }

  .day-num {
    font-size: 9px;
    margin-bottom: 2px;
  }

  .day-pnl {
    font-size: 10px;
    letter-spacing: -0.3px;
  }

  .weekday {
    padding: 6px 2px;
    font-size: 8px;
    letter-spacing: 0;
  }

  /* Week recap cell */
  .week-recap-pnl {
    font-size: 10px;
  }

  .week-recap-num {
    font-size: 8px;
  }

  .week-recap-trades {
    display: none;
  }

  /* Month title smaller */
  .month-title {
    font-size: 18px;
  }

  /* Annual stats: 2 cols */
  .annual-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .annual-stat {
    padding: 8px 10px;
  }

  /* Monthly summary: 4 cols to save space */
  .monthly-summary-row {
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
  }

  .msr-name {
    font-size: 7px;
  }

  .msr-pnl {
    font-size: 9px;
  }

  /* Year title */
  .year-title {
    font-size: 24px;
  }

  /* Analytics: tighter */
  .analysis-view-title {
    font-size: 20px;
  }

  .av-sum-value {
    font-size: 16px;
  }

  /* Side panel */
  .sp-date {
    font-size: 15px;
  }

  .sp-pnl-badge {
    font-size: 15px;
  }

  .sp-body {
    padding: 12px;
    gap: 12px;
  }

  .ticker-card {
    padding: 10px 12px;
  }

  /* DAS modal */
  .das-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .das-modal {
    border-radius: 16px 16px 0 0;
    max-height: 95vh;
    width: 100%;
  }

  /* Modal full-width on small phones */
  .modal {
    width: 100vw;
    max-width: 100vw;
    border-radius: 14px 14px 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    margin: 0;
  }

  .modal-overlay {
    align-items: flex-end;
  }

  /* Analysis panel */
  #panelAnalysis {
    padding: 0 10px 20px;
  }

  /* Weekday perf: still 5 cols but ultra compact */
  .weekday-perf {
    gap: 3px;
  }

  .wd-item {
    padding: 6px 2px;
  }

  .wd-name {
    font-size: 7px;
    letter-spacing: 0;
  }

  .wd-val {
    font-size: 10px;
  }
}

/* ════════════════════════════════════════
   BREAKPOINT: ≤ 360px  (very small phones)
   ════════════════════════════════════════ */
@media (max-width: 360px) {

  .app {
    padding: 10px 8px;
  }

  .logo h1 {
    font-size: 16px;
  }

  .logo-mark {
    width: 24px;
    height: 24px;
  }

  .day-cell {
    min-height: 48px;
    padding: 3px;
  }

  .day-num {
    font-size: 8px;
  }

  .day-pnl {
    font-size: 9px;
  }

  .stat-value {
    font-size: 14px;
  }

  .annual-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Ultra-compact month summary */
  .monthly-summary-row {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ════════════════════════════════════════
   TOUCH IMPROVEMENTS (all mobile)
   ════════════════════════════════════════ */
@media (hover: none) and (pointer: coarse) {

  /* Ensure tap targets are at least 44px */
  .nav-btn {
    width: 40px;
    height: 40px;
  }

  .btn {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
  }

  .sidebar-item {
    padding: 11px 12px;
  }

  .sidebar-sub-item {
    padding: 9px 12px;
  }

  .cal-view-btn {
    min-height: 34px;
  }

  /* Disable hover-only tooltips on touch */
  .mini-day:hover .mini-tooltip {
    display: none;
  }

  /* Remove hover-dependent empty-cell prompts */
  .day-cell:hover .empty-prompt {
    opacity: 0;
  }

  /* Increase close button size for touch */
  .sp-close {
    width: 38px;
    height: 38px;
  }

  .modal-close {
    width: 36px;
    height: 36px;
  }

  /* Sidebar overlay tap area */
  .sidebar-overlay {
    cursor: pointer;
  }

  /* Sidebar logo — sized to harmonise with the title text */
  .sidebar-logo-mark {
    height: 32px;
    width: auto;
  }

  /* Sidebar header layout — logo block takes available space, close btn stays right */
  .sidebar-header {
    gap: 12px;
  }

  .sidebar-logo {
    flex: 1;
    min-width: 0;
    gap: 8px;
  }

  .sidebar-logo-text {
    font-size: 15px;
    white-space: nowrap;
    overflow: visible;
  }

  .sidebar-close {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
  }
}

/* ================================================================
   MOBILE FIXES — appended, all inside media queries, zero desktop impact
   ================================================================ */

/* ── 1. Hamburger icon bars — visible on mobile ─────────────────
   .logo span { display:none } hides the logo subtitle on mobile,
   but the hamburger <span> bars are also inside .logo, so they get
   hidden too. We must explicitly restore display:block on them. */
@media (max-width: 768px) {
  .hamburger-btn span {
    display: block !important;
    height: 2px !important;
    width: 18px !important;
    background: var(--text2) !important;
    border-radius: 2px !important;
  }
  .hamburger-btn span:first-child { width: 13px !important; }
  .hamburger-btn span:last-child  { width: 13px !important; }
}

/* ── 2. User dropdown menu — touch-friendly sizing ───────────────
   Menu positioning is handled in auth.js (position:fixed).
   These rules make items large enough for fingers. */
@media (max-width: 768px) {
  .user-menu-item {
    padding: 11px 14px !important;
    font-size: 12px !important;
    min-height: 40px !important;
  }
  .user-menu-theme-row {
    display: flex !important;
    gap: 6px !important;
    padding: 4px 10px 10px !important;
  }
  .user-theme-btn {
    flex: 1 !important;
    padding: 8px 4px !important;
    min-height: 38px !important;
    font-size: 11px !important;
    border-radius: 7px !important;
  }
}

/* ── 3. Login screen — breathing room on small phones ────────────
   auth.css only has a 900px breakpoint with padding:40px 24px.
   On phones the form needs more horizontal space. */
@media (max-width: 480px) {
  .auth-right {
    padding: 36px 24px !important;
  }
  .auth-card {
    max-width: 100% !important;
    width: 100% !important;
  }
}
@media (max-width: 380px) {
  .auth-right {
    padding: 28px 18px !important;
  }
}

/* ── Billing / Plans screen — mobile layout ─────────────────────────
   The plans grid is 3-column on desktop. On mobile it must stack to
   1 column, the wrap must scroll, and font sizes must scale down.
   
   Root cause of scroll failure: #authOverlay is position:fixed;inset:0
   with no overflow set — it clips its children. On mobile we must give
   both the overlay and the screen overflow-y:auto so content scrolls. */
@media (max-width: 768px) {

  /* The fixed overlay must scroll on mobile */
  #authOverlay {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* The pricing screen fills content height, not viewport height */
  #screenPricing {
    min-height: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }

  .pricing-wrap {
    padding: 32px 16px 48px !important;
    min-height: 100vh !important;
    box-sizing: border-box !important;
    align-items: stretch !important;
  }

  /* Scale down the hero title */
  .pricing-title {
    font-size: 28px !important;
    letter-spacing: -1px !important;
  }

  .pricing-sub {
    font-size: 13px !important;
  }

  .pricing-header {
    margin-bottom: 32px !important;
  }

  /* Stack plan cards vertically, full width */
  .plans-grid {
    grid-template-columns: 1fr !important;
    max-width: 100% !important;
    gap: 14px !important;
    margin-bottom: 32px !important;
  }

  .plan-card {
    padding: 22px 20px !important;
    /* Disable the hover lift — causes layout jump on touch */
    transform: none !important;
  }

  .plan-card.featured {
    transform: none !important;
  }

  /* Ensure the "Volver a la app" fixed button doesn't overlap content */
  #backToAppBtn {
    top: 12px !important;
    right: 12px !important;
    font-size: 12px !important;
    padding: 7px 12px !important;
  }

  /* Footer tags — wrap instead of overflow */
  .pricing-footer {
    flex-wrap: wrap !important;
    gap: 10px 16px !important;
    justify-content: center !important;
    font-size: 12px !important;
  }

}

/* ================================================================
   FINAL MOBILE IMPROVEMENTS
   ================================================================ */

/* ── Fix 2: Sidebar account panel (mobile only) ─────────────────── */
/* Desktop: hide the panel entirely — it only appears on mobile */
.sidebar-account {
  display: none;
}

@media (max-width: 768px) {
  .sidebar-account {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 14px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
  }

  .sidebar-account-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 2px;
  }

  .sidebar-account-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    flex-shrink: 0;
  }

  .sidebar-account-email {
    font-size: 12px;
    font-weight: 600;
    color: var(--text2);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sidebar-account-plan {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 2px 7px;
    border-radius: 8px;
    background: var(--surface2);
    color: var(--text3);
    border: 1px solid var(--border);
    flex-shrink: 0;
  }

  .sidebar-account-plan[data-plan="pro"],
  .sidebar-account-plan[data-plan="founder"] {
    background: var(--green-dim);
    color: var(--green);
    border-color: var(--green-mid);
  }

  .sidebar-account-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--text3);
    display: block;
    margin-bottom: 7px;
    padding: 0 2px;
  }

  .sidebar-account-theme-row {
    display: flex;
    gap: 6px;
  }

  .sidebar-theme-btn {
    flex: 1;
    padding: 8px 4px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text2);
    font-family: var(--title);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.12s;
    white-space: nowrap;
  }

  .sidebar-theme-btn:hover,
  .sidebar-theme-btn:active {
    border-color: var(--green);
    color: var(--text);
  }

  .sidebar-account-actions {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .sidebar-account-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border-radius: 7px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: var(--title);
    font-size: 12px;
    font-weight: 500;
    color: var(--text2);
    transition: all 0.12s;
  }

  .sidebar-account-btn:hover,
  .sidebar-account-btn:active {
    background: var(--surface2);
    color: var(--text);
  }

  .sidebar-account-signout {
    color: var(--red) !important;
  }

  .sidebar-account-signout:hover,
  .sidebar-account-signout:active {
    background: var(--red-dim) !important;
  }
}

/* ── Fix 3: DAS import modal — more compact on mobile ────────────── */
@media (max-width: 768px) {
  .das-modal {
    padding: 18px 14px !important;
    max-height: 92vh !important;
  }

  .das-modal-header {
    margin-bottom: 14px !important;
  }

  .das-title {
    font-size: 17px !important;
  }

  .das-subtitle {
    font-size: 10px !important;
  }

  /* Compact the dropzone significantly */
  .das-dropzone {
    padding: 18px 14px !important;
    margin-bottom: 14px !important;
  }

  .das-dropzone-icon {
    font-size: 22px !important;
    margin-bottom: 6px !important;
  }

  .das-dropzone-text {
    font-size: 12px !important;
    margin-bottom: 4px !important;
  }

  .das-dropzone-hint {
    font-size: 10px !important;
  }

  /* Hide the verbose format guide — saves a lot of vertical space */
  .das-formats {
    display: none !important;
  }

  /* Compact broker selector */
  #brokerSelector {
    font-size: 13px !important;
    padding: 8px 10px !important;
  }
}

/* ── Fix 4: Chart trades row — collapsible on mobile ─────────────── */
@media (max-width: 768px) {

  /* Wrapper for the toggle button + trades list */
  .cm-trades-section {
    border-top: 1px solid var(--border);
    padding-top: 0;
    flex-shrink: 0;
  }

  /* Toggle button */
  .cm-trades-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 9px 2px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: var(--title);
    font-size: 11px;
    font-weight: 600;
    color: var(--text3);
    letter-spacing: 0.8px;
    text-transform: uppercase;
  }

  .cm-trades-toggle-arrow {
    font-size: 10px;
    color: var(--text3);
    transition: transform 0.15s;
  }

  /* Trades row: hidden by default on mobile, shown when toggled */
  .cm-trades-row {
    display: none !important;
    padding-top: 8px !important;
    border-top: none !important;
  }

  .cm-trades-row.cm-trades-open {
    display: flex !important;
  }

}

/* On desktop: hide the toggle button, always show the trades row normally */
@media (min-width: 769px) {
  .cm-trades-toggle {
    display: none;
  }
  .cm-trades-section {
    /* transparent pass-through on desktop */
  }
}

/* ================================================================
   FINAL MOBILE IMPROVEMENTS — Round 2
   ================================================================ */

/* ── Fix 1: Collapsible sidebar account section ──────────────────── */
@media (max-width: 768px) {

  /* The user row is now a button */
  .sidebar-account-user {
    display: flex !important;
    width: 100%;
    align-items: center;
    gap: 8px;
    padding: 10px 2px;
    background: transparent;
    border: none;
    border-top: 1px solid var(--border);
    cursor: pointer;
    text-align: left;
  }

  /* Chevron rotates when open */
  .sidebar-account-chevron {
    margin-left: auto;
    font-size: 14px;
    color: var(--text3);
    transition: transform 0.2s ease;
    flex-shrink: 0;
    line-height: 1;
  }

  /* Details panel: hidden by default, shown when toggled */
  .sidebar-account-details {
    display: none;
    flex-direction: column;
    gap: 10px;
    padding-top: 4px;
    padding-bottom: 4px;
  }

  .sidebar-account-details.sidebar-account-open {
    display: flex;
  }

  /* Keep the outer panel padding minimal since the user row has its own border */
  .sidebar-account {
    padding: 0 14px 12px !important;
    gap: 0 !important;
    border-top: none !important;
  }
}

/* ── Fix 2: Monthly balance / stat values — less dominant ────────── */
@media (max-width: 768px) {
  /* Main stat value — readable but not huge */
  .stat-value {
    font-size: 16px !important;
    letter-spacing: -0.3px !important;
  }

  /* The PnL total card is the biggest value — keep it a bit larger */
  .stat-positive .stat-value,
  .stat-negative .stat-value {
    font-size: 17px !important;
  }

  /* Ensure long dollar amounts don't overflow their card */
  .stat-card {
    min-width: 0;
    overflow: hidden;
  }

  .stat-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .stat-value {
    font-size: 14px !important;
  }

  .stat-positive .stat-value,
  .stat-negative .stat-value {
    font-size: 15px !important;
  }
}

/* ================================================================
   MOBILE INTERACTIVE INLINE CHART
   The inline ticker chart becomes fully interactive on mobile,
   replacing the need for the "Expand" button and fullscreen modal.
   ================================================================ */

@media (max-width: 768px) {

  /* ── Hide the expand button — chart is already interactive ── */
  .intraday-expand-btn {
    display: none !important;
  }

  /* ── Give the intraday chart wrapper more room ── */
  .intraday-wrap {
    padding: 10px 8px !important;
    border-radius: 10px;
  }

  /* ── Title row: compact ── */
  .intraday-wrap .intraday-title-row {
    margin-bottom: 8px;
  }

  .intraday-wrap .intraday-sym-label {
    font-size: 11px !important;
  }

  .intraday-wrap .intraday-status {
    font-size: 9px !important;
  }

  /* ── Canvas: fill available width, generous height set by JS ── */
  .intraday-wrap canvas#intradayChart {
    width: 100% !important;
    height: auto !important;
    display: block;
    touch-action: none;
    cursor: crosshair;
    border-radius: 6px;
  }

  /* ── Legend: compact below chart ── */
  .intraday-wrap .chart-legend {
    margin-top: 8px;
    gap: 10px;
    justify-content: center;
  }

  .intraday-wrap .chart-legend .legend-item {
    font-size: 9px;
  }

  .intraday-wrap .chart-legend .legend-dot {
    width: 6px;
    height: 6px;
  }
}

/* ================================================================
   ISSUE 2: Collapsible calendar sub-sections (mobile only)
   ================================================================ */

/* Desktop: hide toggle buttons, always show content */
.mobile-section-toggle {
  display: none;
}

.mobile-section-body.mobile-collapsed {
  display: block;
}

@media (max-width: 768px) {

  /* Show toggle button on mobile */
  .mobile-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0 0 10px 0;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: var(--title);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text3);
  }

  .mobile-section-arrow {
    font-size: 10px;
    color: var(--text3);
    transition: transform 0.15s;
  }

  /* Hide the desktop-only title on mobile (replaced by toggle button) */
  .mobile-section-title-desktop {
    display: none !important;
  }

  /* Collapsed state: hide content */
  .mobile-section-body.mobile-collapsed {
    display: none;
  }

  /* Expanded state: show content */
  .mobile-section-body {
    display: block;
  }
}

/* ================================================================
   ISSUE 3: Collapsible trade list in ticker detail (mobile only)
   ================================================================ */

/* Desktop: always visible, toggle hidden */
.sp-trades-toggle {
  display: none;
}

@media (max-width: 768px) {

  .sp-trades-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0 0 8px 0;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: var(--title);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text3);
  }

  .sp-trades-arrow {
    font-size: 10px;
    color: var(--text3);
    transition: transform 0.15s;
  }

  /* When toggle is present, hide the original section title */
  .sp-trades-section .sp-section-title {
    display: none;
  }

  /* Collapsed by default */
  .trade-list.sp-trades-collapsed {
    display: none;
  }
}

/* ================================================================
   ISSUE 4: Inline chart improvements (mobile only)
   ================================================================ */

@media (max-width: 768px) {

  /* Timeframe selector row for inline chart */
  .intraday-tf-btns {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
  }

  .intraday-tf-btn {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text3);
    font-family: var(--title);
    font-size: 10px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s;
  }

  .intraday-tf-btn.active {
    background: var(--blue-dim);
    border-color: var(--blue);
    color: var(--blue);
  }

  /* Hide entry/exit legend items on inline mobile chart */
  .intraday-wrap .chart-legend .legend-item:nth-child(3),
  .intraday-wrap .chart-legend .legend-item:nth-child(4) {
    display: none !important;
  }
}

/* Desktop: hide inline timeframe buttons (they use the modal ones) */
@media (min-width: 769px) {
  .intraday-tf-btns {
    display: none;
  }
}
