/* FinToolbox — Trading Journal styles (ported from design-reference/journal.css).
   Premium-only tool. Pairs with /css/styles.css tokens. */


/* ============================================================
   Trading Journal
   ============================================================ */

/* Page header — special with premium pill + Add Trade CTA */
.jrn-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding-bottom: 18px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line-soft);
}
.jrn-head h1 { margin: 0 0 6px; font-size: 26px; font-weight: 700; letter-spacing: -0.022em; }
.jrn-head p { margin: 0; color: var(--text-2); font-size: 13.5px; max-width: 64ch; }
.jrn-tag-premium {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: 5px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  background: linear-gradient(135deg, #ffce5e 0%, var(--yellow) 100%);
  color: #1a1209;
}
.jrn-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* Sub-tab bar */
.jrn-tabs {
  display: inline-flex;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.jrn-tab {
  border: 0; background: transparent;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  transition: color 0.12s, background 0.12s;
}
.jrn-tab:hover { color: var(--text); }
.jrn-tab.on { background: var(--card-hi); color: var(--text); }
.jrn-tab .ic { width: 14px; height: 14px; opacity: 0.7; }
.jrn-tab.on .ic { color: var(--green); opacity: 1; }

/* Calendar */
.jrn-cal {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-card);
}
.jrn-cal-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 14px;
  gap: 12px;
}
.jrn-cal-title { flex: 1 1 auto; min-width: 0; }
.jrn-cal-nav {
  display: flex; align-items: center; gap: 8px;
}
.jrn-cal-month { min-width: 0; }
.jrn-cal-btn {
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--card);
  color: var(--text-2); font-size: 15px; line-height: 1;
  cursor: pointer; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.jrn-cal-btn:hover { border-color: var(--green); color: var(--green); background: var(--card-2); }
.jrn-cal-btn:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.jrn-cal-today {
  height: 28px; padding: 0 10px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--card);
  color: var(--text-3); font-size: 11.5px; font-weight: 600;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}
.jrn-cal-today:hover { border-color: var(--green); color: var(--green); }
.jrn-cal-wkhdr {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}
.jrn-cal-wkhdr span {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-4);
  text-align: center;
  padding: 4px 0;
}
.jrn-cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.jrn-cal-cell {
  background: var(--card-2);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  aspect-ratio: 1.4 / 1;
  display: flex; flex-direction: column; gap: 1px;
  padding: 5px 7px;
  text-align: left;
  cursor: default;
  position: relative;
  font: inherit;
  color: inherit;
  min-height: 56px;
}
.jrn-cal-cell.has { cursor: pointer; transition: transform 0.06s, box-shadow 0.12s; }
.jrn-cal-cell.has:hover { transform: translateY(-1px); box-shadow: 0 4px 14px -6px rgba(0,0,0,0.45); }
.jrn-cal-cell.empty { background: transparent; border-color: transparent; }
.jrn-cal-cell.wknd:not(.has) { opacity: 0.5; }
.jrn-cal-cell .d {
  font-size: 11px; font-weight: 600; color: var(--text-3);
}
.jrn-cal-cell .p {
  font-size: 12px; font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.jrn-cal-cell .p.empty { color: var(--text-4); font-weight: 500; }
.jrn-cal-cell .n {
  position: absolute;
  bottom: 4px; right: 6px;
  font-size: 9.5px; font-weight: 600;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* Colored calendar days (green = winning day, red = losing day). The cell
   background is tinted via inline style and previously used a matching-hue
   P&L text colour — the two colours canceled each other out for low-magnitude
   days and the text became unreadable, especially in light mode. Force every
   text child to white with a strong text-shadow that reads on both the dark-
   theme tinted backgrounds AND the lighter light-mode tints. !important is
   required to override the inline color="var(--green)|var(--red)" on .p. */
.jrn-cal-cell.cal-green .d,
.jrn-cal-cell.cal-green .p,
.jrn-cal-cell.cal-green .n,
.jrn-cal-cell.cal-red   .d,
.jrn-cal-cell.cal-red   .p,
.jrn-cal-cell.cal-red   .n {
  color: #fff !important;
  text-shadow:
    0 0 2px rgba(0, 0, 0, 0.55),
    0 1px 2px rgba(0, 0, 0, 0.55);
}
/* Light mode: the bg is paler so an even stronger shadow keeps the white
   text legible at the lowest alphas without losing the visual softness of
   the tint. */
[data-theme="light"] .jrn-cal-cell.cal-green .d,
[data-theme="light"] .jrn-cal-cell.cal-green .p,
[data-theme="light"] .jrn-cal-cell.cal-green .n,
[data-theme="light"] .jrn-cal-cell.cal-red   .d,
[data-theme="light"] .jrn-cal-cell.cal-red   .p,
[data-theme="light"] .jrn-cal-cell.cal-red   .n {
  text-shadow:
    0 0 2px rgba(0, 0, 0, 0.7),
    0 1px 2px rgba(0, 0, 0, 0.7),
    0 0 6px rgba(0, 0, 0, 0.35);
}

/* Stat row variant with embedded delta line */
.jrn-stat-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px; background: var(--line-soft); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-card); }
.jrn-stat-row .stat { background: var(--card); padding: 16px 18px; }
@media (max-width: 900px) {
  .jrn-stat-row { grid-template-columns: repeat(2, 1fr); }
}

