*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Apple-style light palette */
  --bg: #fbfbfd;
  --surface: #ffffff;
  --surface2: #f5f5f7;
  --border: rgba(0,0,0,0.08);
  --border2: rgba(0,0,0,0.14);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --green: #1e8e5a;
  --red: #d70015;
  --green-bg: rgba(30,142,90,0.08);
  --red-bg: rgba(215,0,21,0.06);
  --green-border: rgba(30,142,90,0.22);
  --red-border: rgba(215,0,21,0.18);
  --warn: #bf5b04;
  --warn-bg: rgba(191,91,4,0.08);
  --hover-tint: rgba(0,0,0,0.03);
  --color-scheme: light;

  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-text: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Menlo", "Consolas", monospace;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

/* ---- whole-page dark theme ----
   Toggled by adding data-theme="dark" to <html> (see nav.js / the theme
   toggle button). Because every component below is already built on these
   custom properties, redefining them here re-themes the entire page, not
   just the navbar/sidebar chrome. */
:root[data-theme="dark"] {
  --bg: #121212;
  --surface: #1c1c1e;
  --surface2: #262629;
  --border: rgba(255,255,255,0.09);
  --border2: rgba(255,255,255,0.17);
  --text: #f2f2f3;
  --muted: #9a9a9e;
  --accent: #3b9eff;
  --accent-hover: #5aacff;
  --green: #34c777;
  --red: #ff5c5c;
  --green-bg: rgba(52,199,119,0.12);
  --red-bg: rgba(255,92,92,0.1);
  --green-border: rgba(52,199,119,0.28);
  --red-border: rgba(255,92,92,0.24);
  --warn: #e8a13c;
  --warn-bg: rgba(232,161,60,0.12);
  --hover-tint: rgba(255,255,255,0.06);
  --color-scheme: dark;
}

html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

body {
  font-family: var(--font-text);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.47;
}

a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---- ticker: quiet price strip, Apple-Stocks-app tone ---- */
.ticker { border-bottom: 1px solid var(--border); overflow: hidden; white-space: nowrap; background: var(--surface); position: sticky; top: 0; z-index: 30; }
.ticker-track { display: inline-flex; gap: 2.25rem; padding: 7px 0; animation: scroll-left 32s linear infinite; font-family: var(--font-text); font-size: 12px; font-weight: 500; }
.ticker-track span { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); letter-spacing: -0.01em; }
.ticker-track .up { color: var(--green); }
.ticker-track .down { color: var(--red); }
@keyframes scroll-left { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .ticker-track { animation: none; } }

/* ---- top nav: translucent, centered, small tight caps ---- */
.top-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; height: 52px;
  border-bottom: 1px solid var(--border);
  background: rgba(251,251,253,0.8); backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  position: sticky; top: 33px; z-index: 25;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; letter-spacing: -0.01em; font-family: var(--font-display); }
.brand .logo-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text); }
.nav-links { display: flex; gap: 2rem; font-family: var(--font-text); font-size: 12.5px; font-weight: 400; }
.nav-links a { color: var(--muted); transition: color 0.15s; letter-spacing: -0.005em; }
.nav-links a:hover, .nav-links a.active { color: var(--text); }
.nav-right { display: flex; align-items: center; gap: 2rem; }

.sub-nav { display: flex; gap: 1.75rem; padding: 12px 1.5rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.sub-nav a { font-size: 13px; font-weight: 500; color: var(--muted); transition: color 0.15s; }
.sub-nav a:hover { color: var(--text); }
.sub-nav a.active { color: var(--accent); }

/* ==================== Welcome dashboard ==================== */
.totals-grid { max-width: 760px; margin: 1.5rem auto 0; padding: 0 1.5rem 6rem; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 620px) { .totals-grid { grid-template-columns: 1fr; } }
.total-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.75rem 1.75rem 1.5rem; transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.total-card:hover { border-color: var(--border2); transform: translateY(-2px); box-shadow: 0 10px 34px rgba(0,0,0,0.07); }
.total-card-label { font-size: 12px; font-weight: 590; color: var(--muted); margin-bottom: 10px; }
.total-card-value { font-family: var(--font-display); font-size: 34px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); margin-bottom: 8px; }
.total-card-sub { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin-bottom: 1.25rem; min-height: 38px; }
.total-card-cta { font-size: 13px; font-weight: 590; color: var(--accent); }

