/* shared.css - Cloze Leaderboard */
/* Design language: Majestic Realty Collective */

:root {
    --bg: #060e1a;
    --bg-blue: #0D3755;
    --surface: rgba(255,255,255,0.04);
    --surface-hover: rgba(255,255,255,0.07);
    --border: rgba(255,255,255,0.1);
    --border-hover: rgba(255,255,255,0.2);
    --text: #ffffff;
    --text-secondary: #ccc;
    --text-muted: #90a0b0;
    --positive: #7cb68a;
    --negative: #b05555;
    --radius: 4px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #060e1a url('/bg.webp') center/cover no-repeat fixed;
    min-height: 100vh;
    color: var(--text);
    font-size: clamp(18px, 1.25vw, 48px);
}
body.tv-mode {
    background: linear-gradient(170deg, #060e1a 0%, #0d1b2a 40%, #0a1628 100%);
}

/* === Layout === */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: clamp(240px, 19vw, 460px);
    background: rgba(0,0,0,0.5);
    border-right: 1px solid var(--border);
    padding: clamp(16px, 1.7vw, 40px);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-logo {
    display: block;
    max-width: clamp(160px, 14vw, 320px);
    height: auto;
    margin-bottom: clamp(10px, 1.1vw, 24px);
    opacity: 0.9;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 20px;
    transition: color 0.2s;
}
.back-link:hover { color: var(--text); }

.sidebar h1 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.sidebar .subtitle {
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
}

.updated-badge {
    display: inline-block;
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.main { flex: 1; padding: clamp(16px, 1.7vw, 40px) clamp(20px, 2.2vw, 52px); overflow-x: hidden; }
.main-full {
    max-width: clamp(900px, 70vw, 1600px);
    margin: 0 auto;
    padding: clamp(16px, 1.7vw, 40px) clamp(20px, 2.2vw, 52px);
}

/* === Scoring Guide (collapsible) === */
.scoring-guide { margin: 24px 0; }
.scoring-guide summary {
    font-size: 0.65rem;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
}
.scoring-guide summary::-webkit-details-marker { display: none; }
.scoring-guide summary::after {
    content: '+';
    margin-left: auto;
    font-size: 0.8rem;
    transition: transform 0.2s;
}
.scoring-guide[open] summary::after { content: '-'; }
.scoring-guide .guide-content { padding-top: 10px; }

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.score-item:last-child { border-bottom: none; }
.score-item .label { font-size: 0.75rem; color: var(--text); font-weight: 500; }
.score-item .desc { font-size: 0.65rem; color: var(--text-muted); margin-top: 2px; }
.score-item .points { font-weight: 600; color: var(--text); font-size: 0.8rem; }

.tier-section h3 {
    font-size: 0.65rem;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.tier-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; }
.tier-badge-preview {
    padding: 4px 14px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 600;
    min-width: 80px;
    text-align: center;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.tier-bronze-preview { background: #8b6f4e; color: #fff; }
.tier-silver-preview { background: #7a7a7a; color: #fff; }
.tier-gold-preview { background: #c9a96e; color: var(--bg); }
.tier-platinum-preview { background: #d4d4d4; color: var(--bg); }
.tier-score { font-size: 0.7rem; color: var(--text-muted); }

/* === Scoring Guide Card (main content area) === */
.scoring-guide-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: clamp(14px, 1.4vw, 32px) clamp(16px, 1.7vw, 40px);
    margin-bottom: clamp(16px, 1.7vw, 40px);
}
.scoring-guide-card summary {
    font-size: 0.8rem;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    font-weight: 600;
}
.scoring-guide-card summary::-webkit-details-marker { display: none; }
.scoring-guide-card summary::after {
    content: '+';
    margin-left: auto;
    font-size: 0.9rem;
}
.scoring-guide-card[open] summary::after { content: '\2212'; }
.guide-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: clamp(10px, 1.2vw, 24px);
    padding-top: clamp(14px, 1.4vw, 28px);
}
.guide-item {
    text-align: center;
    padding: clamp(10px, 1vw, 20px);
    border-radius: var(--radius);
    background: rgba(0,0,0,0.2);
}
.guide-points {
    font-size: 1.4rem;
    font-weight: 300;
    color: var(--text);
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}
.guide-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 4px;
}
.guide-desc {
    font-size: 0.65rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* === Tier Footer === */
.tier-footer {
    display: flex;
    justify-content: center;
    gap: clamp(10px, 1.5vw, 24px);
    padding: clamp(12px, 1.2vw, 28px) 0;
    margin-bottom: clamp(16px, 1.7vw, 40px);
}
.tier-footer .tier-badge-preview {
    cursor: pointer;
    transition: all 0.2s;
}
.tier-footer .tier-badge-preview:hover {
    transform: scale(1.05);
}
.tier-footer .tier-badge-preview.tier-active {
    box-shadow: 0 0 0 2px var(--text);
    transform: scale(1.08);
}

/* === Stats Bar === */
.stats-bar {
    display: flex;
    gap: clamp(16px, 2.1vw, 48px);
    margin-bottom: clamp(16px, 1.7vw, 40px);
    padding: clamp(12px, 1.25vw, 28px) clamp(16px, 1.7vw, 40px);
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    flex-wrap: wrap;
    align-items: center;
}
.stat { text-align: center; }
.stat .number { font-size: 1.8rem; font-weight: 300; color: var(--text); line-height: 1; letter-spacing: -0.5px; }
.stat .number.highlight { color: var(--text); }
.stat .label { font-size: 0.6rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 6px; }

/* === Search (icon toggle) === */
.search-container {
    margin-left: auto;
    display: flex;
    align-items: center;
    position: relative;
}
.search-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    color: var(--text-muted);
    transition: color 0.2s;
}
.search-toggle:hover { color: var(--text); }
.search-input {
    width: 0;
    padding: 8px 0;
    border: none;
    border-bottom: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    font-size: 0.85rem;
    outline: none;
    letter-spacing: 0.3px;
    overflow: hidden;
    transition: width 0.3s ease, border-color 0.3s ease;
}
.search-container.active .search-input {
    width: 200px;
}
.search-input:focus { border-bottom-color: var(--text); }
.search-input::placeholder { color: var(--text-muted); }

/* === Rising Stars === */
.rising-stars {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 24px;
}
.rising-stars h3 {
    font-size: 0.65rem;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 14px;
}
.rising-stars h3::before { content: none; }
.rising-star-list { display: flex; flex-wrap: wrap; gap: 10px; }
.rising-star-item {
    background: rgba(0,0,0,0.3);
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    border: 1px solid var(--border);
}
.rising-star-item .name { font-weight: 500; color: var(--text); }
.rising-star-item .change { color: var(--positive); font-weight: 600; margin-left: 8px; }
.rising-star-item .meta { font-size: 0.7rem; color: var(--text-muted); display: block; margin-top: 3px; }

/* === Office Cards === */
.office-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(250px, 20vw, 400px), 1fr));
    gap: clamp(10px, 1.1vw, 24px);
    margin-bottom: clamp(16px, 1.7vw, 40px);
}
.office-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, background 0.2s;
}
.office-card:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
}
.office-card-header {
    background: rgba(0,0,0,0.3);
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.office-card-name { font-weight: 600; font-size: 0.95rem; letter-spacing: 0.3px; }
.office-card-count { font-size: 0.7rem; color: var(--text-muted); }
.office-card-stats { padding: 14px 18px; display: flex; gap: 20px; }
.office-stat { text-align: center; }
.office-stat .num { font-weight: 300; font-size: 1.2rem; color: var(--text); }
.office-stat .lbl { font-size: 0.55rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.office-card-top { padding: 0 18px 14px; }
.top-agent {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-top: 1px solid rgba(255,255,255,0.05);
    font-size: 0.85rem;
}
.top-agent .medal { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; width: 20px; text-align: center; }
.top-agent .name { flex: 1; font-weight: 500; }
.top-agent .score { font-weight: 600; color: var(--text); }

/* === Agent List === */
.agents-list {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}
.list-header {
    display: grid;
    grid-template-columns: clamp(35px, 3.5vw, 80px) 1fr clamp(50px, 5vw, 100px);
    padding: clamp(10px, 1vw, 24px) clamp(16px, 1.7vw, 40px);
    background: rgba(0,0,0,0.3);
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.list-header .sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}
.list-header .sortable:hover { color: var(--text); }
.list-header .sortable.active { color: var(--text); }
.list-header .sort-arrow { font-size: 0.6rem; margin-left: 3px; }

.agent-row {
    display: grid;
    grid-template-columns: clamp(35px, 3.5vw, 80px) 1fr clamp(50px, 5vw, 100px);
    padding: clamp(10px, 1vw, 24px) clamp(16px, 1.7vw, 40px);
    border-bottom: 1px solid rgba(255,255,255,0.04);
    align-items: center;
    gap: 15px;
    transition: background 0.2s;
}
.agent-row:last-child { border-bottom: none; }
.agent-row:hover { background: rgba(255,255,255,0.03); }
.agent-row.high-score { border-left: 3px solid rgba(255,255,255,0.3); }
.agent-row.rising { border-left: 3px solid var(--positive); }

.rank { font-weight: 300; color: var(--text-muted); font-size: 1rem; text-align: center; }
.rank-1 { color: var(--text); font-weight: 600; }
.rank-2 { color: var(--text-secondary); font-weight: 500; }
.rank-3 { color: var(--text-secondary); font-weight: 500; }

.agent-info { overflow: hidden; }
.agent-name-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.agent-name { font-weight: 500; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tier-pill {
    padding: 3px 10px;
    border-radius: 3px;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tier-pill.bronze { background: #8b6f4e; color: #fff; }
.tier-pill.silver { background: #7a7a7a; color: #fff; }
.tier-pill.gold { background: #c9a96e; color: #1c1c1c; }
.tier-pill.platinum { background: #d4d4d4; color: #1c1c1c; }
.tier-pill.none { background: rgba(255,255,255,0.06); color: var(--text-muted); }

.agent-meta { font-size: 0.75rem; margin-top: 5px; display: flex; gap: 10px; align-items: center; color: var(--text-muted); }
.change-badge { color: var(--positive); font-weight: 600; font-size: 0.8rem; }
.change-badge.negative { color: var(--negative); }

.score { font-weight: 300; color: var(--text); font-size: 1.3rem; text-align: right; letter-spacing: -0.5px; }
.score.elite { color: var(--text); }

/* === View Toggle === */
.view-toggle { display: flex; gap: 8px; margin-bottom: 24px; }
.view-btn {
    padding: 8px 18px;
    border-radius: var(--radius);
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s;
}
.view-btn:hover { border-color: var(--border-hover); color: var(--text); }
.view-btn.active {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
    font-weight: 600;
}

/* === Company Tabs (all.html) === */
.company-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.company-tab {
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    transition: all 0.2s;
}
.company-tab:hover { border-color: var(--border-hover); color: var(--text); }
.company-tab.active {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
    font-weight: 600;
}
.company-tab .count { font-size: 0.65rem; opacity: 0.6; margin-left: 5px; }

/* === Top Menu Bar === */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: clamp(14px, 1.4vw, 36px) clamp(20px, 1.95vw, 50px);
    background: rgba(6, 14, 26, 0.95);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-left {
    display: flex;
    align-items: center;
    flex: 1;
}
.topbar-logo {
    height: clamp(28px, 2.5vw, 72px);
    width: auto;
    opacity: 0.9;
}
.topbar-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.topbar-title {
    font-size: 0.85rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.25em;
    color: var(--text);
}
.topbar-date {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}
.topbar-right {
    display: flex;
    align-items: center;
    flex: 1;
    justify-content: flex-end;
}
.topbar-back {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.2s;
}
.topbar-back:hover { color: var(--text); }
.topbar-company-logo {
    height: clamp(32px, 3vw, 80px);
    width: auto;
    max-width: clamp(140px, 14vw, 340px);
    object-fit: contain;
    opacity: 0.9;
}

/* === Homepage === */
body.homepage {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.homepage-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(20px, 3vw, 60px) clamp(16px, 2vw, 40px);
}
.companies-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(8px, 1.1vw, 24px);
    max-width: clamp(340px, 42vw, 1200px);
    width: 100%;
}
.company-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: clamp(16px, 1.95vw, 48px);
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.2s, background 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    aspect-ratio: 1;
}
.company-card:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
}
.company-card-logo-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}
.company-card-logo {
    width: 100%;
    max-height: clamp(28px, 2.5vw, 72px);
    object-fit: contain;
    opacity: 0.9;
}
.company-card-footer {
    margin-top: auto;
    text-align: center;
    width: 100%;
}
.company-state {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 6px;
}
.company-name { font-size: 1.1rem; font-weight: 500; margin-bottom: 8px; letter-spacing: 0.3px; }
.company-stats { font-size: 0.75rem; color: var(--text-secondary); }
.all-link {
    display: inline-block;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 500;
    padding: 6px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    transition: all 0.2s;
}
.all-link:hover { border-color: var(--text); color: var(--text); }

/* === Admin === */
.admin-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 60px 24px;
    max-width: 900px;
    margin: 0 auto;
}
.admin-body h1 {
    font-size: 1.8rem;
    font-weight: 300;
    color: var(--text);
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 8px;
}
.admin-body .subtitle { color: var(--text-muted); font-size: 0.8rem; letter-spacing: 0.5px; margin-bottom: 40px; }

.admin-section {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 16px;
}
.admin-section h2 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 20px;
    color: var(--text);
}

.dropzone {
    border: 1px dashed var(--border-hover);
    border-radius: var(--radius);
    padding: 48px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--text-muted);
}
.dropzone:hover, .dropzone.dragover {
    border-color: var(--text);
    background: rgba(255,255,255,0.03);
    color: var(--text);
}
.dropzone .icon { font-size: 1.5rem; margin-bottom: 12px; color: var(--text-muted); }
.dropzone p { font-size: 0.85rem; }
.dropzone .hint { font-size: 0.7rem; margin-top: 8px; color: var(--text-muted); }

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    margin-top: 12px;
}
.preview-table th {
    text-align: left;
    padding: 10px 12px;
    color: var(--text-muted);
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border);
}
.preview-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: var(--text-secondary);
}

