:root {
    --red: #E82127;
    --red-dark: #c41a1f;
    --black: #181B21;
    --white: #FFFFFF;
    --dark-gray: #212121;
    --mid-gray: #717074;
    --silver-gray: #818181;
    --light-gray: #C9CBCC;
    --off-white: #F2F2F2;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'ITC Clearface', 'Clearface', serif;
    background-color: var(--off-white);
    color: var(--black);
    min-height: 100vh;
    line-height: 1.5;
}

/* ── Header ── */

.header {
    background-color: var(--white);
    border-bottom: 1px solid var(--light-gray);
    height: 40px;
    display: flex;
    align-items: center;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--red);
    text-decoration: none;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-link {
    color: var(--mid-gray);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: color 0.15s;
}

.nav-link:hover {
    color: var(--black);
}

.nav-link--button {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    padding: 0;
}

.nav-link--auth {
    padding: 0.3rem 0.85rem;
    border: 1.5px solid var(--light-gray);
    border-radius: 6px;
    color: var(--mid-gray);
}

.nav-link--auth:hover {
    border-color: var(--red);
    color: var(--red);
}

.logout-form {
    display: inline;
}

/* ── Main ── */

.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* ── Page header ── */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--black);
}

/* ── Table ── */

.table-wrapper {
    overflow-x: auto;
    background: var(--white);
    border-radius: 8px;
    border: 1px solid var(--light-gray);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

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

.table thead {
    background: var(--off-white);
}

.table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 700;
    color: var(--mid-gray);
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.07em;
    border-bottom: 1px solid var(--light-gray);
    white-space: nowrap;
}

.table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--light-gray);
    color: var(--dark-gray);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover td {
    background: #fef2f2;
    color: var(--black);
}

.table-empty {
    text-align: center;
    color: var(--mid-gray);
    padding: 3rem 1rem !important;
    font-size: 0.95rem;
}

.grand-total-label {
    font-weight: 600;
    border-top: 2px solid var(--light-gray);
    padding-top: 0.6rem;
}

.grand-total-value {
    font-weight: 600;
    border-top: 2px solid var(--light-gray);
    padding-top: 0.6rem;
}

/* ── Sticky columns (Name, Ticker — cols 1–2) ── */

.table th:nth-child(-n+2),
.table td:nth-child(-n+2) {
    position: sticky;
    z-index: 1;
}

.table th:nth-child(1), .table td:nth-child(1) { left: 0;     min-width: 180px; }
.table th:nth-child(2), .table td:nth-child(2) { left: 180px; min-width: 80px;  }
.table th:nth-child(3), .table td:nth-child(3) { min-width: 90px; }
.table th:nth-child(4), .table td:nth-child(4) { min-width: 90px; }

.table thead th:nth-child(-n+2)          { background: var(--off-white); }
.table tbody td:nth-child(-n+2)          { background: var(--white); }
.table tbody tr:hover td:nth-child(-n+2) { background: #fef2f2; }

.table th:nth-child(2),
.table td:nth-child(2) {
    border-right: 2px solid var(--light-gray);
    box-shadow: 2px 0 4px rgba(0,0,0,0.06);
}

/* ── Top scrollbar mirror ── */
.scroll-mirror {
    overflow-x: auto;
    overflow-y: hidden;
    height: 12px;
    border-radius: 8px 8px 0 0;
}
.scroll-mirror-inner {
    height: 1px;
}

/* ── Numeric columns (market cap, revenue, net income, EPS, price) ── */

th.market-cap-col,
td.market-cap-col,
th.num-col,
td.num-col {
    text-align: right;
    min-width: 90px;
    font-variant-numeric: tabular-nums;
}

/* ── Auth ── */

.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 60px);
    padding: 2rem;
}

.auth-card {
    background: var(--white);
    border: 1px solid var(--light-gray);
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.auth-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--red);
    text-align: center;
    margin-bottom: 2rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--dark-gray);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-group input {
    background: var(--off-white);
    border: 1px solid var(--light-gray);
    border-radius: 6px;
    padding: 0.65rem 0.85rem;
    color: var(--black);
    font-family: inherit;
    font-size: 0.95rem;
    width: 100%;
    transition: border-color 0.15s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--red);
    background: var(--white);
}