/* ---- mission board ---- */
.mission-wrap { max-width: 760px; margin: 1.5rem auto 0; padding: 0 1.5rem 5rem; }
.mission-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.mission-edit-link { font-size: 12.5px; font-weight: 500; color: var(--accent); }
.mission-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.75rem 1.75rem 1.5rem;
}
.mission-current { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 1.75rem; }
.mission-current-label { font-size: 13px; color: var(--muted); }
.mission-current-value { font-family: var(--font-display); font-size: 28px; font-weight: 600; letter-spacing: -0.015em; color: var(--text); }
.mission-current-note { font-size: 12.5px; color: var(--muted); }

.mission-track { position: relative; height: 6px; background: var(--surface2); border-radius: 4px; margin: 0 6px; }
.mission-fill { position: absolute; top: 0; left: 0; height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.4s ease; }
.mission-dot {
  position: absolute; top: 50%; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border2); transform: translate(-50%, -50%);
  transition: border-color 0.3s, background 0.3s;
}
.mission-dot.reached { background: var(--accent); border-color: var(--accent); }
.mission-marker {
  position: absolute; top: 50%; width: 4px; height: 18px; background: var(--text);
  border-radius: 2px; transform: translate(-50%, -50%); box-shadow: 0 0 0 3px var(--surface);
}

.mission-scale { padding-top: 4px; }
.mission-labels { position: relative; height: 18px; margin: 14px 6px 0; }
.mission-label {
  position: absolute; top: 0; transform: translateX(-50%);
  font-size: 11.5px; font-weight: 500; color: var(--muted); white-space: nowrap;
}
.mission-label.reached { color: var(--accent); font-weight: 590; }

/* ---- hero: large, centered, tight tracking ---- */
.hero { max-width: 760px; margin: 0 auto; padding: 5.5rem 1.5rem 3rem; text-align: center; }
.hero .eyebrow {
  font-family: var(--font-text); font-size: 13px; color: var(--muted);
  letter-spacing: 0.01em; margin-bottom: 18px; font-weight: 590;
}
.hero h1 {
  font-family: var(--font-display); font-size: 52px; font-weight: 600;
  letter-spacing: -0.022em; line-height: 1.07; margin-bottom: 18px; color: var(--text);
}
.hero h1 .accent { color: var(--accent); }
.hero p.lede {
  font-size: 19px; color: var(--muted); max-width: 560px; margin: 0 auto;
  line-height: 1.42; font-weight: 400; letter-spacing: -0.005em;
}


