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

:root {
    --primary-color: #3d00b4;
    --primary-hover: #2d0087;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

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

/* App Container with Sidebar */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: -320px;
    top: 0;
    width: 320px;
    height: 100vh;
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    transition: left 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    left: 0;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin: 0;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    font-size: 1.25rem;
    border-radius: 4px;
    transition: all 0.2s;
    line-height: 1;
}

.icon-btn:hover {
    background: var(--bg-color);
    color: var(--text-primary);
}

.sidebar-filters {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
}

.filter-select {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-color);
    color: var(--text-primary);
    font-size: 0.875rem;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    position: fixed;
    left: 1rem;
    top: 1rem;
    width: 44px;
    height: 44px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.2s;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.sidebar-toggle:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.sidebar-toggle.hidden {
    left: 340px;
}

/* Backend Insights Toggle Button */
.backend-toggle {
    position: fixed;
    right: 1rem;
    top: 1rem;
    width: 44px;
    height: 44px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.2s;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.backend-toggle:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.backend-toggle.hidden {
    right: 420px;
}

/* Backend Panel */
.backend-panel {
    position: fixed;
    right: -420px;
    top: 0;
    width: 420px;
    height: 100vh;
    background: var(--card-bg);
    border-left: 1px solid var(--border-color);
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.backend-panel.open {
    right: 0;
}

.backend-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.backend-header h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin: 0;
}

.backend-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    background: var(--bg-color);
}

.backend-tab {
    flex: 1;
    padding: 0.75rem 1rem;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.backend-tab:hover {
    color: var(--primary-color);
    background: rgba(61, 0, 180, 0.05);
}

.backend-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: white;
}

