:root {
    --primary-color: #10b981;
    --primary-variant: #059669;
    --secondary-color: #3b82f6;
    --accent-color: #0ea5e9;
    --background-dark: #0f172a;
    --surface-dark: #1e293b;
    --text-light: #f8fafc;
    --text-muted: #94a3b8;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    --font-main: 'Outfit', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--background-dark);
    color: var(--text-light);
    height: 100vh;
    overflow: hidden;
    background:
        radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.15) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(59, 130, 246, 0.15) 0%, transparent 20%);
    background-color: var(--background-dark);
    position: relative;
}

body::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60vh;
    height: 60vh;
    background: url('./assets/logo.svg') no-repeat center center;
    background-size: contain;
    opacity: 0.05;
    pointer-events: none;
    z-index: -1;
}

.app-container {
    display: flex;
    height: 100%;
    position: relative;
    /* z-index: 1; Removed to fix mobile sidebar stacking */
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--surface-dark);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 2rem 1rem;
    backdrop-filter: blur(10px);
}

.logo {
    margin-bottom: 2.5rem;
    padding: 0 1rem;
}

.logo h2 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo span {
    font-weight: 300;
    color: var(--text-light);
    -webkit-text-fill-color: var(--text-light);
}

/* Navigation */
.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-y: auto;
    padding-right: 5px;
    /* Scrollbar space */
}

/* Scrollbar for nav */
.nav-menu::-webkit-scrollbar {
    width: 4px;
}

.nav-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.nav-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--primary-color);
    /* Pop with color */
    font-weight: 800;
    /* Bolder */
    letter-spacing: 1.2px;
    margin: 1.5rem 0 0.5rem 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 2px solid rgba(16, 185, 129, 0.2);
    /* Underline */
    display: block;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.nav-item {
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    font-family: var(--font-main);
    padding: 0.65rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

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

.nav-item.active {
    background: linear-gradient(90deg, var(--primary-color), var(--primary-variant));
    color: white;
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.3);
}

.nav-item .icon {
    font-size: 1.1em;
    line-height: 1;
}

/* Sidebar Footer */
.sidebar-footer {
    margin-top: auto;
    padding: 1rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.version-tag {
    color: var(--text-muted);
    opacity: 0.7;
}

.btn-reset {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    text-align: left;
    padding: 0;
    font-size: 0.75rem;
    text-decoration: underline;
    transition: color 0.2s;
}

.btn-reset:hover {
    color: #ef4444;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    overflow-y: auto;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-heading {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

#page-title {
    font-size: 2rem;
    font-weight: 600;
}

.page-subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.date-display {
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.content-wrapper {
    flex: 1;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: visible;
}

.shared-split-view {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

.shared-calc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    align-items: start;
}

.section-heading {
    color: var(--primary-color);
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
}

.primary-result {
    background: rgba(99, 102, 241, 0.1);
    border-left: 4px solid var(--primary-color);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.primary-result label {
    color: var(--primary-color);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
}

.primary-result .value {
    color: var(--secondary-color);
    font-size: 2.25rem;
    font-weight: 700;
    margin-top: 0.5rem;
}

.primary-result .sub-text,
.result-caption,
.hint,
.sub-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.result-item {
    margin-bottom: 1.5rem;
}

.result-item label {
    display: block;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.result-item .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-light);
}

.result-item .value.large {
    font-size: 2.25rem;
}

.breakdown-list {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 1rem;
}

.breakdown-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.breakdown-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.breakdown-item label {
    display: block;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
}

.breakdown-item .value {
    color: var(--text-light);
    font-size: 1.1rem;
    font-weight: 600;
}

.result-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.result-row label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.result-row span,
.result-row .value {
    font-weight: 600;
    color: var(--text-light);
}

.separator {
    height: 1px;
    background: var(--glass-border);
    margin: 1.5rem 0;
}

.warning-box {
    border: 1px solid rgba(245, 158, 11, 0.25);
    background: rgba(245, 158, 11, 0.08);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
}

.warning-box small {
    color: var(--text-muted);
    line-height: 1.45;
}

.total-cost-box {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05));
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 1.25rem;
    border-radius: var(--radius-md);
}

.total-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.total-cost-box label {
    color: #f87171;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
}

.total-cost-box .value {
    color: #fca5a5;
    font-size: 1.5rem;
    font-weight: 700;
}

