/* =====================================================================
   Contrarian Cash Freedom Dashboard — style.css
   ===================================================================== */

:root {
    --bg:           #0f1419;
    --bg-card:      #1a1f26;
    --bg-elevated:  #232932;
    --border:       #2a3038;
    --text:         #e6edf3;
    --text-muted:   #8b949e;
    --text-dim:     #6e7681;
    --accent:       #4493f8;
    --accent-hover: #58a6ff;
    --green:        #3fb950;
    --green-bg:     rgba(63, 185, 80, 0.15);
    --red:          #f85149;
    --red-bg:       rgba(248, 81, 73, 0.15);
    --yellow:       #d29922;
    --yellow-bg:    rgba(210, 153, 34, 0.15);
    --gray:         #8b949e;
    --gray-bg:      rgba(139, 148, 158, 0.15);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ===== Topbar ===== */
.topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 18px 0;
    margin-bottom: 28px;
}
.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.topbar h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}
.back-link {
    font-size: 22px;
    color: var(--text-muted);
    text-decoration: none;
    margin-right: 4px;
}
.back-link:hover { color: var(--accent); text-decoration: none; }
.company-name-header {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 16px;
    margin-left: 6px;
}
.muted { color: var(--text-muted); }
.small { font-size: 13px; }

/* ===== Summary Card ===== */
.summary-card,
.company-summary {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 22px;
    margin-bottom: 28px;
}
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 22px;
}
.summary-cell { min-width: 0; }
.summary-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}
.summary-value {
    font-size: 22px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ===== Holdings Grid ===== */
.holdings h2 {
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin: 0 0 16px;
}
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}
.ticker-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px;
    color: var(--text);
    display: block;
    transition: border-color 0.15s, transform 0.15s;
}
.ticker-card:hover {
    text-decoration: none;
    border-color: var(--accent);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
}
.ticker {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.company-name {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 2px;
}

.card-numbers {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-bottom: 12px;
}
.num-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}
.num-label { color: var(--text-muted); }
.num-row.total {
    font-weight: 600;
    border-top: 1px dashed var(--border);
    margin-top: 6px;
    padding-top: 10px;
}

.card-reports {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ===== P&L colors ===== */
.gain-positive { color: var(--green); }
.gain-negative { color: var(--red); }
.gain-neutral  { color: var(--text-muted); }

/* ===== Rating pills ===== */
.rating-pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}
.rating-strong-buy  { background: var(--green-bg);  color: var(--green); }
.rating-buy         { background: var(--green-bg);  color: var(--green); opacity: 0.85; }
.rating-neutral     { background: var(--gray-bg);   color: var(--text-muted); }
.rating-sell        { background: var(--red-bg);    color: var(--red); opacity: 0.85; }
.rating-strong-sell { background: var(--red-bg);    color: var(--red); }
.rating-unrated     { background: var(--gray-bg);   color: var(--text-dim); }

/* ===== Report freshness badges ===== */
.rep-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
}
.rep-fresh   { background: var(--green-bg);  color: var(--green); }
.rep-aging   { background: var(--yellow-bg); color: var(--yellow); }
.rep-stale   { background: var(--red-bg);    color: var(--red); }
.rep-missing { background: var(--gray-bg);   color: var(--text-dim); }

.rep-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 6px;
    vertical-align: middle;
}
.rep-dot.rep-fresh   { background: var(--green); }
.rep-dot.rep-aging   { background: var(--yellow); }
.rep-dot.rep-stale   { background: var(--red); }
.rep-dot.rep-missing { background: var(--text-dim); }

/* ===== Tabs ===== */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.tab {
    padding: 12px 18px;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    font-weight: 500;
    transition: color 0.15s, border-color 0.15s;
    text-decoration: none;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ===== Report body ===== */
.report-meta {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 16px;
}
.report-body {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 28px 32px;
    line-height: 1.7;
}
.report-body h1 { font-size: 26px; margin-top: 0; }
.report-body h2 { font-size: 21px; margin-top: 32px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.report-body h3 { font-size: 17px; margin-top: 24px; color: var(--text); }
.report-body h4 { font-size: 15px; margin-top: 20px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.report-body p  { margin: 12px 0; }
.report-body ul, .report-body ol { padding-left: 24px; }
.report-body li { margin: 6px 0; }
.report-body code {
    background: var(--bg-elevated);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: "SF Mono", Menlo, Consolas, monospace;
}
.report-body pre {
    background: var(--bg-elevated);
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    border: 1px solid var(--border);
}
.report-body pre code { background: none; padding: 0; }
.report-body blockquote {
    border-left: 3px solid var(--accent);
    margin: 14px 0;
    padding: 4px 18px;
    background: var(--bg-elevated);
    border-radius: 0 6px 6px 0;
    color: var(--text-muted);
}
.report-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 18px 0;
    font-size: 14px;
}
.report-body th, .report-body td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
}
.report-body th {
    background: var(--bg-elevated);
    font-weight: 600;
}
.report-body hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 28px 0;
}
.report-body a { color: var(--accent); }

/* ===== Empty state ===== */
.empty-state {
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: 10px;
    padding: 48px 24px;
    text-align: center;
}
.empty-state h2 { margin-top: 0; color: var(--text-muted); }
.empty-state code {
    background: var(--bg-elevated);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9em;
}

/* ===== Legend ===== */
.legend {
    margin-top: 36px;
    padding: 16px 22px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-muted);
}
.legend h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0 0 10px;
    color: var(--text-muted);
}
.legend-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.legend-row .rep-badge { margin-right: 4px; }

/* ===== Footer ===== */
.footer {
    margin: 60px auto 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    text-align: center;
}

/* ===== Mobile ===== */
@media (max-width: 600px) {
    .container { padding: 0 16px; }
    .topbar h1 { font-size: 17px; }
    .summary-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
    .summary-value { font-size: 18px; }
    .card-grid { grid-template-columns: 1fr; }
    .report-body { padding: 18px; }
    .tab { padding: 10px 12px; font-size: 14px; }
}
