/* app/assets/stylesheets/dashboard.css */

/* ========================================
   DASHBOARD STYLES — PREMIUM REDESIGN
   ======================================== */

/* === BASE === */
body.dashboard-body {
  margin: 0;
  background-color: #f8fafc;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #0f172a;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* === APP SHELL === */
.dashboard-container {
  display: grid;
  grid-template-columns: var(--sidebar-w, 280px) 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Collapsed width — flip this one value to change the icon-rail size */
.dashboard-container.is-collapsed {
  --sidebar-w: 76px;
}

/* Restore guard: the layout script re-applies the collapsed state from
   localStorage AFTER the body is swapped in (Turbo nav / first load).
   Without this, the re-apply animates and the sidebar visually
   "re-collapses" on every navigation. The guard is removed after the
   first paint, so user-initiated toggles still animate normally. */
.dashboard-container.is-restoring,
.dashboard-container.is-restoring .sidebar,
.dashboard-container.is-restoring .sidebar *,
.dashboard-container.is-restoring .sidebar-toggle,
.dashboard-container.is-restoring .sidebar-toggle svg,
.dashboard-container.is-restoring .main-content {
  transition: none !important;
}

/* ========================================
   SIDEBAR
======================================== */
/* ---- Ask Wick launcher — locked (non-Pro/Elite) ---- */
.ask-wick-locked {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  background: #f8fafc;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  filter: grayscale(1);
  opacity: 0.8;
  transition: background .2s, color .2s;
}
.ask-wick-locked:hover { background: #f1f5f9; color: #64748b; filter: none; }
.ask-wick-locked .icon-small { width: 18px; height: 18px; flex-shrink: 0; }
.ask-wick-lock-chip {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #94a3b8;
  flex-shrink: 0;
}

/* collapsed sidebar: chips shrink to the icon only */
.dashboard-container.is-collapsed .ask-wick-locked > span,
.dashboard-container.is-collapsed .ask-wick-lock-chip { display: none; }
.dashboard-container.is-collapsed .ask-wick-locked { padding: 12px 0; gap: 0; }


.sidebar {
  width: var(--sidebar-w, 280px);
  background: #ffffff;
  border-right: 1px solid #f1f5f9;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  /* Scrolling is confined to .sidebar-nav below — the logo, Ask Wick
     launcher and bottom widgets stay pinned; the sidebar never scrolls
     as a whole. */
  overflow: hidden;
  z-index: 100;
  height: 100vh;
  -ms-overflow-style: none;
  scrollbar-width: none;
  transition: width 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
.sidebar::-webkit-scrollbar { display: none; }

/* Only the nav buttons (Dashboard → Settings) scroll when the Analytics
   submenu is open on a short screen; everything above and below the nav
   (logo, Ask Wick, bottom widgets) stays pinned. */
.sidebar-nav {
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;      /* Firefox */
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.is-locked { opacity: 0.45; }
.nav-lock-badge { font-size: 11px; margin-left: auto; }

/* LOGO */
.sidebar .logo {
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
  margin: 24px 24px 32px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}
.logo-icon {
  width: 28px;
  height: 28px;
  background: #22c55e;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
  flex-shrink: 0;
}

/* Icon-only mark: hidden in the expanded rail; swapped in when collapsed,
   because the 204px wordmark can't fit the 76px icon rail. */
.logo-mark {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  flex-shrink: 0;
}
.logo-mark img {
  width: 44px;
  height: 44px;
  display: block;
}

/* NAVIGATION */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 16px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 12px;
  text-decoration: none;
  color: #64748b;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  position: relative;
}

.nav-item .icon {
  width: 20px;
  height: 20px;
  color: #94a3b8;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.nav-item:hover {
  background: #f8fafc;
  color: #0f172a;
}
.nav-item:hover .icon { color: #64748b; }

.nav-item:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* Active state */
.nav-item.active {
  background: #f6fdf9;
  color: #16a34a;
  font-weight: 600;
}
.nav-item.active .icon { color: #16a34a; }

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 24px;
  background: #22c55e;
  border-radius: 0 4px 4px 0;
}

/* Disabled / locked */
.nav-item.disabled { opacity: 0.6; cursor: not-allowed; }
.nav-item.disabled:hover { background: transparent; color: #64748b; }

.pro-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  background: #e2e8f0;
  color: #475569;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

/* ========================================
   NAV GROUP (expandable section, e.g. Analytics)
======================================== */
.nav-group { display: flex; flex-direction: column; }

/* The group toggle behaves exactly like a plain nav-item. */
.nav-group .nav-group-toggle {
  width: 100%;
  border: 0;
  background: none;
  font-family: inherit;
  text-align: left;
  padding: 12px 16px;
  cursor: pointer;
}

/* The caret sits inside .nav-caret-toggle, a separate click target that
   toggles the submenu in place (the parent link itself navigates). */
.nav-caret-toggle {
  margin-left: auto;
  margin-right: 2px;        /* keeps icon, and caret, a little in from the edge */
  padding: 6px;             /* widens the click target without moving the icon */
  cursor: pointer;
  display: flex;
  flex-shrink: 0;
}
.nav-group .nav-caret {
  width: 12px;
  height: 12px;
  color: #94a3b8;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.nav-caret-toggle:focus-visible { outline: 2px solid #16a34a; outline-offset: 2px; border-radius: 6px; }
.nav-group.open > .nav-group-toggle .nav-caret {
  transform: rotate(180deg);
}

/* Group lights up in the brand color while any of its pages is active,
   with a shorter accent bar so it reads as a parent, not a page. */
.nav-group.active > .nav-group-toggle {
  color: #16a34a;
  font-weight: 600;
}
.nav-group.active > .nav-group-toggle .icon { color: #16a34a; }

/* Submenu */
.nav-group .nav-submenu {
  display: none;
  flex-direction: column;
  gap: 2px;
  margin: 0 0 2px 40px;     /* aligns with the toggle's text */
}
/* Opens on click (the toggle JS flips `open`), and stays open while its
   pages are active (the layout server-renders `open` for active groups). */
.nav-group.open > .nav-submenu { display: flex; }

.nav-group .nav-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 13px;
  color: #64748b;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.15s ease;
}
.nav-group .nav-sub:hover {
  background: #f8fafc;
  color: #0f172a;
}
.nav-group .nav-sub.active {
  background: #f6fdf9;
  color: #16a34a;
  font-weight: 700;
}
.nav-group .nav-sub.active::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 14px;
  background: #22c55e;
  border-radius: 0 3px 3px 0;
}
.nav-group .nav-sub { position: relative; }

/* Collapsed sidebar: hide the submenu entirely; carets don't matter. */
.dashboard-container.is-collapsed .nav-group .nav-submenu { display: none; }
.dashboard-container.is-collapsed .nav-group .nav-caret { display: none; }

/* ========================================
   SIDEBAR COLLAPSE TOGGLE (floating button)
======================================== */
.sidebar-toggle {
  position: fixed;
  top: 30px;
  left: calc(var(--sidebar-w, 280px) - 13px);
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  cursor: pointer;
  z-index: 101;
  transition:
    left 0.28s cubic-bezier(0.16, 1, 0.3, 1),
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease,
    transform 0.15s ease;
}
.sidebar-toggle:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #cbd5e1;
  transform: scale(1.08);
}
.sidebar-toggle:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}
.sidebar-toggle svg {
  width: 13px;
  height: 13px;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
.dashboard-container.is-collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

/* ========================================
   COLLAPSED STATE — hide labels, center icons
======================================== */
.dashboard-container.is-collapsed .logo-text,
.dashboard-container.is-collapsed .nav-item > span,
.dashboard-container.is-collapsed .brokerage-button > span,
.dashboard-container.is-collapsed .import-button > span,
.dashboard-container.is-collapsed .user-info,
.dashboard-container.is-collapsed .sign-out-btn {
  display: none;
}

/* Logo */
.dashboard-container.is-collapsed .logo {
  margin: 24px 0 14px;
  justify-content: center;
}
.dashboard-container.is-collapsed .dashboard-logo { display: none; }
.dashboard-container.is-collapsed .logo-mark { display: flex; }

/* Nav */
.dashboard-container.is-collapsed .sidebar-nav {
  padding: 0 12px;
}
.dashboard-container.is-collapsed .nav-item {
  justify-content: center;
  padding: 12px 0;
  gap: 0;
}
.dashboard-container.is-collapsed .nav-item.active::before {
  left: -12px;
}

/* Bottom widgets */
.dashboard-container.is-collapsed .sidebar-bottom {
  padding: 20px 10px 16px;
}
.dashboard-container.is-collapsed .brokerage-button,
.dashboard-container.is-collapsed .import-button {
  justify-content: center;
  padding: 12px 0;
  gap: 0;
}
.dashboard-container.is-collapsed .user-profile-widget {
  justify-content: center;
  padding: 8px 0;
  gap: 0;
}

/* ========================================
   BOTTOM WIDGETS
======================================== */
.sidebar-bottom {
  padding: 20px 16px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid #f1f5f9;
  margin-top: 8px;
}

/* ---- Brokerage CTA (soft indigo, distinct from dark Import) ---- */
.brokerage-section { display: block; }

.brokerage-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
  color: #4338ca;
  border: 1px solid #c7d2fe;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  box-sizing: border-box;
  box-shadow: 0 1px 2px rgba(67, 56, 202, 0.06);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}
.brokerage-button .icon-small {
  width: 18px;
  height: 18px;
  color: #6366f1;
  flex-shrink: 0;
}
.brokerage-button:hover {
  background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
  border-color: #a5b4fc;
  box-shadow: 0 2px 6px rgba(67, 56, 202, 0.12);
}
.brokerage-button:active { transform: translateY(1px); }
.brokerage-button:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

/* ---- Import Trades ---- */
.import-section { display: block; }

.import-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: #0f172a;
  color: white;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  transition: all 0.2s ease;
  box-sizing: border-box;
}
.import-button .icon-small {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.import-button:hover {
  background: #1e293b;
  transform: translateY(-1px);
}
.import-button:focus-visible {
  outline: 2px solid #0f172a;
  outline-offset: 2px;
}
.import-button.disabled {
  background: #f1f5f9;
  color: #94a3b8;
  cursor: not-allowed;
}
.import-button.disabled:hover { transform: none; }

/* ---- User Profile Widget ---- */
.user-profile-widget {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f8fafc;
  padding: 12px;
  border-radius: 16px;
}

.user-avatar {
  background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.user-avatar img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}
.user-avatar-initials {
  font-size: 15px;
  font-weight: 700;
  color: #475569;
  line-height: 1;
  user-select: none;
}

.user-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
.user-name {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-plan {
  font-size: 12px;
  color: #3b82f6;
  font-weight: 500;
}

.sign-out-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: #64748b;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}
.sign-out-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}
.sign-out-btn:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.kpi-spark:empty { display: none; }

/* ========================================
   MAIN CONTENT
======================================== */
.main-content {
  grid-column: 2;
  margin-left: 0;
  max-width: calc(100vw - var(--sidebar-w, 280px) - var(--askwick-w, 0px)); /* ← ADDED var(--askwick-w, 0px) */
  min-width: 0;
  overflow-x: hidden;
  padding: 32px 40px;
  min-height: 100vh;
  box-sizing: border-box;
  transition: max-width 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ========================================
   DASHBOARD CONTENT — design-system version
   (app shell / sidebar styles stay above)
   ======================================== */

.dash-page {
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e5e7eb;
  --border-soft: #f1f5f9;
  --text-1: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #eff6ff;
  --profit-strong: #047857;
  --profit-soft: #ecfdf5;
  --profit-border: #a7f3d0;
  --loss-strong: #b91c1c;
  --loss-soft: #fef2f2;
  --loss-border: #fecaca;
  --weekly: #6366f1;
  --weekly-soft: #eef2ff;
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-lift: 0 12px 24px -10px rgba(15, 23, 42, 0.16);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  display: flex;
  flex-direction: column;
  gap: 24px;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

.dash-page .is-positive { color: var(--profit-strong); }
.dash-page .is-negative { color: var(--loss-strong); }
.dash-page .is-muted    { color: #cbd5e1; }
.dash-page .is-neutral  { color: #d97706; }

/* ---------- Header ---------- */
.dash-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.dash-heading { min-width: 0; }

.dash-heading h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: var(--text-1);
}
.dash-heading-name { color: var(--text-1); }
.dash-wave {
  display: inline-block;
  margin-left: 2px;
  font-size: 20px;
  transform-origin: 70% 70%;
  animation: dash-wave 2.6s ease-in-out infinite;
}

@keyframes dash-wave {
  0%, 60%, 100% { transform: rotate(0deg); }
  10%, 30%      { transform: rotate(14deg); }
  20%, 40%      { transform: rotate(-8deg); }
}

/* Inline meta line — replaces the old chip rows */
.dash-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  flex-wrap: wrap;
}
.dash-meta-item { white-space: nowrap; }
.dash-meta-dot {
  color: var(--text-3);
  opacity: 0.55;
  font-weight: 600;
}
.dash-meta-live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-2);
  font-weight: 600;
}
.dash-meta-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
  animation: dash-pulse 2s ease-in-out infinite;
}

@keyframes dash-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45); opacity: 1; }
  50%      { box-shadow: 0 0 0 5px rgba(16, 185, 129, 0);    opacity: 0.85; }
}

