:root {
  --primary: #1f4e78;
  --bg: #f4f6f8;
  --panel-bg: #ffffff;
  --border: #d8dee4;
  --text: #222;
  --muted: #666;
  --pass: #1a7f37;
  --fail: #c0392b;
}

* { box-sizing: border-box; }

body {
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
}

.site-header {
  background: var(--primary);
  color: #fff;
  padding: 1.25rem 2rem;
}

.site-header h1 {
  margin: 0;
  font-size: 1.5rem;
}

.site-header .subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  opacity: 0.85;
}

.site-footer {
  margin-top: 2rem;
  padding: 1rem 2rem;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  text-align: center;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem;
}

.container.wide {
  max-width: 1400px;
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.panel h2 {
  margin-top: 0;
  color: var(--primary);
}

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

form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
}

.field label {
  font-size: 0.85rem;
  font-weight: bold;
  margin-bottom: 0.25rem;
  color: var(--muted);
}

input, select {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.95rem;
}

button {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.55rem 1.25rem;
  font-size: 0.95rem;
  cursor: pointer;
  height: fit-content;
}

button:hover {
  background: #163a59;
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

.status {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
  display: none;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  text-align: center;
}

.stat .label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
}

.stat .value {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--primary);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.85rem;
}

th, td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.5rem;
  text-align: left;
}

th {
  background: var(--bg);
}

.pass { color: var(--pass); font-weight: bold; }
.fail { color: var(--fail); font-weight: bold; }
.warn { color: #b7791f; font-weight: bold; }

.param-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.param-grid .field {
  display: flex;
  flex-direction: column;
}

.param-grid .field label {
  font-size: 0.7rem;
  margin-bottom: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.param-grid .field input {
  padding: 0.3rem 0.4rem;
  font-size: 0.85rem;
}

.param-desc {
  font-size: 0.7rem;
  color: var(--muted);
  margin: 0.25rem 0 0;
  line-height: 1.3;
}

#live-form {
  display: block;
}

#live-form .param-grid {
  margin-bottom: 1rem;
}

.info-icon {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  line-height: 1rem;
  border-radius: 50%;
  background: var(--border);
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: bold;
  text-align: center;
  cursor: help;
  font-style: normal;
}

.recommended { font-weight: bold; }
.na { color: var(--muted); }

.ticker-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1rem;
}

.top-trades {
  margin-bottom: 1.5rem;
}

.top-trade-card {
  border-color: var(--primary);
}

.unusual-flag {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffc107;
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-size: 0.78rem;
  font-weight: bold;
  cursor: help;
}

.oi-delta {
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  cursor: help;
}

.top-trade-card .ticker-symbol {
  font-size: 1rem;
}

.sort-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0.75rem 0 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.sort-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-right: 0.25rem;
  white-space: nowrap;
}

.sort-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}

.sort-btn:hover {
  background: var(--border);
}

.sort-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.calendar-note {
  font-size: 0.78rem;
  color: var(--muted);
  background: #f0f4ff;
  border-left: 3px solid #6c8ebf;
  border-radius: 0 4px 4px 0;
  padding: 0.4rem 0.6rem;
  margin: 0.4rem 0 0.6rem;
  line-height: 1.4;
}

/* ── Greeks ──────────────────────────────────────────────────────────────── */

.greeks-explainer {
  background: #f8faff;
  border: 1px solid #d0ddf0;
  border-radius: 6px;
  padding: 0.55rem 0.8rem;
  margin: 0.5rem 0 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.greek-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
  font-size: 0.82rem;
  line-height: 1.4;
}

.greek-label {
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  min-width: 6rem;
}

.greek-desc {
  font-weight: 500;
  color: var(--text);
}

.greek-tech {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: monospace;
  white-space: nowrap;
}

/* ── Hedge Analysis block ────────────────────────────────────────────────── */