/* Trade row in table — adds side pill, tag pill */
.jrn-side {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 4px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.jrn-side.long  { background: var(--green-soft); color: var(--green); }
.jrn-side.short { background: var(--red-soft); color: var(--red); }
.jrn-strategy {
  display: inline-flex; align-items: center;
  padding: 2px 7px; border-radius: 999px;
  font-size: 10.5px; font-weight: 600;
  background: var(--card-2); border: 1px solid var(--line-soft);
  color: var(--text-2);
}

/* Strategy color dot */
.jrn-strategy::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--blue);
  margin-right: 5px;
  display: inline-block;
}
.jrn-strategy[data-c="breakout"]::before { background: #4d8dff; }
.jrn-strategy[data-c="reversal"]::before { background: #c389ff; }
.jrn-strategy[data-c="swing"]::before    { background: var(--green); }
.jrn-strategy[data-c="scalp"]::before    { background: var(--yellow); }
.jrn-strategy[data-c="news"]::before     { background: var(--red); }
.jrn-strategy[data-c="trend"]::before    { background: #7fc46b; }

/* Mistake heatmap grid */
.jrn-heat {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px;
}
.jrn-heat-cell {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line-soft);
  display: flex; flex-direction: column; gap: 4px;
  background: var(--card-2);
}
.jrn-heat-tag { font-size: 12.5px; font-weight: 700; color: var(--text); }
.jrn-heat-count { font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.jrn-heat-pnl { font-size: 13px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* Colored heatmap cells — same readability fix as the calendar. Every text
   child goes white with a strong shadow that holds up against the rgba
   tinted backgrounds set inline. !important defeats the inline color
   var(--green)/var(--red) the JS still emits on the .jrn-heat-pnl element. */
.jrn-heat-cell.heat-green .jrn-heat-tag,
.jrn-heat-cell.heat-green .jrn-heat-count,
.jrn-heat-cell.heat-green .jrn-heat-pnl,
.jrn-heat-cell.heat-red   .jrn-heat-tag,
.jrn-heat-cell.heat-red   .jrn-heat-count,
.jrn-heat-cell.heat-red   .jrn-heat-pnl {
  color: #fff !important;
  text-shadow:
    0 0 2px rgba(0, 0, 0, 0.55),
    0 1px 2px rgba(0, 0, 0, 0.55);
}
[data-theme="light"] .jrn-heat-cell.heat-green .jrn-heat-tag,
[data-theme="light"] .jrn-heat-cell.heat-green .jrn-heat-count,
[data-theme="light"] .jrn-heat-cell.heat-green .jrn-heat-pnl,
[data-theme="light"] .jrn-heat-cell.heat-red   .jrn-heat-tag,
[data-theme="light"] .jrn-heat-cell.heat-red   .jrn-heat-count,
[data-theme="light"] .jrn-heat-cell.heat-red   .jrn-heat-pnl {
  text-shadow:
    0 0 2px rgba(0, 0, 0, 0.7),
    0 1px 2px rgba(0, 0, 0, 0.7),
    0 0 6px rgba(0, 0, 0, 0.35);
}

/* Modal */
.jrn-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  z-index: 300;
  display: grid; place-items: center;
  padding: 20px;
  animation: jrn-fade 0.16s ease-out;
}
@keyframes jrn-fade { from { opacity: 0; } to { opacity: 1; } }
.jrn-modal {
  width: 100%; max-width: 760px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.7);
  animation: jrn-pop 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.jrn-modal.wide { max-width: 880px; }
@keyframes jrn-pop {
  from { transform: translateY(8px) scale(0.98); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.jrn-modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.jrn-modal-head h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.jrn-modal-head .sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.jrn-modal-x {
  width: 30px; height: 30px;
  border-radius: 7px;
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  cursor: pointer; display: grid; place-items: center;
}
.jrn-modal-x:hover { background: var(--card-hi); color: var(--text); }
.jrn-modal-body { padding: 22px; }
.jrn-modal-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 22px;
  border-top: 1px solid var(--line-soft);
  background: var(--card-2);
  gap: 10px;
}

/* Side toggle (Long/Short) */
.jrn-side-toggle {
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
  height: 38px;
}
.jrn-side-toggle button {
  border: 0; background: transparent;
  color: var(--text-3);
  font-size: 12.5px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.jrn-side-toggle button.on.long  { background: var(--green-soft); color: var(--green); }
.jrn-side-toggle button.on.short { background: var(--red-soft); color: var(--red); }

/* Screenshot dropzone */
.jrn-drop {
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  background: var(--card-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 22px 18px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  color: var(--text-3);
  font-size: 12.5px;
  text-align: center;
}
.jrn-drop:hover { border-color: var(--green-dim); background: var(--bg-elev); }
.jrn-drop .ic-big {
  width: 38px; height: 38px;
  border-radius: 9px;
  background: var(--card);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  color: var(--text-2);
}

/* Auto-calc row */
.jrn-autocalc {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.jrn-autocalc .cell {
  background: var(--card-2);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 2px;
}
.jrn-autocalc .l {
  font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-3);
  display: inline-flex; align-items: center; gap: 5px;
}
.jrn-autocalc .v {
  font-size: 18px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.jrn-autocalc .v.green { color: var(--green); }
.jrn-autocalc .v.red { color: var(--red); }

/* Premium overlay */
.jrn-locked {
  position: relative;
}
.jrn-locked::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--bg) 30%, transparent) 0%,
    color-mix(in srgb, var(--bg) 90%, transparent) 50%,
    var(--bg) 100%);
  z-index: 4;
  pointer-events: none;
  border-radius: var(--radius);
}
.jrn-locked > .jrn-locked-content {
  filter: blur(3.5px);
  pointer-events: none;
  user-select: none;
}
.jrn-premium-cta {
  position: absolute;
  left: 50%; top: 56%;
  transform: translate(-50%, -50%);
  z-index: 5;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px 30px;
  text-align: center;
  display: flex; flex-direction: column; gap: 12px;
  align-items: center;
  box-shadow: 0 24px 60px -16px rgba(0,0,0,0.5);
  max-width: 420px;
}
.jrn-premium-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, #ffce5e 0%, var(--yellow) 100%);
  display: grid; place-items: center;
  color: #1a1209;
  box-shadow: 0 8px 24px -6px rgba(240, 178, 50, 0.55);
}
.jrn-premium-cta h3 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.jrn-premium-cta p { margin: 0; color: var(--text-2); font-size: 13.5px; line-height: 1.5; max-width: 36ch; }
.jrn-premium-price {
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
}
.jrn-premium-price b {
  font-size: 22px;
  font-weight: 800;
  color: var(--yellow);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.jrn-premium-perks {
  display: flex; flex-direction: column; gap: 6px;
  margin: 4px 0 4px;
  align-self: stretch;
}
.jrn-premium-perks li {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px;
  color: var(--text-2);
  list-style: none;
}
.jrn-premium-perks li .ic {
  width: 14px; height: 14px;
  color: var(--green);
  flex-shrink: 0;
}

/* Trade detail layout */
.jrn-detail-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
}
@media (max-width: 720px) {
  .jrn-detail-grid { grid-template-columns: 1fr; }
}
.jrn-shot {
  background: var(--card-2);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  height: 240px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  overflow: hidden;
  color: var(--text-3);
}
.jrn-shot.has-shot {
  background:
    linear-gradient(180deg, rgba(0, 200, 150, 0.04) 0%, transparent 50%, rgba(224, 92, 92, 0.04) 100%),
    repeating-linear-gradient(0deg, transparent 0 23px, var(--line-soft) 23px 24px),
    repeating-linear-gradient(90deg, transparent 0 31px, var(--line-soft) 31px 32px),
    var(--card-2);
}
.jrn-shot .shot-meta {
  position: absolute; top: 8px; left: 10px;
  font-size: 10.5px; color: var(--text-3); font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  background: color-mix(in srgb, var(--card) 80%, transparent);
  padding: 3px 7px; border-radius: 4px;
  backdrop-filter: blur(4px);
}
.jrn-detail-tbl {
  width: 100%;
  font-size: 13px;
}
.jrn-detail-tbl tr { border-bottom: 1px dashed var(--line-soft); }
.jrn-detail-tbl tr:last-child { border-bottom: 0; }
.jrn-detail-tbl td {
  padding: 9px 0;
  font-variant-numeric: tabular-nums;
}
.jrn-detail-tbl td:first-child {
  color: var(--text-3);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  width: 130px;
}
.jrn-detail-tbl td:last-child { font-weight: 600; color: var(--text); text-align: right; }
.jrn-detail-tbl td.green { color: var(--green); }
.jrn-detail-tbl td.red { color: var(--red); }

.jrn-notes {
  padding: 14px;
  background: var(--card-2);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-2);
  white-space: pre-wrap;
}

/* Sticky equity-curve toolbar */
.jrn-curve-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.jrn-curve-head h3 { margin: 0; font-size: 14px; font-weight: 700; }
.jrn-curve-head .sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* Row of analytics cards */
.jrn-anlt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 960px) {
  .jrn-anlt-grid { grid-template-columns: 1fr; }
}

