/* ── LAYOUT: SCREENER ─────────────────────────────────────────────── */
.screener-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
  height: 100%;
}

/* ── FILTER PANEL ─────────────────────────────────────────────────── */
.filter-panel {
  width: 252px;
  min-width: 252px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.filter-panel::-webkit-scrollbar { width: 4px; }
.filter-panel::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.filter-top {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--bg2);
  z-index: 5;
}
.filter-top-label {
  font-size: calc(11px * var(--fs));
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text3);
}
.reset-btn {
  font-size: calc(11px * var(--fs));
  color: var(--accent);
  background: none; border: none;
  cursor: pointer; font-family: var(--sans);
  padding: 2px 6px; border-radius: 3px;
  transition: background 0.1s; font-weight: 500;
}
.reset-btn:hover { background: var(--accentbg); }

/* ── THEMATIC BASKETS ─────────────────────────────────────────────── */
.cb-row.basket-cb-row { align-items: flex-start; }
.cb-row.basket-cb-row input[type=checkbox] { margin-top: 3px; }
.basket-cb-content { display: flex; flex-direction: column; gap: 1px; }
.basket-cb-desc {
  font-size: calc(10px * var(--fs));
  color: var(--text3);
  font-family: var(--mono);
}

.fg { border-bottom: 1px solid var(--border); }
.fg-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px;
  cursor: pointer; user-select: none;
  transition: background 0.1s;
}
.fg-hdr:hover { background: var(--bg3); }
.fg-label { font-size: calc(12px * var(--fs)); font-weight: 500; color: var(--text2); }
.fg-arrow { font-size: 15px; color: var(--text2); transition: transform 0.2s; line-height: 1; }
.fg.open .fg-arrow { transform: rotate(180deg); }
.fg-body { display: none; padding: 4px 14px 12px; }
.fg.open .fg-body { display: block; }

.cb-list { display: flex; flex-direction: column; gap: 4px; }
.cb-row {
  display: flex; align-items: center; gap: 7px;
  cursor: pointer; padding: 2px 4px; border-radius: 4px;
  transition: background 0.1s;
}
.cb-row:hover { background: var(--bg3); }
.cb-row input[type=checkbox], .cb-row input[type=radio] {
  width: 13px; height: 13px;
  accent-color: var(--accent);
  cursor: pointer; flex-shrink: 0;
}
.cb-row label {
  font-size: calc(12px * var(--fs));
  color: var(--text2); cursor: pointer;
  font-family: var(--mono);
}
.cb-row:hover label { color: var(--text); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }

.ytm-range { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
.mini-input {
  flex: 1; min-width: 0; box-sizing: border-box;
  background: var(--bg3);
  border: 1px solid var(--border2); color: var(--text);
  font-family: var(--mono); font-size: calc(11px * var(--fs));
  padding: 5px 8px; border-radius: var(--radius);
  width: 0;
}
.mini-input::-webkit-outer-spin-button,
.mini-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.mini-input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}
.mini-input:focus { outline: none; border-color: var(--accent); background: var(--bg2); }
.mini-sep { font-size: calc(11px * var(--fs)); color: var(--text3); }
.date-col { display: flex; flex-direction: column; gap: 5px; margin-top: 6px; }

.apply-btn {
  width: 100%;
  padding: 9px;
  background: var(--accent);
  color: #111;
  border: none;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: calc(13px * var(--fs));
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  box-shadow: 0 2px 6px rgba(180,140,50,0.3);
  box-sizing: border-box;
}
.apply-btn:hover { background: var(--accent2); }
.filter-footer {
  flex-shrink: 0;
  padding: 10px 14px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.filter-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: none;
}
.filter-scroll::-webkit-scrollbar { display: none; }


/* ── SEARCH-WITH-DROPDOWN ─────────────────────────────────────────── */
.search-dd-wrap { position: relative; margin-top: 6px; }
.search-dd-input {
  width: 100%; background: var(--bg3);
  border: 1px solid var(--border2); color: var(--text);
  font-family: var(--mono); font-size: calc(11px * var(--fs));
  padding: 5px 8px; border-radius: var(--radius);
  box-sizing: border-box;
}
.search-dd-input:focus { outline: none; border-color: var(--accent); background: var(--bg2); }
.search-dd-input::placeholder { color: var(--text3); }
.search-dd-list {
  position: absolute; top: calc(100% + 2px); left: 0; right: 0;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--radius); z-index: 50;
  max-height: 160px; overflow-y: auto;
  box-shadow: var(--shadow-md);
  display: none;
}
.search-dd-list.open { display: block; }
.search-dd-list::-webkit-scrollbar { width: 4px; }
.search-dd-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
.search-dd-item {
  padding: 6px 10px; font-size: calc(11px * var(--fs));
  font-family: var(--mono); color: var(--text2);
  cursor: pointer; transition: background 0.1s;
}
.search-dd-item:hover { background: var(--bg4); color: var(--text); }
.search-dd-item.selected { color: var(--accent); }

/* ── TABLE AREA ───────────────────────────────────────────────────── */
.table-area {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
}