/* ---- trade statistics widgets ---- */
.stats-wrap { max-width: 760px; margin: 0 auto; padding: 0 1.5rem 1rem; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 620px) { .stat-grid { grid-template-columns: 1fr 1fr; } }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 1.25rem 1.4rem; transition: border-color 0.2s, transform 0.2s;
}
.stat-card:hover { border-color: var(--border2); transform: translateY(-1px); }
.stat-label { font-size: 11px; font-weight: 590; color: var(--muted); margin-bottom: 8px; }
.stat-value { font-family: var(--font-display); font-size: 24px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.stat-sub { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.stat-card-breakdown { grid-column: span 3; }
@media (max-width: 620px) { .stat-card-breakdown { grid-column: span 2; } }
.stat-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.stat-chip { font-size: 12px; font-weight: 590; padding: 5px 12px; border-radius: 980px; }
.chip-open { background: rgba(0,113,227,0.08); color: var(--accent); }
.chip-pending { background: var(--surface2); color: var(--muted); }
.chip-win { background: var(--green-bg); color: var(--green); }
.chip-loss { background: var(--red-bg); color: var(--red); }
.chip-breakeven { background: var(--warn-bg); color: var(--warn); }

/* ---- module list ---- */
.modules { max-width: 760px; margin: 0 auto; padding: 1rem 1.5rem 6rem; }
.modules .section-label {
  font-size: 12px; font-weight: 590; letter-spacing: -0.005em;
  color: var(--muted); margin-bottom: 1rem; font-family: var(--font-text);
}
.module-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }

.module-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.5rem; margin-bottom: 0; transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.module-card.available:hover { border-color: var(--border2); transform: translateY(-2px); box-shadow: 0 8px 30px rgba(0,0,0,0.06); }
.module-card.locked { opacity: 0.5; }
.mc-left { display: flex; gap: 16px; align-items: flex-start; }
.mc-icon {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  font-family: var(--font-display); font-size: 16px; font-weight: 600;
}
.module-card.locked .mc-icon { color: var(--muted); }
.mc-title { font-size: 16px; font-weight: 590; margin-bottom: 4px; font-family: var(--font-display); letter-spacing: -0.01em; }
.mc-desc { font-size: 13.5px; color: var(--muted); line-height: 1.5; max-width: none; }
.mc-status {
  font-family: var(--font-text); font-size: 11.5px; font-weight: 590; letter-spacing: -0.005em;
  padding: 6px 14px; border-radius: 980px; white-space: nowrap; flex-shrink: 0; align-self: flex-start;
}
.mc-status.live { background: var(--accent); color: #fff; }
.mc-status.soon { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }

.footnote { text-align: center; font-family: var(--font-text); font-size: 12px; color: var(--muted); padding: 2rem 1.5rem 3rem; border-top: 1px solid var(--border); }

/* ---- trade log ---- */
.log-wrap { max-width: 1200px; margin: 0 auto; padding: 3rem 1.5rem 6rem; }
.log-wrap.wide { max-width: 1600px; }
.log-empty {
  text-align: center; padding: 4rem 1.5rem; color: var(--muted); font-family: var(--font-text);
  font-size: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.log-empty a { color: var(--accent); }
.log-table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
table.log-table { width: 100%; border-collapse: collapse; font-family: var(--font-text); font-size: 13px; }
.log-table th {
  text-align: left; font-size: 11px; font-weight: 590; letter-spacing: -0.005em; color: var(--muted);
  padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--surface2);
}
.log-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; transition: color 0.15s; }
.log-table th.sortable:hover { color: var(--text); }
.log-table th.sortable.sorted { color: var(--accent); }
.log-table th.sortable .sort-arrow { display: inline-block; width: 12px; font-size: 10px; }
.log-table td { padding: 14px 18px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.log-table tr:last-child td { border-bottom: none; }
.log-table tr:hover td { background: var(--hover-tint); }
.log-dir { font-weight: 590; letter-spacing: -0.005em; font-size: 11.5px; padding: 4px 11px; border-radius: 980px; background: var(--surface2); color: var(--muted); }
.log-dir.long { background: var(--green-bg); color: var(--green); }
.log-dir.short { background: var(--red-bg); color: var(--red); }
.log-asset { font-weight: 590; color: var(--text); font-family: var(--font-mono); letter-spacing: 0; }
.log-refresh {
  font-family: var(--font-text); font-size: 12.5px; font-weight: 500; color: var(--text); background: var(--surface2);
  border: 1px solid var(--border); border-radius: 980px; padding: 7px 16px; cursor: pointer; transition: all 0.15s;
}
.log-refresh:hover { background: var(--border); }
.log-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap; }

.outcome-select {
  font-family: var(--font-text); font-size: 12px; font-weight: 590; letter-spacing: -0.005em;
  border-radius: 980px; padding: 5px 26px 5px 12px; cursor: pointer; appearance: none;
  background-repeat: no-repeat; background-position: right 10px center; background-size: 9px;
  border: 1px solid var(--border2);
}
.outcome-select.pending { background-color: var(--surface2); color: var(--muted); }
.outcome-select.open { background-color: rgba(0,113,227,0.08); color: var(--accent); border-color: rgba(0,113,227,0.2); }
.outcome-select.win { background-color: var(--green-bg); color: var(--green); border-color: var(--green-border); }
.outcome-select.loss { background-color: var(--red-bg); color: var(--red); border-color: var(--red-border); }
.outcome-select.breakeven { background-color: var(--warn-bg); color: var(--warn); border-color: rgba(191,91,4,0.18); }
.outcome-select.cancelled { background-color: var(--surface2); color: var(--muted); text-decoration: line-through; }

.outcome-select.status-pending { background-color: var(--surface2); color: var(--muted); }
.outcome-select.status-open { background-color: var(--green-bg); color: var(--green); border-color: var(--green-border); }
.outcome-select.status-waiting { background-color: var(--warn-bg); color: var(--warn); border-color: rgba(191,91,4,0.18); }
.outcome-select.status-close { background-color: var(--surface2); color: var(--muted); }

.table-scroll { overflow-x: auto; }
.log-desc { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.desc-link { color: var(--accent); text-decoration: none; cursor: pointer; }
.desc-link:hover { text-decoration: underline; }
.closing-date-input { width: auto; padding: 6px 12px; font-size: 12px; }

.trade-image-cell { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.trade-thumb {
  width: 40px; height: 40px; object-fit: cover; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); transition: transform 0.15s;
}
.trade-thumb:hover { transform: scale(1.08); }
.img-upload-btn {
  display: inline-flex; align-items: center; font-family: var(--font-text); font-size: 12px; font-weight: 500;
  color: var(--muted); background: var(--surface2); border: 1px dashed var(--border2); border-radius: 980px;
  padding: 6px 14px; cursor: pointer; transition: all 0.15s;
}
.img-upload-btn:hover { color: var(--accent); border-color: var(--accent); background: rgba(0,113,227,0.06); }
.img-remove-btn {
  font-family: var(--font-text); font-size: 11px; font-weight: 500; color: var(--muted);
  background: none; border: none; cursor: pointer; text-decoration: underline; padding: 0;
}
.img-remove-btn:hover { color: var(--red); }

/* ==================== Auth pages ==================== */
.auth-wrap { display: flex; justify-content: center; padding: 5rem 1.5rem; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-family: var(--font-display); font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 8px; }
.auth-sub { font-size: 14px; color: var(--muted); margin-bottom: 2rem; }
.auth-error { font-size: 13px; color: var(--red); min-height: 18px; margin: -0.25rem 0 1rem; }
.auth-submit { width: 100%; text-align: center; padding: 13px 20px; font-size: 15px; margin-top: 0.5rem; }

/* ==================== Analytics ==================== */
.breakdown-list { display: flex; flex-direction: column; gap: 10px; }
.breakdown-row { display: grid; grid-template-columns: 70px 1fr 44px 90px; gap: 10px; align-items: center; font-size: 13px; }
.breakdown-label { font-weight: 590; font-family: var(--font-mono); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breakdown-bar-wrap { background: var(--surface2); border-radius: 4px; height: 8px; overflow: hidden; }
.breakdown-bar { background: var(--accent); height: 100%; border-radius: 4px; }
.breakdown-wr { color: var(--muted); text-align: right; }
.breakdown-pnl { text-align: right; font-weight: 590; }

.calendar-heatmap { display: flex; flex-wrap: nowrap; gap: 4px; overflow-x: auto; padding-bottom: 4px; }
.calendar-cell { flex: 0 0 20px; width: 20px; height: 20px; border-radius: 4px; border: 2px solid transparent; cursor: default; box-sizing: border-box; }
.calendar-cell.loss-day {
  border-color: var(--red);
  box-shadow: 0 0 0 1px var(--red), 0 0 6px 1px var(--red);
}

/* ==================== Mini list (recent trades / assets in sidebars) ==================== */
.mini-list { display: flex; flex-direction: column; gap: 2px; }
.mini-list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 4px; text-decoration: none; border-radius: 8px; transition: background 0.15s;
}
.mini-list-row:hover { background: var(--hover-tint); }
.mini-list-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mini-list-asset { font-family: var(--font-mono); font-size: 13px; font-weight: 590; color: var(--text); }
.mini-list-sub { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list-end { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ==================== Tag picker (edit-trade modal) ==================== */
.tag-picker { position: relative; }
.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tag-chips:empty { margin-bottom: 0; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 590;
  padding: 4px 8px 4px 10px; border-radius: 980px;
}
.tag-chip button {
  background: rgba(255,255,255,0.25); border: none; color: #fff; cursor: pointer;
  width: 15px; height: 15px; border-radius: 50%; font-size: 11px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.tag-chip button:hover { background: rgba(255,255,255,0.4); }
.tag-picker input[type="text"] {
  width: 100%; background: var(--surface2); border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 10px 14px; font-family: var(--font-text); font-size: 14px; color: var(--text); outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.tag-picker input[type="text"]:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0,113,227,0.12); }
.tag-dropdown {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  max-height: 200px; overflow-y: auto; z-index: 20; display: none;
  box-shadow: 0 12px 34px rgba(0,0,0,0.12);
}
.tag-dropdown.open { display: block; }
.tag-option {
  padding: 9px 14px; font-size: 13.5px; color: var(--text); cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
}
.tag-option:hover, .tag-option.active { background: var(--surface2); }
.tag-option-new { color: var(--accent); font-weight: 500; }
.tag-dropdown-empty { padding: 9px 14px; font-size: 13px; color: var(--muted); }

/* ==================== Bulk select action bar ==================== */
.bulk-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface2); border: 1px solid var(--accent); border-radius: var(--radius-md);
  padding: 10px 16px; margin-bottom: 1rem; font-size: 13px; font-weight: 590; color: var(--text);
}
.bulk-bar-actions { display: flex; align-items: center; gap: 8px; }
.bulk-bar-actions input[type="text"] {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 10px; font-size: 12.5px; color: var(--text); width: 140px;
}
.log-table td.select-cell, .log-table th.select-cell { width: 36px; text-align: center; }

/* ==================== Dashboard exposure widget ==================== */
.breach-banner {
  display: flex; align-items: center; gap: 10px;
  max-width: 760px; margin: 0 auto 1.5rem; padding: 14px 18px;
  background: var(--red-bg); border: 1px solid var(--red-border); border-radius: var(--radius-md);
  color: var(--red); font-size: 13.5px; font-weight: 500;
}

.exposure-widget { max-width: 760px; margin: 0 auto 1.5rem; }
.auth-switch { font-size: 13.5px; color: var(--muted); margin-top: 1.75rem; text-align: center; }
.auth-switch a { color: var(--accent); font-weight: 500; }

/* ==================== Nav user menu ==================== */
.nav-user { display: flex; align-items: center; gap: 18px; }
.nav-username-link { font-size: 12.5px; color: var(--muted); font-weight: 500; transition: color 0.15s; }
.nav-username-link:hover, .nav-username-link.active { color: var(--accent); }
.nav-logout {
  font-family: var(--font-text); font-size: 12px; font-weight: 500; color: var(--muted);
  background: var(--surface2); border: none; border-radius: 980px; padding: 6px 14px; cursor: pointer;
  transition: all 0.15s;
}
.nav-logout:hover { background: var(--border2); color: var(--text); }

/* ==================== Calculator page ==================== */
.page-wrap { display: flex; justify-content: center; padding: 3rem 1.5rem 6rem; }
.page { width: 100%; max-width: 560px; }
.page.page-wide { max-width: 1040px; }

/* ---- two-pane form layout: inputs on the left, live results/summary on the right ---- */
.two-pane { display: flex; gap: 2rem; align-items: flex-start; }
.two-pane-main { flex: 1 1 0; min-width: 0; }
.two-pane-aside { flex: 0 0 360px; width: 360px; }
.two-pane-aside .sticky-panel {
  position: sticky;
  top: calc(var(--ll-ticker-h, 33px) + var(--ll-navbar-h, 52px) + 20px);
}
@media (max-width: 860px) {
  .two-pane { flex-direction: column; }
  .two-pane-aside { width: 100%; flex: 1 1 auto; }
  .two-pane-aside .sticky-panel { position: static; }
}

.result-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 1.5rem;
}
.result-panel .formula { margin-bottom: 0; }

.calc-header { margin-bottom: 2.5rem; }
.calc-header h1 { font-family: var(--font-display); font-size: 32px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 6px; color: var(--text); }
.calc-header p { font-size: 15px; color: var(--muted); font-weight: 400; }

.dir-wrap { margin-bottom: 2.25rem; }
.dir-toggle { display: inline-flex; background: var(--surface2); border-radius: 980px; padding: 3px; gap: 2px; }
.dir-btn {
  padding: 9px 34px; font-size: 13.5px; font-weight: 590; font-family: var(--font-text);
  border: none; border-radius: 980px; cursor: pointer;
  background: transparent; color: var(--muted); letter-spacing: -0.005em;
  transition: all 0.2s;
}
.dir-btn:hover:not(.active) { color: var(--text); }
.dir-btn.long.active { background: var(--surface); color: var(--green); box-shadow: 0 1px 4px rgba(0,0,0,0.1); }
.dir-btn.short.active { background: var(--surface); color: var(--red); box-shadow: 0 1px 4px rgba(0,0,0,0.1); }
.kbd-hint { font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.kbd-hint kbd {
  font-family: var(--font-mono); font-size: 10.5px; background: var(--surface2);
  border: 1px solid var(--border2); border-radius: 4px; padding: 1px 5px; color: var(--text);
}

.section { margin-bottom: 1.75rem; }
.section-label {
  font-size: 12px; font-weight: 590; letter-spacing: -0.005em;
  color: var(--muted); margin-bottom: 1rem;
}

.field { margin-bottom: 1rem; }
.field label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 7px; font-weight: 450; }
.two-col-aligned-labels .field label { min-height: 34px; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-prefix, .input-suffix {
  position: absolute; font-family: var(--font-text); font-size: 15px;
  color: var(--muted); pointer-events: none; z-index: 1;
}
.input-prefix { left: 16px; }
.input-suffix { right: 16px; }
.input-wrap input, .asset-wrap input {
  width: 100%; background: var(--surface2); border: 1px solid transparent;
  border-radius: var(--radius-sm); padding: 12px 16px 12px 40px; font-family: var(--font-text);
  font-size: 15px; font-weight: 450; color: var(--text); outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  -moz-appearance: textfield;
}
.input-wrap input::-webkit-outer-spin-button,
.input-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; }
.input-wrap input:focus, .asset-wrap input:focus {
  background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0,113,227,0.12);
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 700px) {
  .two-col { grid-template-columns: 1fr; }
}