.total-cost-box .sub-text {
    color: #fca5a5;
    font-size: 0.8rem;
    opacity: 0.8;
    margin-top: 0.25rem;
}

.info-badge {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 999px;
    white-space: nowrap;
}

.highlight-val {
    color: var(--secondary-color) !important;
    font-weight: 700 !important;
}

.chart-panel {
    margin-top: 1.5rem;
    height: 220px;
}

.reference-section {
    margin-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1rem;
}

.reference-section summary {
    cursor: pointer;
    color: var(--primary-color);
    font-weight: 500;
}

.ref-table {
    width: 100%;
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-collapse: collapse;
}

.ref-table th,
.ref-table td {
    text-align: left;
    padding: 0.55rem 0.4rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.reference-meta {
    margin-top: 1rem;
    font-size: 0.8rem;
    line-height: 1.5;
}

.inline-note {
    color: var(--text-muted);
}

/* Dashboard Styling */
.dashboard-welcome h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.dashboard-welcome p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.quick-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    padding: 1.5rem;
    border-radius: var(--radius-md);
}

.stat-card h4 {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-card .value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-light);
    margin-bottom: 0.25rem;
}

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

/* Calculator Form Styles (Shared) */
.form-group {
    margin-bottom: 1.5rem;
}

.double-input {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-light);
    font-family: var(--font-main);
    font-size: 1rem;
    transition: all 0.2s;
}

.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-light);
    font-family: var(--font-main);
    font-size: 1rem;
    transition: all 0.2s;
    resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-family: var(--font-main);
    cursor: pointer;
    transition: transform 0.1s;
    width: 100%;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.result-card {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    margin-top: 2rem;
    display: none;
    /* Hidden by default */
}

.result-card.visible {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal.hidden {
    display: none;
    pointer-events: none;
    opacity: 0;
}

.modal-content {
    background: rgba(15, 23, 42, 0.65);
    /* Dark Glass */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

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

.modal-header h3 {
    margin: 0;
}

.close-modal,
.close-modal-res,
.close-modal-confirm,
.close-modal-client {
    border: none;
    background: transparent;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.close-modal:hover,
.close-modal-res:hover,
.close-modal-confirm:hover,
.close-modal-client:hover {
    color: var(--text-light);
}

.modal-body {
    padding: 1.5rem;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    border: 1px solid var(--glass-border);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-family: var(--font-main);
    cursor: pointer;
    margin-right: 0.5rem;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.16);
    color: #fecaca;
    border: 1px solid rgba(239, 68, 68, 0.35);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-family: var(--font-main);
    cursor: pointer;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.24);
}

/* Profile List */
.profile-list {
    list-style: none;
    max-height: 300px;
    overflow-y: auto;
}

.profile-controls {
    display: grid;
    grid-template-columns: 1fr 180px;
    gap: 0.6rem;
    margin-bottom: 0.8rem;
}

.profile-controls input,
.profile-controls select {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    color: var(--text-light);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.7rem;
    font-size: 0.85rem;
}

.profile-portability {
    grid-column: 1 / -1;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.profile-portability label.btn-secondary {
    margin-right: 0;
}

.profile-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    margin-bottom: 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
}

.profile-item:hover {
    border-color: var(--primary-color);
}

.profile-info h4 {
    margin: 0 0 0.2rem 0;
    font-size: 0.95rem;
}

.profile-info p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.profile-actions {
    display: flex;
    gap: 0.5rem;
}

.confirm-modal-content {
    max-width: 420px;
}

.confirm-message {
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 1.25rem;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.btn-sm-load {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
}

.btn-sm-del {
    background: #ef4444;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
}

@media (max-width: 768px) {
    .shared-split-view {
        grid-template-columns: 1fr;
    }

    .double-input {
        grid-template-columns: 1fr;
    }

    .profile-controls {
        grid-template-columns: 1fr;
    }

    .profile-portability {
        flex-wrap: wrap;
    }

    .confirm-actions {
        flex-direction: column-reverse;
    }

    .confirm-actions .btn-secondary,
    .confirm-actions .btn-danger {
        width: 100%;
        margin-right: 0;
    }
}

.text-muted.hidden {
    display: none;
}

.prefill-banner {
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(16, 185, 129, 0.24);
    background: rgba(16, 185, 129, 0.1);
}

.prefill-banner strong {
    display: block;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #d1fae5;
    margin-bottom: 0.3rem;
}

.prefill-banner p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.4;
}

.hidden {
    display: none !important;
}

.toast-container {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: min(360px, calc(100vw - 2rem));
    z-index: 1200;
    pointer-events: none;
}

.toast {
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.95);
    color: var(--text-light);
    padding: 0.9rem 1rem;
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.18s ease-out;
}