.form-errors ul {
    list-style: none;
}

.form-errors {
    color: var(--red);
    font-size: 0.82rem;
    margin-top: 0.2rem;
}

.btn {
    padding: 0.75rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s;
    margin-top: 0.4rem;
    width: 100%;
}

.btn--primary {
    background: var(--red);
    color: var(--white);
}

.btn--primary:hover {
    background: var(--red-dark);
}

/* ── Pager ── */

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1.25rem;
    font-size: 0.875rem;
}

.pager__info {
    color: var(--mid-gray);
    font-weight: 500;
}

.pager__controls {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.pager__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.4rem;
    border-radius: 5px;
    font-weight: 600;
    font-size: 0.875rem;
    text-decoration: none;
    color: var(--dark-gray);
    background: var(--white);
    border: 1px solid var(--light-gray);
    transition: border-color 0.15s, color 0.15s;
}

.pager__btn:hover {
    border-color: var(--red);
    color: var(--red);
}

.pager__btn--active {
    background: var(--red);
    border-color: var(--red);
    color: var(--white);
}

.pager__btn--disabled {
    color: var(--light-gray);
    border-color: var(--light-gray);
    cursor: default;
}

.pager__ellipsis {
    color: var(--mid-gray);
    padding: 0 0.2rem;
}

/* ── Sortable column headers ── */

.sort-link {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    transition: color 0.15s;
}

.sort-link:hover {
    color: var(--red);
}

.sort-link--active {
    color: var(--red);
}

.sort-arrow {
    font-size: 0.8em;
}

/* ── Identifiers cell ── */

.identifiers-cell {
    white-space: nowrap;
}

.identifier-line {
    display: block;
    font-size: 0.66rem;
    line-height: 1.7;
}

.identifier-label {
    display: inline-block;
    width: 3.2rem;
    color: var(--mid-gray);
    font-weight: 600;
    font-size: 0.58rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── AI Layer badges ── */

.table th.ai-col-header {
    text-align: center;
    cursor: default;
}

/* ── AI Stack tooltip ── */
.ai-stack-tooltip {
    display: none;
    position: fixed;
    z-index: 300;
    background: var(--white);
    border: 1px solid var(--light-gray);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.13);
    padding: 0.7rem 0.9rem;
    width: 220px;
    pointer-events: none;
}
.ai-stack-tooltip--visible { display: block; }

.ai-stack-tooltip__title {
    display: block;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--mid-gray);
    margin-bottom: 0.5rem;
}
.ai-stack-tooltip__list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.ai-stack-tooltip__list li {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.78rem;
    color: var(--dark-gray);
}

.ai-col-group {
    display: inline-flex;
    gap: 0.25rem;
    flex-wrap: nowrap;
}

.ai-badge {
    display: inline-block;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    font-size: 0.864rem;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.03em;
}