/* asset combobox */
.asset-wrap { position: relative; }
.asset-wrap input { padding: 12px 16px 12px 40px; text-transform: uppercase; letter-spacing: 0.01em; }
#exchange { text-transform: none; letter-spacing: normal; }
.asset-wrap .input-prefix { top: 50%; transform: translateY(-50%); }
.asset-panel {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  max-height: 240px; overflow-y: auto; z-index: 20; display: none;
  box-shadow: 0 12px 34px rgba(0,0,0,0.12);
}
.asset-panel.open { display: block; }
.asset-opt {
  padding: 11px 16px; display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; font-size: 14px; color: var(--text);
  border-bottom: 1px solid var(--border);
}
.asset-opt:last-child { border-bottom: none; }
.asset-opt:hover { background: var(--surface2); }
.asset-opt .a-name { color: var(--muted); font-size: 12px; }
.asset-create {
  padding: 11px 16px; cursor: pointer; font-size: 13px;
  color: var(--accent); border-top: 1px solid var(--border); display: none; font-weight: 500;
}
.asset-create.show { display: block; }
.asset-create:hover { background: var(--surface2); }
.asset-hint { font-size: 12px; color: var(--muted); margin-top: 6px; min-height: 15px; }
.asset-hint.ok { color: var(--green); }
.asset-hint.err { color: var(--red); }
.unmapped-asset-link { color: var(--warn); font-size: 12.5px; font-weight: 590; text-decoration: none; white-space: nowrap; }
.unmapped-asset-link:hover { text-decoration: underline; }