.toast.success {
    border-color: rgba(16, 185, 129, 0.45);
}

.toast.error {
    border-color: rgba(239, 68, 68, 0.45);
}

.toast.info {
    border-color: rgba(59, 130, 246, 0.45);
}

.toast-title {
    display: block;
    font-size: 0.92rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.toast-message {
    display: block;
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.4;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Resources */
.btn-icon {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-light);
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 0.5rem;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-icon:focus-visible,
.nav-item:focus-visible,
.close-modal:focus-visible,
.close-modal-res:focus-visible,
.close-modal-client:focus-visible,
.btn-sm-load:focus-visible,
.btn-sm-del:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.28);
}

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

/* Resource Items */
.resource-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all 0.2s;
}

.resource-item:hover {
    background: rgba(255, 255, 255, 0.08);
    /* Dark hover */
    border-color: var(--primary-color);
    transform: translateX(4px);
}

.res-icon {
    font-size: 1.5rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 6px;
}

.res-info h4 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-light);
    font-weight: 500;
}

.res-info p {
    margin: 0.25rem 0 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* --- Mobile Responsiveness --- */

/* Menu Toggle Button */
.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
}

.menu-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Overlay for Mobile Sidebar */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.sidebar-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }

    /* Sidebar Mobile Styles */
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        /* Hidden by default */
        height: 100%;
        width: 85vw;
        max-width: 300px;
        z-index: 100;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: var(--shadow-lg);
    }

    .sidebar.active {
        left: 0;
    }

    /* Adjust content padding */
    .main-content {
        padding: 1rem;
    }

    .top-bar {
        margin-bottom: 1.5rem;
    }

    #page-title {
        font-size: 1.5rem;
    }

    .quick-stats {
        grid-template-columns: 1fr;
    }
}

/* --- Mobile Actions & Results Fixes --- */

.actions-container {
    position: relative;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Mobile Actions Toggle */
.mobile-actions-toggle {
    display: none !important;
    /* Hidden by default */
}

@media (max-width: 768px) {

    /* Show Toggle, Hide Buttons initially */
    .mobile-actions-toggle {
        display: flex !important;
    }

    .action-buttons {
        display: none;
        position: absolute;
        top: 100%;
        right: 0;
        background: var(--surface-dark);
        border: 1px solid var(--glass-border);
        border-radius: var(--radius-md);
        padding: 0.5rem;
        flex-direction: column;
        gap: 0.5rem;
        z-index: 50;
        box-shadow: var(--shadow-lg);
        min-width: 160px;
        margin-top: 0.5rem;
    }

    .action-buttons.show {
        display: flex;
    }

    .action-buttons button {
        width: 100%;
        text-align: left;
        justify-content: flex-start;
    }

    /* Fix Result Layout */
    .results-grid {
        grid-template-columns: 1fr !important;
    }

    .result-item,
    .primary-result,
    .result-row {
        width: 100%;
        box-sizing: border-box;
    }

    /* Prevent horizontal scroll */
    .content-wrapper {
        overflow-x: hidden;
        padding: 1rem;
    }
}



/* --- Result Card Overflow Fixes --- */

@media (max-width: 768px) {
    .result-card {
        width: 100%;
        padding: 1rem;
        /* Reduce padding on mobile */
        box-sizing: border-box;
        overflow-x: hidden;
        /* Contain overflow */
    }

    .result-card span,
    .result-card .value,
    .result-card h3,
    .result-card p {
        word-break: break-word;
        /* Prevent long numbers/text from overflowing */
        white-space: normal;
    }

    /* Ensure Charts don't overflow */
    canvas {
        max-width: 100% !important;
        height: auto !important;
    }
}



/* --- Landing Page / Welcome Screen --- */

#landing-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--background-dark);
    overflow-y: auto;
    z-index: 2000;
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
    background:
        radial-gradient(circle at 12% 10%, rgba(14, 165, 233, 0.16) 0%, transparent 28%),
        radial-gradient(circle at 90% 14%, rgba(16, 185, 129, 0.18) 0%, transparent 30%),
        radial-gradient(circle at 52% 88%, rgba(244, 114, 182, 0.12) 0%, transparent 22%),
        var(--background-dark);
}