.btn {
    padding: 10px 28px;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s;
}
.btn-primary {
    background: var(--text);
    color: var(--bg);
}
.btn-primary:hover { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--border-hover); color: var(--text); }

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}
.status-item { text-align: center; padding: 16px; }
.status-item .num { font-size: 1.5rem; font-weight: 300; color: var(--text); }
.status-item .lbl { font-size: 0.6rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 6px; }

/* === Loading === */
.loading { text-align: center; padding: 80px; color: var(--text-muted); }
.loading-spinner {
    width: 40px; height: 40px;
    border: 2px solid var(--border);
    border-top-color: var(--text);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === TV Mode (auto-scroll, activate with ?tv in URL) === */
.tv-mode {
    cursor: none;
    padding-bottom: 120px; /* room for QR banner */
}
.tv-mode .search-container {
    display: none;
}
.tv-mode .scoring-guide,
.tv-mode .scoring-guide-card,
.tv-mode .company-tabs,
.tv-mode .rising-stars,
.tv-mode .view-toggle,
.tv-mode #tierThresholds {
    display: none;
}

/* QR code banner - fixed bottom strip, matches topbar height */
.tv-qr-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: linear-gradient(180deg, rgba(6,14,26,0) 0%, rgba(6,14,26,1) 25%);
    padding: clamp(20px, 2vw, 48px) clamp(20px, 1.95vw, 50px) clamp(14px, 1.4vw, 36px);
    border-top: 1px solid var(--border);
}
.tv-qr-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(16px, 1.5vw, 32px);
}
.tv-qr-img {
    width: clamp(80px, 7vw, 160px);
    height: clamp(80px, 7vw, 160px);
    border-radius: 8px;
    border: 2px solid rgba(255,255,255,0.2);
}
.tv-qr-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.tv-qr-headline {
    font-size: clamp(18px, 1.4vw, 36px);
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.01em;
}
.tv-qr-sub {
    font-size: clamp(14px, 1vw, 24px);
    color: rgba(255,255,255,0.6);
}
/* === Trends === */
.trends-controls {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: clamp(12px, 1.2vw, 24px) clamp(16px, 1.5vw, 32px);
    margin-bottom: clamp(16px, 1.7vw, 40px);
    display: flex;
    align-items: center;
    gap: clamp(16px, 2vw, 40px);
    flex-wrap: wrap;
}
.trends-tabs {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.trends-tab {
    padding: 8px 18px;
    border-radius: var(--radius);
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s;
}
.trends-tab:hover { color: var(--text); }
.trends-tab.active {
    background: var(--text);
    color: var(--bg);
    font-weight: 600;
}
.trends-filters { display: flex; align-items: center; flex: 1; min-width: 0; gap: 8px; flex-wrap: wrap; }
.trends-filter { display: none; width: 100%; }
.trends-filter.active { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.trends-panel { display: none; }
.trends-panel.active { display: block; }

.trends-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: clamp(16px, 1.5vw, 32px);
}
.trends-card-title {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: clamp(12px, 1.2vw, 24px);
}
.trends-empty {
    text-align: center;
    padding: clamp(40px, 5vw, 100px) 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.chart-wrap {
    position: relative;
    height: clamp(280px, 28vw, 500px);
}

.chart-grid-2x2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(8px, 1vw, 16px);
}
.chart-grid-2x2 .chart-wrap {
    height: clamp(200px, 20vw, 320px);
}
@media (max-width: 700px) {
    .chart-grid-2x2 { grid-template-columns: 1fr; }
}

/* Drill-down shared */
.lookup-select {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(0,0,0,0.3);
    color: var(--text);
    font-size: 0.8rem;
    outline: none;
    letter-spacing: 0.3px;
    cursor: pointer;
    min-width: 140px;
    max-width: 200px;
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2390a0b0' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}
.lookup-select:focus { border-color: var(--text-muted); }
.lookup-select:disabled { opacity: 0.4; cursor: not-allowed; }
.lookup-select option { background: #0a1420; color: var(--text); }

.drill-header { margin-bottom: clamp(12px, 1.2vw, 24px); }
.drill-summary {
    display: flex;
    align-items: center;
    gap: clamp(12px, 1.2vw, 24px);
    flex-wrap: wrap;
}
.drill-logo { height: clamp(24px, 2.2vw, 48px); opacity: 0.9; }
.drill-name { font-size: 1rem; font-weight: 500; color: var(--text); }
.drill-stats { display: flex; align-items: center; gap: 8px; }
.drill-score { font-size: 1.3rem; font-weight: 300; color: var(--text); }
.drill-meta { font-size: 0.75rem; color: var(--text-muted); }
.change-up { color: var(--positive); font-weight: 600; font-size: 0.85rem; }
.change-down { color: var(--negative); font-weight: 600; font-size: 0.85rem; }

/* Compare table */
.compare-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    white-space: nowrap;
}
.compare-table th {
    text-align: center;
    padding: 8px 12px;
    color: var(--text-muted);
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    background: rgba(0,0,0,0.2);
    line-height: 1.4;
}
.compare-table th.compare-name-col {
    text-align: left;
    min-width: 180px;
}
.compare-table th.compare-group-header {
    font-size: 0.7rem;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
}
/* Column group borders */
.compare-table .col-group-start {
    border-left: 1px solid var(--border);
}
.compare-table td {
    padding: 8px 12px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}
.compare-table tr:nth-child(even) td {
    background: rgba(255,255,255,0.015);
}
.compare-table .compare-name {
    text-align: left;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}
.compare-table .compare-change.positive { color: var(--positive); font-weight: 600; }
.compare-table .compare-change.negative { color: var(--negative); font-weight: 600; }
.compare-table .compare-change.zero { color: var(--text-muted); }
.compare-table .compare-totals {
    border-top: 2px solid var(--border);
    background: rgba(0,0,0,0.15);
}
.compare-table .compare-totals td {
    color: var(--text);
    background: rgba(0,0,0,0.15);
}
.compare-table .compare-trained {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Date Range Picker */
.date-range-picker {
    position: relative;
}
.date-range-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(0,0,0,0.3);
    color: var(--text);
    font-size: 0.8rem;
    cursor: pointer;
    letter-spacing: 0.3px;
    transition: border-color 0.2s;
    white-space: nowrap;
}
.date-range-btn:hover { border-color: var(--border-hover); }
.date-range-btn:focus { border-color: var(--text-muted); outline: none; }
.date-range-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.7;
}
.date-range-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 200;
    background: rgba(10, 20, 35, 0.97);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 340px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.date-range-dropdown.open { display: block; }
.date-range-presets {
    display: flex;
    gap: 4px;
    padding: 12px 14px 8px;
    border-bottom: 1px solid var(--border);
}
.date-range-presets button {
    flex: 1;
    padding: 6px 10px;
    border-radius: var(--radius);
    font-size: 0.65rem;
    font-weight: 500;
    cursor: pointer;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.15s;
}
.date-range-presets button:hover {
    border-color: var(--border-hover);
    color: var(--text);
}
.date-range-presets button.active {
    background: #c9a96e;
    color: var(--bg);
    border-color: #c9a96e;
    font-weight: 600;
}
.date-range-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    max-height: 50vh;
    overflow: hidden;
}
.date-range-col {
    overflow-y: auto;
    padding: 8px 0;
}
.date-range-col:first-child {
    border-right: 1px solid var(--border);
}
.date-range-col-title {
    font-size: 0.55rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 4px 14px 8px;
    position: sticky;
    top: 0;
    background: rgba(10, 20, 35, 0.97);
}
.date-range-item {
    padding: 6px 14px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.1s;
}
.date-range-item:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text);
}
.date-range-item.selected {
    background: rgba(201, 169, 110, 0.15);
    color: #c9a96e;
    font-weight: 600;
}

