:root {
  --bg: #0b0d11;
  --panel: #12151c;
  --border: #232833;
  --text: #e6e8ee;
  --muted: #8b93a7;
  --accent: #5b8cff;
  --row-hover: #171b24;
  --expand: #1a2030;
  --danger: #ef5350;
  --ok: #26a69a;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 8px 48px;
}

header.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
}

header.app-header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

header.app-header .meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.nav {
  margin-left: auto;
}
.nav a {
  margin-right: 14px;
  font-size: 0.9rem;
}

/* Quick links from inbound email (Zoom, sheets, …) */
.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin: 0 0 16px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  align-items: center;
}

.quick-links .ql-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.quick-links .ql-label {
  color: var(--muted);
  font-size: 0.85rem;
  margin-right: 2px;
}

.quick-links .ql-chip {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--expand);
  color: var(--text);
}

.quick-links .ql-chip:hover {
  text-decoration: none;
  border-color: var(--accent);
  color: var(--accent);
}

.quick-links .ql-zoom {
  border-color: #2d8cff55;
}

.quick-links .ql-sheet {
  border-color: #26a69a55;
}

.quick-links .ql-csv {
  border-color: #8b93a755;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

/*
 * Horizontal scroll is for the trade columns only.
 * Chart rows pin to the scrollport width (set in JS) so the chart
 * is not as wide as the full table and does not require scrolling.
 */
.table-scroll {
  overflow-x: auto;
  overflow-y: hidden;
}

table.trades tr.is-offpage {
  display: none !important;
}

.table-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin: 10px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.table-pager-status {
  font-variant-numeric: tabular-nums;
}

.table-pager-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: #151922;
  color: var(--text);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.table-pager-btn:hover:not(:disabled) {
  border-color: #3a4254;
}

.table-pager-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

table.trades {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.trades th,
table.trades td {
  padding: 5px 2px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.trades th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #0e1118;
  position: sticky;
  top: 0;
  z-index: 1;
}

table.trades tbody tr[data-trade-id] {
  cursor: pointer;
}

table.trades tbody tr[data-trade-id]:hover {
  background: var(--row-hover);
}

table.trades tbody tr.is-expanded {
  background: var(--expand);
}

table.trades tbody tr[data-trade-id].is-exited {
  opacity: 0.4;
}

table.trades tbody tr[data-trade-id].is-exited:hover,
table.trades tbody tr[data-trade-id].is-exited.is-expanded {
  opacity: 0.7;
}

/* Guest preview: nav/filters gone; blurred rows are decoy data, not a hide overlay */
body.is-guest [data-nav-toggle],
body.is-guest [data-rail-toggle],
body.is-guest .admin-nav,
body.is-guest .nav-backdrop,
body.is-guest .admin-rail,
body.is-guest .filter-panel {
  display: none !important;
}

body.is-guest .admin-app.nav-open .admin-nav,
body.is-guest .admin-app.rail-open .admin-rail {
  flex-basis: 0 !important;
  width: 0 !important;
}

body.is-guest table.trades tr.is-guest-hidden {
  filter: blur(9px);
  opacity: 0.28;
  pointer-events: none;
  user-select: none;
}

body.is-guest table.trades tr.is-guest-fade-in {
  filter: blur(3.2px);
  opacity: 0.62;
  pointer-events: none;
  user-select: none;
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0.15), #000 80%);
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.15), #000 80%);
}