.backend-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.backend-tab-content {
    display: none;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.backend-tab-content.active {
    display: flex;
}

.backend-controls {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
    background: var(--bg-color);
}

.toggle-btn {
    padding: 0.5rem 0.75rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

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

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

/* Logs Display */
.logs-display {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #1e293b;
    color: #e2e8f0;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.75rem;
    line-height: 1.5;
}

.logs-display .log-line {
    margin-bottom: 0.25rem;
    white-space: pre-wrap;
    word-break: break-all;
}

.logs-display .log-line.error {
    color: #fca5a5;
}

.logs-display .log-line.warning {
    color: #fcd34d;
}

.logs-display .log-line.success {
    color: #86efac;
}

.logs-display .empty-state,
.metrics-display .empty-state,
.status-display .empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    font-style: italic;
}

/* Metrics Display */
.metrics-display {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.metric-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bg-color);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.metric-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.metric-value {
    font-family: 'Monaco', 'Courier New', monospace;
    color: var(--text-primary);
    font-size: 0.875rem;
}

/* Status Display */
.status-display {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.status-item {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bg-color);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.status-item-header {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.status-item-content {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: 'Monaco', 'Courier New', monospace;
}

/* Mesh section styling */
.mesh-section {
    margin-bottom: 1.25rem;
}

.mesh-section h4 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0 0 0.75rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Mesh code display */
.mesh-code-container {
    position: relative;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.mesh-code {
    margin: 0;
    padding: 1rem;
    padding-top: 2.5rem;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.7rem;
    line-height: 1.4;
    color: var(--text-secondary);
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre;
}

.copy-code-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 1;
}

.copy-code-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.copy-code-btn.copied {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

/* Adjust main container when backend panel is open */
.main-container.backend-open {
    margin-right: 420px;
    transition: margin-right 0.3s ease;
}

/* Header (Full Width) */
.app-header {
    width: 100%;
    padding: 1.5rem 2rem;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.header-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    position: relative;
    max-width: 1400px;
    margin: 0 auto;
}

.header-branding {
    text-align: center;
}

.logo-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.header-logo {
    width: 50px;
    height: 50px;
    object-fit: contain;
}

.app-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #000000;
    margin-bottom: 0.5rem;
}

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

.header-auth,
.header-user {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    position: absolute;
    right: 0;
}

.user-email {
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* Main Container */
.main-container {
    flex: 1;
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
    width: 100%;
}

main {
    flex: 1;
}

section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* Prompt Section */
.prompt-section textarea {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s;
    margin-bottom: 1rem;
}

.prompt-section textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.submit-btn {
    width: 100%;
    padding: 1rem 2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
}

.submit-btn:hover {
    background: var(--primary-hover);
}

.submit-btn:active {
    transform: scale(0.98);
}

.submit-btn:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
}

/* Results Section */
.job-info {
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.info-row:last-child {
    border-bottom: none;
}

.label {
    font-weight: 600;
    color: var(--text-secondary);
}

.value {
    color: var(--text-primary);
    font-family: 'Monaco', 'Courier New', monospace;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge.accepted {
    background: var(--success-color);
    color: white;
}

.badge.completed {
    background: var(--success-color);
    color: white;
}

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

.badge.failed {
    background: var(--error-color);
    color: white;
}

.spec-details, .status-details {
    margin-top: 1.5rem;
}

pre {
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Warnings */
.warnings {
    background: #fef3c7;
    border: 1px solid var(--warning-color);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1.5rem;
}

.warnings h3 {
    color: #92400e;
    margin-bottom: 0.5rem;
}

.warnings ul {
    list-style: none;
    padding: 0;
}

.warnings li {
    color: #92400e;
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.warnings li::before {
    content: "⚠";
    position: absolute;
    left: 0;
}

/* Artifacts */
.artifacts {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.artifacts h3 {
    margin-bottom: 1rem;
}

.artifacts-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.artifact-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: all 0.2s;
}

.artifact-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(61, 0, 180, 0.1);
}

.artifact-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

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

.artifact-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.download-btn {
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.download-btn:hover {
    background: var(--primary-hover);
}

.download-btn:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
}

/* Visualization */
.visualization {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.viz-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.viz-tab {
    padding: 0.75rem 1.5rem;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.viz-tab:hover {
    color: var(--primary-color);
}

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

.viz-panel {
    min-height: 400px;
}

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

.chart-container {
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.chart-container h4 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.chart-container canvas {
    width: 100% !important;
    height: 300px !important;
}

/* VTK Viewer */
.vtk-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 8px;
}

.vtk-controls label {
    font-weight: 600;
    color: var(--text-primary);
}

.vtk-controls select {
    padding: 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
}

.vtk-viewer {
    width: 100%;
    height: 600px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

/* Actions */
.actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.secondary-btn {
    flex: 1;
    padding: 0.75rem 1.5rem;
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

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

/* Loading */
.loading {
    text-align: center;
    padding: 3rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error Section */
.error-section {
    background: #fee2e2;
    border: 1px solid var(--error-color);
}

.error-section h3 {
    color: var(--error-color);
}

.error-section p {
    color: #991b1b;
    margin-bottom: 1rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 640px) {
    .app-header h1 {
        font-size: 2rem;
    }

    .app-header {
        padding: 1rem;
    }

    .header-auth,
    .header-user {
        position: static;
        margin-top: 1rem;
        justify-content: center;
    }

    .header-content {
        flex-direction: column;
    }

    .actions {
        flex-direction: column;
    }

    section {
        padding: 1.5rem;
    }
}

/* Jobs List in Sidebar */
.jobs-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.job-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.875rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}

.job-item:hover {
    border-color: var(--primary-color);
    background: var(--bg-color);
}

.job-item.active {
    border-color: var(--primary-color);
    background: var(--bg-color);
}

.job-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
}

.job-item-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    line-height: 1.3;
    flex: 1;
}

.job-item-id {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-family: monospace;
    margin-top: 0.25rem;
}

.job-item-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.delete-job-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-job-btn:hover {
    background: var(--error-color);
    color: white;
}

.jobs-list-empty {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* Spec Table Styles */
.spec-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.spec-table thead {
    background: var(--primary-color);
    color: white;
}

.spec-table th,
.spec-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.spec-table th {
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.spec-table tbody tr:hover {
    background: var(--bg-color);
}

.spec-table .spec-section {
    background: #f1f5f9;
    font-weight: 600;
    color: var(--text-primary);
    padding: 0.5rem 1rem;
}

.spec-value {
    font-family: 'Monaco', 'Courier New', monospace;
    color: var(--text-primary);
    transition: background-color 0.3s;
}

.edit-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.25rem 0.5rem;
    opacity: 0.6;
    transition: opacity 0.2s, transform 0.2s;
}

.edit-btn:hover {
    opacity: 1;
    transform: scale(1.2);
}

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

/* Authentication Styles */
.auth-btn {
    padding: 0.5rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

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

.auth-btn-primary:hover {
    background: var(--primary-hover);
}

.auth-btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

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

.auth-btn-full {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    margin-top: 0.5rem;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s ease-out;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
    line-height: 1;
}

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

.modal-body {
    padding: 2rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
    font-family: inherit;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.auth-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    display: none;
}

.auth-error.active {
    display: block;
}

.auth-footer {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.auth-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* ==================== Templates Section ==================== */
.templates-section {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.templates-header {
    margin-bottom: 1.5rem;
}

.templates-header h2 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

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

.templates-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.templates-filters .filter-select {
    flex: 1;
    min-width: 150px;
}

.templates-filters .secondary-btn {
    white-space: nowrap;
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.template-card {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.template-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.template-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.template-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.template-card-badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.template-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.template-badge.category {
    background: #ede5fc;
    color: #3d00b4;
}

.template-badge.difficulty-beginner {
    background: #d1fae5;
    color: #065f46;
}

.template-badge.difficulty-intermediate {
    background: #fef3c7;
    color: #92400e;
}

.template-badge.difficulty-advanced {
    background: #fee2e2;
    color: #991b1b;
}

.template-card-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.template-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.template-meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.template-meta-icon {
    font-size: 1rem;
}

.template-use-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.template-use-btn:hover {
    background: var(--primary-hover);
}

.loading-spinner {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.templates-empty {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.templates-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .templates-grid {
        grid-template-columns: 1fr;
    }

    .templates-filters {
        flex-direction: column;
    }

    .templates-filters .filter-select {
        width: 100%;
    }
}
