/* ============================================================================
   TALOS — Terminal-grade design system
   Institutional trading-platform UI (ThinkorSwim / Bloomberg style).
   Single source of truth for all token variables and component classes.
   VISUAL ONLY — consumed by Jinja templates; no data/logic dependencies.
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Roboto+Mono:wght@400;500&display=swap');

/* ---------------------------------------------------------------- TOKENS -- */
:root {
  /* backgrounds */
  --bg-deep:        #0d0d0d;
  --bg-panel:       #141414;
  --bg-panel-head:  #1a1a1a;
  --bg-elevated:    #1e1e1e;
  --border:         #2a2a2a;
  --border-strong:  #333333;

  /* text */
  --text:           #e4e4e4;
  --text-secondary: #888888;
  --text-muted:     #555555;
  --text-label:     #666666;

  /* semantic */
  --pos:            #00c853;
  --neg:            #ff3d3d;
  --warn:           #ffab00;
  --open:           #64b5f6;
  --accent:         #1565c0;
  --accent-hover:   #1976d2;

  /* badges */
  --badge-buy-bg:   #0d2137;
  --badge-buy-tx:   #64b5f6;
  --badge-buy-bd:   #1565c0;
  --badge-sell-bg:  #2a0d0d;
  --badge-sell-tx:  #ef9a9a;
  --badge-sell-bd:  #b71c1c;
  --badge-open-bg:  #0d1f0d;
  --badge-open-tx:  #81c784;
  --badge-open-bd:  #2e7d32;

  /* fonts */
  --font-ui:   'Inter', 'Roboto', system-ui, sans-serif;
  --font-mono: 'Roboto Mono', 'Courier New', monospace;
}

/* ------------------------------------------------------------- RESETS ----- */
html, body {
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 12px;
  -webkit-font-smoothing: antialiased;
}

.font-sans, body.font-sans { font-family: var(--font-ui); }

a { color: inherit; text-decoration: none; }

hr { border: 0; border-top: 1px solid var(--border); margin: 0; }