.table-toolbar {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  display: flex; align-items: center; justify-content: center;
  gap: 12px; flex-shrink: 0; position: relative;
}
.result-info {
  font-size: calc(12px * var(--fs));
  color: var(--text2);
  font-family: var(--mono);
}
.result-info b { color: var(--text); font-weight: 600; }

.search-wrap { position: relative; }
.search-icon {
  position: absolute; left: 9px; top: 50%;
  transform: translateY(-50%);
  display: flex; align-items: center;
  pointer-events: none; line-height: 1;
}
.search-input {
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); font-family: var(--mono);
  font-size: calc(12px * var(--fs));
  padding: 6px 28px 6px 30px;
  border-radius: var(--radius); width: 240px;
}
.search-input:focus { outline: none; border-color: var(--accent); background: var(--bg2); }
.search-input::placeholder { color: var(--text3); }
#search-clear-btn:hover { color: var(--text); }

.tscroll { flex: 1; overflow: auto; }
.tscroll::-webkit-scrollbar { width: 6px; height: 6px; }
.tscroll::-webkit-scrollbar-track { background: var(--bg3); }
.tscroll::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

.pf-tscroll { overflow: auto; }
.pf-tscroll::-webkit-scrollbar { width: 6px; height: 6px; }
.pf-tscroll::-webkit-scrollbar-track { background: var(--bg3); }
.pf-tscroll::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

#pf-scroll-mirror::-webkit-scrollbar { height: 8px; }
#pf-scroll-mirror::-webkit-scrollbar-track { background: var(--bg3); }
#pf-scroll-mirror::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
#pf-scroll-mirror::-webkit-scrollbar-thumb:hover { background: var(--text3); }

#mp-scroll-mirror::-webkit-scrollbar { height: 8px; }
#mp-scroll-mirror::-webkit-scrollbar-track { background: var(--bg3); }
#mp-scroll-mirror::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
#mp-scroll-mirror::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── Portfolio row edit-mode toggle ────────────────────────────────── */
/* Locked state: editable fields look like plain text */
#pf-tbody tr .pf-edit {
  background: transparent !important;
  border: 1px solid transparent !important;
  color: var(--text2) !important;
  pointer-events: none;
  box-shadow: none !important;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}
/* Security Name: white always; amber only in edit mode */
#pf-tbody tr input.pf-edit-name {
  color: #ffffff !important;
}
/* Hide number spinners in locked mode */
#pf-tbody tr:not(.pf-editing) input.pf-edit[type="number"]::-webkit-outer-spin-button,
#pf-tbody tr:not(.pf-editing) input.pf-edit[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
}
/* Edit state: restore full input styling in amber */
#pf-tbody tr.pf-editing .pf-edit {
  background: var(--bg4) !important;
  border: 1px solid var(--border2) !important;
  color: var(--accent) !important;
  pointer-events: auto;
  box-shadow: none !important;
  -webkit-appearance: auto;
  -moz-appearance: auto;
  appearance: auto;
}
#pf-tbody tr.pf-editing input.pf-edit[type="number"] {
  -moz-appearance: number-input;
}
#pf-tbody tr.pf-editing input.pf-edit-name {
  color: var(--accent) !important;
}
/* Edit button highlights when row is in edit mode */
#pf-tbody tr.pf-editing .pf-edit-btn {
  color: var(--accent) !important;
}
/* Lock-only elements: visible in locked mode, hidden when editing */
#pf-tbody tr:not(.pf-editing) .pf-lock-only { display: inline-block; }
#pf-tbody tr.pf-editing .pf-lock-only { display: none; }
/* Edit-only elements: hidden in locked mode, visible when editing */
#pf-tbody tr:not(.pf-editing) .pf-edit-only { display: none !important; }
#pf-tbody tr.pf-editing .pf-edit-only { display: inline-block !important; }
/* Highlighted fields: white in locked, amber in edit (Yield, Coupon) */
#pf-tbody tr .pf-edit.pf-edit-hi { color: #ffffff !important; }
#pf-tbody tr.pf-editing .pf-edit.pf-edit-hi { color: var(--accent) !important; }
/* Price field: always amber */
#pf-tbody tr .pf-edit.pf-edit-price { color: var(--accent) !important; }
#pf-tbody tr.pf-editing .pf-edit.pf-edit-price { color: var(--accent) !important; }
/* Universe-sourced price: purple in light mode */
.mp-price-auto { color: var(--amber); }
[data-theme="light"] .mp-price-auto { color: var(--purple); }
[data-theme="light"] #pf-tbody tr:not(.pf-editing) .pf-edit.pf-edit-price.pf-price-auto { color: var(--purple) !important; }

/* Portfolio Analysis table rows */
#pf-table tbody tr { background: var(--bg); }
#pf-table tbody tr:hover { background: var(--bg2); }

/* ── Build Portfolio — freeze-pane: action buttons + Security Name ── */
#pf-table th:nth-child(1),
#pf-table td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 1;
}
#pf-table th:nth-child(2),
#pf-table td:nth-child(2) {
  position: sticky;
  left: 70px;   /* col-0: 48px content + 11px*2 padding */
  z-index: 1;
  border-right: 1px solid var(--border) !important;
  box-shadow: 3px 0 10px rgba(0,0,0,0.45);
}
/* Explicit backgrounds so scrolled content doesn't bleed through */
#pf-table thead th:nth-child(1),
#pf-table thead th:nth-child(2) {
  background: var(--bg3);
}
#pf-table tbody td:nth-child(1),
#pf-table tbody td:nth-child(2) {
  background: var(--bg);
}
#pf-table tbody tr:hover td:nth-child(1),
#pf-table tbody tr:hover td:nth-child(2) {
  background: var(--bg2);
}