/* Best/worst lists */
.jrn-bw-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 12px; align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.jrn-bw-row:last-child { border-bottom: 0; }
.jrn-bw-row .sym {
  font-weight: 700; font-size: 13.5px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.jrn-bw-row .meta {
  font-size: 11.5px; color: var(--text-3);
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
}
.jrn-bw-row .pnl {
  font-size: 14px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.jrn-bw-row .pnl.green { color: var(--green); }
.jrn-bw-row .pnl.red { color: var(--red); }

/* Placeholder slot when a side (Top winners or Bottom losers) has < 3 trades.
   Strict filtering: never cross-fills, just shows "Not enough data". */
.jrn-bw-row.jrn-bw-empty {
  opacity: 0.55;
  cursor: default;
  background: repeating-linear-gradient(
    45deg,
    transparent 0 8px,
    color-mix(in srgb, var(--text-3) 6%, transparent) 8px 9px
  );
}
.jrn-bw-row.jrn-bw-empty .sym,
.jrn-bw-row.jrn-bw-empty .pnl,
.jrn-bw-row.jrn-bw-empty .meta { color: var(--text-3); font-weight: 500; }

/* ============================================================
   CSS-only tooltips (.ft-tip) — used on KPI labels and the
   Recent Trades table headers. The text comes from data-tip,
   the icon character (ⓘ) is in the markup.

   Pure CSS, no JS. Markup:
     <span class="ft-tip" data-tip="The tooltip text.">ⓘ</span>
     <span class="ft-tip ft-tip--top" …>ⓘ</span>   (force above)

   Default direction: below. The KPI strip and table headers
   live in the upper half of the dashboard where a below-tooltip
   never falls off the bottom of the viewport. Authors can
   add .ft-tip--top for rows near the page bottom (none today).
   ============================================================ */
.ft-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: -1px;
  margin-left: 4px;
  width: 14px; height: 14px;
  font-size: 11px;
  font-style: normal;
  font-weight: 400;
  color: var(--text-3);
  cursor: help;
  user-select: none;
}
.ft-tip:hover, .ft-tip:focus-visible {
  color: var(--text);
  outline: none;
}

/* Tooltip bubble — built with ::after so the icon glyph stays in markup. */
.ft-tip::after {
  content: attr(data-tip);
  position: absolute;
  z-index: 120;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  width: max-content;
  max-width: 260px;
  min-width: 180px;
  padding: 8px 10px;
  background: var(--card-2);
  color: var(--text-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: 0;
  text-align: left;
  white-space: normal;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease-out, transform 120ms ease-out;
}
/* Arrow pointing up at the icon. */
.ft-tip::before {
  content: '';
  position: absolute;
  z-index: 121;
  top: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  width: 0;
  height: 0;
  border: 6px solid transparent;
  border-bottom-color: var(--line);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease-out, transform 120ms ease-out;
}
.ft-tip:hover::after, .ft-tip:focus-visible::after,
.ft-tip:hover::before, .ft-tip:focus-visible::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Above-variant — flip the bubble to sit above the icon. */
.ft-tip--top::after {
  top: auto;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
}
.ft-tip--top::before {
  top: auto;
  bottom: calc(100% + 2px);
  transform: translateX(-50%) translateY(4px);
  border-bottom-color: transparent;
  border-top-color: var(--line);
}
.ft-tip--top:hover::after, .ft-tip--top:focus-visible::after,
.ft-tip--top:hover::before, .ft-tip--top:focus-visible::before {
  transform: translateX(-50%) translateY(0);
}

/* Edge-of-viewport guard for tooltips on rightmost KPI tile or table column.
   When the icon's parent is close to the right edge, the centred bubble
   would clip off-screen. We let the bubble anchor to the right edge of the
   icon instead (still centred on the arrow). */
.ft-tip--right::after { left: auto; right: -6px; transform: translateX(0) translateY(-4px); }
.ft-tip--right:hover::after, .ft-tip--right:focus-visible::after {
  transform: translateX(0) translateY(0);
}
.ft-tip--right::before { left: auto; right: 1px; transform: translateX(0) translateY(-4px); }
.ft-tip--right:hover::before, .ft-tip--right:focus-visible::before {
  transform: translateX(0) translateY(0);
}

/* Make sure the table cell that contains a tooltip allows overflow so the
   bubble can extend past the cell edge without being clipped. */
.tbl th, .tbl td { overflow: visible; }
.jrn-stat-row .stat { overflow: visible; }

/* ============================================================
   Recent Trades — fixed column widths so headers align with data
   ============================================================
   Without table-layout: fixed, the browser auto-distributes column
   widths from the WIDEST cell in each column. A header with a
   tooltip icon ("R ⓘ") is wider than its data cells ("—" / "+1.09R"),
   which pushes the column boundaries around inconsistently and
   leaves the header label and data cell visually misaligned.

   With table-layout: fixed + an explicit width per column, the
   browser respects the declared widths and the column boundaries
   are stable. min-width keeps the table readable on small screens —
   the wrapping .card-body has overflow-x: auto so it scrolls. */
.jrn-recent {
  table-layout: fixed;
  width: 100%;
  min-width: 1060px;
}
.jrn-recent th,
.jrn-recent td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Per-column widths. Sum: 100 %.
   Columns:  1 Symbol · 2 Date · 3 Side · 4 Strategy · 5 Rating ·
             6 Entry · 7 Exit · 8 R · 9 P&L % · 10 P&L USD · 11 F&G */
.jrn-recent th:nth-child(1),  .jrn-recent td:nth-child(1)  { width:  9%; }   /* Symbol */
.jrn-recent th:nth-child(2),  .jrn-recent td:nth-child(2)  { width:  7%; }   /* Date */
.jrn-recent th:nth-child(3),  .jrn-recent td:nth-child(3)  { width:  7%; }   /* Side */
.jrn-recent th:nth-child(4),  .jrn-recent td:nth-child(4)  { width: 10%; }   /* Strategy */
.jrn-recent th:nth-child(5),  .jrn-recent td:nth-child(5)  { width:  8%; }   /* Rating */
.jrn-recent th:nth-child(6),  .jrn-recent td:nth-child(6)  { width: 10%; }   /* Entry */
.jrn-recent th:nth-child(7),  .jrn-recent td:nth-child(7)  { width: 10%; }   /* Exit */
.jrn-recent th:nth-child(8),  .jrn-recent td:nth-child(8)  { width:  7%; }   /* R */
.jrn-recent th:nth-child(9),  .jrn-recent td:nth-child(9)  { width:  9%; }   /* P&L % */
.jrn-recent th:nth-child(10), .jrn-recent td:nth-child(10) { width:  9%; }   /* P&L USD */
.jrn-recent th:nth-child(11), .jrn-recent td:nth-child(11) { width: 14%; }   /* F&G */

/* The ⓘ tooltip icon must NOT contribute to the header's intrinsic width,
   or the column ends up wider than the .tbl th nth-child rule above would
   suggest. We already use display: inline-flex with a fixed 14×14 box on
   .ft-tip, but pin the metrics here defensively in case a future style
   widens it. */
.jrn-recent th .ft-tip {
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  vertical-align: middle;
}

/* ---------- Modal: "optional" chip on field labels ----------
   Used on the MAE / MFE fields in the Add-Trade modal so the user
   immediately sees these two price fields aren't required. */
.jrn-modal .fld-opt {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  color: var(--text-3);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  vertical-align: 1px;
}

/* ============================================================
   Notebook tab (Schritt 35) — premium "second brain" for the journal.
   Two-column layout on desktop (list / editor), stack on mobile so the
   list reads first and tapping an entry switches the visible view.
   ============================================================ */
.jrn-nb {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 16px;
  align-items: start;
}
.nb-list-col, .nb-editor-col {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.nb-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card-2);
}
.nb-list-head h3 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: 0.02em; }
.nb-list-head .muted { color: var(--text-3); font-weight: 500; margin-left: 6px; }
.nb-list { max-height: 70vh; overflow-y: auto; }

