:root {
    --google-blue: #1a73e8;
    --text-primary: #3c4043;
    --text-secondary: #5f6368;
    --bg-main: #f8f9fa;
    --border-color: #dadce0;
    --gemini-gradient: linear-gradient(90deg, #4285f4 0%, #9b72cb 50%, #d96570 100%);
}

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

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-main);
    min-height: 100vh;
    overflow-x: hidden;
}

.mesh-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 20% 20%, #d2e3fc 0%, transparent 40%),
        radial-gradient(circle at 80% 10%, #f1e4ff 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, #ffe8ec 0%, transparent 60%);
    filter: blur(80px);
    z-index: -1;
    opacity: 0.6;
}

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

header {
    text-align: center;
    margin-bottom: 50px;
}

.gemini-logo {
    width: 60px;
    height: 60px;
    margin: 0 auto 15px;
    position: relative;
}

.gemini-logo::before,
.gemini-logo::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--gemini-gradient);
    border-radius: 50%;
}

.gemini-logo::before {
    width: 100%;
    height: 40%;
}

.gemini-logo::after {
    width: 40%;
    height: 100%;
}

.sparkle-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #4285f4;
    border-radius: 50%;
    top: 10%;
    right: 10%;
    box-shadow: 0 0 10px #4285f4;
}

h1 {
    font-size: 42px;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 18px;
}

main {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.config-card,
.results-card {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

label {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-secondary);
}

select,
input {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

select:focus,
input:focus {
    border-color: var(--google-blue);
}

.action-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.gradient-btn {
    background: var(--gemini-gradient);
    border: none;
    border-radius: 50px;
    padding: 2px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
    max-width: 400px;
}

.gradient-btn span {
    display: block;
    background: white;
    padding: 16px 32px;
    border-radius: 48px;
    font-weight: 700;
    font-size: 16px;
    color: var(--text-primary);
    transition: background 0.2s, color 0.2s;
}

.gradient-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

.gradient-btn:hover span {
    background: transparent;
    color: white;
}

.hidden {
    display: none !important;
}

#loader {
    text-align: center;
    color: var(--text-secondary);
}

#stop-btn {
    margin-top: 20px;
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--google-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.header-metrics {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.main-metrics {
    display: flex;
    align-items: center;
    gap: 12px;
}

.granular-scores {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 12px;
}

.arch-score {
    font-size: 11px;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.arch-score span {
    font-weight: 700;
    color: var(--primary);
    margin-left: 4px;
}

.exec-time {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.badge {
    background: #e8f0fe;
    color: var(--google-blue);
    padding: 8px 16px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 14px;
}

.badge.small {
    padding: 4px 10px;
    font-size: 11px;
    text-transform: uppercase;
}

.facet-search-container {
    position: relative;
    margin-bottom: 24px;
    background: #f8faff;
    border-radius: 16px;
    border: 1px solid #eef2f8;
    padding: 8px;
}

.facet-input-wrapper {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: white;
    border: 1.5px solid #e1e7f0;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.facet-input-wrapper:focus-within {
    border-color: var(--google-blue);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

.facet-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.facet-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #e8f0fe;
    color: #1967d2;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
}

.facet-chip .remove-facet {
    cursor: pointer;
    font-size: 14px;
    opacity: 0.6;
}

.facet-chip .remove-facet:hover {
    opacity: 1;
}

.facet-input-wrapper input {
    flex: 1;
    border: none !important;
    padding: 8px 4px !important;
    font-size: 14px;
    outline: none !important;
    min-width: 150px;
}

.facet-suggestions {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid #dadce0;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 100;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.suggestion-group label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    color: #70757a;
    font-weight: 700;
    margin-bottom: 6px;
    padding-left: 8px;
}

.suggestion-item {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.suggestion-item:hover,
.suggestion-item.selected {
    background: #e8f0fe;
    color: #1967d2;
}

.results-filters input,
.results-filters select {
    padding: 10px 14px;
    border: 1.5px solid #e1e7f0;
    border-radius: 8px;
    font-size: 13px;
    color: #3c4043;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    background: white;
}

.results-filters input:focus,
.results-filters select:focus {
    border-color: var(--google-blue);
    outline: none;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

.results-filters select {
    flex: 1;
    min-width: 140px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%235f6368'%3E%3Cpath d='M2 4l4 4 4-4H2z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    appearance: none;
    padding-right: 32px;
}

#results-table th {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background 0.2s ease;
    border-bottom: 2px solid #f1f3f4;
    color: #5f6368;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 700;
    line-height: 1.3;
    vertical-align: top;
}

#results-table th:hover {
    background: #f1f3f4;
}

.sort-icon {
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 6px;
    vertical-align: middle;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    opacity: 0.3;
}

th.sort-asc .sort-icon {
    border-bottom: 4px solid #3c4043;
    opacity: 0.8;
}

th.sort-desc .sort-icon {
    border-top: 4px solid #3c4043;
    opacity: 0.8;
}

#results-table tbody tr {
    transition: transform 0.2s ease, background 0.2s ease;
}

#results-table tbody tr:hover {
    background: #f8f9fa;
    transform: scale(1.002);
}

.table-container {
    overflow-x: auto;
    margin-top: 10px;
}

#results-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

#results-table th,
#results-table td {
    padding: 14px 12px;
    border-bottom: 1px solid #f1f3f4;
    vertical-align: middle;
}

#results-table td {
    color: #3c4043;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Explicit Column Geometry */
.col-4, .col-5, .col-6 {
    text-align: right;
}

#results-table td.col-4,
#results-table td.col-5,
#results-table td.col-6 {
    padding-right: 24px;
}

#results-table th.col-4,
#results-table th.col-5,
#results-table th.col-6 {
    padding-right: 24px;
}

/* Keep header left for better visual flow */

.chart-preview {
    width: 100%;
    height: 48px;
    background: transparent;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.165, 0.84, 0.44, 1), background 0.2s;
    border: 1px solid transparent;
}

.chart-preview:hover {
    transform: scale(1.04);
    background: rgba(26, 115, 232, 0.04);
    border-color: rgba(26, 115, 232, 0.1);
}

/* Lightbox Modal */
.chart-modal-content {
    max-width: 900px;
    width: 95vw;
    padding: 32px;
}

.modal-chart-container {
    width: 100%;
    min-height: 400px;
    background: white;
    border-radius: 16px;
    margin: 24px 0;
    border: 1px solid var(--border-color);
}

#results-table td {
    color: #3c4043;
}

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

.outline-btn {
    background: transparent;
    border: 2px solid #d93025;
    color: #d93025;
    border-radius: 50px;
    padding: 10px 24px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.outline-btn:hover {
    background: #d93025;
    color: white;
}

.outline-btn.danger {
    border-color: #d93025;
    color: #d93025;
}

.outline-btn.danger:hover {
    background: #d93025;
    color: white;
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal {
    background: white;
    padding: 40px;
    border-radius: 28px;
    max-width: 450px;
    width: 90%;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.modal h2 {
    font-size: 24px;
    margin-bottom: 16px;
    font-weight: 700;
}

.modal p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 32px;
}

.modal-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
}

.text-btn {
    background: transparent;
    border: 2px solid transparent;
    /* Match border width of outline-btn for alignment parity */
    color: var(--google-blue);
    font-weight: 600;
    cursor: pointer;
    padding: 10px 24px;
    border-radius: 50px;
    transition: background 0.2s;
}

.text-btn:hover {
    background: #e8f0fe;
}