body.is-guest table.trades tr.is-guest-fade-out {
  filter: blur(3.2px);
  opacity: 0.5;
  pointer-events: none;
  user-select: none;
  -webkit-mask-image: linear-gradient(to bottom, #000 20%, rgba(0,0,0,0.12));
  mask-image: linear-gradient(to bottom, #000 20%, rgba(0,0,0,0.12));
}

body.is-guest table.trades tr.is-guest-clear {
  pointer-events: none;
}

table.trades td.num { font-variant-numeric: tabular-nums; }
table.trades th.num { text-align: right; }
table.trades td.num { text-align: right; }
table.trades td.ticker { font-weight: 600; text-transform: uppercase; }

/*
 * Compact stacked idea rows (table.trades.is-stacked).
 * Remove the class / set $ideaStacked false / ?flat=1 to restore the wide table.
 */
table.trades.is-stacked {
  font-size: 0.75rem;
  line-height: 1.2;
  color: rgba(235, 235, 245, 0.78);
}

table.trades.is-stacked th,
table.trades.is-stacked td,
table.trades.is-stacked th.num,
table.trades.is-stacked td.num {
  padding-top: 4px;
  padding-bottom: 4px;
  vertical-align: top;
  text-align: center;
}

table.trades.is-stacked td.col-date,
table.trades.is-stacked td.col-dir {
  vertical-align: middle;
  text-align: center;
}

table.trades.is-stacked .cell-stack.is-dir {
  align-items: center;
}

table.trades.is-stacked .idea-date-cal {
  width: 1.95rem;
  border-radius: 4px;
}

table.trades.is-stacked .idea-date-month {
  font-size: 0.52rem;
  padding: 2px 0 0;
}

table.trades.is-stacked .idea-date-day {
  font-size: 0.78rem;
  padding: 2px 0 3px;
}

table.trades.is-stacked th {
  font-size: 0.68rem;
}

table.trades.is-stacked th[colspan="2"] {
  text-align: center;
}

.cell-stack {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  line-height: 1.2;
  min-width: 0;
}

table.trades.is-stacked .cell-stack,
table.trades.is-stacked .cell-stack.is-ticker,
table.trades.is-stacked td.num .cell-stack,
table.trades.is-stacked th.num .cell-stack {
  align-items: center;
  width: 100%;
}

.ticker-line {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ticker-text {
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  text-transform: uppercase;
}

table.trades.is-stacked .ticker-text,
table.trades.is-stacked .cell-top {
  color: rgba(235, 235, 245, 0.82);
}

table.trades.is-stacked .cell-bot {
  color: rgba(235, 235, 245, 0.52);
}

td.num .cell-stack,
th.num .cell-stack {
  align-items: flex-end;
  width: 100%;
}

.cell-top {
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
}

.cell-bot {
  font-size: 0.65rem;
  font-weight: 500;
  line-height: 1.15;
}

th .cell-top,
table.trades.is-stacked th .cell-top {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

th .cell-bot,
table.trades.is-stacked th .cell-bot {
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  opacity: 0.8;
}

/* Type / user / fill as small accents, not ticker-sized */
table.trades.is-stacked .idea-type {
  gap: 2px;
}

table.trades.is-stacked .idea-type .dir-glyph {
  width: 0.95rem;
  height: 0.95rem;
  font-size: 0.58rem;
}

table.trades.is-stacked .market-meta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

table.trades.is-stacked .ticker-meta,
table.trades.is-stacked .fills-line,
table.trades.is-stacked .lvl-line {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

table.trades.is-stacked .lvl-tag {
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

table.trades.is-stacked .lvl-px {
  font-variant-numeric: tabular-nums;
}

table.trades.is-stacked .user-mark-row {
  height: auto;
  padding: 0;
  background: transparent;
  gap: 2px;
}

table.trades.is-stacked .user-mark,
table.trades.is-stacked .user-mark-row .user-mark {
  width: 0.95rem;
  min-width: 0.95rem;
  height: 0.95rem;
  font-size: 0.55rem;
}

table.trades.is-stacked td.col-market .cell-bot {
  font-weight: 500;
}

table.trades.is-stacked th.col-alerts,
table.trades.is-stacked td.col-alerts {
  width: 2rem;
  text-align: center;
  padding-left: 2px;
  padding-right: 2px;
}

.ticker-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ticker-cell .btn-add-action {
  width: 1.35rem;
  height: 1.35rem;
  font-size: 1rem;
}
table.trades td.muted { color: var(--muted); }

table.trades td.col-open {
  font-weight: 600;
  min-width: 3.5rem;
}

table.trades td.col-pnl {
  font-weight: 600;
  min-width: 5.5rem;
  white-space: nowrap;
}

table.trades.is-positions th.ticker,
table.trades.is-positions td.ticker {
  width: 1%;
  white-space: nowrap;
  padding-right: 2px;
}

table.trades.is-positions th.col-type,
table.trades.is-positions td.col-type {
  width: 1.6rem;
  max-width: 2.1rem;
  padding-left: 2px;
  padding-right: 8px;
}

table.trades.is-positions th.col-pnl,
table.trades.is-positions td.col-pnl,
table.trades.is-positions th.col-open,
table.trades.is-positions td.col-open,
table.trades.is-positions th.col-cost,
table.trades.is-positions td.col-cost {
  min-width: 0;
  width: 1%;
  padding-left: 6px;
  padding-right: 6px;
  white-space: nowrap;
}

table.trades.is-positions th.col-date,
table.trades.is-positions td.col-date {
  width: 1.7rem;
  padding-left: 2px;
  padding-right: 2px;
}

table.trades.is-positions td.col-open.cell-bot,
table.trades.is-positions td.col-pnl.cell-bot,
table.trades.is-positions td.col-cost.cell-bot {
  font-size: 0.65rem;
  font-weight: 500;
}
table.trades td.pnl-up { color: #26a69a; }
table.trades td.pnl-down { color: #ef5350; }
table.trades td.pnl-flat { color: var(--muted); }
table.trades th.col-add,
table.trades td.col-add,
table.trades th.col-del,
table.trades td.col-del {
  width: 1.55rem;
  padding-left: 1px;
  padding-right: 1px;
  text-align: center;
  white-space: nowrap;
}

#actions-table td.col-action {
  white-space: nowrap;
}

#actions-table td.col-action .action-del-form {
  margin-left: 4px;
  vertical-align: middle;
}

.action-del-form {
  display: inline-flex;
  margin: 0;
}

.action-del-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.55rem;
  height: 1.55rem;
  padding: 0;
  border-radius: 6px;
  border: 1px solid rgba(239, 83, 80, 0.35);
  background: transparent;
  color: #ef5350;
  cursor: pointer;
  line-height: 1;
}

.action-del-btn:hover,
.action-del-btn:focus-visible {
  background: rgba(239, 83, 80, 0.14);
  border-color: #ef5350;
  color: #ff8a80;
}

.btn-add-action {
  appearance: none;
  width: 1.65rem;
  height: 1.65rem;
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #1a2030;
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}
.btn-add-action:hover {
  background: #243049;
  border-color: #3d5a9a;
  color: #fff;
}
.btn-add-action[aria-expanded="true"] {
  background: #2a3f6e;
  border-color: #3d5a9a;
  color: #fff;
}

.badge {
  display: inline-block;
  min-width: 1.6em;
  padding: 2px 7px;
  border-radius: 999px;
  background: #243049;
  color: var(--text);
  font-size: 0.8rem;
  text-align: center;
}

table.trades th.col-type,
table.trades td.col-type,
table.trades th.col-date,
table.trades td.col-date {
  text-align: center;
  width: 1.7rem;
  padding-left: 1px;
  padding-right: 1px;
  vertical-align: middle;
}

table.trades th.col-level,
table.trades td.col-level {
  white-space: nowrap;
  padding-left: 4px;
  padding-right: 4px;
}

table.trades th.col-shares,
table.trades td.col-shares {
  white-space: nowrap;
}

.user-mark-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  flex-wrap: nowrap;
  white-space: nowrap;
  height: 1.5rem;
  padding: 0 0.2rem;
  border-radius: 999px;
  background: #5b8cff22;
}

.user-mark {
  color: var(--accent);
  background: #5b8cff22;
  font-size: 0.78rem;
}

.user-mark-row .user-mark {
  width: auto;
  min-width: 0.7rem;
  height: auto;
  background: transparent;
  font-size: 0.78rem;
}

table.trades th.col-user,
table.trades td.col-user,
table.trades th.col-fill,
table.trades td.col-fill {
  text-align: center;
  padding-left: 1px;
  padding-right: 1px;
  vertical-align: middle;
  white-space: nowrap;
}

table.trades th.col-user,
table.trades td.col-user {
  width: 1.35rem;
}

table.trades th.col-fill,
table.trades td.col-fill {
  width: auto;
  min-width: 1.35rem;
}

.idea-type {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  line-height: 1;
}

.idea-type-icon {
  display: block;
  flex: 0 0 auto;
}

.idea-type.is-long {
  color: #43a047;
}

.idea-type.is-short {
  color: #ef5350;
}

.idea-type.is-unknown {
  color: #ffa726;
}

.idea-date {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  vertical-align: middle;
  line-height: 0;
  position: relative;
  top: 1px;
}

.idea-date-cal {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  width: 1.55rem;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid #3a4252;
  line-height: 1;
}

.idea-date-month {
  background: #c62828;
  color: #fff;
  font-size: 0.42rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 0 0;
  text-align: center;
}

.idea-date-day {
  background: #1b2130;
  color: var(--text);
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 0 2px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.when-icons {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  vertical-align: middle;
  line-height: 0;
}

.idea-time {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  vertical-align: middle;
  line-height: 0;
  position: relative;
  top: 1px;
}

.idea-time-clock {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  background:
    linear-gradient(var(--accent), var(--accent)) 50% 2px / 1.5px 2.5px no-repeat,
    linear-gradient(var(--accent), var(--accent)) 50% calc(100% - 2px) / 1.5px 2.5px no-repeat,
    linear-gradient(var(--accent), var(--accent)) calc(100% - 2px) 50% / 2.5px 1.5px no-repeat,
    linear-gradient(var(--accent), var(--accent)) 2px 50% / 2.5px 1.5px no-repeat,
    var(--panel);
  box-shadow: inset 0 0 0 1px var(--bg);
}

.idea-time-clock::before {
  content: "";
  position: absolute;
  top: -3px;
  left: 50%;
  width: 5px;
  height: 3px;
  margin-left: -2.5px;
  background: var(--accent);
  border-radius: 1px 1px 0 0;
}

.idea-time.is-wide .idea-time-clock {
  width: 2.2rem;
  border-radius: 45%;
}

.idea-time-face {
  position: relative;
  z-index: 1;
  color: var(--accent);
  font-size: 0.5rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.idea-time.is-wide .idea-time-face {
  font-size: 0.44rem;
}

table.trades th.col-when,
table.trades td.col-when {
  text-align: center;
  white-space: nowrap;
  padding-left: 1px;
  padding-right: 1px;
  vertical-align: middle;
}

table.trades th.col-alerts,
table.trades td.col-alerts {
  width: 1.7rem;
  text-align: center;
  padding-left: 1px;
  padding-right: 1px;
  white-space: nowrap;
}

table.trades th.col-type,
table.trades th.col-date,
table.trades th.col-user,
table.trades th.col-fill,
table.trades th.col-when,
table.trades th.col-alerts,
table.trades th.col-del,
table.trades th.col-add {
  letter-spacing: 0;
  font-size: 0.65rem;
}

/* Open / Closed / All (and other top-bar status filters) */
.header-filter {
  display: inline-flex;
  align-items: center;
}

.header-filter-select {
  appearance: none;
  -webkit-appearance: none;
  color: #fff;
  border: 1px solid #3d5a9a;
  border-radius: 999px;
  padding: 3px 22px 3px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
  cursor: pointer;
  background-color: #2a3f6e;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%23e6e8ee' d='M1.2 1.4 6 6.2 10.8 1.4'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 10px 6px;
}

.header-filter-select:hover,
.header-filter-select:focus {
  border-color: var(--accent);
  outline: none;
}

.action-form-row { display: none; }
.action-form-row.is-open { display: table-row; }

.action-form-row > td {
  padding: 0;
  border-bottom: 1px solid var(--border);
  background: #0e1219;
  /* do not use max-width:0 here — it can collapse the form cell */
}

.action-add-form {
  position: sticky;
  left: 0;
  width: var(--chart-width, min(100vw - 16px, 1184px));
  max-width: 100%;
  box-sizing: border-box;
  padding: 12px 14px 14px;
}

.action-form-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
  margin-bottom: 10px;
  font-size: 0.9rem;
}
.action-form-head .form-id {
  font-size: 0.75rem;
  font-family: ui-monospace, monospace;
  opacity: 0.7;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 16rem;
}

.action-form-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: flex-end;
}

.action-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--muted);
  min-width: 7rem;
}
.action-form-grid label.grow {
  flex: 1 1 12rem;
  min-width: 10rem;
}
.action-form-grid label span .muted {
  font-weight: 400;
}

.action-form-grid select,
.action-form-grid input[type="number"],
.action-form-grid input[type="text"],
.action-form-grid input[type="datetime-local"] {
  appearance: none;
  background: #151922;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 7px 10px;
  font-size: 0.9rem;
  min-height: 2.15rem;
}
.action-form-grid input[type="datetime-local"] {
  min-width: 11.5rem;
  color-scheme: dark;
}
.action-form-grid select:focus,
.action-form-grid input:focus {
  outline: none;
  border-color: #3d5a9a;
}

.action-form-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-primary {
  appearance: none;
  border: 1px solid #3d5a9a;
  background: #2a3f6e;
  color: #fff;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 2.15rem;
}
.btn-primary:hover { background: #34508a; }
.btn-primary:disabled { opacity: 0.55; cursor: wait; }

.btn-ghost {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  min-height: 2.15rem;
}
.btn-ghost:hover { color: var(--text); border-color: #3a4254; }

.action-form-status {
  margin-top: 8px;
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--muted);
}
.action-form-status.is-error { color: var(--danger); }
.action-form-status.is-ok { color: var(--ok); }

.chart-panel-row { display: none; }
.chart-panel-row.is-open { display: table-row; }

.chart-panel-row > td {
  padding: 0;
  border-bottom: 1px solid var(--border);
  background: #0c0f15;
  /* Prevent the wide table from forcing the chart shell wider than the scrollport */
  max-width: 0;
}

.chart-panel {
  padding: 12px 14px 16px;
  box-sizing: border-box;
  /* left edge sticks to the visible scrollport while table columns scroll */
  position: sticky;
  left: 0;
  /* --chart-width is set in JS to .table-scroll.clientWidth */
  width: var(--chart-width, 100%);
  max-width: var(--chart-width, 100%);
  /* Keep width locked; allow Apex annotation labels to paint at the edge */
  overflow: visible;
}

.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px 14px;
  margin-bottom: 10px;
}

.chart-title-block {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.chart-toolbar .title {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  font-weight: 600;
  padding-top: 2px;
  flex: 0 0 auto;
  line-height: 1.2;
}

.chart-title-block .btn-add-action {
  flex: 0 0 auto;
}

.chart-title-broker {
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

/* Levels / note / key — sits on the right with the timeframe */
.chart-trade-meta {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px 6px;
  flex: 0 0 auto;
  min-width: 0;
  padding-top: 2px;
}

.chart-meta-item {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  font-size: 0.78rem;
  line-height: 1.25;
  white-space: nowrap;
}

.chart-meta-label {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chart-meta-value {
  color: var(--text);
  font-weight: 500;
}

.chart-meta-value.num {
  font-variant-numeric: tabular-nums;
}

/* Owner over broker — no labels */
.chart-meta-stack {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 1px;
  line-height: 1.2;
  font-size: 0.78rem;
  font-weight: 500;
  min-width: 0;
}

.chart-meta-stack-line {
  white-space: nowrap;
}

.chart-meta-stack-line.muted {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.72rem;
}

/* Notebook icon + popover for long trade notes */
.chart-note-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 2px;
}

.chart-note-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.55rem;
  height: 1.55rem;
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #151922;
  color: var(--muted);
  cursor: pointer;
}

.chart-note-btn:hover,
.chart-note-btn:focus-visible,
.chart-note-wrap.is-open .chart-note-btn {
  color: var(--accent);
  border-color: #3d5a9a;
  background: #1a2438;
  outline: none;
}

.chart-note-icon {
  display: block;
}

.chart-note-pop {
  display: none;
  position: absolute;
  right: 0;
  left: auto;
  top: calc(100% + 6px);
  z-index: 20;
  min-width: 12rem;
  max-width: min(22rem, 70vw);
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(18, 21, 28, 0.97);
  border: 1px solid #2a3140;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.4;
  white-space: normal;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
}

.chart-note-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 16rem;
  overflow-y: auto;
}

.chart-note-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chart-note-date {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.03em;
}

.chart-note-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.chart-note-wrap:hover .chart-note-pop,
.chart-note-wrap:focus-within .chart-note-pop,
.chart-note-wrap.is-open .chart-note-pop {
  display: block;
}

/* Lightbulb icon + popover (entry / stop / pts / exit with chart colors) */
.chart-levels-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 2px;
}

.chart-levels-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.55rem;
  height: 1.55rem;
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #151922;
  color: var(--muted);
  cursor: pointer;
}