/* Right side actions */
.dash-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dash-icon-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-2);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.dash-icon-btn:hover {
  background: var(--surface-2);
  color: var(--text-1);
  border-color: #cbd5e1;
}
.dash-icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dash-cta {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 4px 12px -4px rgba(37, 99, 235, 0.45);
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}
.dash-cta:hover {
  background: var(--accent-strong);
  color: #fff;
  box-shadow: 0 6px 16px -4px rgba(37, 99, 235, 0.55);
}
.dash-cta:active { transform: translateY(1px); }
.dash-cta:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Buttons ---------- */
.dash-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.dash-btn--primary { background: var(--accent); color: #fff; }
.dash-btn--primary:hover { background: var(--accent-strong); color: #fff; }

.dash-btn--ghost { background: var(--surface); color: var(--text-2); border-color: var(--border); }
.dash-btn--ghost:hover { background: var(--surface-2); color: var(--text-1); border-color: #cbd5e1; }

.dash-btn--light { background: rgba(255, 255, 255, 0.12); color: #fff; }
.dash-btn--light:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }

.dash-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Account switcher ---------- */
.dash-switcher { display: flex; gap: 10px; flex-wrap: wrap; }

.dash-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease), border-color 0.15s;
}

.dash-pill:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }

.dash-pill.is-active {
  border-color: #93c5fd;
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px #93c5fd;
}

