/* Core Design System & Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-dark: #09090e;
    --card-bg: rgba(22, 22, 33, 0.45);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-border-focus: rgba(99, 102, 241, 0.5);
    
    --primary: #6366f1;       /* Indigo */
    --primary-glow: rgba(99, 102, 241, 0.35);
    --secondary: #06b6d4;     /* Cyan */
    --secondary-glow: rgba(6, 182, 212, 0.35);
    
    --accent: #a855f7;        /* Purple */
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dark: #1f2937;
    
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    
    --font-sans: 'Outfit', sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Ambient Background Blobs */
.bg-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    z-index: 0;
    opacity: 0.35;
    pointer-events: none;
    animation: pulse 12s infinite alternate ease-in-out;
}

.blob-purple {
    background: var(--accent);
    width: 500px;
    height: 500px;
    top: -100px;
    right: -100px;
}

.blob-blue {
    background: var(--primary);
    width: 600px;
    height: 600px;
    bottom: -150px;
    left: -150px;
    animation-delay: -3s;
}

.blob-cyan {
    background: var(--secondary);
    width: 400px;
    height: 400px;
    top: 40%;
    left: 30%;
    animation-delay: -6s;
}

@keyframes pulse {
    0% {
        transform: translate(0, 0) scale(1);
    }
    100% {
        transform: translate(80px, 40px) scale(1.15);
    }
}

/* App Layout */
.app-container {
    width: 100%;
    max-width: 1280px;
    min-height: 100vh;
    padding: 2rem;
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
}

/* Header & Nav */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--card-border);
    margin-bottom: 2rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.logo-icon {
    width: 1.6rem;
    height: 1.6rem;
    object-fit: contain;
    filter: drop-shadow(0 0 8px var(--primary-glow));
}

.brand-text h1 {
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: 1.5px;
    line-height: 1.1;
    background: linear-gradient(135deg, #ffffff, #a5b4fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-text span {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.8px;
}

.app-nav {
    display: flex;
    gap: 0.8rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.4rem;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    backdrop-filter: blur(8px);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.app-nav::-webkit-scrollbar {
    display: none;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition-smooth);
    white-space: nowrap;
    flex-shrink: 0;
}

.nav-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.nav-btn.active {
    color: var(--text-main);
    background: var(--primary);
    box-shadow: 0 4px 15px var(--primary-glow);
}

/* Tabs & Grid system */
.tab-content {
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
}

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

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

.grid-2col {
    display: grid;
    grid-template-columns: minmax(0, var(--col-1, 1fr)) minmax(0, var(--col-2, 1.1fr));
    gap: 2rem;
    align-items: stretch;
}

@media (max-width: 900px) {
    .grid-2col {
        grid-template-columns: minmax(0, 1fr) !important;
    }
    .app-header {
        flex-direction: column;
        gap: 1.5rem;
        align-items: flex-start;
    }
    .app-nav, .dashboard-nav {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        white-space: nowrap;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }
    .db-tab-btn {
        flex-shrink: 0;
    }
    .dev-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem !important;
    }
}


/* Glass Card */
.glass-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 2.2rem;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.glass-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0.02) 100%);
    pointer-events: none;
}

.card-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.card-title i {
    color: var(--primary);
}

.card-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.8rem;
}

/* Material Selector Grid */
.material-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 0.8rem;
    margin-bottom: 0.5rem;
}

.material-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 0.8rem 0.5rem;
    cursor: pointer;
    text-align: center;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.material-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.material-card.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(6, 182, 212, 0.15));
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

.material-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-main);
}

.material-card.active .material-name {
    color: #a5b4fc;
}

.material-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Form Controls */
.form-group {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: 0.5px;
}

.form-input {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 0.9rem 1.1rem;
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    width: 100%;
    transition: var(--transition-smooth);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
    background: rgba(0, 0, 0, 0.5);
}

.form-row {
    display: flex;
    gap: 1.2rem;
}

@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
        gap: 1rem;
    }
}

.flex-1 {
    flex: 1;
}

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

.input-unit-wrapper {
    position: relative;
}

.input-unit-wrapper .form-input {
    padding-right: 3.5rem;
}

.input-unit {
    position: absolute;
    right: 1.1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
    pointer-events: none;
}

/* File Upload zone */
.upload-dropzone {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.15);
    border-radius: 16px;
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}

.upload-dropzone:hover, .upload-dropzone.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.1);
}

.upload-icon {
    font-size: 2.5rem;
    color: var(--text-muted);
    transition: var(--transition-smooth);
    margin-bottom: 0.4rem;
}

.upload-dropzone:hover .upload-icon, .upload-dropzone.dragover .upload-icon {
    color: var(--primary);
    transform: translateY(-3px);
}

.upload-dropzone h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.upload-dropzone p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.file-limits {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.05);
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    margin-top: 0.4rem;
}

/* File Progress Card */
.upload-progress-container {
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1rem;
    margin-top: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

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

#uploaded-filename {
    font-size: 0.9rem;
    font-weight: 600;
    max-width: 80%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition-smooth);
    padding: 0.2rem;
}