/* numeric / monospace data cells */
.num, .mono {
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

/* semantic text colors */
.t-pos     { color: var(--pos) !important; }
.t-neg     { color: var(--neg) !important; }
.t-warn    { color: var(--warn) !important; }
.t-open    { color: var(--open) !important; }
.t-muted   { color: var(--text-muted) !important; }
.t-sec     { color: var(--text-secondary) !important; }
.t-primary { color: var(--text) !important; }

/* uppercase micro-label */
.term-label {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ------------------------------------------------------------ SCROLLBARS -- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ----------------------------------------------------------- NAV BAR ------ */
.term-nav {
  display: flex;
  align-items: center;
  height: 44px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.term-nav__brand {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.term-nav__logo {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.04em;
}
.term-nav__tag {
  font-family: var(--font-ui);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.15em;
}
.term-nav__sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 16px;
}
.term-nav__links {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 100%;
}
.term-nav__links a {
  display: inline-flex;
  align-items: center;
  height: 100%;
  font-family: var(--font-ui);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: color .15s;
}
.term-nav__links a:hover { color: var(--text-secondary); }
.term-nav__links a.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.term-nav__account {
  margin-left: auto;
  text-align: right;
  line-height: 1.1;
}
.term-nav__account .lbl {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  display: block;
}
.term-nav__account .val {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
}

/* --------------------------------------------------------- SUMMARY CARDS -- */
.summary-strip {
  display: flex;
  width: 100%;
  background: var(--bg-panel);
  border: 1px solid var(--border);
}
.summary-card {
  flex: 1 1 0;
  min-width: 0;
  padding: 12px 16px;
  border-right: 1px solid var(--border);
}
.summary-card:last-child { border-right: 0; }
.summary-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.summary-card__label {
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}
.summary-card__value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
  margin-top: 8px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.summary-card__value.pos  { color: var(--pos); }
.summary-card__value.neg  { color: var(--neg); }
.summary-card__value.warn { color: var(--warn); }
.summary-card__sub {
  font-family: var(--font-ui);
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  flex: 0 0 auto;
}
.status-dot.pos  { background: var(--pos); }
.status-dot.neg  { background: var(--neg); }
.status-dot.warn { background: var(--warn); }
.status-dot.open { background: var(--open); }

/* ----------------------------------------------------------- PANELS ------- */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 0;
}
.panel + .panel { margin-top: 1px; }
.panel__header {
  background: var(--bg-panel-head);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

/* --------------------------------------------------------- DATA TABLE ----- */
.data-table-wrap {
  background: var(--bg-panel);
  border: 1px solid var(--border);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.data-table thead th {
  background: var(--bg-panel-head);
  border-bottom: 1px solid var(--border-strong);
  height: 32px;
  padding: 0 8px;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
}
.data-table thead th.l { text-align: left; }
.data-table tbody td {
  height: 36px;
  padding: 0 8px;
  border-bottom: 1px solid var(--bg-elevated);
  color: var(--text-secondary);
  text-align: right;
  vertical-align: middle;
}
.data-table tbody td.l { text-align: left; }
.data-table tbody tr.trade-row { background: var(--bg-panel); cursor: pointer; }
.data-table tbody tr.trade-row:hover { background: var(--bg-panel-head); }

/* SIGNATURE: 2px left-border position-status channel */
.data-table tbody tr.trade-row { border-left: 2px solid transparent; }
tr.row-buy-open    { border-left-color: var(--accent) !important; }
tr.row-open        { border-left-color: var(--accent) !important; }
tr.row-profit      { border-left-color: var(--pos) !important; }
tr.row-loss        { border-left-color: var(--neg) !important; }
tr.row-open-short  { border-left-color: var(--warn) !important; }
tr.row-prior       { border-left-color: var(--border) !important; }

/* common cell treatments */
td .sym { font-family: var(--font-ui); font-size: 12px; font-weight: 600; color: var(--text); }
td .date { font-family: var(--font-ui); font-size: 11px; color: var(--text-secondary); }
td .time { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
td .cap  { font-family: var(--font-ui); font-size: 8px; color: var(--text-muted); display:block; }
.stop-none { color: var(--border-strong); }

/* % portfolio thresholds */
.pct-lo  { color: var(--pos); }
.pct-mid { color: var(--open); }
.pct-hi  { color: var(--warn); }
.pct-xh  { color: var(--neg); }

/* P&L open / prior period */
.pnl-idle { color: var(--text-muted); font-style: italic; }

/* ------------------------------------------------------------- BADGES ----- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 18px;
  padding: 0 6px;
  border-radius: 2px;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid transparent;
}
.badge--buy  { background: var(--badge-buy-bg);  color: var(--badge-buy-tx);  border-color: var(--badge-buy-bd); }
.badge--sell { background: var(--badge-sell-bg); color: var(--badge-sell-tx); border-color: var(--badge-sell-bd); }
.badge--open { background: var(--badge-open-bg); color: var(--badge-open-tx); border-color: var(--badge-open-bd); }
.class-label {
  display: block;
  font-family: var(--font-ui);
  font-size: 8px;
  color: var(--text-muted);
  text-transform: lowercase;
  margin-top: 2px;
}

/* --------------------------------------------------------- FILTER BAR ----- */
.filter-bar {
  display: flex;
  align-items: center;
  height: 36px;
  background: var(--bg-panel-head);
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
}
.filter-tab {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  height: 36px;
  padding: 0 4px;
  margin-right: 16px;
  font-family: var(--font-ui);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .15s;
}
.filter-tab:hover { color: var(--text-secondary); }
.filter-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.sort-select {
  margin-left: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 10px;
  height: 24px;
  padding: 0 8px;
}

/* ------------------------------------------------------ CLOSED-PAIR STRIP -- */
.closed-strip {
  display: flex;
  align-items: stretch;
  background: var(--bg-panel-head);
  border-top: 1px solid var(--border-strong);
  border-left: 2px solid var(--text-muted);
  padding: 10px 16px;
  gap: 32px;
}
.closed-strip.pos { border-left-color: var(--pos); }
.closed-strip.neg { border-left-color: var(--neg); }
.closed-metric__label {
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}
.closed-metric__value {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text);
  margin-top: 4px;
}
.closed-metric__value.pos { color: var(--pos); }
.closed-metric__value.neg { color: var(--neg); }

/* ------------------------------------------------------ DETAIL PANEL ------ */
.detail-row { display: none; }
.detail-row.open { display: table-row; }
.detail-panel {
  background: #111111;
  border-top: 1px solid var(--border);
  border-bottom: 2px solid var(--accent);
  padding: 12px 16px;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}
.detail-section-header {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin-bottom: 8px;
}
.detail-line {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}
.detail-line .k { font-family: var(--font-ui); font-size: 11px; color: var(--text-muted); }
.detail-line .v { font-family: var(--font-mono); font-size: 12px; color: var(--text); }
.ind-ok   { color: var(--pos); }
.ind-bad  { color: var(--neg); }
.ind-warn { color: var(--warn); }
.detail-violations {
  background: #1a0a0a;
  border: 1px solid #3a1a1a;
  border-left: 2px solid var(--neg);
  padding: 8px 12px;
  margin-top: 8px;
}

/* --------------------------------------------------------- BUTTONS -------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 12px;
  border-radius: 0;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn--primary   { background: var(--accent); color: var(--text); border-color: var(--accent); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--secondary { background: transparent; border-color: var(--border-strong); color: var(--text-secondary); }
.btn--secondary:hover { border-color: var(--text-muted); color: var(--text); }
.btn--danger    { background: transparent; border-color: var(--badge-sell-bd); color: var(--neg); }
.btn--danger:hover { background: var(--badge-sell-bg); }
.btn--lg { height: 36px; font-size: 11px; }
.btn--block { width: 100%; }

/* --------------------------------------------------- STATEMENT CARDS ------ */
.stmt-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-muted);
  border-radius: 0;
  padding: 12px 16px;
}
.stmt-card.pos { border-left-color: var(--pos); }
.stmt-card.neg { border-left-color: var(--neg); }
.stmt-card__range { font-family: var(--font-mono); font-size: 13px; color: var(--text); }
.stmt-card__meta  { font-family: var(--font-ui); font-size: 11px; color: var(--text-muted); }
.stmt-card__pnl   { font-family: var(--font-mono); font-size: 13px; }
.stmt-card__pnl.pos { color: var(--pos); }
.stmt-card__pnl.neg { color: var(--neg); }

/* ----------------------------------------------------------- UPLOAD ------- */
.dropzone {
  background: var(--bg-panel);
  border: 1px dashed var(--border-strong);
  border-radius: 0;
  padding: 48px;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: var(--accent); background: #0d1f37; }
.dropzone.dragover { border: 1px solid var(--accent); background: #0a1929; }
.dropzone__title {
  font-family: var(--font-ui);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
}
.dropzone__sub {
  font-family: var(--font-ui);
  font-size: 10px;
  color: var(--border-strong);
  margin-top: 6px;
}

/* ------------------------------------------------------- FORM INPUTS ------ */
.term-input {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 0;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  height: 32px;
  padding: 0 10px;
}
.term-input:focus { outline: none; border-color: var(--accent); }

.term-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 2px;
  background: var(--border);
  cursor: pointer;
}
.term-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text);
}
.term-range::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--text); border: 0;
}
.term-range::-moz-range-progress { background: var(--accent); height: 2px; }

