/* ==========================================================================
   Tradestie 2027 Macro & House Thesis SEO Design System
   Strict WCAG AA (>= 4.5:1) in Light & Dark Modes · 375px Mobile Safe
   ========================================================================== */

:root {
    --ts-hv-bg: #ffffff;
    --ts-hv-bg-subtle: #f8fafc;
    --ts-hv-bg-elevated: #f1f5f9;
    --ts-hv-border: #cbd5e1;
    --ts-hv-border-subtle: #e2e8f0;

    --ts-hv-text: #0f172a;
    --ts-hv-text-sec: #334155;
    --ts-hv-text-muted: #475569;

    --ts-hv-pos-bg: #ecfdf5;
    --ts-hv-pos-text: #065f46;
    --ts-hv-pos-border: #6ee7b7;
    --ts-hv-pos-accent: #059669;

    --ts-hv-neg-bg: #fef2f2;
    --ts-hv-neg-text: #991b1b;
    --ts-hv-neg-border: #fca5a5;
    --ts-hv-neg-accent: #dc2626;

    --ts-hv-warn-bg: #fffbeb;
    --ts-hv-warn-text: #92400e;
    --ts-hv-warn-border: #fcd34d;
    --ts-hv-warn-accent: #d97706;

    --ts-hv-neu-bg: #f1f5f9;
    --ts-hv-neu-text: #334155;
    --ts-hv-neu-border: #cbd5e1;
    --ts-hv-neu-accent: #475569;

    --ts-hv-link: #1d4ed8;
    --ts-hv-link-hover: #1e40af;
    --ts-hv-btn-pri-bg: #0f172a;
    --ts-hv-btn-pri-text: #ffffff;
    --ts-hv-btn-pri-hover: #1e293b;
    --ts-hv-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
}

html[data-theme="dark"],
body.dark-mode,
[data-bs-theme="dark"] {
    --ts-hv-bg: #0f172a;
    --ts-hv-bg-subtle: #1e293b;
    --ts-hv-bg-elevated: #1e293b;
    --ts-hv-border: #334155;
    --ts-hv-border-subtle: #334155;

    --ts-hv-text: #f8fafc;
    --ts-hv-text-sec: #cbd5e1;
    --ts-hv-text-muted: #94a3b8;

    --ts-hv-pos-bg: rgba(16, 185, 129, 0.14);
    --ts-hv-pos-text: #6ee7b7;
    --ts-hv-pos-border: rgba(110, 231, 183, 0.36);
    --ts-hv-pos-accent: #10b981;

    --ts-hv-neg-bg: rgba(239, 68, 68, 0.14);
    --ts-hv-neg-text: #fca5a5;
    --ts-hv-neg-border: rgba(252, 165, 165, 0.36);
    --ts-hv-neg-accent: #ef4444;

    --ts-hv-warn-bg: rgba(245, 158, 11, 0.14);
    --ts-hv-warn-text: #fcd34d;
    --ts-hv-warn-border: rgba(252, 211, 77, 0.36);
    --ts-hv-warn-accent: #f59e0b;

    --ts-hv-neu-bg: rgba(148, 163, 184, 0.14);
    --ts-hv-neu-text: #e2e8f0;
    --ts-hv-neu-border: rgba(148, 163, 184, 0.32);
    --ts-hv-neu-accent: #94a3b8;

    --ts-hv-link: #93c5fd;
    --ts-hv-link-hover: #bfdbfe;
    --ts-hv-btn-pri-bg: #1d4ed8;
    --ts-hv-btn-pri-text: #ffffff;
    --ts-hv-btn-pri-hover: #2563eb;
    --ts-hv-shadow: 0 6px 20px rgba(0, 0, 0, 0.32);
}

/* --------------------------------------------------------------------------
   1. Per-Ticker House Thesis Counter-Check Card (.ts-hv-*)
   -------------------------------------------------------------------------- */
.ts-hv-card {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 24px 0;
    padding: 22px 24px;
    background: var(--ts-hv-bg);
    border: 1px solid var(--ts-hv-border);
    border-left: 4px solid var(--ts-hv-neu-accent);
    border-radius: 12px;
    box-shadow: var(--ts-hv-shadow);
    color: var(--ts-hv-text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow-wrap: anywhere;
}

.ts-hv-card--danger {
    border-left-color: var(--ts-hv-neg-accent);
}

.ts-hv-card--safe {
    border-left-color: var(--ts-hv-pos-accent);
}

.ts-hv-card--warning {
    border-left-color: var(--ts-hv-warn-accent);
}

.ts-hv-card--neutral {
    border-left-color: var(--ts-hv-neu-accent);
}

.ts-hv-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 12px;
    margin-bottom: 12px;
    min-width: 0;
}