.nb-li {
  display: block;
  width: 100%;
  text-align: left;
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line-soft, var(--line));
  padding: 12px 16px;
  cursor: pointer;
  color: var(--text);
}
.nb-li:hover { background: var(--card-2); }
.nb-li.on   { background: color-mix(in srgb, var(--green) 12%, var(--card-2)); border-left: 3px solid var(--green); padding-left: 13px; }
.nb-li-title {
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nb-li-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 11px;
  color: var(--text-3);
  flex-wrap: wrap;
}
.nb-li-meta .nb-tag {
  background: var(--card-2);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10.5px;
}

/* Trade ↔ Notebook link (Schritt 38) */
.nb-trade-badge {
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid color-mix(in srgb, var(--green) 30%, transparent);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 700;
}
.jrn-note-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--green);
  text-decoration: none;
}
.jrn-note-link:hover { text-decoration: underline; }
.nb-empty {
  padding: 32px 16px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-3);
}

/* ---------- Editor column ---------- */
.nb-editor { display: flex; flex-direction: column; min-height: 70vh; }
.nb-editor-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card-2);
  flex-wrap: wrap;
}
.nb-title {
  flex: 1 1 240px;
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  padding: 4px 2px;
  outline: none;
}
.nb-title:focus { border-bottom-color: var(--green); }
.nb-editor-acts { display: flex; gap: 8px; align-items: center; }
.nb-tpl {
  font-size: 12px;
  padding: 6px 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
}

