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

:root {
    --bg: #0a0a0a;
    --bg-alt: #151515;
    --border: #333;
    --text: #e0e0e0;
    --text-dim: #999;
    --accent: #4a9eff;
    --accent-hover: #6bb0ff;
    --success: #4ade80;
    --danger: #ef4444;
    --warning: #fbbf24;
}

body {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.4;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
}

header {
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.stats {
    display: flex;
    gap: 20px;
    font-size: 12px;
    color: var(--text-dim);
}

.stats span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.stats strong {
    color: var(--text);
    font-weight: 600;
}

.tabs {
    display: flex;
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
}

.tab {
    background: none;
    border: none;
    color: var(--text-dim);
    padding: 10px 16px;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}

.tab:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.03);
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

main {
    padding: 20px;
    max-width: 1800px;
    margin: 0 auto;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.controls {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.controls input[type="text"],
.controls input[type="number"] {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 12px;
    font-family: inherit;
    font-size: 12px;
    border-radius: 4px;
    outline: none;
}

.controls input[type="text"] {
    flex: 1;
    min-width: 300px;
}

.controls input[type="number"] {
    width: 140px;
}

.controls input:focus {
    border-color: var(--accent);
}

.controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-dim);
}

.controls button {
    background: var(--accent);
    color: #000;
    border: none;
    padding: 8px 16px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}

.controls button:hover {
    background: var(--accent-hover);
}

.controls button.btn-secondary {
    background: var(--bg-alt);
    color: var(--text-dim);
    border: 1px solid var(--border);
}

.controls button.btn-secondary:hover {
    background: var(--border);
    color: var(--text);
}

.count {
    color: var(--text-dim);
    font-size: 12px;
    margin-left: auto;
}

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-alt);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

thead {
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

th:hover {
    color: var(--accent);
    background: rgba(255, 255, 255, 0.02);
}

th[data-sort]::after {
    content: ' ⇅';
    opacity: 0.3;
}

th[data-sort].asc::after {
    content: ' ↑';
    opacity: 1;
}

th[data-sort].desc::after {
    content: ' ↓';
    opacity: 1;
}

td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

tbody tr {
    transition: background 0.1s;
    cursor: pointer;
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

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

.number {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.positive {
    color: var(--success);
}

.negative {
    color: var(--danger);
}

.high-score {
    color: var(--warning);
    font-weight: 600;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

#back-btn {
    background: var(--bg-alt);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 6px 12px;
    font-family: inherit;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}

#back-btn:hover {
    background: var(--border);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.detail-section {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 16px;
}

.detail-section.full-width {
    grid-column: 1 / -1;
}

.detail-section h3 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--accent);
}

.detail-section dl {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 8px;
    font-size: 12px;
}

.detail-section dt {
    color: var(--text-dim);
}

.detail-section dd {
    color: var(--text);
    font-weight: 500;
}

.detail-section p {
    font-size: 12px;
    line-height: 1.6;
    color: var(--text);
}

#detail-naics {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.naics-badge {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.naics-badge .code {
    font-weight: 600;
    color: var(--accent);
}

.naics-badge .name {
    color: var(--text-dim);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* Loading state */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-dim);
}

/* Empty state */
.empty {
    text-align: center;
    padding: 40px;
    color: var(--text-dim);
    font-style: italic;
}