#landing-page.hidden {
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
}

.landing-shell {
    width: min(1180px, calc(100vw - 2rem));
    margin: 1rem auto;
    padding: 1.25rem;
}

.landing-nav {
    position: sticky;
    top: 1rem;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.2rem;
    margin-bottom: 1.5rem;
    background: rgba(9, 15, 31, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    backdrop-filter: blur(18px);
    box-shadow: 0 20px 35px rgba(2, 6, 23, 0.25);
}

.landing-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    color: var(--text-light);
    text-decoration: none;
}

.landing-brand img {
    width: 42px;
    height: 42px;
    filter: drop-shadow(0 0 16px rgba(16, 185, 129, 0.3));
}

.landing-brand strong {
    display: block;
    font-size: 1.2rem;
}

.landing-brand-meta {
    display: block;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.landing-links,
.landing-nav-actions,
.landing-cta-row,
.landing-cta-band-actions,
.landing-footer-links {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.landing-links a,
.landing-footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.92rem;
    transition: color 0.2s ease;
}

.landing-links a:hover,
.landing-footer-links a:hover {
    color: var(--text-light);
}

.landing-main {
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
}

.landing-hero,
.landing-section,
.landing-cta-band,
.landing-stats {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 30px;
    background:
        linear-gradient(155deg, rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 0.82)),
        rgba(15, 23, 42, 0.9);
    box-shadow: 0 24px 40px rgba(2, 6, 23, 0.24);
}

.landing-hero::before,
.landing-section::before,
.landing-cta-band::before {
    content: "";
    position: absolute;
    inset: auto -10% -48% 55%;
    height: 280px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.22), transparent 62%);
    pointer-events: none;
}

.landing-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
    gap: 2rem;
    padding: 3rem;
}

.landing-copy,
.landing-preview,
.landing-section,
.landing-cta-band {
    position: relative;
    z-index: 1;
}

.landing-kicker,
.landing-section-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.landing-title {
    font-size: clamp(3.4rem, 8vw, 5.2rem);
    line-height: 0.95;
    letter-spacing: -0.05em;
    margin: 1rem 0 0.85rem;
    background: linear-gradient(90deg, #f8fafc 0%, #c4f1e3 38%, #7dd3fc 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.landing-title span {
    -webkit-text-fill-color: #7dd3fc;
}

.tagline {
    font-size: clamp(1.3rem, 2.8vw, 1.7rem);
    color: var(--text-light);
    margin-bottom: 0.35rem;
}

.sub-tagline {
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    margin-bottom: 1.2rem;
}

.landing-lead {
    max-width: 58ch;
    color: #cbd5e1;
    font-size: 1.05rem;
    line-height: 1.72;
}

.landing-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1.35rem;
}

.landing-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.8rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: #dbe6f5;
    font-size: 0.86rem;
}

.landing-proof-list,
.landing-pricing-card ul,
.preview-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.landing-proof-list {
    display: grid;
    gap: 0.75rem;
    margin-top: 1.4rem;
}

.landing-proof-list li,
.landing-pricing-card li,
.preview-list li {
    position: relative;
    padding-left: 1.2rem;
    color: #dbe6f5;
    line-height: 1.55;
}

.landing-proof-list li::before,
.landing-pricing-card li::before,
.preview-list li::before {
    content: "";
    position: absolute;
    top: 0.55rem;
    left: 0;
    width: 0.42rem;
    height: 0.42rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.5);
}

.landing-primary-btn,
.landing-secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0.85rem 1.2rem;
    border-radius: 999px;
    font-weight: 700;
    font-family: var(--font-main);
    text-decoration: none;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
    cursor: pointer;
}

.landing-primary-btn {
    color: white;
    border: none;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    box-shadow: 0 18px 35px rgba(16, 185, 129, 0.25);
}

