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

:root {
    --primary-color: #3b82f6;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: #475569;
    --ultra-cheap: #10b981;
    --cheap: #3b82f6;
    --moderate: #f59e0b;
    --expensive: #ef4444;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    padding: 20px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px;
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-light) 100%);
    border-radius: 12px;
    border: 1px solid var(--border);
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

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

.search-box {
    flex: 1;
    min-width: 250px;
}

#searchInput {
    width: 100%;
    padding: 12px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
}

#searchInput:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-edit {
    background: var(--warning-color);
    color: white;
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-edit:hover {
    background: #d97706;
}

.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--surface);
    padding: 25px;
    border-radius: 12px;
    border: 1px solid var(--border);
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.table-wrapper {
    overflow-x: auto;
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 30px;
}

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

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

th {
    padding: 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable:hover {
    background: var(--surface);
}

.sort-icon {
    opacity: 0.3;
    margin-left: 5px;
}

th.sorted .sort-icon {
    opacity: 1;
    color: var(--primary-color);
}

.unit {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 400;
}

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

tbody tr {
    transition: background 0.2s;
}

tbody tr:hover {
    background: var(--surface-light);
}

.model-name {
    font-weight: 600;
    color: var(--text-primary);
}

.openrouter-id {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: var(--background);
    padding: 4px 8px;
    border-radius: 4px;
}

.price {
    font-weight: 600;
    font-size: 1.1rem;
}

.price-ultra-cheap { color: var(--ultra-cheap); }
.price-cheap { color: var(--cheap); }
.price-moderate { color: var(--moderate); }
.price-expensive { color: var(--expensive); }

.total-cost {
    font-weight: 700;
    font-size: 1.2rem;
}

.context-badge {
    background: var(--primary-color);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-block;
}

.best-for {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.features {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.availability {
    font-size: 1.5rem;
}

.actions-col {
    white-space: nowrap;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.legend {
    background: var(--surface);
    padding: 25px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.legend h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
}

.legend-items {
    display: flex;
    gap: 25px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-box {
    width: 30px;
    height: 20px;
    border-radius: 4px;
}

.color-box.ultra-cheap { background: var(--ultra-cheap); }
.color-box.cheap { background: var(--cheap); }
.color-box.moderate { background: var(--moderate); }
.color-box.expensive { background: var(--expensive); }

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--surface);
    margin: 50px auto;
    padding: 30px;
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.close {
    color: var(--text-secondary);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.close:hover {
    color: var(--text-primary);
}

#modalTitle {
    margin-bottom: 25px;
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 500;
}

input[type="text"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 10px 15px;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

textarea {
    resize: vertical;
}

.form-buttons {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

.form-buttons .btn {
    flex: 1;
}

/* Responsive */
@media (max-width: 768px) {
    h1 {
        font-size: 1.8rem;
    }

    .controls {
        flex-direction: column;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    th, td {
        padding: 10px;
        font-size: 0.9rem;
    }

    .action-buttons {
        flex-direction: column;
    }
}

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

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}