.hedge-block {
  margin: 0.75rem 0 0.4rem;
  border-radius: 6px;
  border: 1px solid #c5d9f0;
  background: #f4f8ff;
  font-size: 0.82rem;
}
.hedge-block.hedge-urgent {
  border-color: #e8a020;
  background: #fff8ed;
}
.hedge-summary {
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  list-style: none;
  font-size: 0.83rem;
  user-select: none;
}
.hedge-summary::-webkit-details-marker { display: none; }
.hedge-summary::before { content: "▶"; font-size: 0.65rem; color: var(--muted); }
.hedge-block[open] .hedge-summary::before { content: "▼"; }
.hedge-icon { font-size: 1rem; }
.hedge-cost-pill {
  margin-left: auto;
  background: #ddeeff;
  color: #2255aa;
  border-radius: 10px;
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.hedge-urgent .hedge-cost-pill {
  background: #fde8c0;
  color: #8a4f00;
}
.hedge-body {
  padding: 0 0.75rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.hedge-rationale {
  color: var(--text);
  line-height: 1.45;
  margin: 0;
}
.hedge-details-line {
  color: var(--text);
  margin: 0;
  line-height: 1.45;
}
.hedge-comparison {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin: 0.3rem 0;
  flex-wrap: wrap;
}
.hedge-col {
  flex: 1;
  min-width: 140px;
  background: #edf3fb;
  border-radius: 5px;
  padding: 0.4rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.hedge-col-combined {
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
}
.hedge-urgent .hedge-col-combined {
  background: #fff3e0;
  border-color: #ffb74d;
}
.hedge-col-title {
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.1rem;
}
.hedge-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}
.hedge-row span:first-child { color: var(--muted); }
.hedge-row span:last-child  { font-weight: 600; }
.hedge-arrow {
  align-self: center;
  font-weight: 700;
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
}
.hedge-protection-note {
  color: #334;
  margin: 0;
  background: #e8eeff;
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
  line-height: 1.4;
}
.hedge-urgent .hedge-protection-note {
  background: #fef3e0;
  color: #6b3900;
}
.hedge-urgent-note {
  background: #e8f5e9;
  color: #1b5e20;
  font-weight: 600;
}
.hedge-cost-note {
  font-size: 0.72rem;
  margin: 0;
  line-height: 1.3;
}

/* Position alert banners */
.pos-alert {
  padding: 0.45rem 0.75rem;
  border-radius: 5px;
  font-size: 0.82rem;
  font-weight: 600;
  margin: 0.4rem 0 0.2rem;
  line-height: 1.35;
}
.pos-alert-danger {
  background: rgba(220, 53, 69, 0.15);
  border: 1px solid rgba(220, 53, 69, 0.45);
  color: #ff6b7a;
}
.pos-alert-warn {
  background: rgba(255, 165, 0, 0.12);
  border: 1px solid rgba(255, 165, 0, 0.35);
  color: #ffa500;
}

/* Position action buttons */
.pos-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.7rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.pos-action-btn {
  padding: 0.3rem 0.85rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid;
  transition: background 0.15s, color 0.15s;
}
.pos-close-btn {
  background: rgba(220, 53, 69, 0.12);
  border-color: rgba(220, 53, 69, 0.4);
  color: #ff6b7a;
}
.pos-close-btn:hover { background: rgba(220, 53, 69, 0.25); }
.pos-roll-btn {
  background: rgba(58, 123, 213, 0.12);
  border-color: rgba(58, 123, 213, 0.4);
  color: #7ab3f7;
}
.pos-roll-btn:hover { background: rgba(58, 123, 213, 0.25); }

/* Exact hedge trade (live data) */
.hedge-exact-box {
  background: rgba(58, 123, 213, 0.07);
  border: 1px solid rgba(58, 123, 213, 0.25);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  margin: 0.6rem 0;
}
.hedge-exact-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #3a7bd5;
  margin-bottom: 0.4rem;
}
.hedge-exact-leg {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  padding: 0.25rem 0;
  font-size: 0.82rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.hedge-exact-leg:first-of-type { border-top: none; }
.hedge-exact-action  { font-weight: 600; color: #3a7bd5; white-space: nowrap; }
.hedge-exact-strike  { font-weight: 700; white-space: nowrap; }
.hedge-exact-expiry  { color: var(--muted, #888); white-space: nowrap; }
.hedge-exact-mark    { white-space: nowrap; }
.hedge-exact-summary { font-size: 0.78rem; color: var(--muted, #888); }
/* ── Paper Trades Dashboard ──────────────────────────────────────────────────*/

.pt-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.pt-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  padding-top: 0.25rem;
}
.pt-run-btn {
  padding: 0.4rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 5px;
  cursor: pointer;
  border: 1px solid rgba(76, 175, 80, 0.4);
  background: rgba(76, 175, 80, 0.12);
  color: #4caf50;
  transition: background 0.15s;
}
.pt-run-btn:hover { background: rgba(76, 175, 80, 0.25); }
.pt-run-btn-eve {
  border-color: rgba(255, 165, 0, 0.4);
  background:   rgba(255, 165, 0, 0.10);
  color: #ffa500;
}
.pt-run-btn-eve:hover { background: rgba(255, 165, 0, 0.22); }

/* Summary cards */
.pt-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.2rem;
}
.pt-card {
  background: var(--panel-bg, #1e1e2e);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 0.9rem 1rem;
}
.pt-card-loading { color: var(--muted, #888); font-size: 0.85rem; }
.pt-card-title   { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: #888; margin-bottom: 0.3rem; }
.pt-card-value   { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.pt-card-sub     { font-size: 0.72rem; margin-top: 0.25rem; }

/* Breakdown grid */
.pt-breakdown-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.2rem;
}
@media (max-width: 640px) { .pt-breakdown-grid { grid-template-columns: 1fr; } }

/* Status badges */
.pt-status-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}
.pt-status-pass { background: rgba(76,175,80,0.2);  color: #4caf50; }
.pt-status-fail { background: rgba(229,57,53,0.2);  color: #ef5350; }
.pt-status-na   { background: rgba(255,255,255,0.08); color: #aaa; }

/* Trades table */
.pt-trades-table th, .pt-trades-table td {
  white-space: nowrap;
  font-size: 0.8rem;
}
.pt-row-win { background: rgba(76,175,80,0.04); }
.pt-row-loss { background: rgba(229,57,53,0.04); }

/* Progress bar */
.pt-progress-bar {
  position: relative;
  width: 80px;
  height: 8px;
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
  overflow: visible;
}
.pt-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}
.pt-progress-target {
  position: absolute;
  top: -2px;
  width: 2px;
  height: 12px;
  background: #4caf50;
  border-radius: 1px;
}

/* Delete button */
.pt-del-btn {
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}
.pt-del-btn:hover { color: #ef5350; background: rgba(229,57,53,0.12); }

/* ── Paper trade cards (open trades) ────────────────────────────────────────*/

.pt-trade-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  margin-bottom: 1rem;
  overflow: hidden;
}

.pt-card-header {
  padding: 0.7rem 1rem 0.5rem;
}

.pt-card-title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.25rem;
  flex-wrap: wrap;
}

.pt-card-ticker {
  font-size: 1.05rem;
  font-weight: 700;
  color: #e0e0e0;
}

.pt-card-struct {
  font-size: 0.82rem;
  color: #aaa;
  background: rgba(255,255,255,0.07);
  border-radius: 3px;
  padding: 0.1rem 0.45rem;
}

.pt-card-rank {
  font-size: 0.76rem;
}

/* Live status badges */
.pt-live-badge {
  font-size: 0.7rem;
  border-radius: 3px;
  padding: 0.08rem 0.4rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-left: auto;
}
.pt-live-ok      { background: rgba(76,175,80,0.15);  color: #81c784; }
.pt-live-err     { background: rgba(229,57,53,0.15);  color: #ef5350; }
.pt-live-loading { background: rgba(255,255,255,0.07); color: #888;   }

.pt-card-meta {
  font-size: 0.78rem;
}

/* Legs table */
.pt-legs-wrap {
  overflow-x: auto;
  padding: 0 0.5rem;
}

.pt-legs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin: 0.4rem 0;
}

.pt-legs-table th,
.pt-legs-table td {
  padding: 0.28rem 0.55rem;
  text-align: right;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  white-space: nowrap;
}

.pt-legs-table th { color: #777; font-weight: 500; font-size: 0.72rem; }

.pt-legs-table td:first-child,
.pt-legs-table th:first-child { text-align: left; }

.pt-legs-group-hdr {
  text-align: center !important;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  color: #666 !important;
  letter-spacing: 0.04em;
}

.pt-legs-sub-hdr th { color: #555 !important; }

.pt-leg-label  { color: #c0c0c0; font-size: 0.79rem; }
.pt-leg-strike { color: #aaa; }

tr.pt-legs-net td {
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.8rem;
  padding-top: 0.35rem;
}

/* Inline loading placeholder */
span.pt-live-loading {
  color: #555;
  font-style: italic;
  font-size: 0.78rem;
}

/* Summary bar */
.pt-card-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
  padding: 0.5rem 1rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: rgba(0,0,0,0.15);
}

.pt-summary-stat {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
}

.pt-summary-label {
  font-size: 0.68rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.1rem;
}

.pt-card-progress {
  padding: 0.3rem 1rem 0.5rem;
}

.pt-card-footer {
  display: flex;
  justify-content: flex-end;
  padding: 0.3rem 0.75rem 0.4rem;
  border-top: 1px solid rgba(255,255,255,0.04);
}

/* ── Tab nav ─────────────────────────────────────────────────────────────────*/

.pt-tab-nav {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0;
  border-bottom: 2px solid rgba(255,255,255,0.07);
  padding-bottom: 0;
}

.pt-tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 0.55rem 1.1rem;
  font-size: 0.85rem;
  color: #888;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
  transition: color 0.15s, border-color 0.15s;
}
.pt-tab-btn:hover { color: #ccc; }
.pt-tab-btn.active { color: #e0e0e0; border-bottom-color: #3a7bd5; font-weight: 600; }

.pt-tab-panel { display: none; }
.pt-tab-panel.active { display: block; }

/* ── Metrics grid (replaces legs table) ──────────────────────────────────────*/

.pt-metrics-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  padding: 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.pt-metric {
  display: flex;
  flex-direction: column;
  padding: 0.65rem 1.1rem;
  border-right: 1px solid rgba(255,255,255,0.06);
  min-width: 100px;
  flex: 1;
}
.pt-metric:last-child { border-right: none; }

.pt-metric-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #666;
  margin-bottom: 0.25rem;
}

.pt-metric-value {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.1;
}

/* ── Meta row (entered · expiry · signal · spot) ─────────────────────────────*/

.pt-card-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.5rem;
  padding: 0.45rem 1rem;
  font-size: 0.76rem;
  color: #888;
  background: rgba(0,0,0,0.12);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.pt-card-meta-row strong { color: #ccc; }
.pt-meta-dot { color: #444; }

/* ── Portfolio summary bar ───────────────────────────────────────────────────*/

.pt-portfolio-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1rem;
  padding: 0.65rem 1rem;
  margin-top: 0.75rem;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 6px;
  font-size: 0.82rem;
}

.pt-ps-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #555;
  font-weight: 600;
  margin-right: 0.25rem;
}

.pt-ps-item { display: flex; align-items: center; gap: 0.35rem; }
.pt-ps-sep  { color: #444; }

/* ── Day-wise log ────────────────────────────────────────────────────────────*/

.pt-day-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0 0.4rem;
  margin-top: 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 0.4rem;
}

.pt-day-date {
  font-size: 0.9rem;
  font-weight: 700;
  color: #d0d0d0;
  min-width: 90px;
}

/* ── /end Paper Trades ───────────────────────────────────────────────────────*/

/* ── Watchlist editor ────────────────────────────────────────────────────────*/

.wl-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.wl-header-row h2 { margin-bottom: 0.15rem; }

.wl-count-badge {
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255,255,255,0.08);
  color: #aaa;
  border-radius: 10px;
  padding: 0.1rem 0.55rem;
  vertical-align: middle;
}
.wl-count-badge.wl-count-max { background: rgba(229,57,53,0.2); color: #ef5350; }

/* Toolbar */
.wl-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

/* Chip grid */
.wl-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0;
  min-height: 2rem;
}

.wl-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 4px;
  padding: 0.2rem 0.5rem 0.2rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.12s, background 0.12s;
}
.wl-chip-on {
  background: rgba(58,123,213,0.18);
  border: 1px solid rgba(58,123,213,0.4);
  color: #c0d4f5;
}
.wl-chip-off {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.1);
  color: #555;
  text-decoration: line-through;
}
.wl-chip-extra.wl-chip-on {
  background: rgba(76,175,80,0.15);
  border-color: rgba(76,175,80,0.35);
  color: #a5d6a7;
}

.wl-chip-remove {
  background: none;
  border: none;
  color: #6a8fd8;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.1rem;
  border-radius: 2px;
}
.wl-chip-remove:hover { color: #ef5350; }

/* Add row */
.wl-add-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}

.wl-add-row input[type="text"] {
  width: 11rem;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* Save row */
.wl-save-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.25rem;
}

/* Status text */
.wl-search-status {
  font-size: 0.8rem;
}
.wl-search-status.wl-ok      { color: #81c784; }
.wl-search-status.wl-err     { color: #ef5350; }
.wl-search-status.wl-warn    { color: #ffb74d; }
.wl-search-status.wl-loading { color: #888; font-style: italic; }

/* ── /end Watchlist editor ───────────────────────────────────────────────────*/

.log-trade-btn {
  margin-top: 0.6rem;
  padding: 0.4rem 1rem;
  background: #3a7bd5;
  color: #fff;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
}
.log-trade-btn:hover { background: #2a5cb5; }

/* ── Risk banner ─────────────────────────────────────────────────────────── */

.risk-banner {
  margin-bottom: 1rem;
}

.risk-danger, .risk-warn {
  padding: 0.55rem 1rem;
  border-radius: 6px;
  margin-bottom: 0.4rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.risk-danger {
  background: #fde8e8;
  border: 1px solid #e53e3e;
  color: #c53030;
}

.risk-warn {
  background: #fffbea;
  border: 1px solid #d69e2e;
  color: #744210;
}

/* ── Log Trade button ────────────────────────────────────────────────────── */

.btn-log-trade {
  display: inline-block;
  margin-top: 0.6rem;
  padding: 0.3rem 0.8rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-log-trade:hover { opacity: 0.85; }

/* ── Modals ──────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-box {
  background: var(--panel-bg);
  border-radius: 10px;
  padding: 1.5rem 2rem;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.modal-box h3 { margin-top: 0; color: var(--primary); }

.modal-fields {
  margin: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modal-fields label {
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.4rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-primary:hover { opacity: 0.88; }

.modal-actions button:not(.btn-primary) {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  font-size: 0.9rem;
}

/* ── Trade Journal ───────────────────────────────────────────────────────── */

.journal-summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 0.6rem;
}

.jsumm-stat .jsumm-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.jsumm-stat .jsumm-value {
  font-size: 1.05rem;
  font-weight: bold;
  color: var(--text);
}

.muted { color: var(--muted); font-size: 0.85em; }

.deploy-bar-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.deploy-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

.deploy-bar-ok     { background: var(--pass); }
.deploy-bar-warn   { background: #d69e2e; }
.deploy-bar-danger { background: var(--fail); }

.table-scroll {
  overflow-x: auto;
}

.journal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}

.journal-table th {
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 2px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.journal-table td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.journal-table tr:hover td { background: var(--bg); }

.badge-credit, .badge-debit {
  font-size: 0.68rem;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-weight: bold;
  vertical-align: middle;
}

.badge-credit { background: #e6f4ea; color: #1a7f37; }
.badge-debit  { background: #fff3cd; color: #856404; }

.btn-close-pos {
  padding: 0.2rem 0.55rem;
  font-size: 0.78rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
}

.btn-close-pos:hover { background: #fde8e8; border-color: var(--fail); color: var(--fail); }

.ai-view {
  font-size: 0.8rem;
  max-width: 420px;
  line-height: 1.35;
}

.ai-view-full {
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
  padding: 0.6rem 0.8rem;
  background: var(--panel-bg);
  border-left: 3px solid var(--primary);
  border-radius: 0 4px 4px 0;
  line-height: 1.4;
}

.ticker-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.ticker-symbol {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--primary);
}

.ticker-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.ticker-stats strong {
  color: var(--text);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.tab-btn {
  background: var(--panel-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.tab-btn.recommended {
  font-weight: bold;
  color: var(--primary);
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.tab-btn.active.recommended {
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.tab-details {
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
}

.tab-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.6rem;
}

.site-nav {
  background: #163a59;
  padding: 0 2rem;
  display: flex;
  gap: 1.5rem;
}

.site-nav a {
  display: inline-block;
  padding: 0.75rem 0;
  color: #cfe0ee;
  text-decoration: none;
  font-size: 0.9rem;
  border-bottom: 3px solid transparent;
}

.site-nav a:hover {
  color: #fff;
}

.site-nav a.active {
  color: #fff;
  border-bottom-color: #fff;
  font-weight: bold;
}

.site-nav .nav-logout {
  margin-left: auto;
  color: #7aadcc;
  font-size: 0.82rem;
  opacity: 0.75;
}
.site-nav .nav-logout:hover {
  color: #ef5350;
  opacity: 1;
}

/* ── E*TRADE connection bar ───────────────────────────────────────────── */

.etrade-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.55rem 2rem;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.etrade-connected    { background: #f0faf3; color: #1a7f37; }
.etrade-disconnected { background: #fff8f0; color: #7a4000; }
.etrade-unconfigured { background: #f8f8f8; color: var(--muted); }

.etrade-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-on  { background: #1a7f37; box-shadow: 0 0 4px #1a7f3780; }
.dot-off { background: #aaa; }

.etrade-acct {
  font-weight: 600;
  margin-right: 0.25rem;
}

.etrade-stat {
  background: rgba(0,0,0,0.06);
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
}

.etrade-hint { color: var(--muted); font-style: italic; }

.btn-etrade-connect {
  margin-left: 0.5rem;
  padding: 0.3rem 0.9rem;
  background: #1f4e78;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
}
.btn-etrade-connect:hover { background: #163a59; }

.btn-etrade-disconnect {
  margin-left: auto;
  padding: 0.25rem 0.7rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.78rem;
}
.btn-etrade-disconnect:hover { background: #fee; color: var(--fail); border-color: var(--fail); }

/* ── IV term structure note ───────────────────────────────────────────── */
.iv-term-note {
  font-size: 0.82rem;
  color: #1a5276;
  background: #eaf4fb;
  border-left: 3px solid #2980b9;
  padding: 0.4rem 0.7rem;
  margin: 0.5rem 0 0.25rem;
  border-radius: 3px;
}

/* ── Portfolio Upload page ────────────────────────────────────────────────── */

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 2.5rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s;
  background: #fafbfd;
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--primary);
  background: #edf3fb;
}
.upload-icon { font-size: 2.4rem; margin-bottom: 0.5rem; }
.upload-label { font-size: 1rem; font-weight: 600; margin: 0 0 0.4rem; }
.upload-link  { color: var(--primary); text-decoration: underline; cursor: pointer; }
.upload-hint  { font-size: 0.8rem; color: var(--muted); margin: 0; }
.upload-hint code { background: #eee; padding: 0.1rem 0.3rem; border-radius: 3px; font-size: 0.75rem; }

.status.ok    { color: var(--pass); font-weight: 600; }
.status.error { color: var(--fail); font-weight: 600; }

/* Group */
.pu-group       { margin-bottom: 1.5rem; }
.pu-group-title { display: flex; align-items: center; gap: 0.6rem; font-size: 1.05rem; margin: 0 0 0.75rem; color: var(--primary); }
.pu-ticker-badge {
  background: var(--primary); color: #fff;
  border-radius: 4px; padding: 0.15rem 0.55rem;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em;
}

/* Spread card */
.pu-spread-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}
.pu-spread-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 0.5rem; margin-bottom: 0.75rem; flex-wrap: wrap;
}
.pu-spread-title  { font-weight: 700; font-size: 0.95rem; color: var(--text); }
.pu-structure-badge {
  display: inline-block; margin-left: 0.5rem;
  background: #ddeeff; color: #1a3a6e;
  border-radius: 4px; padding: 0.1rem 0.5rem;
  font-size: 0.75rem; font-weight: 600;
}
.pu-risk-badge {
  border-radius: 5px; padding: 0.2rem 0.65rem;
  font-size: 0.78rem; font-weight: 700; white-space: nowrap;
}
.pu-risk-badge.pass { background: #d4edda; color: var(--pass); }
.pu-risk-badge.warn { background: #fff3cd; color: #7a5800; }
.pu-risk-badge.fail { background: #fde8e8; color: var(--fail); }
.pu-risk-badge.na   { background: #eee;    color: var(--muted); }

/* Metrics grid */
.pu-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}
.pu-metric-label {
  font-size: 0.72rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-bottom: 0.15rem;
}
.pu-metric-value { font-size: 0.9rem; font-weight: 600; }
.hint-inline {
  display: inline-block; width: 14px; height: 14px; line-height: 14px;
  text-align: center; border-radius: 50%; background: #ccc;
  font-size: 0.65rem; font-weight: 700; color: #fff;
  cursor: help; vertical-align: middle; margin-left: 3px;
}

/* Leg detail */
.legs-detail { margin-top: 0.6rem; }
.legs-detail summary {
  cursor: pointer; font-size: 0.8rem; color: var(--muted);
  padding: 0.25rem 0; user-select: none;
}
.legs-detail summary::-webkit-details-marker { display: none; }
.legs-detail summary::before { content: "▶ "; font-size: 0.65rem; }
.legs-detail[open] summary::before { content: "▼ "; }
.leg-row td { font-size: 0.8rem; }

/* ── Live Position file picker ───────────────────────────────────────────── */

.lp-file-table {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.lp-file-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafbfd;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-size: 0.88rem;
}
.lp-file-row:hover        { background: #edf3fb; border-color: #aac4e8; }
.lp-file-row.lp-file-selected { background: #ddeeff; border-color: var(--primary); }

.lp-file-icon { font-size: 1.1rem; flex-shrink: 0; }
.lp-file-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-file-meta { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }

.lp-analyse-btn {
  margin-left: auto;
  padding: 0.28rem 0.8rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.lp-analyse-btn:hover { background: #163d5e; }

.lp-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.88rem;
  margin: 1rem 0 0.6rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.lp-close-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  padding: 0.2rem 0.6rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.lp-close-btn:hover { background: #f0f0f0; }

.btn-icon-sm {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  padding: 0.1rem 0.45rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-left: 0.5rem;
  vertical-align: middle;
}
.btn-icon-sm:hover { background: #eee; }