.term-check {
  -webkit-appearance: none;
  appearance: none;
  width: 16px; height: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 0;
  cursor: pointer;
  position: relative;
}
.term-check:checked { background: var(--accent); border-color: var(--accent); }
.term-check:checked::after {
  content: '';
  position: absolute;
  left: 5px; top: 1px;
  width: 4px; height: 9px;
  border: solid var(--text);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.preset-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 0;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  height: 28px;
  padding: 0 12px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.preset-btn:hover { border-color: var(--text-muted); color: var(--text-secondary); }
.preset-btn.active { border-color: var(--accent); color: var(--open); }

.live-preview { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

/* ------------------------------------------------------ CHART CONTAINER --- */
.chart-container {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 16px;
}

/* ------------------------------------------------------------ MODALS ------ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--bg-panel-head);
  border: 1px solid var(--border-strong);
  border-radius: 0;
  max-width: 400px;
  width: 90%;
  padding: 24px;
}
.modal__title { font-family: var(--font-ui); font-size: 13px; font-weight: 600; color: var(--text); }
.modal__body  { font-family: var(--font-ui); font-size: 12px; color: var(--text-secondary); margin-top: 8px; }

/* ------------------------------------------------------------ TOAST ------- */
.toast {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--text-muted);
  border-radius: 0;
  padding: 10px 14px;
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text);
  z-index: 110;
  animation: toast-in .25s ease-out;
}
.toast.pos  { border-left-color: var(--pos); }
.toast.neg  { border-left-color: var(--neg); }
.toast.warn { border-left-color: var(--warn); }
@keyframes toast-in { from { transform: translateX(120%); } to { transform: translateX(0); } }

/* ---------------------------------------- NON-EQUITY / STATEMENT WARNING ---- */
.stmt-warn {
  border-left: 3px solid var(--warn);
  background: #1a1304;
  padding: 6px 10px;
  font-family: var(--font-ui);
  font-size: 11px;
  line-height: 1.4;
  color: var(--warn);
}
.stmt-warn p + p { margin-top: 4px; }

/* -------------------------------------------------------- VIOLATION ICONS - */
.vbadge { position: relative; display: inline-block; }
.vbadge .vtip {
  visibility: hidden; opacity: 0; transition: opacity .15s;
  position: absolute; bottom: 125%; left: 50%; transform: translateX(-50%);
  background: var(--bg-elevated); color: var(--text); font-size: 11px;
  padding: 4px 8px; border: 1px solid var(--border-strong); border-radius: 0;
  white-space: nowrap; z-index: 50; pointer-events: none;
  font-family: var(--font-ui);
}
.vbadge:hover .vtip { visibility: visible; opacity: 1; }