.chart-levels-btn:hover,
.chart-levels-btn:focus-visible,
.chart-levels-wrap.is-open .chart-levels-btn {
  color: #ffd54f;
  border-color: #6a5a20;
  background: #242018;
  outline: none;
}

.chart-levels-icon {
  display: block;
}

.chart-levels-pop {
  display: none;
  position: absolute;
  right: 0;
  left: auto;
  top: calc(100% + 6px);
  z-index: 25;
  min-width: 11.5rem;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(18, 21, 28, 0.97);
  border: 1px solid #2a3140;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.35;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
}

/* Table cell: popover opens below without covering the icon awkwardly */
td.col-levels .chart-levels-pop {
  left: 50%;
  transform: translateX(-50%);
}

.chart-levels-wrap:hover .chart-levels-pop,
.chart-levels-wrap:focus-within .chart-levels-pop,
.chart-levels-wrap.is-open .chart-levels-pop {
  display: block;
}

.levels-pop-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 18rem;
  overflow-y: auto;
}

.levels-pop-item {
  display: grid;
  grid-template-columns: 14px auto 26px minmax(2rem, auto);
  align-items: center;
  column-gap: 6px;
}

.levels-swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.levels-marker-slot,
.levels-line-slot {
  display: block;
  flex-shrink: 0;
}