.landing-secondary-btn {
    color: var(--text-light);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.landing-primary-btn:hover,
.landing-secondary-btn:hover {
    transform: translateY(-2px);
}

.landing-full-width {
    width: 100%;
}

.landing-preview {
    display: flex;
    align-items: stretch;
}

.landing-preview-frame {
    width: 100%;
    padding: 1.15rem;
    border-radius: 26px;
    background:
        linear-gradient(180deg, rgba(8, 15, 33, 0.98), rgba(19, 30, 56, 0.92));
    border: 1px solid rgba(125, 211, 252, 0.16);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.preview-topbar {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 1rem;
}

.preview-dot {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    background: rgba(148, 163, 184, 0.3);
}

.preview-dot:first-child {
    background: rgba(248, 113, 113, 0.8);
}

.preview-dot:nth-child(2) {
    background: rgba(251, 191, 36, 0.85);
}

.preview-dot:nth-child(3) {
    background: rgba(52, 211, 153, 0.8);
}

.preview-status {
    margin-left: auto;
    color: #93c5fd;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
}

.preview-panel {
    min-height: 160px;
    padding: 1rem;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 23, 42, 0.75);
}

.preview-panel-primary {
    grid-column: 1 / -1;
    background:
        linear-gradient(135deg, rgba(16, 185, 129, 0.18), rgba(14, 165, 233, 0.1)),
        rgba(15, 23, 42, 0.9);
}

.preview-label {
    display: inline-flex;
    margin-bottom: 0.75rem;
    color: #93c5fd;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.preview-panel h3 {
    font-size: 1.35rem;
    line-height: 1.2;
    margin-bottom: 1rem;
}

.preview-figure {
    display: block;
    font-size: 1.15rem;
    color: white;
    margin-bottom: 0.45rem;
}

.preview-note {
    color: #cbd5e1;
    line-height: 1.6;
    font-size: 0.92rem;
}

.preview-metric-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.preview-metric-row strong {
    display: block;
    font-size: 1rem;
    color: white;
    margin-bottom: 0.3rem;
}

.preview-metric-row span,
.preview-list li {
    font-size: 0.88rem;
    color: #cbd5e1;
}

.landing-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    padding: 1.2rem;
}

.landing-stat-card {
    padding: 1rem 1.05rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.landing-stat-card strong {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.98rem;
}

.landing-stat-card span,
.landing-section-header p,
.landing-use-case p,
.landing-feature-card p,
.landing-pricing-caption,
.landing-cta-band p {
    color: var(--text-muted);
    line-height: 1.7;
}

.landing-section {
    padding: 2.2rem;
}

.landing-section-band {
    background:
        linear-gradient(135deg, rgba(59, 130, 246, 0.09), rgba(244, 114, 182, 0.08)),
        rgba(15, 23, 42, 0.92);
}

.landing-section-header {
    max-width: 720px;
    margin-bottom: 1.4rem;
}

.landing-section-header h2,
.landing-cta-band h2 {
    font-size: clamp(1.9rem, 3.5vw, 2.8rem);
    line-height: 1.12;
    margin: 0.8rem 0;
}

.landing-card-grid,
.landing-use-case-grid,
.landing-pricing-grid {
    display: grid;
    gap: 1rem;
    align-items: stretch;
}

.landing-card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.landing-use-case-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.landing-pricing-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.flip-card {
    perspective: 1400px;
    min-height: 290px;
}

.flip-card-pricing {
    min-height: 340px;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.72s cubic-bezier(0.22, 1, 0.36, 1);
}

.flip-card.is-flipped .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-face {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: 1.2rem;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    box-shadow: 0 14px 28px rgba(2, 6, 23, 0.16);
}

.flip-card-back {
    transform: rotateY(180deg);
    background:
        linear-gradient(155deg, rgba(16, 185, 129, 0.12), rgba(59, 130, 246, 0.08)),
        rgba(255, 255, 255, 0.04);
}

.flip-card-pricing-featured .flip-card-face {
    border-color: rgba(16, 185, 129, 0.28);
    box-shadow: 0 16px 28px rgba(16, 185, 129, 0.12);
}

.flip-card-face h3 {
    margin: 0;
    font-size: 1.35rem;
    line-height: 1.2;
}

.flip-card-face p {
    color: var(--text-muted);
    line-height: 1.7;
}

.flip-card-tag {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    padding: 0.38rem 0.68rem;
    border-radius: 999px;
    background: rgba(125, 211, 252, 0.12);
    color: #7dd3fc;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.landing-card-toggle {
    margin-top: auto;
    padding: 0;
    border: none;
    background: transparent;
    color: #7dd3fc;
    font-family: var(--font-main);
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
}

.landing-card-toggle:hover {
    color: #bae6fd;
}

.flip-card-back .landing-primary-btn,
.flip-card-back .landing-secondary-btn {
    margin-top: auto;
}

.flip-card-back .landing-card-toggle {
    margin-top: 0;
}

.landing-feature-card,
.landing-use-case,
.landing-pricing-card {
    padding: 1.2rem;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
}

.landing-feature-card h3,
.landing-use-case h3,
.landing-pricing-card h3 {
    margin-bottom: 0.65rem;
}

.landing-use-case-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.2rem;
    height: 2.2rem;
    margin-bottom: 0.85rem;
    border-radius: 50%;
    background: rgba(125, 211, 252, 0.12);
    color: #7dd3fc;
    font-weight: 700;
}