/* ---------- Tag chips ---------- */
.nb-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  align-items: center;
}
.nb-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px 3px 10px;
  background: color-mix(in srgb, var(--green) 14%, var(--card-2));
  color: var(--green);
  border: 1px solid color-mix(in srgb, var(--green) 35%, var(--line));
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.nb-chip-x {
  appearance: none;
  background: transparent;
  border: 0;
  color: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
  border-radius: 50%;
}
.nb-chip-x:hover { background: rgba(0, 0, 0, 0.18); }
.nb-tag-input {
  flex: 1 1 160px;
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text);
  font-size: 12.5px;
  padding: 4px 6px;
  outline: none;
  min-width: 120px;
}
.nb-tag-input::placeholder { color: var(--text-3); }

/* ---------- Textarea (markdown-ish editor) ---------- */
.nb-content {
  flex: 1;
  appearance: none;
  background: var(--card);
  border: 0;
  resize: vertical;
  padding: 16px;
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  outline: none;
  min-height: 360px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- Save-status footer ---------- */
.nb-status {
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--text-3);
  text-align: right;
}
.nb-status-ok  { color: var(--green); }
.nb-status-err { color: var(--red); }

/* ---------- Empty-editor placeholder ---------- */
.nb-empty-editor {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  text-align: center;
  color: var(--text-3);
  min-height: 70vh;
}
.nb-empty-icon { font-size: 48px; margin-bottom: 14px; opacity: 0.55; }
.nb-empty-title { font-size: 15px; font-weight: 600; color: var(--text-2); }
.nb-empty-sub   { font-size: 12.5px; margin-top: 4px; }

/* ---------- Mobile: stack list on top, editor below ----------
   When an entry is opened the editor scrolls into view. The list stays
   reachable above. */
@media (max-width: 760px) {
  .jrn-nb {
    grid-template-columns: 1fr;
  }
  .nb-list { max-height: 280px; }
  .nb-editor { min-height: 480px; }
  .nb-editor-head { flex-wrap: wrap; }
  .nb-title { flex: 1 1 100%; font-size: 16px; }
  .nb-editor-acts { width: 100%; justify-content: flex-end; }
}

/* ============================================================
   Wins vs Losses Report — symmetric two-column compare card.
   Left = winners (green accent), right = losers (red accent).
   ============================================================ */