.levels-marker-slot {
  width: 14px;
  height: 14px;
}

.levels-line-slot {
  width: 26px;
  height: 10px;
}

.levels-pop-label {
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: inherit;
}

.levels-pop-price {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: inherit;
  font-weight: 500;
  justify-self: end;
}

th.col-levels,
td.col-levels {
  width: 2.5rem;
  text-align: center;
  vertical-align: middle;
}

/* Key icon + popover (same pattern as note; holds colored line legend) */
.chart-key-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 2px;
}

.chart-key-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.55rem;
  height: 1.55rem;
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #151922;
  color: var(--muted);
  cursor: pointer;
}

.chart-key-btn:hover,
.chart-key-btn:focus-visible,
.chart-key-wrap.is-open .chart-key-btn {
  color: var(--accent);
  border-color: #3d5a9a;
  background: #1a2438;
  outline: none;
}

.chart-key-icon {
  display: block;
}

.chart-key-pop {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 20;
  min-width: 12rem;
  max-width: min(28rem, 80vw);
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(18, 21, 28, 0.97);
  border: 1px solid #2a3140;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.4;
  white-space: normal;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.chart-key-wrap:hover .chart-key-pop,
.chart-key-wrap:focus-within .chart-key-pop,
.chart-key-wrap.is-open .chart-key-pop {
  display: block;
}

.chart-toolbar-right {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px 10px;
  margin-left: auto;
  flex: 0 0 auto;
}

/* Line key inside key popover: 3 columns, colored strokes */
.chart-line-keys {
  display: block;
  min-width: 0;
}

.chart-line-key-group {
  display: block;
  min-width: 0;
}

/*
 * Price-line key: tiny stroke sample + action name (matching colors).
 * Fixed 3 columns — 3 items per line.
 */
.chart-line-key {
  display: grid;
  grid-template-columns: repeat(3, auto);
  grid-auto-flow: row;
  column-gap: 14px;
  row-gap: 6px;
  align-content: start;
  justify-content: start;
}

.chart-line-key-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
  min-height: 1.05em;
}

.chart-line-key-swatch {
  flex: 0 0 auto;
  display: block;
  vertical-align: middle;
}

.chart-marker-key-swatch {
  flex: 0 0 auto;
}

.chart-line-key-label {
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  color: inherit;
}

.tf-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: #151922;
  color: var(--muted);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
}