@media (max-width: 768px) {
    .trends-controls { flex-direction: column; align-items: stretch; }
    .date-range-dropdown { min-width: 280px; }
}

/* Agent search */
.agent-search-wrap {
    position: relative;
    max-width: 400px;
}
.agent-search-input {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(0,0,0,0.3);
    color: var(--text);
    font-size: 0.85rem;
    outline: none;
    letter-spacing: 0.3px;
    transition: border-color 0.2s;
}
.agent-search-input:focus { border-color: var(--text-muted); }
.agent-search-input::placeholder { color: var(--text-muted); }

/* Agent directory */
.agent-directory { }
.agent-dir-empty { padding: 20px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }
.agent-company-group { margin-bottom: 2px; }
.agent-office-group { }

.agent-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
    border-radius: var(--radius);
}
.agent-group-header:hover { background: rgba(255,255,255,0.04); }
.agent-group-header .chevron {
    width: 16px; height: 16px; flex-shrink: 0;
    transition: transform 0.2s;
    color: var(--text-muted);
}
.agent-group-header[data-collapsed="true"] .chevron { transform: rotate(-90deg); }
.agent-group-header .group-name { font-weight: 600; color: var(--text); }
.agent-group-header .group-count {
    font-size: 0.7rem; color: var(--text-muted);
    background: rgba(255,255,255,0.06); padding: 2px 8px; border-radius: 10px;
    margin-left: auto;
}