.jrn-wl-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 760px) {
  .jrn-wl-grid { grid-template-columns: 1fr; }
}
.jrn-wl-col {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card-2);
  padding: 14px 16px 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.jrn-wl-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; letter-spacing: 0.2px;
}
.jrn-wl-head .dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}
.jrn-wl-rows {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.jrn-wl-row {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 9px 11px;
  display: flex; flex-direction: column; gap: 2px;
}
.jrn-wl-row .l {
  font-size: 11px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.jrn-wl-row .v {
  font-size: 15px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.jrn-wl-row .v.green { color: var(--green); }
.jrn-wl-row .v.red   { color: var(--red); }
.jrn-wl-row .sub {
  font-size: 10.5px; color: var(--text-3); margin-top: 1px;
}
.jrn-wl-empty {
  font-size: 12px; color: var(--text-3);
  padding: 14px 10px;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
}
.jrn-wl-chart {
  margin-top: 16px;
  padding: 16px 14px;
  background: var(--card-2);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  display: flex; flex-direction: column; gap: 14px;
}
.jrn-wlb-row {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  align-items: center;
  gap: 14px;
}
.jrn-wlb-label {
  font-size: 12px; font-weight: 600; color: var(--text-2);
  text-align: right;
}
.jrn-wlb-track {
  height: 22px; background: var(--card);
  border: 1px solid var(--line-soft); border-radius: 6px;
  overflow: hidden;
}
.jrn-wlb-fill {
  height: 100%; border-radius: 5px 0 0 5px;
  transition: width 0.25s ease-out;
  min-width: 2px;
}
.jrn-wlb-fill--win  { background: var(--green); }
.jrn-wlb-fill--loss { background: var(--red); }
.jrn-wlb-value {
  font-size: 12.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 70px; text-align: left;
}
.jrn-wlb-value.green { color: var(--green); }
.jrn-wlb-value.red   { color: var(--red); }
@media (max-width: 560px) {
  .jrn-wlb-row { grid-template-columns: 64px 1fr auto; gap: 8px; }
  .jrn-wlb-value { min-width: 56px; font-size: 11.5px; }
}
.jrn-wl-insight {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--card-2);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.5;
}
.jrn-wl-insight b { color: var(--text); }

/* Cross-promo tiles (Analytics tab footer) — two internal tool cards, no
   affiliate disclaimer, same card weight as surrounding analytics blocks. */
.jrn-cross {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 720px) {
  .jrn-cross { grid-template-columns: 1fr; }
}
.jrn-cross-card {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.12s, transform 0.06s, box-shadow 0.12s;
}
.jrn-cross-card:hover {
  border-color: var(--green);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px -10px rgba(0,0,0,0.45);
}
.jrn-cross-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.jrn-cross-title { font-size: 15px; font-weight: 700; }
.jrn-cross-sub {
  font-size: 10.5px; color: var(--text-3);
  letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600;
}
.jrn-cross-pitch { font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.jrn-cross-cta {
  margin-top: auto;
  font-size: 12.5px; font-weight: 700; color: var(--green);
}

/* ============================================================
   Mobile fixes — Bugs 6/7/8/9 (page-scoped to body[data-page="journal"]
   so layout changes don't leak into other tools).
   ============================================================ */
@media (max-width: 720px) {
  /* Bug 6 — header: actions wrap below the title, tabs on row 1,
     Add Trade full-width on row 2 so it doesn't get cut off. */
  body[data-page="journal"] .jrn-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 10px;
  }
  body[data-page="journal"] .jrn-tabs {
    display: flex;
    width: 100%;
    justify-content: space-between;
  }
  body[data-page="journal"] .jrn-tab { flex: 1 1 0; justify-content: center; padding: 8px 10px; }
  body[data-page="journal"] #jrn-add { width: 100%; justify-content: center; }

  /* Bug 7 — calendar: enable horizontal scroll, ensure each weekday
     cell has a minimum width so SAT/SUN don't get clipped. The card
     keeps its 16px padding. */
  body[data-page="journal"] .jrn-cal { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  body[data-page="journal"] .jrn-cal-wkhdr,
  body[data-page="journal"] .jrn-cal-grid {
    min-width: 560px;     /* ~80px per column × 7 columns — keeps SAT/SUN readable */
  }
  /* Reduce header right column emphasis a touch so the title nav row
     has room to breathe. */
  body[data-page="journal"] .jrn-cal-head { flex-wrap: wrap; gap: 8px; }

  /* Bug 8 — Recent Trades card-head: title on its own row, chips + CSV
     wrap below. Same rule applies to any card-head inside the journal
     page that mixes a title with a chip-row. */
  body[data-page="journal"] .card-head {
    flex-wrap: wrap;
    align-items: flex-start;
    row-gap: 10px;
  }
  body[data-page="journal"] .card-head h3 { flex: 1 1 100%; }
  body[data-page="journal"] .card-head .right {
    margin-left: 0;
    width: 100%;
    flex-wrap: wrap;
    justify-content: space-between;
  }
  body[data-page="journal"] .card-head .chips { flex: 1 1 auto; flex-wrap: wrap; }
  body[data-page="journal"] #jrn-export { flex: 0 0 auto; }
}

/* Bug 9 — Trade-detail modal: tighter padding + 2×2 KPI grid on mobile.
   The KPI grid is set inline via grid-template-columns:repeat(4,1fr), so
   we override with !important. Modal also lets head buttons wrap so
   Delete never gets clipped. */
@media (max-width: 640px) {
  .jrn-modal-backdrop { padding: 10px; }
  .jrn-modal-head {
    padding: 14px 16px 12px;
    flex-wrap: wrap;
    row-gap: 8px;
  }
  .jrn-modal-body { padding: 16px; }
  .jrn-modal-foot { padding: 12px 16px; }
  /* Inline grid-template-columns:repeat(4,1fr) → 2×2 on phones. */
  .jrn-modal .jrn-autocalc[style*="repeat(4"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  /* Cells get a touch more vertical breathing room when stacked. */
  .jrn-modal .jrn-autocalc .v { font-size: 16px; }
}

/* ============================================================
   Trade Rating (Schritt 36) — 5-star widget in the modal +
   compact read-only display in the Recent Trades table.
   ============================================================ */
.jrn-rating {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
}
.jrn-star {
  border: 0; background: transparent;
  cursor: pointer; padding: 4px 4px;
  font-size: 22px; line-height: 1;
  color: var(--text-4);
  transition: color 0.1s, transform 0.08s;
}
.jrn-star:hover { transform: scale(1.12); color: color-mix(in srgb, var(--yellow) 60%, var(--text-3)); }
.jrn-star.on   { color: var(--yellow); }
.jrn-star:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 4px; }
.jrn-rating-label {
  margin-left: 8px;
  font-size: 11.5px;
}

/* Read-only row stars: yellow filled + grey hollow, monospace tight */
.jrn-row-rating {
  font-size: 13px; line-height: 1;
  color: var(--yellow);
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}
.jrn-row-rating-off { color: var(--text-4); }

/* ============================================================
   Recent-Trades filter toolbar — grouped chip rows + tag dropdown
   + clear button. Each .jrn-filter-group sits on its own visual
   pill so the user can see which kind of filter they're toggling.
   ============================================================ */
.jrn-filters { align-items: center; }
.jrn-filter-group {
  display: inline-flex; gap: 0;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
}
.jrn-filter-group .chip {
  margin: 0;
  border-radius: 6px;
  background: transparent;
  border: 0;
}
.jrn-filter-group .chip.on { background: var(--card-hi); color: var(--text); }
/* Star chips: yellow-when-active so they read at a glance */
.jrn-filter-star {
  font-size: 10.5px; letter-spacing: 0.5px;
  color: var(--text-4);
  padding: 4px 7px;
}
.jrn-filter-star.on { color: var(--yellow); background: color-mix(in srgb, var(--yellow) 12%, var(--card-2)); }
/* Strategy dropdown — native <select> restyled so it stops looking like a
   Windows-95 control inside the dark / light theme. The arrow is a stroked
   chevron inline-SVG, encoded for both data-URI use AND theme-aware color
   via currentColor in an oklch-friendly form. Two copies (dark + light)
   because data: URIs can't read CSS vars. */
.jrn-filter-tag,
select.jrn-filter-tag {
  height: 32px;
  padding: 0 28px 0 10px;          /* extra right padding for the chevron */
  font-size: 13px;
  font-family: inherit;
  line-height: 1;
  color: var(--text);
  background-color: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  min-width: 130px;
  /* Native chrome off — restored via background-image chevron below. */
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a8294' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px 14px;
  transition: border-color 0.12s ease, background-color 0.12s ease, box-shadow 0.12s ease;
}
select.jrn-filter-tag:hover  { border-color: var(--green); }
select.jrn-filter-tag:focus  { border-color: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 18%, transparent); outline: none; }
select.jrn-filter-tag:focus-visible { outline: none; }
select.jrn-filter-tag:disabled { opacity: 0.55; cursor: not-allowed; }
/* The chevron PNG-encodes one stroke colour — invert it in light mode so it
   still reads against the lighter background. */
[data-theme="light"] select.jrn-filter-tag {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a8294' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
}
/* The <option> elements inherit the system menu on most browsers; only Chromium
   + Firefox honour these inside a popped-up listbox, but it's worth doing. */
select.jrn-filter-tag option {
  background: var(--card-2);
  color: var(--text);
}

/* Clear-Filters button — always in the DOM so its width doesn't shift the
   filter row when it (dis)appears. We just toggle visibility from JS via
   the .is-visible modifier. */
.jrn-filter-clear {
  visibility: hidden;
  color: var(--text-3);
  border-color: color-mix(in srgb, var(--red) 30%, var(--line));
}
.jrn-filter-clear.is-visible { visibility: visible; }
.jrn-filter-clear:hover { color: var(--red); border-color: var(--red); }

@media (max-width: 720px) {
  .jrn-filter-tag { width: 100%; }
  .jrn-filter-group { flex-wrap: wrap; }
}

/* ============================================================
   Skeleton loader (Schritt 39)
   First paint of the Trading Journal before journal.js runs.
   Replaced atomically when root.innerHTML is overwritten by the
   first render. Pulse + subtle shimmer hint at "loading", not
   "broken". `prefers-reduced-motion` disables the animations
   so users with vestibular sensitivities just see static plates.
   ============================================================ */
.jrn-skel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px 0;
}
.jrn-skel-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.jrn-skel-box {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  animation: jrnSkelPulse 1.5s ease-in-out infinite;
}
.jrn-skel-stat  { height: 92px; }
.jrn-skel-chart { height: 320px; }
.jrn-skel-table { height: 240px; }

/* Subtle shimmer — diagonal gradient sweep across each box. Slightly
   slower than the pulse so the two effects feel layered rather than
   competing. */
.jrn-skel-box::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    transparent 35%,
    color-mix(in srgb, var(--text) 6%, transparent) 50%,
    transparent 65%
  );
  transform: translateX(-100%);
  animation: jrnSkelShimmer 2.4s ease-in-out infinite;
}