.ts-hv-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    line-height: 1.3;
    border: 1px solid transparent;
}

.ts-hv-badge--danger {
    background: var(--ts-hv-neg-bg);
    color: var(--ts-hv-neg-text);
    border-color: var(--ts-hv-neg-border);
}

.ts-hv-badge--safe {
    background: var(--ts-hv-pos-bg);
    color: var(--ts-hv-pos-text);
    border-color: var(--ts-hv-pos-border);
}

.ts-hv-badge--warning {
    background: var(--ts-hv-warn-bg);
    color: var(--ts-hv-warn-text);
    border-color: var(--ts-hv-warn-border);
}

.ts-hv-badge--neutral {
    background: var(--ts-hv-neu-bg);
    color: var(--ts-hv-neu-text);
    border-color: var(--ts-hv-neu-border);
}

.ts-hv-pills {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.ts-hv-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.35;
    border: 1px solid var(--ts-hv-border-subtle);
    background: var(--ts-hv-bg-subtle);
    color: var(--ts-hv-text-sec);
}

.ts-hv-pill--kill-intact,
.ts-hv-pill--alpha-pos {
    background: var(--ts-hv-pos-bg);
    color: var(--ts-hv-pos-text);
    border-color: var(--ts-hv-pos-border);
}

.ts-hv-pill--kill-monitoring {
    background: var(--ts-hv-warn-bg);
    color: var(--ts-hv-warn-text);
    border-color: var(--ts-hv-warn-border);
}

.ts-hv-pill--kill-closed {
    background: var(--ts-hv-neu-bg);
    color: var(--ts-hv-neu-text);
    border-color: var(--ts-hv-neu-border);
}

.ts-hv-pill--alpha-neg {
    background: var(--ts-hv-neg-bg);
    color: var(--ts-hv-neg-text);
    border-color: var(--ts-hv-neg-border);
}

.ts-hv-headline {
    margin: 0 0 10px 0;
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.35;
    color: var(--ts-hv-text);
}

.ts-hv-narrative {
    margin: 0 0 14px 0;
    font-size: 0.94rem;
    line-height: 1.6;
    color: var(--ts-hv-text-sec);
}

.ts-hv-thesis-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--ts-hv-bg-subtle);
    border: 1px solid var(--ts-hv-border-subtle);
    min-width: 0;
}

.ts-hv-thesis-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ts-hv-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.ts-hv-thesis-pill,
a.ts-hv-thesis-pill,
.ts-hv-sleeve-link,
a.ts-hv-sleeve-link {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--ts-hv-link) !important;
    text-decoration: none;
    min-width: 0;
}

.ts-hv-thesis-pill:hover,
a.ts-hv-thesis-pill:hover,
.ts-hv-sleeve-link:hover,
a.ts-hv-sleeve-link:hover {
    color: var(--ts-hv-link-hover) !important;
    text-decoration: underline;
}

.ts-hv-thesis-cat {
    color: var(--ts-hv-text-sec);
    font-weight: 700;
}

.ts-hv-thesis-sep {
    color: var(--ts-hv-text-muted);
}

.ts-hv-secondary-note {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--ts-hv-text-muted);
}

.ts-hv-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.ts-hv-btn,
a.ts-hv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--ts-hv-text) !important;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    box-sizing: border-box;
    max-width: 100%;
}

.ts-hv-btn--primary,
a.ts-hv-btn--primary {
    background: var(--ts-hv-btn-pri-bg);
    color: var(--ts-hv-btn-pri-text) !important;
    border: 1px solid var(--ts-hv-btn-pri-bg);
}

.ts-hv-btn--primary:hover,
a.ts-hv-btn--primary:hover {
    background: var(--ts-hv-btn-pri-hover);
    color: var(--ts-hv-btn-pri-text) !important;
    text-decoration: none;
}

.ts-hv-btn--secondary,
a.ts-hv-btn--secondary {
    background: var(--ts-hv-bg-subtle);
    color: var(--ts-hv-text) !important;
    border: 1px solid var(--ts-hv-border);
}

.ts-hv-btn--secondary:hover,
a.ts-hv-btn--secondary:hover {
    background: var(--ts-hv-bg-elevated);
    color: var(--ts-hv-link) !important;
    border-color: var(--ts-hv-link);
    text-decoration: none;
}

.ts-hv-btn--trial,
a.ts-hv-btn--trial,
.ts-hv-btn--ghost,
a.ts-hv-btn--ghost {
    background: transparent;
    color: var(--ts-hv-link) !important;
    border: 1px dashed var(--ts-hv-border);
}