.tf-btn:hover { color: var(--text); border-color: #3a4254; }
.tf-btn.is-active {
  color: #fff;
  background: #2a3f6e;
  border-color: #3d5a9a;
}

.tf-select {
  appearance: none;
  border: 1px solid var(--border);
  background: #151922 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b93a7' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center;
  color: var(--text);
  border-radius: 6px;
  padding: 4px 26px 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
}

.tf-select:hover,
.tf-select:focus {
  border-color: #3a4254;
  outline: none;
}

.chart-status {
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.2em;
}

.chart-status.is-error { color: var(--danger); }

[data-chart-mount] {
  position: relative;
  width: 100%;
  min-height: 450px;
  overflow: hidden;
}

/*
 * Covers the right slice of the plot so horizontal gridlines look "shortened"
 * (canvas cannot trim grid strokes like the old Apex SVG x2 hack).
 * Labels sit on top of this band.
 */
.chart-grid-mask {
  position: absolute;
  top: 0;
  /* `right` set in JS so mask stops before the price scale */
  right: 64px;
  bottom: 0;
  /* width set in JS from gridline_fraction */
  width: 12%;
  pointer-events: none;
  z-index: 2;
  /* Match chart background so grid appears to stop early */
  background: linear-gradient(
    to right,
    rgba(12, 15, 21, 0) 0%,
    rgba(12, 15, 21, 0.92) 28%,
    #0c0f15 55%
  );
}

/* OHLC crosshair tooltip */
.chart-ohlc-tip {
  position: absolute;
  z-index: 5;
  min-width: 110px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(18, 21, 28, 0.94);
  border: 1px solid #2a3140;
  color: #e6e8ee;
  font: 12px/1.45 system-ui, sans-serif;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
.chart-ohlc-tip-date {
  opacity: 0.75;
  margin-bottom: 4px;
}
.chart-ohlc-tip span {
  display: inline-block;
  width: 1.1em;
  font-weight: 700;
  opacity: 0.85;
}

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}

.hint {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ── Admin shell (top bar + left menu + main + right stats) ── */

.admin-body {
  min-height: 100vh;
}

.admin-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.admin-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #0e1118;
  position: sticky;
  top: 0;
  z-index: 40;
}

.admin-topbar h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.admin-topbar .meta {
  color: var(--muted);
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.topbar-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: #1a2030;
  color: var(--accent);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
}

.topbar-add:hover {
  background: #243049;
  border-color: #3d5a9a;
  color: #fff;
  text-decoration: none;
}

.topbar-count {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.topbar-sep {
  opacity: 0.55;
}

.admin-topbar .meta .user-mark {
  width: 1.15rem;
  height: 1.15rem;
  font-size: 0.65rem;
}

.topbar-titles {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
  min-width: 0;
}

.topbar-extra {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.55rem;
  height: 1.45rem;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #151922;
  color: rgba(235, 235, 245, 0.78);
  font-size: 0.72rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.admin-topbar .rail-toggle-btn {
  margin-left: 0;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.topbar-account {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
}

.topbar-account a {
  color: var(--muted);
  text-decoration: none;
}

.topbar-account a:hover {
  color: var(--text);
  text-decoration: none;
}

.topbar-user {
  font-weight: 600;
}

.topbar-settings {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  color: var(--muted);
  text-decoration: none;
  border-radius: 5px;
}

.topbar-settings:hover,
.topbar-settings.is-active {
  color: var(--text);
  text-decoration: none;
}

.topbar-settings-icon {
  display: block;
}

.auth-page .admin-main {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 22px 20px 18px;
  margin: 24px auto 0;
}

.auth-card-title {
  margin: 0 0 14px;
  font-size: 1.15rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.85rem;
}

.auth-form input,
.auth-form select {
  background: #0e1118;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.9rem;
}

.auth-form input:focus,
.auth-form select:focus {
  outline: none;
  border-color: #3d5a9a;
}

.auth-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}

.settings-form {
  max-width: 720px;
  gap: 16px;
}

.settings-card {
  padding: 18px 18px 16px;
}

.settings-card .auth-card-title {
  margin-bottom: 10px;
}

.settings-subhead {
  margin: 14px 0 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.settings-subhead:first-of-type {
  margin-top: 0;
}

.settings-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px 12px;
}

.users-table td {
  vertical-align: top;
}

.user-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.user-status-pending {
  background: rgba(255, 193, 7, 0.12);
  color: #ffc107;
}

.user-status-active {
  background: rgba(38, 166, 154, 0.12);
  color: var(--ok);
}

.user-status-disabled {
  background: rgba(139, 147, 167, 0.12);
  color: var(--muted);
}

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

.user-inline-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.user-password-form input,
.user-inline-form input[name="name"] {
  width: 8.5rem;
  background: #0e1118;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 0.8rem;
}

.btn-danger {
  color: var(--danger);
  border-color: rgba(239, 83, 80, 0.4);
}

.btn-danger:hover {
  color: #ff8a80;
  border-color: var(--danger);
}

.icon-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #151922;
  color: var(--muted);
  cursor: pointer;
  flex: 0 0 auto;
}

.icon-btn:hover,
.icon-btn[aria-expanded="true"] {
  color: var(--text);
  border-color: #3a4254;
  background: #1a2030;
}

.icon-bars,
.icon-rail {
  display: block;
  width: 16px;
  height: 12px;
  position: relative;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  box-sizing: border-box;
}

.icon-bars::before,
.icon-rail::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  margin-top: -1px;
  border-top: 2px solid currentColor;
}

.icon-rail {
  width: 14px;
  border-right: 2px solid currentColor;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  border-left: none;
  height: 14px;
}

.icon-rail::before {
  display: none;
}

.admin-shell {
  display: flex;
  flex: 1 1 auto;
  align-items: stretch;
  min-height: 0;
  width: 100%;
  position: relative;
}

.admin-main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 20px 8px 48px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.admin-app.nav-open .admin-main,
.admin-app.rail-open .admin-main {
  max-width: none;
  margin: 0;
}

/* Left nav menu */
.admin-nav {
  flex: 0 0 0;
  width: 0;
  overflow: hidden;
  border-right: 0 solid var(--border);
  background: #0e1118;
  transition: flex-basis 0.18s ease, width 0.18s ease;
}

.admin-app.nav-open .admin-nav {
  flex: 0 0 220px;
  width: 220px;
  border-right-width: 1px;
  overflow: auto;
}

.nav-inner {
  width: 220px;
  min-height: 100%;
  padding: 12px 12px 28px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.nav-logout {
  display: block;
  margin-top: auto;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
}

.nav-logout:hover {
  background: #1a2030;
  color: #fff;
  text-decoration: none;
}

.nav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 2px;
}

.nav-head strong {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-links a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.92rem;
}

.nav-links a:hover,
.nav-links a.is-active {
  background: #1a2030;
  color: #fff;
  text-decoration: none;
}

/* Collapsible left-nav groups (Trades, Positions, TOL, Settings) */
.nav-group {
  margin-top: 2px;
  border-radius: 8px;
}

.nav-group-summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
}

.nav-group-summary::-webkit-details-marker {
  display: none;
}

.nav-group-summary::after {
  content: "▸";
  color: var(--muted);
  font-size: 0.75rem;
  transition: transform 0.12s ease;
}

.nav-group[open] > .nav-group-summary::after {
  transform: rotate(90deg);
}

.nav-group-summary:hover,
.nav-group-summary.is-active {
  background: #1a2030;
}

.nav-group-summary.is-active {
  color: #fff;
}

.nav-group-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 0 6px 0;
}

.nav-sublink {
  display: block;
  padding: 8px 12px 8px 22px !important;
  border-radius: 8px;
  color: var(--muted) !important;
  font-size: 0.86rem !important;
  font-weight: 400;
  text-decoration: none;
}

.nav-sublink:hover {
  color: var(--accent) !important;
  background: #151922 !important;
  text-decoration: none;
}

.nav-sublink.is-active {
  color: #fff !important;
  background: #1a2030 !important;
}

.nav-sublink.is-disabled,
span.nav-sublink.is-disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
  font-style: italic;
}