/* ── My Portfolio — freeze-pane: action button + Security Name ─────── */
#mp-table th:nth-child(1),
#mp-table td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 1;
}
#mp-table th:nth-child(2),
#mp-table td:nth-child(2) {
  position: sticky;
  left: 68px;   /* col-0: 60px content + 4px*2 padding (inline override) */
  z-index: 1;
  border-right: 1px solid var(--border) !important;
  box-shadow: 3px 0 10px rgba(0,0,0,0.45);
}
/* Explicit left border on first non-sticky column so it's always visible after the freeze pane */
#mp-table th:nth-child(3),
#mp-table td:nth-child(3) {
  border-left: 1px solid var(--border);
}
/* Explicit backgrounds so scrolled content doesn't bleed through */
#mp-table thead th:nth-child(1),
#mp-table thead th:nth-child(2) {
  background: var(--bg3);
}
#mp-table tbody td:nth-child(1),
#mp-table tbody td:nth-child(2) {
  background: var(--bg);
}
#mp-table tbody tr:hover td:nth-child(1),
#mp-table tbody tr:hover td:nth-child(2) {
  background: #282828;  /* matches #mp-table tbody tr:hover */
}
#mp-table tbody tr.mp-totals-row:hover,
#mp-table tbody tr.mp-totals-row:hover td:nth-child(1),
#mp-table tbody tr.mp-totals-row:hover td:nth-child(2) {
  background: var(--bg) !important;
}

/* ── My Portfolio row edit-mode toggle ─────────────────────────────── */
#mp-tbody tr .mp-edit {
  background: transparent !important;
  border: 1px solid transparent !important;
  color: var(--text2) !important;
  pointer-events: none;
  box-shadow: none !important;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}
#mp-tbody tr:not(.mp-editing) input.mp-edit[type="number"]::-webkit-outer-spin-button,
#mp-tbody tr:not(.mp-editing) input.mp-edit[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
}
#mp-tbody tr.mp-editing .mp-edit {
  background: var(--bg4) !important;
  border: 1px solid var(--border2) !important;
  color: var(--accent) !important;
  font-family: var(--mono) !important;
  font-size: calc(11px * var(--fs)) !important;
  pointer-events: auto;
  box-shadow: none !important;
  -webkit-appearance: auto;
  -moz-appearance: auto;
  appearance: auto;
}
#mp-tbody tr.mp-editing input.mp-edit[type="number"] {
  -moz-appearance: number-input;
}
#mp-tbody tr.mp-editing .mp-edit-btn { color: var(--accent) !important; }
#mp-tbody tr:not(.mp-editing) .mp-lock-only { display: inline-block; }
#mp-tbody tr.mp-editing .mp-lock-only { display: none; }
#mp-tbody tr:not(.mp-editing) .mp-edit-only { display: none !important; }
#mp-tbody tr.mp-editing .mp-edit-only { display: inline-block !important; }
#mp-tbody tr.mp-editing div.mp-edit-only { display: inline-flex !important; flex-direction: column; gap: 3px; }
#mp-tbody tr .mp-edit.mp-edit-hi { color: #ffffff !important; }
#mp-tbody tr.mp-editing .mp-edit.mp-edit-hi { color: var(--accent) !important; }
#mp-tbody tr.mp-editing .mp-edit.mp-edit-price { color: var(--amber) !important; font-family: var(--mono) !important; font-size: calc(11px * var(--fs)) !important; }
[data-theme="light"] #mp-tbody tr.mp-editing .mp-edit.mp-edit-price { color: var(--text) !important; }

/* My Portfolio table rows */
#mp-table tbody tr { background: var(--bg); }
#mp-table tbody tr:hover { background: var(--bg2); }

/* My Portfolio table */
#mp-table thead th {
  padding: 9px 11px; text-align: left;
  font-size: calc(10px * var(--fs)); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text3); white-space: nowrap;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  cursor: pointer; user-select: none;
}
#mp-table thead th:hover { color: var(--text2); background: var(--bg4); }
#mp-table tbody tr { border-bottom: 1px solid var(--border); }
#mp-table tbody tr:hover { background: #282828; }
[data-theme="light"] #mp-table tbody tr:hover { background: #e8e8e8; }
[data-theme="light"] #mp-table tbody tr:hover td:nth-child(1),
[data-theme="light"] #mp-table tbody tr:hover td:nth-child(2) { background: #e8e8e8; }
#mp-table td {
  padding: 9px 11px;
  font-size: calc(12px * var(--fs));
  white-space: nowrap;
  vertical-align: middle;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

/* Dark mode: Build Portfolio + My Portfolio tables — no vertical gridlines (freeze-pane divider kept) */
[data-theme="dark"] #pf-table th,
[data-theme="dark"] #pf-table td,
[data-theme="dark"] #mp-table th,
[data-theme="dark"] #mp-table td { border-right: none; }
[data-theme="dark"] #mp-table th:nth-child(3),
[data-theme="dark"] #mp-table td:nth-child(3) { border-left: none; }