.ts-hv-btn--trial:hover,
a.ts-hv-btn--trial:hover,
.ts-hv-btn--ghost:hover,
a.ts-hv-btn--ghost:hover {
    background: var(--ts-hv-bg-subtle);
    color: var(--ts-hv-link-hover) !important;
    text-decoration: underline;
}

/* --------------------------------------------------------------------------
   2. Reusable 2027 Macro Hub & Sector Overlay Components (.ts-macro27-*)
   -------------------------------------------------------------------------- */
.ts-macro27-section {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 28px 0 36px 0;
    color: var(--ts-hv-text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow-wrap: anywhere;
}

.ts-macro27-banner {
    box-sizing: border-box;
    padding: 24px 26px;
    border-radius: 14px;
    background: var(--ts-hv-bg);
    border: 1px solid var(--ts-hv-border);
    box-shadow: var(--ts-hv-shadow);
    margin-bottom: 22px;
    min-width: 0;
}

.ts-macro27-eyebrow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    min-width: 0;
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ts-hv-link);
    margin-bottom: 8px;
}

.ts-macro27-title {
    margin: 0 0 10px 0;
    font-size: 1.4rem;
    font-weight: 800;
    line-height: 1.3;
    color: var(--ts-hv-text);
}

.ts-macro27-summary {
    margin: 0 0 18px 0;
    font-size: 0.96rem;
    line-height: 1.62;
    color: var(--ts-hv-text-sec);
}

.ts-macro27-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.ts-macro27-kpi {
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--ts-hv-bg-subtle);
    border: 1px solid var(--ts-hv-border-subtle);
    min-width: 0;
}

.ts-macro27-kpi-label {
    display: block;
    font-size: 0.74rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--ts-hv-text-muted);
    margin-bottom: 4px;
}

.ts-macro27-kpi-value {
    display: block;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--ts-hv-text);
}

/* 4 Macro Pillars Grid */
.ts-macro27-pillars {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 16px;
}

.ts-macro27-pillar {
    padding: 16px 18px;
    border-radius: 10px;
    background: var(--ts-hv-bg-subtle);
    border: 1px solid var(--ts-hv-border-subtle);
    min-width: 0;
}

.ts-macro27-pillar-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.ts-macro27-pillar-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--ts-hv-text);
    margin: 0;
}

.ts-macro27-pillar-metric {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--ts-hv-link);
    margin-bottom: 6px;
}

.ts-macro27-pillar-detail {
    font-size: 0.85rem;
    line-height: 1.55;
    color: var(--ts-hv-text-sec);
    margin: 0;
}

/* Semantic Status Badges */
.ts-macro27-badge {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border: 1px solid transparent;
    max-width: 100%;
}

.ts-macro27-eyebrow .ts-macro27-badge {
    white-space: normal;
    flex-shrink: 1;
    overflow-wrap: anywhere;
}

@media (min-width: 768px) {
    .ts-macro27-stance-col .ts-macro27-badge {
        white-space: nowrap;
        flex-shrink: 0;
    }
}

.ts-macro27-badge--pos {
    background: var(--ts-hv-pos-bg);
    color: var(--ts-hv-pos-text);
    border-color: var(--ts-hv-pos-border);
}

.ts-macro27-badge--warn {
    background: var(--ts-hv-warn-bg);
    color: var(--ts-hv-warn-text);
    border-color: var(--ts-hv-warn-border);
}

.ts-macro27-badge--neg {
    background: var(--ts-hv-neg-bg);
    color: var(--ts-hv-neg-text);
    border-color: var(--ts-hv-neg-border);
}

.ts-macro27-badge--neutral {
    background: var(--ts-hv-neu-bg);
    color: var(--ts-hv-neu-text);
    border-color: var(--ts-hv-neu-border);
}

/* 3-Column Overweight / Selective / Underweight Sector Stance Matrix */
.ts-macro27-stance-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin: 20px 0 24px 0;
}

.ts-macro27-stance-col {
    box-sizing: border-box;
    padding: 18px;
    border-radius: 12px;
    background: var(--ts-hv-bg);
    border: 1px solid var(--ts-hv-border);
    border-top: 4px solid var(--ts-hv-neu-accent);
    min-width: 0;
}

.ts-macro27-stance-col--pos {
    border-top-color: var(--ts-hv-pos-accent);
}

.ts-macro27-stance-col--warn {
    border-top-color: var(--ts-hv-warn-accent);
}

.ts-macro27-stance-col--neg {
    border-top-color: var(--ts-hv-neg-accent);
}

.ts-macro27-stance-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--ts-hv-border-subtle);
    min-width: 0;
}