@keyframes jrnSkelPulse {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}
@keyframes jrnSkelShimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Stagger the shimmer across the 4 stat tiles so they don't all
   pulse in lockstep. Cheap delay-based animation polish. */
.jrn-skel-stats .jrn-skel-stat:nth-child(2)::after { animation-delay: 0.15s; }
.jrn-skel-stats .jrn-skel-stat:nth-child(3)::after { animation-delay: 0.30s; }
.jrn-skel-stats .jrn-skel-stat:nth-child(4)::after { animation-delay: 0.45s; }

/* Mobile: collapse the KPI strip to a 2×2 grid so each box is
   still readable rather than squeezed into 25% slivers. */
@media (max-width: 720px) {
  .jrn-skel-stats { grid-template-columns: repeat(2, 1fr); }
  .jrn-skel-stat  { height: 84px; }
  .jrn-skel-chart { height: 220px; }
  .jrn-skel-table { height: 200px; }
}

/* Vestibular-safety: kill the pulse + shimmer for users who opt out. */
@media (prefers-reduced-motion: reduce) {
  .jrn-skel-box,
  .jrn-skel-box::after { animation: none; }
  .jrn-skel-box { opacity: 0.7; }
}

/* Trade Sharing — Schritt 36. The per-row Share icon in the Recent Trades
   table. Kept low-contrast by default (so it doesn't compete with P&L
   colours) and lifts on hover. The header cell + body cell both wear
   .jrn-row-actions so the column stays a fixed 36px regardless of row. */