.company-header { font-size: 0.95rem; background: rgba(255,255,255,0.03); }
.company-header .group-name { font-size: 0.95rem; }
.office-header { padding-left: 32px; font-size: 0.85rem; }
.office-header .group-name { font-weight: 500; font-size: 0.85rem; color: var(--text-secondary); }

.agent-group-body { }
.office-header + .agent-group-body { }

.agent-dir-item {
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.agent-dir-item:last-child { border-bottom: none; }

.agent-dir-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
}
.agent-dir-summary:hover { background: rgba(255,255,255,0.03); }
.agent-dir-item.expanded .agent-dir-summary { background: rgba(201,169,110,0.06); }
.agent-dir-summary > .chevron-sm {
    width: 14px; height: 14px; color: var(--text-muted);
    transition: transform 0.2s; flex-shrink: 0;
}
.agent-dir-item.expanded > .agent-dir-summary > .chevron-sm { transform: rotate(180deg); }
.agent-dir-name { font-size: 0.85rem; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 240px; flex-shrink: 0; }
.agent-dir-office {
    font-size: 0.7rem; color: var(--text-muted);
    text-align: left; flex: 1; min-width: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* When no office column, name fills the space */
.agent-dir-name:last-of-type:not(~ .agent-dir-office) { flex: 1; }
.agent-dir-summary:not(:has(.agent-dir-office)) .agent-dir-name { flex: 1; }
.agent-dir-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.agent-dir-score { font-size: 0.9rem; font-weight: 700; color: var(--text); min-width: 28px; text-align: right; }

/* Agent detail panel */
.agent-dir-detail {
    padding: 12px 16px 12px 40px;
    background: rgba(0,0,0,0.2);
    border-top: 1px solid rgba(255,255,255,0.04);
    overflow: hidden;
}
.agent-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.agent-detail-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}
.agent-edit-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255,255,255,0.04);
    color: var(--text-muted);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.15s;
}
.agent-edit-btn:hover:not(:disabled) {
    border-color: #c9a96e;
    color: #c9a96e;
    background: rgba(201, 169, 110, 0.08);
}
.agent-edit-btn:disabled {
    opacity: 0.4;
    cursor: default;
}
.agent-detail-grid-3col {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    overflow: hidden;
}
.agent-detail-section { min-width: 0; overflow: hidden; }
.agent-detail-title {
    font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 1px; color: var(--text-muted); margin-bottom: 8px;
}