.price-toggle-row { display: flex; align-items: center; gap: 10px; margin-bottom: 1.1rem; }
.price-toggle-row span { font-size: 13px; color: var(--muted); }
.sw { position: relative; display: inline-block; width: 40px; height: 24px; }
.sw input { opacity: 0; width: 0; height: 0; }
.sw-track {
  position: absolute; inset: 0; background: var(--border2);
  border-radius: 980px; cursor: pointer; transition: background 0.2s;
}
.sw-track::before {
  content: ''; position: absolute; width: 20px; height: 20px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.sw input:checked + .sw-track { background: var(--green); }
.sw input:checked + .sw-track::before { transform: translateX(16px); }

#price-fields { overflow: hidden; max-height: 0; transition: max-height 0.3s ease; }
.auto-note { font-size: 12.5px; color: var(--accent); margin: 6px 0 12px; min-height: 18px; font-weight: 500; }
.sl-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

.divider { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

.result-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.result-card { background: var(--surface2); border-radius: var(--radius-md); padding: 16px; }
.r-label { font-size: 11px; color: var(--muted); margin-bottom: 8px; font-weight: 500; }
.r-value { font-size: 18px; font-weight: 600; font-family: var(--font-display); color: var(--text); letter-spacing: -0.01em; }
.r-sub { font-size: 10.5px; color: var(--muted); margin-top: 4px; }

.main-result {
  border-radius: var(--radius-lg); padding: 1.5rem 1.75rem;
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; transition: background 0.25s;
}
.main-result.long { background: var(--green-bg); }
.main-result.short { background: var(--red-bg); }
.mr-left { display: flex; flex-direction: column; gap: 5px; }
.mr-dir { font-size: 11px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; display: flex; align-items: center; gap: 6px; }
.main-result.long .mr-dir { color: var(--green); }
.main-result.short .mr-dir { color: var(--red); }
.dir-badge { width: 6px; height: 6px; border-radius: 50%; }
.main-result.long .dir-badge { background: var(--green); }
.main-result.short .dir-badge { background: var(--red); }
.mr-label { font-size: 13px; color: var(--muted); }
.mr-value {
  font-size: 32px; font-weight: 600; font-family: var(--font-display); letter-spacing: -0.02em;
  background: transparent; border: none; outline: none; text-align: right; width: 190px;
  border-radius: 8px; transition: background 0.15s, box-shadow 0.15s;
}
.mr-value:hover { background: var(--hover-tint); }
.mr-value:focus { background: var(--surface); box-shadow: 0 0 0 3px rgba(0,113,227,0.18); }
.main-result.long .mr-value { color: var(--green); }
.main-result.short .mr-value { color: var(--red); }
.reset-link {
  font-family: var(--font-text); font-size: 11px; font-weight: 500; color: var(--accent);
  background: none; border: none; padding: 0; margin-left: 6px; cursor: pointer;
  text-decoration: underline; display: none;
}
.reset-link.show { display: inline; }

.lev-wrap { margin-bottom: 1.75rem; }
.lev-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.lev-title { font-size: 12px; color: var(--muted); font-weight: 500; }
.lev-pill { font-size: 11px; font-weight: 590; padding: 4px 12px; border-radius: 980px; }
.pill-low { background: var(--green-bg); color: var(--green); }
.pill-med { background: var(--warn-bg); color: var(--warn); }
.pill-high { background: var(--red-bg); color: var(--red); }
.lev-track { height: 4px; border-radius: 2px; background: var(--surface2); overflow: hidden; }
.lev-fill { height: 100%; border-radius: 2px; transition: width 0.4s ease, background 0.3s; }
.lev-scale { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-top: 6px; }

.formula { font-size: 12px; color: var(--muted); font-family: var(--font-mono); line-height: 1.7; padding-top: 0.75rem; border-top: 1px solid var(--border); margin-bottom: 2rem; }
.formula span { color: var(--accent); }

.save-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.save-btn {
  font-family: var(--font-text); font-weight: 590; font-size: 14px; letter-spacing: -0.005em;
  padding: 12px 24px; border-radius: 980px; border: none; background: var(--accent);
  color: #fff; cursor: pointer; transition: background 0.15s;
}
.save-btn:hover { background: var(--accent-hover); }
.date-input {
  font-family: var(--font-text); font-size: 14px; font-weight: 500; color: var(--text); background: var(--surface2);
  border: 1px solid transparent; border-radius: 980px; padding: 11px 20px; outline: none;
  width: auto; display: inline-block;
  color-scheme: var(--color-scheme);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.date-input:hover { background: var(--border2); }
.date-input:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0,113,227,0.12); }
.save-status { font-size: 13px; color: var(--muted); }
.save-status.ok { color: var(--green); }
.save-status.err { color: var(--red); }
.view-log-link { display: none; font-size: 13px; font-weight: 500; color: var(--accent); }

.spot-textarea {
  width: 100%; min-height: 90px; background: var(--surface2); border: 1px solid transparent;
  border-radius: var(--radius-sm); padding: 12px 16px; font-family: var(--font-text);
  font-size: 14px; color: var(--text); outline: none; resize: vertical;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.spot-textarea:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0,113,227,0.12); }