/* ── BOND TABLE ───────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; min-width: 1280px; }
thead { position: sticky; top: 0; z-index: 10; }
th {
  padding: 9px 11px; text-align: left;
  font-size: calc(10px * var(--fs)); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text3); white-space: nowrap;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  cursor: pointer; user-select: none;
}
th:first-child { border-left: none; }
th:hover { color: var(--text2); background: var(--bg4); }
#bond-table th { position: sticky; top: 0; z-index: 10; border-right: none; border-top: none; border-bottom: none; box-shadow: inset 0 1px 0 var(--border), inset 0 -1px 0 var(--border); }
#bond-table td { border-right: none; }
th.sort-asc::after { content: ' ↑'; color: var(--accent); }
th.sort-desc::after { content: ' ↓'; color: var(--accent); }

tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.1s;
}
tbody tr:hover { background: #282828; }
[data-theme="light"] tbody tr:hover { background: #d4d4d4; }
tbody tr.row-selected { background: #111; }
tbody tr.detail-tr { background: var(--bg3) !important; cursor: default; }
tbody tr.detail-tr:hover { background: var(--bg3) !important; }
tbody tr.loading-row { border-bottom: none; cursor: default; }
#bond-table:has(.loading-row) thead { display: none; }

/* ── Header loading wheel ──────────────────────────────────────────── */
#bond-load {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 18px; height: 18px;
  border: 2px solid #3a3a3a;
  border-top-color: #666;
  border-radius: 50%;
  animation: bond-spin 0.75s linear infinite;
  pointer-events: none;
}
@keyframes bond-spin { to { transform: translateX(-50%) rotate(360deg); } }

#ai-search-spinner {
  width: 14px; height: 14px;
  border: 2px solid #3a3a3a;
  border-top-color: #666;
  border-radius: 50%;
  animation: ai-spin 0.75s linear infinite;
  flex-shrink: 0;
  align-self: center;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }

td {
  padding: 9px 11px; font-size: calc(12px * var(--fs));
  white-space: nowrap; vertical-align: middle;
  border-right: 1px solid var(--border);
}
td:first-child { border-left: none; }

.sn { font-weight: 500; color: var(--text); max-width: 350px; overflow: hidden; text-overflow: ellipsis; }
.in-sm { font-size: calc(11px * var(--fs)); color: var(--text3); margin-top: 1px; }
.mono-cell { font-family: var(--mono); font-size: calc(11px * var(--fs)); }