.nav-group-empty {
  display: block;
  padding: 6px 12px 8px 22px;
  font-size: 0.8rem;
}

.nav-backdrop {
  display: none;
}

/* Right rail (pages) */
.admin-rail {
  flex: 0 0 0;
  width: 0;
  overflow: hidden;
  border-left: 0 solid var(--border);
  background: #0e1118;
  transition: flex-basis 0.18s ease, width 0.18s ease;
}

.admin-app.rail-open .admin-rail {
  flex: 0 0 320px;
  width: 320px;
  border-left-width: 1px;
  overflow: auto;
}

.rail-inner {
  width: 320px;
  padding: 12px 12px 28px;
  box-sizing: border-box;
}

.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 2px;
}

.rail-head strong {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.rail-close {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
}

.rail-close:hover {
  color: var(--text);
  background: #1a2030;
}

.rail-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 12px 14px;
  margin-bottom: 12px;
}

.rail-title {
  margin: 0 0 2px;
  font-size: 0.92rem;
  font-weight: 600;
}

.rail-sub {
  margin: 0 0 10px;
  font-size: 0.75rem;
}

.rail-foot {
  margin: 8px 0 0;
  font-size: 0.75rem;
}

.rail-stats {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.rail-stats th,
.rail-stats td {
  padding: 5px 4px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.rail-stats th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.rail-stats .num,
.rail-trades .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rail-stats .pnl-up,
.rail-trades .pnl-up { color: #26a69a; }
.rail-stats .pnl-down,
.rail-trades .pnl-down { color: #ef5350; }
.rail-stats .pnl-flat,
.rail-trades .pnl-flat { color: var(--muted); }

.rail-table-wrap {
  overflow-x: auto;
  margin: 0 -4px;
}

.rail-trades {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.rail-trades th,
.rail-trades td {
  padding: 5px 4px;
  border-bottom: 1px solid var(--border);
}

.rail-trades th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.rail-trades td.ticker {
  font-weight: 600;
  text-transform: uppercase;
}

.rail-trades a {
  color: var(--text);
  text-decoration: none;
}

.rail-trades a:hover {
  color: var(--accent);
}

.rail-links {
  list-style: none;
  margin: 0;
  padding: 0;
}

.rail-links li {
  margin: 0;
  border-bottom: 1px solid var(--border);
}

.rail-links li:last-child {
  border-bottom: none;
}

.rail-links a {
  display: block;
  padding: 7px 2px;
  font-size: 0.86rem;
  color: var(--text);
  text-decoration: none;
}

.rail-links a:hover,
.rail-links a.is-active {
  color: var(--accent);
}

.rail-links a.is-active {
  font-weight: 600;
}

.rail-backdrop {
  display: none;
}

/* Sortable headers */
th.is-sortable {
  cursor: pointer;
  user-select: none;
}

th.is-sortable:hover {
  color: var(--text);
}

/* Config editor */
.config-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.config-list li {
  border-bottom: 1px solid var(--border);
}

.config-list a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  text-decoration: none;
  color: var(--text);
}

.config-list a:hover {
  background: var(--row-hover);
  text-decoration: none;
}

.config-list .cfg-label {
  font-weight: 600;
}

.config-list .cfg-desc {
  color: var(--muted);
  font-size: 0.85rem;
}

.config-form label.cfg-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.config-form .cfg-key {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: ui-monospace, monospace;
}

.config-form input[type="text"],
.config-form input[type="password"],
.config-form input[type="number"],
.config-form textarea,
.config-form select {
  appearance: none;
  background: #151922;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.9rem;
  width: 100%;
  max-width: 48rem;
  font-family: inherit;
}

.config-form textarea {
  min-height: 6rem;
  font-family: ui-monospace, monospace;
  font-size: 0.82rem;
  line-height: 1.4;
}

.config-form input:focus,
.config-form textarea:focus,
.config-form select:focus {
  outline: none;
  border-color: #3d5a9a;
}

.config-form .cfg-bool {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.config-form .cfg-hint {
  font-size: 0.75rem;
  color: var(--muted);
}

.config-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  align-items: center;
}

.flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 0.9rem;
}

.flash-ok {
  background: rgba(38, 166, 154, 0.12);
  border: 1px solid rgba(38, 166, 154, 0.35);
  color: #26a69a;
}

.flash-err {
  background: rgba(239, 83, 80, 0.1);
  border: 1px solid rgba(239, 83, 80, 0.35);
  color: #ef5350;
}

/* Schwab OAuth refresh-token warning (all admin pages) */
.auth-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  padding: 12px 14px;
  border-radius: 10px;
  margin: 0 0 16px;
  font-size: 0.9rem;
  line-height: 1.4;
}

.auth-banner-body {
  flex: 1 1 240px;
  min-width: 0;
}

.auth-banner-body strong {
  display: block;
  margin: 0 0 3px;
  font-size: 0.95rem;
  color: var(--text);
}

.auth-banner-body p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.auth-banner-warn {
  background: rgba(255, 193, 7, 0.1);
  border: 1px solid rgba(255, 193, 7, 0.4);
}

.auth-banner-warn .auth-banner-body strong {
  color: #ffca28;
}

.auth-banner-danger {
  background: rgba(239, 83, 80, 0.1);
  border: 1px solid rgba(239, 83, 80, 0.4);
}

.auth-banner-danger .auth-banner-body strong {
  color: #ef5350;
}

.auth-banner-btn {
  flex: 0 0 auto;
  text-decoration: none;
  white-space: nowrap;
}

.auth-banner-btn:hover {
  text-decoration: none;
}

.muted { color: var(--muted); }

/* Mobile: left menu + right stats as overlay drawers */
@media (max-width: 959px) {
  .admin-app.nav-open .admin-nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 55;
    flex: none;
    width: min(260px, 86vw);
    border-right: 1px solid var(--border);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.45);
    overflow: auto;
  }

  .admin-app.nav-open .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.5);
  }

  .admin-app.rail-open .admin-rail {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 55;
    flex: none;
    width: min(340px, 92vw);
    border-left: 1px solid var(--border);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.45);
    overflow: auto;
  }

  .admin-app.rail-open .rail-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.5);
  }

  .admin-main {
    max-width: none;
  }
}

@media (min-width: 960px) {
  /* Desktop: close buttons optional; toggles live in topbar */
  .nav-head .rail-close,
  .rail-head .rail-close {
    display: none;
  }
}

/* —— Home portfolio stats (P&L + top open, above overview cards) —— */
.home-portfolio-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
  align-items: start;
}

.home-portfolio-stats .rail-panel {
  margin-bottom: 0;
}