.icon-btn:hover {
    color: var(--error);
}

.progress-bar-wrapper {
    height: 6px;
    background: rgba(255,255,255,0.05);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 3px;
    transition: width 0.3s ease;
}

#upload-status-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* 3D Viewer Container */
.viewer-container {
    background: #040406;
    border: 1px solid var(--card-border);
    border-radius: 16px;
    height: 240px;
    position: relative;
    overflow: hidden;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.viewer-placeholder {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.placeholder-icon {
    font-size: 3rem;
    color: rgba(255,255,255,0.05);
}

.viewer-placeholder p {
    font-size: 0.9rem;
    max-width: 250px;
}

#stl-canvas {
    width: 100%;
    height: 100%;
    cursor: grab;
}

#stl-canvas:active {
    cursor: grabbing;
}

.viewer-loading {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--text-muted);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.viewer-legend {
    position: absolute;
    bottom: 0.8rem;
    left: 0.8rem;
    display: flex;
    gap: 0.8rem;
    background: rgba(0,0,0,0.6);
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.05);
    pointer-events: none;
}

.viewer-legend span {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* Public Estimate Result Card */
.result-card {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(6, 182, 212, 0.08));
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    animation: scaleIn 0.3s ease-out;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.97);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.estimate-header {
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.8rem;
}

.estimate-header span {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.estimate-header h3 {
    font-size: 2.2rem;
    font-weight: 800;
    color: #ffffff;
    background: linear-gradient(90deg, #ffffff, #67e8f9);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-top: 0.2rem;
}

.estimate-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.stat-item {
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.03);
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

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

.stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
}

.disclaimer-alert {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
}

.disclaimer-alert i {
    color: var(--warning);
    font-size: 0.9rem;
    margin-top: 0.1rem;
}

.disclaimer-alert span {
    font-size: 0.72rem;
    color: rgba(243, 244, 246, 0.8);
    line-height: 1.3;
}

/* Submit & Loading Button */
.submit-btn {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border: none;
    color: #ffffff;
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 700;
    padding: 1rem;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    box-shadow: 0 4px 20px var(--primary-glow);
    width: 100%;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(99, 102, 241, 0.45);
}

.submit-btn:active {
    transform: translateY(0);
}

.submit-btn:disabled {
    background: rgba(255,255,255,0.05);
    color: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* Admin Placeholder & Invoice */
.admin-placeholder-state {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.invoice-box {
    background: #ffffff;
    color: var(--text-dark);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    font-family: var(--font-sans);
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    animation: scaleIn 0.3s ease-out;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 1rem;
}

.invoice-header h3 {
    font-size: 1.2rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #111827;
}

.status-tag {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.invoice-items {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.invoice-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #4b5563;
    font-weight: 500;
}

.invoice-item .val {
    font-weight: 700;
    color: #111827;
}

.invoice-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 0.3rem 0;
}

.invoice-item.highlight {
    font-size: 0.95rem;
    font-weight: 700;
    color: #111827;
}

.invoice-total {
    border-top: 2px solid #e5e7eb;
    padding-top: 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.total-label {
    font-weight: 800;
    font-size: 1.1rem;
    color: #111827;
    text-transform: uppercase;
}

.total-amount-box {
    display: flex;
    align-items: baseline;
    gap: 0.2rem;
}

.total-amount {
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--primary);
}

.currency {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-dark);
}

/* Settings Unlock & Configuration CSS */
.lock-screen-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 3rem 0;
}

.lock-card {
    max-width: 400px;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
}

.lock-icon {
    font-size: 2.8rem;
    color: var(--accent);
    filter: drop-shadow(0 0 8px rgba(168, 85, 247, 0.4));
}

.passcode-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    width: 100%;
    margin-top: 0.5rem;
}

.error-text {
    color: var(--error);
    font-size: 0.8rem;
    font-weight: 600;
}

.config-sections {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.config-sec h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.8rem;
    border-left: 3px solid var(--primary);
    padding-left: 0.6rem;
}

.table-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.config-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.config-table th, .config-table td {
    padding: 0.7rem 0.8rem;
    text-align: left;
}

.config-table th {
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--card-border);
}

.config-table td {
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.config-table .tbl-input {
    background: rgba(0,0,0,0.5);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    width: 100%;
    font-family: var(--font-sans);
    font-weight: 600;
}

.config-table .tbl-input:focus {
    outline: none;
    border-color: var(--primary);
}

.settings-action-bar {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding-top: 1rem;
}

.save-btn {
    padding: 0.8rem 1.5rem;
    width: auto;
}

.margin-top-lg {
    margin-top: 1.5rem;
}

.margin-top-sm {
    margin-top: 0.8rem;
}

.margin-top-auto {
    margin-top: auto;
}

/* API Key Badges & Styling */
.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    display: inline-block;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.key-text {
    font-family: monospace;
    font-weight: 600;
    color: #a5b4fc;
    background: rgba(0, 0, 0, 0.35);
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
    font-size: 0.82rem;
    cursor: pointer;
    border: 1px dashed var(--card-border);
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.key-text:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.action-btn-group {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
}

.tbl-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
    font-size: 0.78rem;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.tbl-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.tbl-btn.btn-danger:hover {
    background: var(--error);
    border-color: var(--error);
    color: #ffffff;
}


/* Helper Utilities */
.hidden {
    display: none !important;
}

.flex-column {
    display: flex;
    flex-direction: column;
}

.justify-center {
    justify-content: center;
}

/* Footer styling */
.app-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--card-border);
    margin-top: 4rem;
    padding-top: 1.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.footer-links a:hover {
    color: var(--primary);
}

/* Auth Portal Tabs */
.auth-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 700;
    padding: 0.8rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    border-bottom: 2px solid transparent;
}

