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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #1a1a1a;
    background: #f5f7fa;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
}

/* Header */
header {
    background: linear-gradient(135deg, #0066cc 0%, #004d99 100%);
    color: white;
    padding: 32px 0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 6px;
}

header p {
    font-size: 14px;
    opacity: 0.95;
    font-weight: 400;
    letter-spacing: 0.3px;
}

.header-credit {
    font-size: 13px;
    opacity: 0.85;
    margin-top: 2px;
    letter-spacing: 0.2px;
}

.header-stats {
    display: flex;
    gap: 48px;
}

.header-stat {
    text-align: right;
}

.header-stat-number {
    font-size: 32px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 6px;
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
    letter-spacing: -0.5px;
}

.header-stat-label {
    font-size: 11px;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

/* Main */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 24px 0 0;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
}

.tab-panel::-webkit-scrollbar {
    width: 8px;
}

.tab-panel::-webkit-scrollbar-track {
    background: transparent;
}

.tab-panel::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.tab-panel::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Search Card */
.search-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    margin-bottom: 24px;
    margin-top: 24px;
}

/* Inline Tabs */
.tabs-inline {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: #f3f4f6;
    padding: 4px;
    border-radius: 10px;
}

.tab-inline {
    background: transparent;
    border: none;
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    justify-content: center;
}

.tab-icon {
    font-size: 14px;
}

.tab-inline:hover {
    color: #0066cc;
    background: rgba(0, 102, 204, 0.1);
}

.tab-inline.active {
    color: white;
    background: #0066cc;
    box-shadow: 0 2px 6px rgba(0, 102, 204, 0.3);
}

.tab-content-inline {
    display: none;
}

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

.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.search-wrapper {
    position: relative;
    flex: 1;
}

#search-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    background: white;
    transition: all 0.2s;
}

#search-input::placeholder {
    color: #9ca3af;
}

#search-input:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

button {
    padding: 12px 24px;
    background: #0066cc;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

button:hover {
    background: #0052a3;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
}

button:active {
    transform: scale(0.98);
}

/* Pulse animation for search button */
#search-btn {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(0, 102, 204, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(0, 102, 204, 0);
    }
}

#search-btn:hover {
    animation: none;
}

.btn-secondary {
    background: #f3f4f6;
    color: #1a1a1a;
    border: none;
}

.btn-secondary:hover {
    background: #e5e7eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Autocomplete */
.autocomplete {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    max-height: 360px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    display: none;
}

.autocomplete.show {
    display: block;
}

.autocomplete-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: #f8f9fa;
}

.autocomplete-name {
    font-size: 14px;
    color: #1a1a1a;
    font-weight: 600;
    margin-bottom: 2px;
}

.autocomplete-ticker {
    font-size: 12px;
    color: #6b7280;
}

.autocomplete-empty {
    padding: 16px;
    color: #9ca3af;
    font-size: 13px;
    text-align: center;
}

/* Filters */
.filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 16px;
    border-top: 1px solid #f3f4f6;
}

.filters select,
.filters input[type="date"] {
    padding: 8px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    background: white;
    color: #1a1a1a;
    transition: all 0.2s;
}

.filters select:focus,
.filters input[type="date"]:focus {
    outline: none;
    border-color: #0066cc;
}

.filters select {
    min-width: 160px;
}

.filters input[type="date"] {
    width: 150px;
}

/* Popular Companies */
.popular-companies {
    margin-top: 16px;
}

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

.popular-header h3 {
    font-size: 14px;
    font-weight: 700;
    color: #1a1a1a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.popular-icon {
    font-size: 16px;
}

.companies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.company-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.company-card:hover {
    border-color: #0066cc;
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.15);
    transform: translateY(-2px);
}

.company-ticker {
    font-size: 18px;
    font-weight: 800;
    color: #0066cc;
    margin-bottom: 6px;
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
    letter-spacing: 0.5px;
}

.company-name {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.company-filings {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 6px;
    font-weight: 600;
}

/* SQL Specific */
.sql-examples {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 10px;
    align-items: center;
}

.examples-label {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    margin-right: 6px;
}

.example {
    padding: 6px 14px;
    background: white;
    color: #0066cc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
}

.example:hover {
    background: #0066cc;
    color: white;
    border-color: #0066cc;
    transform: scale(1.05);
}

#sql-input {
    width: 100%;
    padding: 16px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    background: #fafbfc;
    resize: vertical;
    margin-bottom: 12px;
    line-height: 1.6;
    height: 100px;
}

#sql-input:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
    background: white;
}

/* Results */
#results,
#sql-results {
    display: none;
}

#results.show,
#sql-results.show {
    display: block;
}