.home-portfolio-stats .home-stats-loading,
.home-portfolio-stats > .muted:only-child {
  grid-column: 1 / -1;
  margin: 0;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}

/* —— Home overview stats —— */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

a.stats-card {
  display: block;
  padding: 16px 16px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.12s ease, background 0.12s ease;
}

a.stats-card:hover {
  text-decoration: none;
  border-color: #3d5a9a;
  background: var(--expand);
}

a.stats-card.stats-card-warn {
  border-color: #ef535055;
}

.stats-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.stats-card-head h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.stats-card-link {
  font-size: 0.8rem;
  color: var(--accent);
  white-space: nowrap;
}

.stats-big {
  font-size: 1.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.stats-sub {
  margin: 2px 0 12px;
  font-size: 0.85rem;
}

.stats-dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  margin: 0;
}

.stats-dl div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.85rem;
}

.stats-dl dt {
  margin: 0;
  color: var(--muted);
  font-weight: 400;
}

.stats-dl dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.stats-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 0;
  font-size: 0.78rem;
}

.stats-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #0e1118;
}

.stats-chip.is-crit {
  border-color: #ef535055;
  color: #ef9a9a;
}

/* —— Filter form (icon in top bar) —— */
.filter-panel {
  position: relative;
  margin: 0;
  border: none;
  background: transparent;
}

.filter-icon-btn {
  list-style: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #151922;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.filter-icon-btn::-webkit-details-marker {
  display: none;
}

.filter-icon-btn:hover,
.filter-panel[open] .filter-icon-btn {
  color: var(--text);
  border-color: #3a4254;
  background: #1a2030;
}

.filter-panel-body {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 60;
  min-width: min(42rem, 94vw);
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(18, 21, 28, 0.98);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

.trades-subnav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 18px;
  margin: -16px 0 6px;
  padding: 0 2px 6px;
  border-bottom: 1px solid var(--border);
}

.trades-subnav-link {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}

.trades-subnav-link:hover {
  color: var(--text);
  text-decoration: none;
}

.trades-subnav-link.is-active {
  color: var(--text);
}

.filter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 12px;
}

.filter-form label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.8rem;
}

.filter-form input[type="text"],
.filter-form select {
  min-width: 7rem;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0e1118;
  color: var(--text);
  font-size: 0.9rem;
}

.filter-checks,
.settings-checks {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 0;
  padding: 0;
  border: none;
  min-width: 7rem;
  max-height: 11rem;
  overflow: auto;
}

.filter-checks legend,
.settings-checks legend {
  padding: 0;
  margin: 0 0 3px;
  font-size: 0.8rem;
}

.filter-check,
.settings-checks .filter-check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text);
  white-space: nowrap;
  cursor: pointer;
}

.filter-check input,
.settings-checks input {
  margin: 0;
  accent-color: var(--ok);
}

/* —— Direction glyphs —— */
.col-dir {
  text-align: center;
  width: 1.5rem;
  padding-left: 1px;
  padding-right: 1px;
}

.dir-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
}

.dir-glyph.dir-above {
  color: var(--ok);
  background: #26a69a22;
}

.dir-glyph.dir-below {
  color: var(--danger);
  background: #ef535022;
}

.dir-glyph.dir-none {
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  font-size: 0.7rem;
  opacity: 0.75;
}

.dir-glyph.dir-unknown {
  color: #ffa726;
  background: #ffa72622;
}

.col-note {
  max-width: 12rem;
}