/* Score breakdown bars */
.score-bar-row {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 8px; font-size: 0.78rem;
}
.score-bar-label { width: 180px; color: var(--text-secondary); flex-shrink: 0; }
.score-bar-track {
    flex: 1; height: 6px; background: rgba(255,255,255,0.06);
    border-radius: 3px; overflow: hidden;
}
.score-bar-fill {
    height: 100%; background: #c9a96e; border-radius: 3px;
    transition: width 0.4s ease;
}
.score-bar-pts { font-size: 0.7rem; color: var(--text-muted); min-width: 40px; text-align: right; }

/* Integration tags */
.integration-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.integration-tag {
    font-size: 0.65rem; padding: 2px 8px;
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px; color: var(--text-secondary);
}
.integration-missing {
    opacity: 0.3;
    text-decoration: line-through;
    border-style: dashed;
}
.text-muted { color: var(--text-muted); font-size: 0.78rem; }

/* Suggestions */
.suggestion-list { display: flex; flex-direction: column; gap: 8px; }
.suggestion-item {
    font-size: 0.75rem; color: var(--text-secondary); line-height: 1.4;
    padding: 6px 8px; background: rgba(255,255,255,0.03); border-radius: var(--radius);
    border-left: 2px solid #c9a96e;
}
.suggestion-pts {
    font-weight: 700; color: #c9a96e; margin-right: 4px;
}
.suggestion-perfect {
    color: var(--positive); border-left-color: var(--positive);
}