.auth-tab-btn:hover {
    color: var(--text-main) !important;
}

.auth-tab-btn.active {
    border-bottom-color: var(--primary) !important;
    color: var(--text-main) !important;
}

/* Modal Overlay & Card Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: rgba(22, 22, 33, 0.95);
    border: 1px solid var(--card-border-focus);
    border-radius: 12px;
    padding: 1.8rem;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay:not(.hidden) .modal-card {
    transform: scale(1);
}

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

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-main);
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.modal-close-btn:hover {
    color: var(--text-main);
}

.modal-body {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Toast Notifications Container */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    background: rgba(22, 22, 33, 0.9);
    border-left: 4px solid var(--primary);
    border-top: 1px solid var(--card-border);
    border-right: 1px solid var(--card-border);
    border-bottom: 1px solid var(--card-border);
    backdrop-filter: blur(12px);
    color: var(--text-main);
    padding: 0.9rem 1.2rem;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 280px;
    max-width: 420px;
    pointer-events: auto;
    transform: translateY(20px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--error);
}

.toast.warning {
    border-left-color: var(--warning);
}

/* Public Estimator Upload Confirmation Panel */
.upload-confirm-panel {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    animation: fadeIn 0.3s ease;
}

.confirm-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    background: rgba(0,0,0,0.15);
    border-radius: 8px;
    padding: 1rem;
}

.confirm-stat {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.confirm-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.confirm-val {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

/* User & Admin Dashboard Layouts */
.dashboard-nav {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

.db-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.db-tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.04);
}

.db-tab-btn.active {
    color: var(--primary-light);
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.25);
}

.dashboard-sections > div {
    display: none;
}

.dashboard-sections > div.active {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.security-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #f87171;
    border-bottom: 1px solid rgba(248, 113, 113, 0.15);
    padding-bottom: 0.4rem;
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Settings Grids & Action buttons */
.badge-role {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
}

.badge-role.admin {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

#superadmin-dashboard-card, #developer-dashboard-card {
    border-radius: 14px;
    padding: 2.8rem;
}

/* Forgot Password Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden {
    display: none;
}

.modal-card {
    animation: slideUp 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* Auth tab active state */
.auth-tab-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 700;
    padding: 0.8rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.auth-tab-btn.active {
    border-bottom-color: var(--primary);
    color: var(--text-main);
}

/* Rate Limit Overlay */
.rate-limited {
    pointer-events: none;
    position: relative;
}

.rate-limit-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 15, 25, 0.95);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    z-index: 10;
    animation: fadeIn 0.3s ease;
    border: 2px solid rgba(239, 68, 68, 0.3);
}

.rate-limit-overlay.hidden {
    display: none !important;
}

.rate-limit-overlay i {
    font-size: 2.2rem;
    color: var(--error);
    margin-bottom: 0.6rem;
    animation: saPulse 2s infinite ease-in-out;
}

.rate-limit-overlay h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

.rate-limit-overlay p {
    margin: 0.3rem 0 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

@keyframes saPulse {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.1); opacity: 1; filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.6)); }
    100% { transform: scale(1); opacity: 0.8; }
}

/* Mobile Screen Responsiveness adjustments */
@media (max-width: 600px) {
    .app-container {
        padding: 1rem;
    }
    
    .glass-card {
        padding: 1.25rem;
        border-radius: 16px;
    }
    
    #superadmin-dashboard-card, #developer-dashboard-card {
        padding: 1.25rem;
        border-radius: 16px;
    }
    
    .app-header {
        padding-bottom: 1.25rem;
        margin-bottom: 1.5rem;
        gap: 1.25rem;
    }
    
    .brand-text h1 {
        font-size: 1.2rem;
        letter-spacing: 1px;
    }
    
    .brand-text span {
        font-size: 0.65rem;
    }
    
    .logo-icon {
        width: 1.35rem;
        height: 1.35rem;
    }
    
    .grid-2col {
        gap: 1.25rem;
    }
    
    .estimate-stats {
        grid-template-columns: 1fr;
    }
    
    .confirm-details {
        grid-template-columns: 1fr;
        padding: 0.75rem;
    }
    
    .app-footer {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        margin-top: 2rem;
        padding-top: 1.25rem;
    }
}