button.note-clip {
  appearance: none;
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

button.note-clip.is-open {
  white-space: normal;
  word-break: break-word;
}

/* —— Errors page —— */
tr.error-row.is-critical td:first-child {
  box-shadow: inset 3px 0 0 var(--danger);
}

tr.error-row.is-expanded {
  background: var(--expand);
}

.badge-crit {
  background: #ef535033;
  color: #ef9a9a;
  border: 1px solid #ef535055;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
}

.col-err-msg {
  max-width: 28rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.error-detail-row > td {
  padding: 0 !important;
  background: #0c0f15;
  white-space: normal;
}

.error-detail {
  padding: 12px 14px 16px;
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
}

.error-detail p {
  margin: 0 0 6px;
}

.error-pre {
  margin: 0 0 12px;
  padding: 10px 12px;
  background: #0e1118;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #c8cdd8;
}


/* —— Positions page —— */
.positions-stats-grid {
  margin-bottom: 14px;
}

.positions-import-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.pos-symbol {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.pos-under {
  display: block;
  font-size: 0.75rem;
  margin-top: 1px;
}

.pos-type {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--border);
  color: var(--muted);
}

.pos-type-stock { color: #90caf9; border-color: #90caf944; }
.pos-type-option { color: #ce93d8; border-color: #ce93d844; }
.pos-type-future { color: #ffe082; border-color: #ffe08244; }
.pos-type-other { color: var(--muted); }

.pos-side-long { color: #26a69a; text-transform: capitalize; }
.pos-side-short { color: #ef5350; text-transform: capitalize; }
.pos-side-flat { color: var(--muted); text-transform: capitalize; }

.pos-status {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.75rem;
  text-transform: capitalize;
  border: 1px solid var(--border);
}

.pos-status-open {
  color: #26a69a;
  border-color: #26a69a55;
  background: #26a69a14;
}

.pos-status-closed {
  color: var(--muted);
  border-color: var(--border);
}

#positions-table td.ticker {
  max-width: 14rem;
  white-space: normal;
  word-break: break-word;
}

/* —— Position ↔ trade idea link —— */
#positions-table th.col-idea,
#positions-table td.col-idea {
  width: 3.2rem;
  text-align: center;
  padding-left: 4px;
  padding-right: 4px;
}
.pos-idea-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  vertical-align: middle;
}
.pos-idea-dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  flex-shrink: 0;
}
.pos-idea-dot.is-linked {
  background: #26a69a;
  box-shadow: 0 0 0 1px rgba(38, 166, 154, 0.45);
}
.pos-idea-dot.is-unlinked {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px #ef5350aa;
}
.pos-idea-link {
  font-size: 0.72rem;
  line-height: 1;
  color: var(--muted);
  text-decoration: none;
  padding: 1px 2px;
}
.pos-idea-link:hover {
  color: #90caf9;
}
.pos-attach-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  vertical-align: middle;
}
.pos-attach-btn:hover,
.pos-attach-btn:focus-visible,
.pos-attach-btn[aria-expanded="true"] {
  color: #90caf9;
  background: rgba(144, 202, 249, 0.1);
  outline: none;
}
.pos-attach-btn svg {
  display: block;
}

.pos-idea-picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: transparent;
}
/* Author display rules override UA [hidden]{display:none} — keep closed state real */
.pos-idea-picker-backdrop[hidden],
.pos-idea-picker[hidden] {
  display: none !important;
}
.pos-idea-picker {
  position: absolute;
  z-index: 90;
  width: min(300px, calc(100vw - 16px));
  max-height: min(360px, 70vh);
  display: flex;
  flex-direction: column;
  background: #141821;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.pos-idea-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.pos-idea-picker-close {
  min-width: auto;
  padding: 2px 8px;
  font-size: 0.85rem;
  line-height: 1.2;
}
.pos-idea-picker-body {
  padding: 8px;
  overflow: auto;
  font-size: 0.85rem;
}
.pos-idea-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pos-idea-option {
  appearance: none;
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #0e1118;
  color: inherit;
  cursor: pointer;
  font: inherit;
}
.pos-idea-option:hover,
.pos-idea-option:focus-visible {
  border-color: #90caf988;
  background: #161b26;
  outline: none;
}
.pos-idea-option.is-current {
  border-color: #26a69a88;
}
.pos-idea-option:disabled {
  opacity: 0.6;
  cursor: wait;
}
.pos-idea-opt-main {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
}
.pos-idea-opt-date {
  text-transform: capitalize;
  font-weight: 600;
}
/* Full type badge: L, L/A, L/LT, L/2, S, S/A, … */
.pos-idea-opt-type {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.2;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: transparent;
  white-space: nowrap;
  font-variant-ligatures: none; /* keep L/LT, L/2 readable */
}
.pos-idea-opt-type.is-long {
  color: #26a69a;
  border-color: #26a69a66;
  background: #26a69a14;
}
.pos-idea-opt-type.is-short {
  color: #ef5350;
  border-color: #ef535066;
  background: #ef535014;
}
.pos-idea-opt-type.is-unknown {
  color: var(--muted);
  border-color: var(--border);
}
.pos-idea-opt-entry {
  font-variant-numeric: tabular-nums;
  color: #90caf9;
}
.pos-idea-opt-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
}
.pos-idea-opt-status.is-open {
  color: #26a69a;
}
.pos-idea-opt-status.is-closed {
  color: #ef5350;
}
.pos-idea-opt-linked {
  color: #26a69a;
  font-weight: 600;
}
.pos-idea-unlink {
  appearance: none;
  width: 100%;
  margin: 0 0 8px;
  padding: 7px 10px;
  border: 1px solid #ef535055;
  border-radius: 6px;
  background: #ef535012;
  color: #ef5350;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.pos-idea-unlink:hover,
.pos-idea-unlink:focus-visible {
  background: #ef535022;
  border-color: #ef5350aa;
  outline: none;
}
.pos-idea-unlink:disabled {
  opacity: 0.6;
  cursor: wait;
}
.pos-idea-create {
  appearance: none;
  width: 100%;
  margin: 0 0 8px;
  padding: 7px 10px;
  border: 1px solid #90caf955;
  border-radius: 6px;
  background: #90caf912;
  color: #90caf9;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.pos-idea-create:hover,
.pos-idea-create:focus-visible {
  background: #90caf922;
  border-color: #90caf9aa;
  outline: none;
}
.pos-idea-create:disabled {
  opacity: 0.6;
  cursor: wait;
}
.pos-idea-ok {
  color: #26a69a;
}
.pos-idea-err {
  color: #ef5350;
}

/* —— Position row expand (fills) —— */
tr.pos-row {
  cursor: pointer;
}
tr.pos-row.is-expanded {
  background: var(--expand);
}
.pos-detail-row > td {
  padding: 0 !important;
  background: #0e1118;
  border-bottom: 1px solid var(--border);
}
.pos-detail {
  padding: 12px 14px 14px;
}
.pos-detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 14px;
  margin-bottom: 8px;
  font-size: 0.9rem;
}
.pos-tx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.pos-tx-table th,
.pos-tx-table td {
  padding: 5px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.pos-tx-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pos-tx-table th.num,
.pos-tx-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.pos-tx-table tbody tr:last-child td {
  border-bottom: none;
}

/* —— Risk planner —— */
.risk-form {
  margin: 0 0 14px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.risk-toolbar {
  margin: 0 0 14px;
  align-items: flex-start;
}

.risk-toolbar label {
  min-width: 6.5rem;
}

.risk-last {
  font-size: 0.72rem;
  min-height: 1em;
  margin-top: 2px;
}

.risk-form datalist { display: none; }

.risk-section {
  margin: 0 0 16px;
}

.risk-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
  margin: 0 0 8px;
}

.risk-section-head h2 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
}

.risk-table-wrap {
  overflow-x: auto;
}

.risk-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.risk-table th,
.risk-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.risk-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
}

.risk-table th.num,
.risk-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.risk-table tfoot td {
  border-bottom: none;
  font-weight: 600;
  padding-top: 8px;
}

.risk-row-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  width: 4.2rem;
}

.risk-row-actions {
  width: 2.4rem;
  text-align: right;
}

.risk-table input[type="text"],
.risk-table input[type="number"] {
  appearance: none;
  width: 6.5rem;
  background: #151922;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 8px;
  font-size: 0.9rem;
  min-height: 2.05rem;
}

.risk-table input[name="pt_shares[]"],
.risk-table input[name="buy_shares[]"] {
  width: 4.8rem;
}

.risk-table input[name="buy_r[]"] {
  width: 4.4rem;
}

.risk-table input:focus {
  outline: none;
  border-color: #3d5a9a;
}

.risk-pt-btn {
  min-height: 2.05rem;
  min-width: 2.05rem;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
}

.risk-outcomes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 4px;
}

.risk-outcome {
  background: #0e1118;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.risk-outcome h3 {
  margin: 0 0 4px;
  font-size: 0.88rem;
}

.risk-outcome > .muted {
  margin: 0 0 10px;
  font-size: 0.78rem;
}

.risk-outcome dl {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
}

.risk-outcome dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.risk-outcome dd {
  margin: 2px 0 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.risk-outcome-note {
  margin: 10px 0 0;
  min-height: 1em;
  font-size: 0.78rem;
}

.pnl-up { color: #26a69a; }
.pnl-down { color: #ef5350; }
.pnl-flat { color: var(--muted); }

.risk-chart-host { padding: 0; }

.risk-tf-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding-top: 4px;
}

.risk-chart-host .chart-panel {
  position: relative;
  left: auto;
  width: 100%;
  max-width: 100%;
}