.rbadge {
  display: inline-block; padding: 2px 7px; border-radius: 3px;
  font-family: var(--mono); font-size: calc(11px * var(--fs)); font-weight: 600;
}
.r-aaa { background: #0e2018; color: #4caf7d; }
.r-aa  { background: #0e2018; color: #6bcf9a; }
.r-a   { background: #16220f; color: #8fd17a; }
.r-bbb { background: #222010; color: #d4a843; }
.r-hy  { background: #220d0d; color: #ff5252; }
.r-nr  { background: #222222; color: #5c5c5a; }
/* Light theme: rating badges */
[data-theme="light"] .r-aaa { background: #d4f0e4; color: #1a6b44; }
[data-theme="light"] .r-aa  { background: #d4f0e4; color: #1e7a50; }
[data-theme="light"] .r-a   { background: #e6f0d4; color: #4f7a1e; }
[data-theme="light"] .r-bbb { background: #fef3cd; color: #7a5c00; }
[data-theme="light"] .r-hy  { background: #fde8e8; color: #8b1030; }
[data-theme="light"] .r-nr  { background: #e8e8e8; color: #606060; }

.yield-c { font-family: var(--mono); color: var(--green); font-weight: 600; font-size: calc(12px * var(--fs)); }
.price-c { font-family: var(--mono); color: var(--text); font-size: calc(12px * var(--fs)); }
.spread-c { font-family: var(--mono); color: var(--amber); font-size: calc(11px * var(--fs)); }
.mat-c { font-family: var(--mono); color: var(--text2); font-size: calc(11px * var(--fs)); }

.type-chip {
  display: inline-block; padding: 2px 7px; border-radius: 3px;
  font-size: calc(10px * var(--fs)); font-weight: 500;
  background: var(--bg4); color: var(--text2);
}
.regs-y { color: var(--green); font-family: var(--mono); font-size: calc(11px * var(--fs)); font-weight: 600; }
.regs-n { color: var(--text3); font-family: var(--mono); font-size: calc(11px * var(--fs)); }

.sen-sp  { color: var(--amber); font-size: calc(11px * var(--fs)); }
.sen-sub { color: #d48843; font-size: calc(11px * var(--fs)); }
.sen-jr  { color: var(--red); font-size: calc(11px * var(--fs)); }
.sen-oth { color: var(--text2); font-size: calc(11px * var(--fs)); }

.star-btn {
  background: none; border: none; cursor: pointer;
  font-size: 17px; padding: 2px 3px; color: var(--text3);
  transition: all 0.15s; line-height: 1;
}
.star-btn:hover { color: var(--gold); transform: scale(1.2); }
.star-btn.on { color: var(--gold); }

/* ── DETAIL PANEL ─────────────────────────────────────────────────── */

.dp-overview-label { font-size: calc(11px * var(--fs)); font-weight: 600; letter-spacing: 0.02em; color: var(--text2); margin-bottom: 6px; }
.dp-overview p { font-size: calc(13px * var(--fs)); color: var(--text2); line-height: 1.65; margin-bottom: 5px; }
.dp-overview p:last-child { margin-bottom: 0; }


.dp-section-title {
  font-size: calc(11px * var(--fs)); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--text2); margin-bottom: 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border2);
}

.id-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.id-chip {
  background: var(--bg4); border: 1px solid var(--border);
  border-radius: 3px; padding: 3px 9px;
  font-family: var(--mono); font-size: calc(11px * var(--fs)); color: var(--text2);
}
.id-chip span { color: var(--text3); margin-right: 4px; }

.ai-box {
  background: rgba(255,82,82,0.05);
  border-radius: var(--radius-lg); padding: 14px 16px;
}
.ai-box-hdr { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.ai-lbl { font-size: calc(11px * var(--fs)); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--red); }
.ai-badge-chip { font-size: calc(10px * var(--fs)); background: rgba(167,139,250,0.12); color: #a78bfa; padding: 1px 7px; border-radius: 8px; font-family: var(--mono); font-weight: 600; }
.ai-run-btn { display: inline-block; padding: 6px 16px; background: rgba(255,82,82,0.12); color: var(--red); border: 1px solid rgba(255,82,82,0.35); border-radius: var(--radius); font-family: var(--sans); font-size: calc(12px * var(--fs)); font-weight: 600; cursor: pointer; transition: all 0.15s; }
.ai-run-btn:hover { background: rgba(255,82,82,0.24); }
/* Bond Analysis AI card — purple theme */
#sim-ai-box.ai-box { background: rgba(167,139,250,0.06); border-color: rgba(167,139,250,0.4); }
#sim-ai-box .ai-lbl { color: #a78bfa; }
#sim-ai-box .ai-badge-chip { background: rgba(167,139,250,0.12); color: #a78bfa; }
#sim-ai-box .ai-run-btn { background: rgba(167,139,250,0.12); color: #a78bfa; border: 1px solid rgba(167,139,250,0.4); }
#sim-ai-box .ai-run-btn:hover { background: rgba(167,139,250,0.24); }
/* My Portfolio AI card — purple theme */
#mp-ai-card.ai-box { background: rgba(167,139,250,0.06); border-color: rgba(167,139,250,0.4); }
#mp-ai-card .ai-lbl { color: #a78bfa; }
#mp-ai-card .ai-badge-chip { background: rgba(167,139,250,0.12); color: #a78bfa; }
#mp-ai-card .ai-run-btn { background: rgba(167,139,250,0.12); color: #a78bfa; border: 1px solid rgba(167,139,250,0.4); }
#mp-ai-card .ai-run-btn:hover { background: rgba(167,139,250,0.24); }
/* Build Portfolio AI card — purple theme */
#pf-ai-card.ai-box { background: rgba(167,139,250,0.06); border-color: rgba(167,139,250,0.4); }
#pf-ai-card .ai-lbl { color: #a78bfa; }
#pf-ai-card .ai-badge-chip { background: rgba(167,139,250,0.12); color: #a78bfa; }
#pf-ai-card .ai-run-btn { background: rgba(167,139,250,0.12); color: #a78bfa; border: 1px solid rgba(167,139,250,0.4); }
#pf-ai-card .ai-run-btn:hover { background: rgba(167,139,250,0.24); }
/* Light mode: Credit & Valuation Analysis card — light purple theme */
[data-theme="light"] #sim-ai-box.ai-box {
  background: rgba(167,139,250,0.10);
  border: 1px solid rgba(167,139,250,0.35);
}
/* Light mode: portfolio AI cards — match Credit & Valuation Analysis light purple theme */
[data-theme="light"] #mp-ai-card.ai-box,
[data-theme="light"] #pf-ai-card.ai-box {
  background: rgba(167,139,250,0.10);
  border: 1px solid rgba(167,139,250,0.35);
}
.ai-loading { font-size: calc(12px * var(--fs)); color: var(--text3); font-style: italic; animation: blink 1s infinite; margin-top: 14px; }
@keyframes blink { 0%,100%{opacity:1}50%{opacity:0.3} }
.risk-ul { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.risk-ul li { font-size: calc(13px * var(--fs)); color: var(--text2); line-height: 1.6; padding-left: 16px; position: relative; }
.risk-ul li::before { content: '•'; position: absolute; left: 0; color: var(--text2); top: 2px; font-size: 14px; }

/* ── VALUE SIGNAL CHIPS ─────────────────────────────────────────── */
.val-chip-cell { text-align: center; width: 64px; }
.val-chip {
  display: inline-block; padding: 2px 8px; border-radius: 3px;
  font-family: var(--mono); font-size: calc(10px * var(--fs)); font-weight: 700;
  letter-spacing: 0.04em; cursor: default; white-space: nowrap;
}
.val-cheap { background: rgba(42,139,102,0.18); color: var(--green); }
.val-rich  { background: rgba(203,40,88,0.14);  color: var(--red); }
.val-fair  { background: rgba(212,168,67,0.18);  color: var(--accent); }


/* ── BOND INTELLIGENCE CARD ─────────────────────────────────────── */
.bond-intel-card {
  background: var(--bg3); border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius); padding: 14px 16px 12px; margin-bottom: 14px;
}
.bond-intel-hdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.bond-intel-title {
  font-size: calc(11px * var(--fs)); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--accent);
}
.bond-intel-badge {
  font-size: calc(10px * var(--fs)); font-family: var(--mono); font-weight: 700;
  padding: 2px 10px; border-radius: 8px;
}
.bi-cheap { background: rgba(42,139,102,0.18); color: var(--green); border: 1px solid rgba(42,139,102,0.35); }
.bi-rich  { background: rgba(203,40,88,0.14);  color: var(--red);   border: 1px solid rgba(203,40,88,0.3); }
.bi-fair  { background: rgba(255,255,255,0.06); color: var(--text3); border: 1px solid rgba(255,255,255,0.1); }
[data-theme="light"] .bi-fair { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.10); }
.bi-row {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.05);
}
.bi-row:last-child { border-bottom: none; padding-bottom: 0; }
.bi-label { font-size: calc(11px * var(--fs)); color: var(--text3); flex: 0 0 140px; }
.bi-value { font-family: var(--mono); font-size: calc(12px * var(--fs)); color: var(--text2); flex: 1; text-align: right; }
.bi-value.hi  { color: var(--green); }
.bi-value.lo  { color: var(--red); }
.bi-value.mid { color: var(--text2); }
.bi-note { font-size: calc(10px * var(--fs)); color: var(--text3); margin-left: 8px; }

/* ── STARRED PAGE ───────────────────────────────────────────────── */
.starred-page {
  flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0;
}
.sl-header {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; flex-shrink: 0;
  background: var(--bg2); border-bottom: 1px solid var(--border);
}
.sl-title { font-family: var(--sans); font-weight: 600; font-size: calc(13px * var(--fs)); color: var(--text); text-transform: uppercase; letter-spacing: 0.05em; }
.sl-count { font-family: var(--mono); font-size: calc(12px * var(--fs)); color: var(--text3); }
.sl-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
}
.sl-empty-star { font-size: 36px; opacity: 0.2; }
.sl-empty-msg { font-size: calc(13px * var(--fs)); color: var(--text3); }
#sl-content { flex: 1; flex-direction: column; min-height: 0; }
.sl-table-wrap { flex: 1; overflow: auto; min-height: 0; }
.sl-table-wrap::-webkit-scrollbar { width: 6px; height: 6px; }
.sl-table-wrap::-webkit-scrollbar-track { background: var(--bg3); }
.sl-table-wrap::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
#sl-table th {
  position: sticky; top: 0; z-index: 10;
  border-right: none; border-top: none; border-bottom: none;
  box-shadow: inset 0 1px 0 var(--border), inset 0 -1px 0 var(--border);
}
#sl-table td { border-right: none; }

/* ── LIGHT THEME OVERRIDES ───────────────────────────────────────── */
/* Table rows: visible grey instead of near-white */
[data-theme="light"] tbody tr { background: var(--bg2); }
[data-theme="light"] #pf-table tbody tr { background: #fcfcfc; }
[data-theme="light"] #pf-table tbody td:nth-child(1),
[data-theme="light"] #pf-table tbody td:nth-child(2) { background: #fcfcfc; }
[data-theme="light"] #mp-table tbody tr { background: #fcfcfc; }
[data-theme="light"] #mp-table tbody td:nth-child(1),
[data-theme="light"] #mp-table tbody td:nth-child(2) { background: #fcfcfc; }
/* Totals row hardcodes background:var(--bg) inline (js/myportfolio.js) — override for light mode */
[data-theme="light"] #mp-table tbody tr.mp-totals-row { background: #fcfcfc !important; }
/* Editing row: row fill stays e8e8e8; only the editable input fields turn fcfcfc */
[data-theme="light"] #pf-tbody tr.pf-editing .pf-edit { background: #fcfcfc !important; }
[data-theme="light"] #mp-tbody tr.mp-editing .mp-edit { background: #fcfcfc !important; }
/* Starred page: flat light background matching screener */
[data-theme="light"] .starred-page { background: #fcfcfc; }
[data-theme="light"] .sl-header { background: #fcfcfc; border-bottom: none; }
[data-theme="light"] #sl-table th { background: #fcfcfc; }
[data-theme="light"] #sl-table tbody tr { background: #fcfcfc; }
[data-theme="light"] #sl-table tbody tr:hover { background: #e8e8e8; }
[data-theme="light"] #sl-table tbody tr.row-selected { background: #e8e8e8; }
[data-theme="light"] #sl-table tbody tr.detail-tr { background: #fcfcfc !important; }
/* Filter panel inputs: #d4d4d4 fill, subtle border one shade darker */
[data-theme="light"] .mini-input { background: var(--bg4); border: 1px solid var(--bg5); }
[data-theme="light"] .mini-input:focus { border: 1px solid var(--accent); }
[data-theme="dark"] .search-input { border-color: var(--border); }
[data-theme="light"] .search-input { background: #e2e2e2; border: none; }
[data-theme="light"] .search-input:focus { border: 1px solid #aaaaaa; }
/* Filter field header labels: darker text */
[data-theme="light"] .filter-top-label { color: var(--text2); }
/* Filter grouping section headers and checkbox labels: black in light mode */
[data-theme="light"] .fg-label,
[data-theme="light"] .fg-arrow,
[data-theme="light"] .cb-row label { color: var(--text); }
/* Filter hover: one step darker in light mode */
[data-theme="light"] .fg-hdr:hover,
[data-theme="light"] .cb-row:hover { background: var(--bg4); }
/* Light mode: --text3 elements 🡢  --text2 (too light on light backgrounds) */
[data-theme="light"] .basket-cb-desc { color: #909090; }
[data-theme="light"] .mini-sep { color: var(--text2); }
[data-theme="light"] .search-dd-input::placeholder { color: rgba(26,26,26,0.45); }
[data-theme="light"] .search-input::placeholder { color: rgba(26,26,26,0.45); }
[data-theme="light"] th { color: var(--text2); }
[data-theme="light"] #mp-table thead th { color: var(--text2); }
[data-theme="light"] .in-sm { color: var(--text2); }
[data-theme="light"] .regs-n { color: var(--text2); }
[data-theme="light"] .star-btn { color: var(--text2); }
[data-theme="light"] .star-btn.on { color: var(--amber); }
[data-theme="light"] .star-btn:hover { color: var(--amber); }
[data-theme="light"] .id-chip span { color: var(--text2); }
[data-theme="light"] .ai-loading { color: var(--text2); }
[data-theme="light"] .price-c { color: #7c3aed !important; }
[data-theme="light"] .tbl-ytm,
[data-theme="light"] .tbl-cpn { color: #1a1a1a !important; }
[data-theme="light"] .val-cheap { background: #d4f0e4; color: #1e7a50; }
[data-theme="light"] .val-fair { background: #fef3c7; color: #d97706; }
[data-theme="light"] .bi-fair { color: var(--text2); }
[data-theme="light"] .bi-label { color: var(--text2); }
[data-theme="light"] .bi-note { color: var(--text2); }
[data-theme="light"] .sl-count { color: var(--text2); }
[data-theme="light"] .sl-empty-msg { color: var(--text2); }
[data-theme="light"] #screen-status { color: var(--text2) !important; }
[data-theme="light"] .no-results td { color: var(--text2) !important; }
[data-theme="light"] .bond-issuer { color: var(--text2) !important; }
[data-theme="light"] .ai-score-num { color: var(--text2) !important; }
/* Light mode: screener expanded detail panel — all values dark grey (overrides yield-c green, spread-c amber, dirty-price inline amber) */
[data-theme="light"] .detail-tr .dp-v { color: #000 !important; }
/* Light mode: Build Portfolio accrued interest and income accrued columns → dark grey */
[data-theme="light"] [id^="pf-accrint-"],
[data-theme="light"] [id^="pf-incinc-"],
[data-theme="light"] #pf-total-accrint,
[data-theme="light"] #pf-total-incinc { color: var(--text2) !important; }
/* Light mode: Market Value, Weight, Yield, Coupon columns → dark grey */
[data-theme="light"] [id^="pf-mktval-"],
[data-theme="light"] [id^="pf-wgt-"],
[data-theme="light"] [id^="pf-ytm-locked-"],
[data-theme="light"] [id^="pf-coupon-locked-"],
[data-theme="light"] #pf-total-mktval,
[data-theme="light"] #pf-total-wgt,
[data-theme="light"] #pf-total-ytm,
[data-theme="light"] #pf-total-coupon { color: var(--text2) !important; }
[data-theme="light"] .mp-neutral { color: var(--text2) !important; }
/* Light mode: Build Portfolio totals row — all dark grey except green coupon columns */
[data-theme="light"] #pf-total-row td { color: var(--text2) !important; }
[data-theme="light"] #pf-total-row #pf-total-ytd,
[data-theme="light"] #pf-total-row #pf-total-remaining,
[data-theme="light"] #pf-total-row #pf-total-cy,
[data-theme="light"] #pf-total-row #pf-total-ny,
[data-theme="light"] #pf-total-row #pf-total-couponmat { color: var(--green) !important; }
/* Light mode: Build Portfolio & My Portfolio totals rows — light grey background instead of white */
[data-theme="light"] #pf-table tbody tr#pf-total-row,
[data-theme="light"] #pf-table tbody tr#pf-total-row td:nth-child(1),
[data-theme="light"] #pf-table tbody tr#pf-total-row td:nth-child(2) { background: var(--bg3) !important; }
[data-theme="light"] #mp-table tbody tr.mp-totals-row,
[data-theme="light"] #mp-table tbody tr.mp-totals-row td:nth-child(1),
[data-theme="light"] #mp-table tbody tr.mp-totals-row td:nth-child(2),
[data-theme="light"] #mp-table tbody tr.mp-totals-row:hover,
[data-theme="light"] #mp-table tbody tr.mp-totals-row:hover td:nth-child(1),
[data-theme="light"] #mp-table tbody tr.mp-totals-row:hover td:nth-child(2) { background: var(--bg3) !important; }
/* Light mode: Add to Portfolio entry-type toggle (Bond/Fund/Cash) — lighter border for less contrast */
[data-theme="light"] .entry-type-toggle { border-color: var(--border) !important; }
/* Light mode: Nom Qty/Amt locked values stay soft grey */
[data-theme="light"] [id^="pf-notional-locked-"],
[data-theme="light"] [id^="mp-facevalue-locked-"] { color: var(--text2); }
/* Light mode: Security Name locked values stay black */
[data-theme="light"] [id^="pf-secname-locked-"],
[data-theme="light"] [id^="mp-secname-locked-"] { color: #1a1a1a !important; }
/* Light mode: metric tile values dark grey by default; keep green and JS-set performance colors */
[data-theme="light"] .metric-card-val { color: #262626; }
[data-theme="light"] .metric-card-val.green { color: var(--green) !important; }
/* Accrued and Coupons YTD + Accrued tiles stay at softer grey */
[data-theme="light"] #mp-s-accrint,
[data-theme="light"] #mp-s-ytdaccrint,
[data-theme="light"] #pf-s-accrint,
[data-theme="light"] #pf-s-incinc { color: var(--text2) !important; }
/* Bond Analysis accrued interest metric tile → match Build Portfolio (text2) */
[data-theme="light"] #m-accrued { color: var(--text2) !important; }
/* Override JS-set var(--text) on yield-at-cost tile in light mode */
[data-theme="light"] #mp-s-yieldatcost { color: var(--text2) !important; }
/* Bond Analysis "held to maturity" label → dark text in light mode */
[data-theme="light"] .sim-htv-label { color: #262626 !important; }
/* Bond Analysis dirty price values → purple in light mode */
[data-theme="light"] #dirty-price-val { color: var(--purple) !important; }
[data-theme="light"] .sim-dirty-price-val { color: var(--purple) !important; }
/* Bond Analysis CF schedule: coupon type pill → purple in light mode */
[data-theme="light"] .sim-cf-coupon-pill { background: rgba(124,58,237,0.1) !important; color: var(--purple) !important; }
/* Dark mode: same border rules as light mode below — filter panel, investment box, table toolbar all flat */
[data-theme="dark"] .filter-panel { border-right: none; }
[data-theme="dark"] .filter-top { border-bottom: none; }
[data-theme="dark"] .filter-invest { border-bottom: none !important; }
[data-theme="dark"] .table-toolbar { border-bottom: none; }
/* Dark mode: table's dark background should extend up through the yield bar + toolbar to the navbar, not stop at a lighter bg2 band */
[data-theme="dark"] #page-bonds .table-area { background: var(--bg); }
[data-theme="dark"] .yield-bar { background: var(--bg); }
[data-theme="dark"] .table-toolbar { background: var(--bg); }
[data-theme="dark"] #bond-table th { background: var(--bg); }
/* Dark mode: starred page — same flat dark background as screener, no card chrome */
[data-theme="dark"] .starred-page { background: var(--bg); }
[data-theme="dark"] .sl-header { background: var(--bg); border-bottom: none; }
[data-theme="dark"] #sl-table th { background: var(--bg); }
/* Filter panel: no right border in light mode */
[data-theme="light"] .filter-panel { border-right: none; }
/* Currency & Investment Amount section: no top/bottom borders, slightly darker bg */
[data-theme="light"] .filter-top { border-bottom: none; }
[data-theme="light"] .filter-invest { border-bottom: none !important; background: var(--bg4) !important; }
[data-theme="light"] #filter-ccy:focus,
[data-theme="light"] #filter-amount:focus { outline: none; border-color: var(--accent) !important; }
#filter-ccy:focus,
#filter-amount:focus { outline: none; border-color: var(--accent) !important; }
[data-theme="light"] .filter-invest > div:first-child,
[data-theme="light"] .filter-invest > div:last-child { color: var(--text2) !important; }
/* Bond screener table area: flat white background */
[data-theme="light"] #page-bonds .table-area { background: #fcfcfc; }
[data-theme="light"] .yield-bar { background: #fcfcfc; }
[data-theme="light"] .yield-bar-label,
[data-theme="light"] .yield-item-tenor,
[data-theme="light"] .yield-as-of { color: var(--text2); }
[data-theme="light"] .table-toolbar { background: #fcfcfc; border-bottom: none; }
[data-theme="light"] #bond-table th { background: #fcfcfc; }
[data-theme="light"] #bond-table tbody tr { background: #fcfcfc; }
[data-theme="light"] #bond-table tbody tr:hover { background: #e8e8e8; }
[data-theme="light"] #bond-table tbody tr.row-selected { background: #e8e8e8; }
[data-theme="light"] #bond-table tbody tr.detail-tr { background: #fcfcfc !important; }
/* Bond detail panel */
[data-theme="light"] .detail-panel { background: #e0e0e0; border-top-color: var(--purple); }
[data-theme="light"] .dp-bond-name { color: var(--text) !important; }
[data-theme="light"] .dp-sim-btn { color: #fff !important; }
[data-theme="light"] .detail-panel .dp-k { color: var(--text2); }