.dash-pill:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dash-pill-name { font-size: 13px; font-weight: 700; color: var(--text-1); white-space: nowrap; }
.dash-pill-pnl  { font-size: 13px; font-weight: 700; }

/* ---------- Sections & edit mode ---------- */
#dashboard-sections { display: flex; flex-direction: column; gap: 24px; }

.dash-section { position: relative; }

.drag-handle {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text-3);
  cursor: grab;
  z-index: 50;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.drag-handle:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.drag-handle:active { cursor: grabbing; }

body.edit-mode .drag-handle { display: flex; }

body.edit-mode .dash-section {
  border: 2px dashed #cbd5e1;
  border-radius: 16px;
  padding: 10px;
  transition: border-color 0.2s, background 0.2s;
}

body.edit-mode .dash-section:hover { border-color: var(--accent); background: var(--accent-soft); }

.dash-section.sortable-ghost { opacity: 0.4; background: var(--accent-soft); border: 2px dashed var(--accent); }
.dash-section.sortable-chosen { cursor: grabbing; }

.dash-edit-toolbar {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #fff;
  padding: 12px 16px;
  border-radius: 14px;
  display: none;
  align-items: center;
  gap: 10px;
  z-index: 1000;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.35);
  font-size: 13px;
  font-weight: 600;
}