.result-header,
.results-header {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.result-card:hover {
    border-color: #0066cc;
    box-shadow: 0 4px 16px rgba(0, 102, 204, 0.15);
    transform: translateY(-2px);
}

.result-card h3 {
    font-size: 17px;
    font-weight: 700;
    color: #0066cc;
    margin-bottom: 10px;
}

.result-info {
    display: flex;
    gap: 24px;
    font-size: 13px;
    color: #6b7280;
    flex-wrap: wrap;
}

.result-info span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.no-results {
    text-align: center;
    padding: 48px;
    color: #9ca3af;
    font-size: 15px;
    background: white;
    border-radius: 12px;
    border: 1px dashed #e5e7eb;
}

/* Table */
.table-wrapper {
    overflow-x: auto;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    margin-bottom: 16px;
}

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

th {
    background: #f8f9fa;
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border-bottom: 2px solid #e5e7eb;
}

td {
    padding: 12px 16px;
    font-size: 14px;
    color: #1a1a1a;
    border-bottom: 1px solid #f3f4f6;
}

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

tr:hover {
    background: #fafbfc;
}

.error {
    background: #fef2f2;
    border: 2px solid #fecaca;
    color: #991b1b;
    padding: 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.modal-content {
    position: relative;
    background: white;
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-close {
    position: absolute;
    right: 16px;
    top: 16px;
    width: 32px;
    height: 32px;
    padding: 0;
    background: #f3f4f6;
    color: #6b7280;
    border-radius: 50%;
    font-size: 20px;
    font-weight: 300;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.modal-close:hover {
    background: #e5e7eb;
    color: #1a1a1a;
    transform: scale(1.1);
}

#modal-body {
    padding: 28px;
    overflow-y: auto;
}

#modal-body h2 {
    font-size: 22px;
    font-weight: 700;
    color: #0066cc;
    margin-bottom: 16px;
    padding-right: 32px;
}

.company-info {
    display: flex;
    gap: 24px;
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e5e7eb;
    flex-wrap: wrap;
}

.company-info-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.company-info-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #9ca3af;
}

.company-info-value {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
}

#modal-body h3 {
    font-size: 14px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filings-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.filing-row {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 13px;
    transition: all 0.2s;
}

.filing-row:hover {
    background: #e5e7eb;
}

.filing-type {
    font-weight: 700;
    color: #0066cc;
    min-width: 60px;
}

.filing-separator {
    color: #d1d5db;
    margin: 0 10px;
}

.filing-date {
    color: #6b7280;
    min-width: 90px;
}

.filing-status {
    font-size: 12px;
    margin-right: 8px;
}

.filing-status.processed {
    color: #10b981;
}

.filing-status.pending {
    color: #9ca3af;
}

.filing-link {
    color: #0066cc;
    text-decoration: none;
    font-weight: 600;
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}

.filing-link:hover {
    color: #0052a3;
    gap: 6px;
}

/* Filing images badge */
.filing-images-badge {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    margin-right: 8px;
}

.filing-images-badge.has-images {
    background: #dcfce7;
    color: #166534;
    cursor: pointer;
    transition: all 0.2s;
}

.filing-images-badge.has-images:hover {
    background: #bbf7d0;
}

.filing-images-badge.no-images {
    background: #f3f4f6;
    color: #6b7280;
}

.filing-images-badge.not-processed {
    background: #fef3c7;
    color: #92400e;
}

.toggle-icon {
    font-size: 10px;
    margin-right: 4px;
}

/* Filing item wrapper */
.filing-item {
    margin-bottom: 2px;
}

/* Expandable images list */
.filing-images-list {
    display: none;
    background: #f8f9fa;
    border-left: 3px solid #0066cc;
    margin: 4px 0 8px 12px;
    padding: 8px 12px;
    border-radius: 0 6px 6px 0;
    max-height: 200px;
    overflow-y: auto;
}

.filing-images-list.show {
    display: block;
}

.image-url {
    display: block;
    font-size: 11px;
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
    color: #0066cc;
    text-decoration: none;
    padding: 4px 0;
    border-bottom: 1px solid #e5e7eb;
    word-break: break-all;
}

.image-url:last-child {
    border-bottom: none;
}

.image-url:hover {
    color: #0052a3;
    background: #e5e7eb;
}

/* Footer */
footer {
    background: #1a1a1a;
    color: white;
    padding: 16px 0;
    text-align: center;
    flex-shrink: 0;
}

footer p {
    font-size: 12px;
    opacity: 0.9;
    line-height: 1.4;
    margin: 0;
}

footer strong {
    font-weight: 600;
}

.footer-sub {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 4px;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }
    
    header {
        padding: 24px 0;
    }
    
    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }
    
    header h1 {
        font-size: 26px;
    }
    
    header p {
        font-size: 13px;
    }
    
    .header-stats {
        gap: 32px;
    }
    
    .header-stat-number {
        font-size: 22px;
    }
    
    .search-card {
        padding: 20px;
    }
    
    .search-bar {
        flex-direction: column;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .filters select,
    .filters input[type="date"],
    .filters button {
        width: 100%;
    }
    
    .result-info {
        flex-direction: column;
        gap: 8px;
    }
    
    .company-info {
        flex-direction: column;
        gap: 12px;
    }
    
    .companies-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    #modal-body {
        padding: 20px;
    }
    
    #modal-body h2 {
        font-size: 20px;
    }
    
    .modal-container {
        padding: 20px 12px;
    }
    
    .filing-row {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .filing-separator {
        display: none;
    }
}