/* Edit panel */
.agent-edit-panel {
    margin: 12px 0;
    padding: 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.agent-edit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin: 10px 0;
}
.edit-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.edit-field-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.edit-input {
    padding: 6px 10px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.78rem;
    font-family: inherit;
}
.edit-input:focus {
    border-color: #c9a96e;
    outline: none;
}
.edit-field-toggle {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    justify-content: flex-start;
}
.edit-field-toggle .edit-field-label {
    order: 1;
}
.edit-toggle {
    order: 0;
    width: 16px;
    height: 16px;
    accent-color: #c9a96e;
}
.agent-edit-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
.agent-edit-save, .agent-edit-cancel {
    padding: 6px 18px;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: all 0.15s;
}
.agent-edit-save {
    background: #c9a96e;
    color: var(--bg);
    border-color: #c9a96e;
    font-weight: 600;
}
.agent-edit-save:hover { background: #d4b878; }
.agent-edit-save:disabled { opacity: 0.5; cursor: default; }
.agent-edit-cancel {
    background: transparent;
    color: var(--text-muted);
}
.agent-edit-cancel:hover { border-color: var(--border-hover); color: var(--text); }
@media (max-width: 600px) {
    .agent-edit-grid { grid-template-columns: 1fr; }
}

/* Sparklines */
.sparkline-wrap { height: 80px; min-width: 0; overflow: hidden; position: relative; }
.agent-sparklines-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 2px 8px;
    margin-top: 12px;
    overflow: hidden;
}
.agent-sparklines-grid > div { min-width: 0; overflow: hidden; }
.agent-sparklines-grid .agent-detail-title {
    margin-top: 4px !important;
    font-size: 0.7rem;
}
@media (max-width: 900px) {
    .agent-detail-grid-3col { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
    .agent-detail-grid-3col { grid-template-columns: 1fr; }
    .agent-sparklines-grid { grid-template-columns: 1fr; }
}

/* Agent trend header */
.agent-trend-header {
    margin-bottom: 16px;
}
.agent-trend-name {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text);
}
.agent-trend-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.agent-trend-stats {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* === Responsive === */
@media (max-width: 900px) {
    .layout { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .search-input { width: 150px; }
    .guide-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 600px) {
    .stats-bar { gap: 15px; padding: 12px 16px; }
    .stat .number { font-size: 1.3rem; }
    .agent-row { padding: 10px 16px; }
    .search-input { width: 120px; }
    .companies-grid { grid-template-columns: 1fr 1fr; }
    .topbar-title { display: none; }
    .topbar { padding: 10px 16px; }
    .guide-grid { grid-template-columns: repeat(2, 1fr); }
    .tier-footer { flex-wrap: wrap; }
}

/* === Drill-down Dashboard === */

/* Breadcrumb */
.drill-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: clamp(12px, 1.2vw, 24px);
    font-size: 0.8rem;
}
.breadcrumb-link {
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}
.breadcrumb-link:hover { color: var(--text); }
.breadcrumb-current {
    color: var(--text);
    font-weight: 600;
}
.breadcrumb-sep {
    color: var(--text-muted);
    opacity: 0.5;
}

/* Company score cards */
.company-cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(10px, 1.1vw, 24px);
    margin-bottom: clamp(16px, 1.7vw, 40px);
}
.company-score-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 3px solid transparent;
    border-radius: var(--radius);
    padding: clamp(16px, 1.5vw, 32px);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.company-score-card:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
    transform: translateY(-2px);
}
.csc-logo-wrap {
    height: clamp(32px, 3vw, 64px);
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}
.csc-logo {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    opacity: 0.9;
}
.csc-name-fallback {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}
.csc-score-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}
.csc-score {
    font-size: 1.6rem;
    font-weight: 300;
    color: var(--text);
    letter-spacing: -0.5px;
}
.csc-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}
.csc-tier-bar {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    display: flex;
    overflow: hidden;
    gap: 1px;
}
.csc-tier-bar > div {
    height: 100%;
}

/* Agent roster (flat list override + virtual scroller) */
.agent-roster {
    overflow-y: auto;
    max-height: 60vh;
    position: relative;
}
.agent-roster-spacer {
    width: 100%;
}
.agent-roster .agent-dir-summary {
    padding-left: 16px;
}
.agent-roster .agent-dir-detail {
    padding-left: 16px;
}
.agent-office-tag {
    font-size: 0.65rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.05);
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
    margin-left: 8px;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .company-cards-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .company-cards-grid { grid-template-columns: 1fr; }
}