.ai-badge--energy         { background: #E82127; color: #fff; }
.ai-badge--chips          { background: #C41A1F; color: #fff; }
.ai-badge--infra          { background: #212121; color: #fff; }
.ai-badge--models         { background: #717074; color: #fff; }
.ai-badge--app            { background: rgba(232,33,39,0.12); color: #C41A1F; border: 1px solid rgba(232,33,39,0.35); }
.ai-badge--hidden         { visibility: hidden; }

/* ── Country flag ── */

.country-cell {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.country-flag {
    flex-shrink: 0;
    width: 24px;
    height: 16px;
    object-fit: cover;
    border-radius: 2px;
    border: 1px solid var(--light-gray);
}

/* ── Layer filter ── */

.layer-filter {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.layer-filter__label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--mid-gray);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-right: 0.15rem;
}

.layer-filter__pill {
    display: inline-block;
    padding: 0.28rem 0.8rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: 0.03em;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
    border: 1.5px solid transparent;
    cursor: pointer;
}

.layer-filter__pill--all {
    background: var(--white);
    border-color: var(--light-gray);
    color: var(--mid-gray);
}
.layer-filter__pill--all:hover { border-color: var(--dark-gray); color: var(--dark-gray); }
.layer-filter__pill--all.is-active { background: var(--dark-gray); border-color: var(--dark-gray); color: var(--white); box-shadow: 0 1px 4px rgba(0,0,0,0.18); }

.layer-filter__pill--energy  { background: rgba(232,33,39,0.07);  border-color: #E82127; color: #E82127; }
.layer-filter__pill--chips   { background: rgba(196,26,31,0.07);  border-color: #C41A1F; color: #C41A1F; }
.layer-filter__pill--infra   { background: rgba(33,33,33,0.05);   border-color: #212121; color: #212121; }
.layer-filter__pill--models  { background: rgba(113,112,116,0.08);border-color: #717074; color: #717074; }
.layer-filter__pill--app     { background: rgba(232,33,39,0.07);  border-color: rgba(232,33,39,0.4); color: #C41A1F; }

.layer-filter__pill--energy:hover,  .layer-filter__pill--energy.is-active  { background: #E82127; color: #fff; border-color: #E82127; box-shadow: 0 1px 6px rgba(232,33,39,0.35); }
.layer-filter__pill--chips:hover,   .layer-filter__pill--chips.is-active   { background: #C41A1F; color: #fff; border-color: #C41A1F; box-shadow: 0 1px 6px rgba(196,26,31,0.35); }
.layer-filter__pill--infra:hover,   .layer-filter__pill--infra.is-active   { background: #212121; color: #fff; border-color: #212121; box-shadow: 0 1px 6px rgba(0,0,0,0.25); }
.layer-filter__pill--models:hover,  .layer-filter__pill--models.is-active  { background: #717074; color: #fff; border-color: #717074; box-shadow: 0 1px 6px rgba(113,112,116,0.35); }
.layer-filter__pill--app:hover,     .layer-filter__pill--app.is-active     { background: rgba(232,33,39,0.18); border-color: #C41A1F; box-shadow: 0 1px 4px rgba(196,26,31,0.2); }

.layer-filter__pill--not-ai     { background: var(--off-white);       border-color: var(--light-gray);     color: var(--silver-gray); }
.layer-filter__pill--not-ai:hover, .layer-filter__pill--not-ai.is-active { background: var(--silver-gray); border-color: var(--silver-gray); color: #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.18); }

.layer-filter__pill--listed     { background: rgba(39,174,96,0.08);  border-color: rgba(39,174,96,0.5);  color: #1e8449; }
.layer-filter__pill--non-listed { background: var(--off-white);       border-color: var(--light-gray);     color: var(--silver-gray); }

.layer-filter__pill--listed:hover,     .layer-filter__pill--listed.is-active     { background: #27ae60; border-color: #27ae60; color: #fff; box-shadow: 0 1px 6px rgba(39,174,96,0.35); }
.layer-filter__pill--non-listed:hover, .layer-filter__pill--non-listed.is-active { background: var(--silver-gray); border-color: var(--silver-gray); color: #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.18); }

/* ── Dashboard search ── */

.search-form { display: contents; }

.search-input-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.search-input {
    height: 1.85rem;
    padding: 0 1.6rem 0 0.7rem;
    border: 1.5px solid var(--light-gray);
    border-radius: 999px;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--dark-gray);
    background: var(--white);
    outline: none;
    width: 160px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input::placeholder { color: var(--light-gray); font-weight: 500; }
.search-input:focus { border-color: var(--mid-gray); box-shadow: 0 1px 4px rgba(0,0,0,0.10); }
.search-input--active { border-color: var(--red); box-shadow: 0 0 0 2px rgba(232,33,39,0.10); }
.search-input--active:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(232,33,39,0.15); }

.layer-filter--search { margin-bottom: 0.35rem; }

.search-input::-webkit-search-cancel-button { display: none; }

.search-clear {
    position: absolute;
    right: 0.6rem;
    font-size: 0.65rem;
    color: var(--light-gray) !important;
    text-decoration: none !important;
    line-height: 1;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}
.search-clear:hover { color: var(--red) !important; }

/* ── Listing status badge ── */

.listing-badge {
    display: inline-block;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.listing-badge--listed     { background: rgba(39,174,96,0.12); color: #1e8449; border: 1px solid rgba(39,174,96,0.35); }
.listing-badge--non-listed { background: var(--off-white); color: var(--silver-gray); border: 1px solid var(--light-gray); }

.exchange-name,
.exchange-ticker {
    display: block;
    line-height: 1.3;
}
.exchange-ticker {
    font-size: 0.8rem;
    color: var(--mid-gray);
}

/* ── Messages ── */

.messages {
    margin-bottom: 1.5rem;
}

.message {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.message--error {
    background: #fff0f0;
    border: 1px solid var(--red);
    color: var(--red-dark);
}

.message--success {
    background: #f0fff4;
    border: 1px solid #27ae60;
    color: #1e8449;
}

.message--warning {
    background: #fffbf0;
    border: 1px solid #f39c12;
    color: #b7770d;
}

/* ── Wide main override (companies page) ── */

.main--wide {
    max-width: 1800px;
}

/* ── Master / Detail layout ── */

.companies-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.companies-master {
    flex: 0 1 auto;
    min-width: 0;
}

.dashboard-tagline {
    font-size: 1rem;
    color: var(--silver-gray);
    letter-spacing: 0.04em;
    margin-bottom: 0.75rem;
    padding-left: 0.1rem;
}

.company-detail-panel {
    flex: 1 1 300px;
    min-width: 300px;
    position: sticky;
    top: 56px;
    max-height: calc(100vh - 72px);
    overflow-y: auto;
    scrollbar-width: none;
    padding-right: 2px;
}
.company-detail-panel::-webkit-scrollbar {
    display: none;
}

/* ── Detail placeholder ── */

.detail-placeholder {
    background: var(--white);
    border: 1.5px dashed var(--light-gray);
    border-radius: 8px;
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--light-gray);
    font-size: 0.9rem;
    font-weight: 600;
}

/* ── Detail card ── */

.detail-card {
    background: var(--white);
    border: 1px solid var(--light-gray);
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    overflow: hidden;
}

.detail-header {
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--light-gray);
    background: var(--off-white);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
}

.detail-company-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--black);
}

.detail-ticker {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--mid-gray);
    background: var(--light-gray);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.detail-meta {
    padding: 0.5rem 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0 0.5rem;
    font-size: 0.76rem;
    color: var(--mid-gray);
    border-bottom: 1px solid var(--light-gray);
}

.detail-meta span + span::before {
    content: '·';
    margin-right: 0.5rem;
}

.detail-description {
    padding: 0.75rem 1.25rem;
    font-size: 0.78rem;
    color: var(--mid-gray);
    line-height: 1.6;
    border-bottom: 1px solid var(--light-gray);
}

.detail-notice {
    padding: 1.5rem 1.25rem;
    font-size: 0.85rem;
    color: var(--mid-gray);
    text-align: center;
}

.detail-notice--error {
    color: var(--red);
}

.detail-section {
    border-bottom: 1px solid var(--light-gray);
}

.detail-section:last-child {
    border-bottom: none;
}

.detail-section-title {
    padding: 0.45rem 1.25rem 0.2rem;
    font-size: 0.63rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--mid-gray);
    background: var(--off-white);
}

.detail-table {
    width: 100%;
    border-collapse: collapse;
}

.detail-table td {
    padding: 0.4rem 1.25rem;
    font-size: 0.83rem;
    border-bottom: 1px solid var(--off-white);
}

.detail-table tr:last-child td {
    border-bottom: none;
}

.detail-label {
    color: var(--mid-gray);
    width: 55%;
}

.detail-value {
    color: var(--dark-gray);
    font-weight: 600;
    text-align: right;
}

.detail-section-dates {
    font-size: 0.6rem;
    font-weight: 400;
    color: var(--silver-gray);
    margin-left: 0.4rem;
    text-transform: none;
    letter-spacing: 0;
}

/* ── Sentiment blocks in detail panel ── */

.sentiment-block {
    padding: 0.55rem 1.25rem;
    border-left: 3px solid transparent;
    border-bottom: 1px solid var(--off-white);
}
.sentiment-block:last-child { border-bottom: none; }
.sentiment-block--pos { border-left-color: #27ae60; }
.sentiment-block--neu { border-left-color: #e6a200; }
.sentiment-block--neg { border-left-color: #C41A1F; }
.sentiment-block--bottom { border-left-color: var(--mid-gray); }

.sentiment-block-label {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--mid-gray);
    margin-bottom: 0.2rem;
}
.sentiment-block-text {
    font-size: 0.82rem;
    color: var(--dark-gray);
    line-height: 1.5;
}

/* ── Selected master row ── */

.table tbody tr {
    cursor: pointer;
}

.table tbody tr.is-selected td {
    background: #fef2f2;
    color: var(--black);
}

.table tbody tr.is-selected td:nth-child(-n+2) {
    background: #fef2f2;
}

/* loading state while HTMX fetches */
.table tbody tr.htmx-request td {
    opacity: 0.6;
}

/* ── Markets Dashboard strips layout ── */

.markets-strips {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    align-items: flex-start;
}

/* ── Exchange rate strip ── */

.xr-strip {
    background: var(--white);
    border: 1px solid var(--light-gray);
    border-radius: 8px;
    padding: 0.55rem 1rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    display: inline-block;
}

.xr-strip__header {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--mid-gray);
    margin-bottom: 0.4rem;
}

.xr-table {
    border-collapse: collapse;
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
}

.xr-table td {
    padding: 0.1rem 1.25rem 0.1rem 0;
    white-space: nowrap;
    color: var(--dark-gray);
}

.xr-table tr td:last-child {
    padding-left: 1.25rem;
    border-left: 1px solid var(--light-gray);
}

.xr-meta {
    color: var(--mid-gray);
    font-size: 0.68rem;
}

.xr-table th {
    padding: 0.1rem 1.25rem 0.35rem 0;
    text-align: left;
    border-bottom: 1px solid var(--light-gray);
}

.xr-table tr th:last-child {
    padding-left: 1.25rem;
    border-left: 1px solid var(--light-gray);
}

.xr-sort-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0;
}

.xr-code {
    color: var(--mid-gray);
    font-weight: 600;
    display: inline-block;
    position: relative;
}

.xr-code[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 5px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--dark-gray);
    color: var(--white);
    font-size: 0.65rem;
    font-weight: 500;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.12s;
    z-index: 10;
}

.xr-code[data-tooltip]:hover::after {
    opacity: 1;
}

.xr-rate {
    font-weight: 700;
}

/* ── Master table compact overrides ── */

#master-table {
    font-size: 0.78rem;
}

#master-table th {
    padding: 0.45rem 0.75rem;
    font-size: 0.67rem;
}

#master-table td {
    padding: 0.28rem 0.75rem;
}

#master-table .ai-badge {
    font-size: 0.72rem;
    padding: 0.1rem 0.45rem;
}

#master-table .listing-badge {
    font-size: 0.68rem;
    padding: 0.1rem 0.45rem;
}

#master-table .country-flag {
    width: 20px;
    height: 13px;
}

#master-table .identifier-line {
    font-size: 0.62rem;
    line-height: 1.6;
}

/* ── Sentiment pill ── */
.sentiment-pill {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    white-space: nowrap;
    border: 1px solid transparent;
}
.sentiment-pill--positive { background: rgba(39,174,96,0.12); color: #1e8449; border-color: rgba(39,174,96,0.35); }
.sentiment-pill--neutral  { background: rgba(230,162,0,0.12);  color: #9a6f00; border-color: rgba(230,162,0,0.35);  }
.sentiment-pill--negative { background: rgba(232,33,39,0.10);  color: #C41A1F; border-color: rgba(232,33,39,0.30);  }
.sentiment-pill--stale    { opacity: 0.5; }