.input-wrap input:disabled { color: var(--muted); cursor: default; }

/* ==================== Trade log filters ==================== */
.log-filters { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 1.75rem; flex-wrap: wrap; }
.log-filters label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 6px; font-weight: 450; }
.log-filters input, .log-filters select {
  background: var(--surface2); border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 9px 12px; font-family: var(--font-text); font-size: 13px; color: var(--text); outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s; color-scheme: var(--color-scheme);
}
.log-filters input:focus, .log-filters select:focus {
  background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0,113,227,0.12);
}
.log-subtitle { font-size: 14px; color: var(--muted); font-weight: 400; margin-top: 4px; }

.log-pagination { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 16px 18px; border-top: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }
.log-page-info { font-size: 12.5px; color: var(--muted); font-family: var(--font-text); }
.log-page-controls { display: flex; align-items: center; gap: 8px; }
.log-page-btn {
  font-family: var(--font-text); font-size: 12.5px; font-weight: 500; color: var(--text); background: var(--surface2);
  border: none; border-radius: 980px; padding: 7px 14px; cursor: pointer; transition: background 0.15s;
}
.log-page-btn:hover:not(:disabled) { background: var(--border2); }
.log-page-btn:disabled { opacity: 0.4; cursor: default; }
.log-page-current { font-size: 12.5px; color: var(--muted); font-weight: 500; min-width: 70px; text-align: center; }