.landing-pricing-card {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.landing-pricing-card h3 {
    font-size: clamp(2rem, 3.5vw, 2.8rem);
    line-height: 1;
}

.landing-pricing-card h3 span {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-left: 0.25rem;
}

.landing-pricing-tier {
    color: #7dd3fc;
    font-size: 0.82rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 700;
}

.landing-pricing-card-featured {
    background:
        linear-gradient(155deg, rgba(16, 185, 129, 0.14), rgba(14, 165, 233, 0.08)),
        rgba(255, 255, 255, 0.04);
    border-color: rgba(16, 185, 129, 0.28);
    box-shadow: 0 16px 28px rgba(16, 185, 129, 0.12);
}

.landing-cta-band {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 2rem 2.2rem;
}

.landing-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 0.4rem 0.25rem;
    color: var(--text-muted);
    font-size: 0.82rem;
}

@media (max-width: 1040px) {
    .landing-nav {
        border-radius: 28px;
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .landing-hero,
    .landing-card-grid,
    .landing-use-case-grid,
    .landing-pricing-grid,
    .landing-stats {
        grid-template-columns: 1fr;
    }

    .landing-cta-band {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 768px) {
    .landing-shell {
        width: calc(100vw - 1rem);
        margin: 0.5rem auto;
        padding: 0.5rem;
    }

    .landing-nav,
    .landing-hero,
    .landing-section,
    .landing-cta-band {
        padding: 1.4rem;
    }

    .landing-links,
    .landing-nav-actions,
    .landing-cta-row,
    .landing-cta-band-actions,
    .landing-footer,
    .landing-footer-links {
        flex-direction: column;
        align-items: stretch;
    }

    .landing-links {
        width: 100%;
        gap: 0.65rem;
    }

    .landing-links a {
        padding: 0.25rem 0;
    }

    .landing-primary-btn,
    .landing-secondary-btn {
        width: 100%;
    }

    .preview-grid,
    .preview-metric-row,
    .landing-use-case-grid {
        grid-template-columns: 1fr;
    }

    .flip-card,
    .flip-card-pricing {
        min-height: 280px;
    }

    .landing-title {
        font-size: 3.05rem;
    }

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



/* --- Calculator Layout (Grid) --- */
.calculator-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

.calculator-results {
    position: sticky;
    top: 2rem;
    display: flex !important;
    flex-direction: column;
    gap: 1.5rem;
    min-height: 200px;
    /* Ensure it has size even if empty */
    z-index: 10;
    /* Ensure on top of background */
}

@media (max-width: 900px) {
    .calculator-layout {
        grid-template-columns: 1fr;
    }

    .calculator-results {
        position: static;
    }
}


/* Result Cards - Refined for Visibility */
.result-card {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    background: var(--surface-dark, #1f2937);
    /* Fallback to dark grey if var missing */
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
    padding: 1.5rem;
    border-radius: var(--radius-md, 0.5rem);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    margin-bottom: 1rem;
}

.result-card h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1rem;
    color: var(--text-muted, #9ca3af);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
    padding-bottom: 0.5rem;
}

.result-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

.result-row label {
    color: var(--text-muted, #9ca3af);
}

.result-row span {
    font-weight: 500;
    color: var(--text-light, #f3f4f6);
}

.primary-result {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.05));
    border: 1px solid rgba(16, 185, 129, 0.3);
    text-align: center;
}

.primary-result label {
    display: block;
    color: var(--primary-color, #10b981);
    font-size: 0.9rem;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.primary-result .value {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color, #10b981);
    line-height: 1.1;
    text-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

.result-caption {
    margin: 0.5rem 0 0 0;
    font-size: 0.8rem;
    color: var(--text-muted, #9ca3af);
}

/* Landing Page Transition */
.fade-out {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}