.jrn-recent th.jrn-row-actions,
.jrn-recent td.jrn-row-actions { width: 36px; text-align: center; padding-left: 0; padding-right: 0; }
.jrn-share-icon {
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  width: 26px; height: 26px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1; color: var(--text-3); cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.jrn-share-icon:hover {
  background: var(--card-2); border-color: var(--line); color: var(--green);
}
.jrn-share-icon:disabled { opacity: 0.55; cursor: wait; }

/* Multi-Portfolio (Schritt 37) — selector pill in the journal header +
   dropdown menu + Manage modal. Lives under .jrn-* namespace next to the
   tabs and Add Trade button. */
.jrn-pf-bar { position: relative; display: inline-block; }
.jrn-pf-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 8px;
  background: var(--card-2); border: 1px solid var(--line);
  color: var(--text-1); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.jrn-pf-btn:hover { border-color: color-mix(in srgb, var(--green) 35%, var(--line)); }
.jrn-pf-btn[aria-expanded="true"] { border-color: var(--green); }
.jrn-pf-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 999px;
  box-shadow: 0 0 0 1px color-mix(in srgb, currentColor 14%, transparent);
  flex-shrink: 0;
}
.jrn-pf-dot.lg { width: 14px; height: 14px; }
.jrn-pf-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jrn-pf-caret { font-size: 10px; color: var(--text-3); }
.jrn-pf-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30;
  min-width: 240px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  padding: 6px;
}
.jrn-pf-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: 6px;
  background: transparent; border: 0; color: var(--text-1);
  font-size: 13px; font-weight: 500; text-align: left; cursor: pointer;
}
.jrn-pf-item:hover { background: var(--card-2); }
.jrn-pf-item.on { color: var(--green); font-weight: 600; }
.jrn-pf-item.manage { color: var(--text-2); font-size: 12.5px; }
.jrn-pf-sep { height: 1px; background: var(--line); margin: 6px 4px; }

/* Manage Portfolios modal — list view + inline create/edit form. Uses
   the existing .jrn-modal* shell so it inherits the responsive sizing. */
.jrn-pf-list { display: flex; flex-direction: column; gap: 8px; }
.jrn-pf-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
}
.jrn-pf-row.editing { display: block; padding: 14px; background: var(--card-2); }
.jrn-pf-meta { flex: 1 1 auto; min-width: 0; }
.jrn-pf-rname { font-weight: 600; font-size: 14px; }
.jrn-pf-rdesc { color: var(--text-2); font-size: 12.5px; margin-top: 2px; }
.jrn-pf-rcount { font-size: 11.5px; margin-top: 3px; }
.jrn-pf-form .fld { margin-bottom: 10px; }
.jrn-pf-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.jrn-pf-swatch {
  width: 26px; height: 26px; border-radius: 999px; cursor: pointer;
  border: 2px solid transparent; padding: 0;
  transition: transform 0.12s, border-color 0.12s;
}
.jrn-pf-swatch:hover { transform: scale(1.1); }
.jrn-pf-swatch.on { border-color: var(--text-1); transform: scale(1.1); }

/* Trade Checklist (Schritt 39) — pre-trade checkboxes in the Add Trade
   modal + the warning banner + the Manage-modal editor panel. */
.jrn-chk-list { display: flex; flex-direction: column; gap: 8px; }
.jrn-chk-item {
  display: flex; align-items: center; gap: 9px;
  font-size: 13px; color: var(--text-1); cursor: pointer;
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card-2);
}
.jrn-chk-item input { width: 16px; height: 16px; flex-shrink: 0; cursor: pointer; accent-color: var(--green); }
.jrn-chk-warn {
  margin-top: 10px; padding: 9px 12px; border-radius: 8px;
  font-size: 12px; font-weight: 600;
  background: color-mix(in srgb, var(--yellow) 14%, transparent);
  color: var(--yellow);
  border: 1px solid color-mix(in srgb, var(--yellow) 35%, transparent);
}
/* Manage-modal per-portfolio checklist editor panel */
.jrn-chk-panel {
  margin: 0 0 8px; padding: 12px 14px;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 10px;
}
.jrn-chk-panel-head {
  font-size: 11.5px; font-weight: 700; color: var(--text-3);
  letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 10px;
}
.jrn-chk-items { display: flex; flex-direction: column; gap: 6px; }
.jrn-chk-edit-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--card);
}
.jrn-chk-edit-text { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Compact buttons for the checklist editor rows (journal doesn't load admin.css). */
.jrn-chk-panel .btn-xs { padding: 5px 9px; font-size: 11.5px; border-radius: 6px; }

/* Screenshot monthly-quota counter under the upload field (Schritt 40). */
.jrn-shot-quota { font-size: 11.5px; margin-top: 6px; }
.jrn-shot-quota.over { color: var(--red); font-weight: 600; }