body.edit-mode .dash-edit-toolbar { display: flex; }

/* ---------- Cards (shared) ---------- */
.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
}

.dash-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 15px;
  margin-bottom: 15px;
  border-bottom: 1px solid var(--border-soft);
  flex-wrap: wrap;
}

.dash-card-head-text { display: flex; align-items: center; gap: 11px; min-width: 0; }
.dash-card-head h3 { margin: 0; font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
.dash-card-head p  { margin: 2px 0 0; font-size: 11.5px; color: var(--text-3); }

.dash-card-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
}
.dash-card-icon--indigo  { background: var(--weekly-soft); color: var(--weekly); }
.dash-card-icon--violet  { background: #f5f3ff; color: #7c3aed; }
.dash-card-icon--amber   { background: #fffbeb; color: #d97706; }
.dash-card-icon--emerald { background: var(--profit-soft); color: #059669; }

.dash-head-stats { display: flex; gap: 8px; }
.dash-head-stat {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dash-head-stat span { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-3); }
.dash-head-stat strong { font-size: 13px; font-weight: 800; }

.dash-card-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.dash-card-foot--grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }

.dash-foot-stat > span {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  margin-bottom: 3px;
}
.dash-foot-stat > strong { font-size: 13px; font-weight: 800; display: inline-flex; align-items: baseline; gap: 5px; white-space: nowrap; }
.dash-foot-stat > strong em { font-style: normal; font-size: 11px; font-weight: 600; color: var(--text-3); }

.dash-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.dash-link-btn:hover { background: #e2e8f0; color: var(--text-1); }

.sw { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.sw-profit { background: #10b981; }
.sw-loss { background: #ef4444; }
.dash-dl { font-size: 12px; font-weight: 600; color: var(--text-2); }

/* ---------- Week calendar ---------- */
.dash-week-card { padding: 22px; }

.dash-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.dash-section-title h2 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
.dash-section-title p  { margin: 3px 0 0; font-size: 12.5px; color: var(--text-3); font-weight: 500; }

.dash-week-side { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.dash-week-total {
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 800;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.dash-week-total.is-positive { background: var(--profit-soft); border-color: var(--profit-border); }
.dash-week-total.is-negative { background: var(--loss-soft); border-color: var(--loss-border); }

.dash-week-nav { display: flex; align-items: center; gap: 8px; }

.dash-nav-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.dash-nav-btn:hover { color: var(--accent); background: var(--accent-soft); border-color: #bfdbfe; }

.dash-today-btn {
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  text-decoration: none;
}
.dash-today-btn:hover { background: var(--accent-strong); color: #fff; }

.dash-week-scroll {
  overflow-x: auto;
  padding-top: 4px;
}

.dash-week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(96px, 1fr));
  gap: 10px;
  min-width: 640px;
}

.dash-day {
  min-height: 105px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.dash-day.has-trades.is-positive { background: var(--profit-soft); border-color: var(--profit-border); }
.dash-day.has-trades.is-negative { background: var(--loss-soft); border-color: var(--loss-border); }

.dash-week-grid > .dash-day.is-today {
  border-color: #93c5fd;
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px #93c5fd;
}

.dash-day.has-trades:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }

.dash-day-top { display: flex; justify-content: space-between; align-items: flex-start; }
.dash-day-label { display: block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-3); }
.dash-day-num { display: block; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }

.dash-day-badge {
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dash-day-body { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.dash-day-pnl { font-size: 16px; font-weight: 800; letter-spacing: -0.01em; }
.dash-day-count { font-size: 11px; color: var(--text-3); font-weight: 500; }

/* ---------- Metrics ---------- */
.dash-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.dash-metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.dash-metric:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }

.dash-metric-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.dash-metric-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
}

.dash-metric-value { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; color: var(--text-1); }

.dash-metric-sub { font-size: 11px; color: var(--text-3); font-weight: 500; }

.dash-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.dash-trend.is-up   { background: var(--profit-soft); color: var(--profit-strong); }
.dash-trend.is-down { background: var(--loss-soft); color: var(--loss-strong); }

.dash-metric-bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.dash-metric-bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #34d399, #059669); transition: width 0.8s var(--ease); }

/* ---------- Goals ---------- */
/* One period is visible at a time (D/W/M toggle), so the top card gets
   the full width of the panel. */
[data-goals-panel] > .dash-goals { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.dash-card { padding: 22px; }

/* Header actions: period toggle + Edit goals */
.dash-head-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.dash-goals-toggle {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: 999px; padding: 3px;
}
.dash-goals-toggle-btn {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 700; color: var(--text-3);
  padding: 4px 10px; border-radius: 999px; line-height: 1.4;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.dash-goals-toggle-btn:hover { color: var(--text-2); }
.dash-goals-toggle-btn.active { background: #0f172a; color: #ffffff; }

/* Hidden period scopes — set by the switcher JS (is-hidden) */
[data-goals-panel] .is-hidden { display: none !important; }

.dash-goal {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dash-goal-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.dash-goal-pct { font-size: 14px; font-weight: 800; }
.dash-goal-pct.achieved { color: var(--profit-strong); }

.dash-goal-amount { font-size: 19px; font-weight: 800; letter-spacing: -0.01em; }
.dash-goal-amount span { font-size: 12px; font-weight: 600; color: var(--text-3); }

.dash-goal-track { height: 8px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.dash-goal-fill { height: 100%; border-radius: 999px; transition: width 0.6s var(--ease); }
.dash-goal-fill.is-positive { background: linear-gradient(90deg, #34d399, #059669); }
.dash-goal-fill.is-negative { background: linear-gradient(90deg, #f87171, #dc2626); }
.dash-goal-fill.achieved { box-shadow: 0 0 10px rgba(5, 150, 105, 0.45); }

/* Per-account goal breakdown (all-accounts view) — one period per row,
   selected by the panel's D/W/M toggle. */
.dash-goals-by { margin-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.dash-goals-by-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-3); padding: 0 2px 4px; border-bottom: 1px solid var(--border-soft);
}
.dash-goals-by-row {
  display: flex; align-items: center; gap: 14px;
  font-size: 13px;
}
.dash-goals-by-name {
  font-weight: 600; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 0 0 180px; min-width: 0;
}

.dash-goal-cell { flex: 1; min-width: 0; }
.dash-goal-cell-top {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
}
.dash-goal-cell-pnl { font-weight: 800; color: var(--text-2); font-size: 14px; }
.dash-goal-cell-pnl.pnl-positive { color: var(--profit-strong); }
.dash-goal-cell-pnl.pnl-negative { color: var(--loss-strong); }
.dash-goal-cell-of { font-size: 12px; font-weight: 600; color: var(--text-3); }
.dash-goal-cell-pct { font-size: 12px; font-weight: 700; color: var(--text-3); }
.dash-goal-cell-pct.pnl-positive { color: var(--profit-strong); }
.dash-goal-cell-pct.pnl-negative { color: var(--loss-strong); }
.dash-goal-cell-pct.achieved { background: rgba(5, 150, 105, 0.12); color: var(--profit-strong); padding: 3px 8px; border-radius: 999px; }

.dash-goal-bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 5px; }
.dash-goal-bar-fill { height: 100%; border-radius: 999px; transition: width 0.6s var(--ease); }
.dash-goal-bar-fill.is-positive { background: linear-gradient(90deg, #34d399, #059669); }
.dash-goal-bar-fill.is-negative { background: linear-gradient(90deg, #f87171, #dc2626); }

/* ---- Daily loss-limit strip (all-accounts view) ---- */
.dash-loss-strip { margin-top: 14px; }
.dash-loss-row { display: flex; align-items: center; gap: 14px; }
.dash-loss-meta {
  display: flex; align-items: baseline; gap: 6px;
  flex: 0 0 200px; min-width: 0;
}
.dash-loss-amt { font-weight: 700; font-size: 13px; color: var(--text-2); }
.dash-loss-amt.is-neg { color: var(--loss-strong); }
.dash-loss-of { font-size: 12px; font-weight: 600; color: var(--text-3); }
.dash-loss-bar {
  flex: 1; height: 6px; border-radius: 999px;
  background: var(--surface-2); overflow: hidden;
}
.dash-loss-bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #34d399, #059669); transition: width 0.6s var(--ease); }
.dash-loss-bar-fill.is-close { background: linear-gradient(90deg, #fbbf24, #d97706); }
.dash-loss-bar-fill.is-breach { background: linear-gradient(90deg, #f87171, #dc2626); }
.dash-loss-pill {
  flex-shrink: 0; font-size: 11px; font-weight: 700; line-height: 1;
  padding: 5px 9px; border-radius: 999px; min-width: 56px; text-align: center;
}
.dash-loss-pill.is-ok { background: rgba(5, 150, 105, 0.12); color: var(--profit-strong); }
.dash-loss-pill.is-close { background: rgba(217, 119, 6, 0.14); color: #b45309; }
.dash-loss-pill.is-breach { background: rgba(220, 38, 38, 0.12); color: var(--loss-strong); }
.dash-loss-status {
  margin-left: auto; font-size: 12px; font-weight: 600;
  color: var(--text-3); font-style: italic;
}

/* ---------- Chart cards ---------- */
.dash-charts { display: grid; gap: 20px; align-items: stretch; }
.dash-charts--main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.dash-charts--pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dash-charts--performers { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }

.dash-chart-card { display: flex; flex-direction: column; }
.dash-chart { min-height: 240px; }
.dash-chart--eq { min-height: 320px; }

.dash-donut-wrap { position: relative; }
.dash-donut-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}
.dash-donut-center strong { display: block; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.dash-donut-center span { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); }

/* ---------- Rows / records ---------- */
.dash-rows { display: flex; flex-direction: column; }

.dash-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
}
.dash-row:first-child { padding-top: 0; }
.dash-row:last-child { border-bottom: 0; padding-bottom: 0; }

.dash-row > span { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.dash-row > strong { font-size: 13px; font-weight: 700; display: inline-flex; align-items: baseline; gap: 5px; white-space: nowrap; }
.dash-row > strong em { font-style: normal; font-size: 11px; font-weight: 600; color: var(--text-3); }

/* ---------- Top symbols ---------- */
.dash-sym-list { display: flex; flex-direction: column; margin-top: 8px; }

.dash-sym-row {
  display: grid;
  grid-template-columns: 70px 70px minmax(0, 1fr) 80px;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-soft);
}
.dash-sym-row:last-child { border-bottom: 0; }

.dash-sym-name { font-size: 13px; font-weight: 700; white-space: nowrap; }
.dash-sym-meta { font-size: 10.5px; color: var(--text-3); font-weight: 500; }
.dash-sym-track { height: 7px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.dash-sym-fill { height: 100%; border-radius: 999px; }
.dash-sym-fill.is-positive { background: #10b981; }
.dash-sym-fill.is-negative { background: #ef4444; }
.dash-sym-pnl { font-size: 12.5px; font-weight: 700; text-align: right; white-space: nowrap; }

/* ---------- Achievements ---------- */
.dash-achievements { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.dash-achievement {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
  position: relative;
  transition: transform 0.15s var(--ease);
}
.dash-achievement:hover { transform: translateY(-2px); }

.dash-achievement.unlocked {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border-color: #fde68a;
}

.dash-achievement-icon { font-size: 22px; line-height: 1.2; flex-shrink: 0; }
.dash-achievement-info { flex: 1; min-width: 0; }
.dash-achievement-info strong { display: block; font-size: 12.5px; font-weight: 700; }
.dash-achievement-info > span { display: block; font-size: 10.5px; color: var(--text-2); margin-top: 1px; }

.dash-achievement-progress { margin-top: 7px; display: flex; align-items: center; gap: 8px; }
.dash-achievement-bar { flex: 1; height: 5px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.dash-achievement-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #6366f1, #8b5cf6); transition: width 0.6s var(--ease); }
.dash-achievement-progress em { font-style: normal; font-size: 10px; font-weight: 700; color: var(--text-3); white-space: nowrap; }

.dash-achievement-check {
  background: #059669;
  color: #fff;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ---------- Table ---------- */
.dash-table-wrap { overflow-x: auto; }

.dash-table { width: 100%; border-collapse: collapse; min-width: 720px; }

.dash-table th {
  text-align: left;
  padding: 0 12px 10px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border-soft);
}

.dash-table td { padding: 11px 12px; font-size: 13px; color: var(--text-2); border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
.dash-table tbody tr:last-child td { border-bottom: 0; }
.dash-table tbody tr:hover td { background: var(--surface-2); }

.dash-table .td-strong { color: var(--text-1); font-weight: 700; }
.dash-table .td-muted { color: var(--text-3); font-size: 12px; }
.ta-right { text-align: right !important; }

.dash-side-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.dash-side-badge.is-long  { background: var(--profit-soft); border: 1px solid var(--profit-border); color: var(--profit-strong); }
.dash-side-badge.is-short { background: var(--loss-soft); border: 1px solid var(--loss-border); color: var(--loss-strong); }

/* ---------- Empty states ---------- */
.dash-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
}
.dash-empty p { margin: 0; font-size: 13px; font-weight: 600; color: var(--text-2); }
.dash-empty--slim { padding: 22px 12px; }

/* ---------- Entrance animation ---------- */
@keyframes dash-rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dash-header { animation: dash-rise 0.45s var(--ease) both; }
.dash-switcher { animation: dash-rise 0.45s var(--ease) 0.05s both; }
.dash-section { animation: dash-rise 0.45s var(--ease) both; }
.dash-section:nth-child(1) { animation-delay: 0.10s; }
.dash-section:nth-child(2) { animation-delay: 0.15s; }
.dash-section:nth-child(3) { animation-delay: 0.20s; }
.dash-section:nth-child(4) { animation-delay: 0.25s; }
.dash-section:nth-child(5) { animation-delay: 0.30s; }
.dash-section:nth-child(6) { animation-delay: 0.35s; }
.dash-section:nth-child(7) { animation-delay: 0.40s; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .dash-charts--performers { grid-template-columns: 1fr; }
}

@media (max-width: 1150px) {
  .dash-charts--main { grid-template-columns: 1fr; }
  .dash-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
  .dash-charts--pair { grid-template-columns: 1fr; }
  .dash-card > .dash-goals { grid-template-columns: 1fr; }
  .dash-goals-by-name { flex-basis: 120px; }
  .dash-loss-meta { flex-basis: 140px; }
  .dash-head-actions { width: 100%; justify-content: space-between; }
  .dash-header { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 700px) {
  .dash-achievements { grid-template-columns: 1fr; }
  .dash-week-total { display: none; }
  .dash-metric-value { font-size: 20px; }
}

@media (max-width: 520px) {
  .dash-metrics { grid-template-columns: 1fr; }
  .dash-sym-row { grid-template-columns: 58px minmax(0, 1fr) 70px; }
  .dash-sym-meta { display: none; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .dash-page *,
  .dash-page *::before,
  .dash-page *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ========================================
   GOALS MODAL
======================================== */
.dash-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.dash-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.dash-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.dash-modal-panel {
  position: relative;
  background: #ffffff;
  border-radius: 18px;
  width: 100%;
  max-width: 620px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 48px -12px rgba(15, 23, 42, 0.35);
  transform: translateY(14px) scale(0.98);
  transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

.dash-modal.is-open .dash-modal-panel {
  transform: translateY(0) scale(1);
}

.dash-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 26px 18px;
  border-bottom: 1px solid #f1f5f9;
}

.dash-modal-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #0f172a;
}

.dash-modal-head p {
  margin: 4px 0 0;
  font-size: 13px;
  color: #64748b;
}

.dash-modal-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: #f8fafc;
  color: #64748b;
  border-radius: 8px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.dash-modal-close:hover { background: #e2e8f0; color: #0f172a; }

.dash-modal-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.dash-modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 26px 10px;
}

.dash-modal-empty {
  margin: 32px 0;
  font-size: 13px;
  color: #64748b;
  text-align: center;
}

.dash-modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dash-modal-field label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #64748b;
}

.dash-modal-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.dash-modal-currency {
  position: absolute;
  left: 14px;
  font-size: 14px;
  font-weight: 600;
  color: #94a3b8;
  pointer-events: none;
}

.dash-modal-input {
  width: 100%;
  padding: 9px 12px 9px 26px;
  border: 1px solid #e5e7eb;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  color: #0f172a;
  background: #ffffff;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s, border-radius 0.15s;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
}
.dash-modal-input::-webkit-inner-spin-button,
.dash-modal-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.dash-modal-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.dash-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Goals modal — ledger layout: one row per account, captions above */
.goals-ledger-header,
.goals-ledger-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.15fr) repeat(4, minmax(74px, 94px));
  gap: 10px;
  align-items: end;
}

.goals-ledger-header {
  padding: 12px 0 9px;
  border-bottom: 1px solid #e5e9f0;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #94a3b8;
  white-space: nowrap;
}
.goals-ledger-header .is-risk { color: #b91c1c; }

.goals-ledger-row {
  padding: 15px 0;
  border-bottom: 1px solid #f1f5f9;
}
.goals-ledger-row:last-of-type { border-bottom: 0; }

.goals-ledger-account {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 1px;
}
.goals-ledger-account strong {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.goals-ledger-account span {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
}

.goals-ledger-cell { min-width: 0; }

/* Hidden on desktop (captions cover these); shown on mobile when the
   captions are gone and inputs wrap. */
.goals-ledger-cell-label {
  display: none;
  margin-bottom: 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #94a3b8;
}
.goals-ledger-cell.is-risk .goals-ledger-cell-label { color: #b91c1c; }

.goals-money { position: relative; }
.goals-money > span {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  pointer-events: none;
}
.goals-money .goals-money-input { padding-left: 24px; }

/* Live totals + actions pinned in the goals modal footer */
.goals-modal-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 26px 20px;
  border-top: 1px solid #f1f5f9;
  background: #ffffff;
  border-radius: 0 0 18px 18px;
}

/* Live totals strip in the goals modal */
.dash-goals-totals {
  display: flex;
  align-items: flex-end;
  gap: 18px;
}

.dash-goals-totals-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #64748b;
  margin-right: auto;
}

.dash-goals-totals-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
}

.dash-goals-totals-cell small {
  font-size: 10px;
  font-weight: 600;
  color: #94a3b8;
}

.dash-goals-totals-cell strong {
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 520px) {
  .dash-modal-head { padding: 18px 18px 14px; }
  .dash-modal-body { padding: 4px 18px 10px; }
  .goals-modal-foot { padding: 14px 18px 16px; }
  .goals-modal-foot { flex-direction: column-reverse; align-items: stretch; }
  .dash-modal-actions { flex-direction: row; }
  .dash-modal-actions .dash-btn { flex: 1; justify-content: center; }
  .dash-goals-totals { justify-content: space-between; }
}

@media (max-width: 640px) {
  /* Ledger collapses: captions gone, labels ride each input, rows wrap. */
  .goals-ledger-header { display: none; }
  .goals-ledger-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px 12px;
  }
  .goals-ledger-account { grid-column: 1 / -1; }
  .goals-ledger-cell-label { display: block; }
  .dash-modal-panel { max-width: 480px; }
}

@media (max-width: 640px) {
  .dash-header { align-items: flex-start; flex-direction: column; gap: 14px; }
  .dash-header-actions { width: 100%; }
  .dash-cta { flex: 1; justify-content: center; }
}

/* ========================================
   COLLAPSE — reduced motion fallback
======================================== */
@media (prefers-reduced-motion: reduce) {
  .dashboard-container,
  .sidebar,
  .main-content,
  .sidebar-toggle,
  .sidebar-toggle svg {
    transition: none !important;
  }
}

.dashboard-logo {
  width: 204px;
  height: 60px;
  border-radius: 9px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.35s var(--ease);
  margin-top: -15px;
  margin-bottom: -26px;
  transform: scale(1.2);
}

.dashboard-logo img { width: 100%; height: 100%; object-fit: contain; }

.dash-page .pnl-positive { color: var(--profit-strong); }
.dash-page .pnl-negative { color: var(--loss-strong); }

.dash-goal-fill.pnl-positive { background: linear-gradient(90deg, #34d399, #059669); }
.dash-goal-fill.pnl-negative { background: linear-gradient(90deg, #f87171, #dc2626); }

.dash-sym-fill.pnl-positive  { background: #10b981; }
.dash-sym-fill.pnl-negative  { background: #ef4444; }

.dash-pill-pnl.pnl-positive { color: var(--profit-strong); }
.dash-pill-pnl.pnl-negative { color: var(--loss-strong); }

.dash-week-total.pnl-positive { background: var(--profit-soft); border-color: var(--profit-border); }
.dash-week-total.pnl-negative { background: var(--loss-soft);   border-color: var(--loss-border); }