.ts-macro27-stance-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.ts-macro27-stance-link,
a.ts-macro27-stance-link,
.ts-macro27-sector-link,
a.ts-macro27-sector-link {
    font-size: 0.94rem;
    font-weight: 700;
    color: var(--ts-hv-link) !important;
    text-decoration: none;
}

.ts-macro27-stance-link:hover,
a.ts-macro27-stance-link:hover,
.ts-macro27-sector-link:hover,
a.ts-macro27-sector-link:hover {
    color: var(--ts-hv-link-hover) !important;
    text-decoration: underline;
}

.ts-macro27-stance-rationale {
    margin: 5px 0 8px 0;
    font-size: 0.84rem;
    line-height: 1.5;
    color: var(--ts-hv-text-sec);
}

/* Active House Thesis Sleeve Cards */
.ts-macro27-theses-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.ts-macro27-thesis-card {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 18px;
    border-radius: 12px;
    background: var(--ts-hv-bg);
    border: 1px solid var(--ts-hv-border);
    min-width: 0;
}

.ts-macro27-ticker-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
}

.ts-macro27-chip,
a.ts-macro27-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 0.75rem;
    font-weight: 700;
    text-decoration: none;
    border: 1px solid var(--ts-hv-border-subtle);
    background: var(--ts-hv-bg-subtle);
    color: var(--ts-hv-text) !important;
}

.ts-macro27-chip--long,
a.ts-macro27-chip--long,
.ts-macro27-conviction-pill,
a.ts-macro27-conviction-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--ts-hv-pos-bg);
    color: var(--ts-hv-pos-text) !important;
    border: 1px solid var(--ts-hv-pos-border);
    text-decoration: none;
}

.ts-macro27-chip--avoid,
a.ts-macro27-chip--avoid,
.ts-macro27-avoid-pill,
a.ts-macro27-avoid-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--ts-hv-neg-bg);
    color: var(--ts-hv-neg-text) !important;
    border: 1px solid var(--ts-hv-neg-border);
    text-decoration: none;
}

.ts-macro27-chip--locked,
a.ts-macro27-chip--locked {
    background: var(--ts-hv-neu-bg);
    color: var(--ts-hv-neu-text) !important;
    border: 1px dashed var(--ts-hv-border);
    font-weight: 600;
}

/* Sector Page Stance Callout & Consensus Trap Watchlist Card */
.ts-macro27-sector-callout {
    box-sizing: border-box;
    padding: 20px 22px;
    margin: 20px 0 24px 0;
    border-radius: 12px;
    background: var(--ts-hv-bg);
    border: 1px solid var(--ts-hv-border);
    border-left: 4px solid var(--ts-hv-neu-accent);
    box-shadow: var(--ts-hv-shadow);
    min-width: 0;
}

.ts-macro27-sector-callout--pos {
    border-left-color: var(--ts-hv-pos-accent);
}

.ts-macro27-sector-callout--warn {
    border-left-color: var(--ts-hv-warn-accent);
}

.ts-macro27-sector-callout--neg {
    border-left-color: var(--ts-hv-neg-accent);
}

.ts-macro27-trap-card {
    box-sizing: border-box;
    padding: 20px 22px;
    margin: 24px 0;
    border-radius: 12px;
    background: var(--ts-hv-bg);
    border: 1px solid var(--ts-hv-neg-border);
    border-left: 4px solid var(--ts-hv-neg-accent);
    min-width: 0;
}

.ts-macro27-trap-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 14px;
}

.ts-macro27-trap-item {
    padding: 14px 16px;
    border-radius: 10px;
    background: var(--ts-hv-bg-subtle);
    border: 1px solid var(--ts-hv-border-subtle);
    min-width: 0;
}

/* --------------------------------------------------------------------------
   3. Responsive & 375px Mobile Zero-Overflow Collapse
   -------------------------------------------------------------------------- */
@media (max-width: 991px) {
    .ts-macro27-stance-grid,
    .ts-macro27-theses-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .ts-macro27-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    .ts-hv-card,
    .ts-macro27-banner,
    .ts-macro27-sector-callout,
    .ts-macro27-trap-card {
        padding: 16px;
    }

    .ts-hv-headline {
        font-size: 1.04rem;
    }

    .ts-macro27-title {
        font-size: 1.18rem;
    }

    .ts-macro27-kpis,
    .ts-macro27-pillars,
    .ts-macro27-stance-grid,
    .ts-macro27-theses-grid,
    .ts-macro27-trap-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .ts-hv-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .ts-hv-btn {
        width: 100%;
        text-align: center;
    }

    .ts-macro27-badge {
        white-space: normal;
        flex-shrink: 1;
        overflow-wrap: anywhere;
    }
}