.log-actions { display: flex; gap: 6px; align-items: center; }

.log-delete-btn {
  font-family: var(--font-text); font-size: 12px; font-weight: 500; color: var(--muted);
  background: transparent; border: 1px solid var(--border2); border-radius: 980px;
  padding: 5px 12px; cursor: pointer; transition: all 0.15s;
}
.log-delete-btn:hover:not(:disabled) { color: var(--red); border-color: var(--red-border); background: var(--red-bg); }
.log-delete-btn:disabled { opacity: 0.5; cursor: default; }

/* Fixed-size icon action buttons (asset list) — same footprint on every row, so the
   actions column stays aligned regardless of what else is in the row. */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; flex: 0 0 32px; padding: 0; line-height: 0;
  background: transparent; border: 1px solid var(--border2); border-radius: 8px;
  color: var(--muted); cursor: pointer; transition: all 0.15s;
}
.icon-btn svg { display: block; }
.icon-btn:disabled { opacity: 0.5; cursor: default; }
.icon-btn-edit:hover:not(:disabled) { color: var(--accent); border-color: rgba(0,113,227,0.3); background: rgba(0,113,227,0.06); }
.icon-btn-delete:hover:not(:disabled) { color: var(--red); border-color: var(--red-border); background: var(--red-bg); }

/* ---- edit modal ---- */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 100; align-items: center; justify-content: center; padding: 1.5rem;
}
.modal-overlay.open { display: flex; }
.modal-card {
  background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 30px 80px rgba(0,0,0,0.25);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.5rem 1.75rem 0.5rem;
}
.modal-header h2 { font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.modal-close { background: none; border: none; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 0.75rem 1.75rem 0.5rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 1rem 1.75rem 1.5rem; }
