/* Reset & Tokens */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #06080f;
    --surface: #0c1019;
    --surface-2: #111620;
    --border: rgba(255, 255, 255, 0.06);
    --border-h: rgba(255, 255, 255, 0.12);
    --text: #e2e8f0;
    --text-muted: #64748b;
    --text-dim: #475569;

    --flurazide: #2563eb;
    --flurazide-dim: rgba(37, 99, 235, 0.15);
    --chromium: #dc2626;
    --chromium-dim: rgba(220, 38, 38, 0.15);

    --online: #22c55e;
    --offline: #ef4444;
    --radius: 16px;
    --radius-sm: 10px;
}

body {
    font-family: 'Outfit', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    position: relative;
    overflow-x: hidden;
}

/* Technical telemetry blueprint grid */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
}

/* Background molecular canvas */
#molecules-canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    width: 100vw;
    height: 100vh;
    transition: opacity 0.35s ease;
}

/* Work mode (config/logs) or manual ambient toggle: hide moving canvas for clean focus */
body.in-work-mode #molecules-canvas,
body.hide-ambient #molecules-canvas {
    opacity: 0;
    pointer-events: none;
}

/* Container */
.container {
    position: relative;
    z-index: 1;
    max-width: 1120px;
    margin: 0 auto;
    padding: 24px 24px 32px;
}

/* Navbar */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(6, 8, 15, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
}

.navbar-brand h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.5px;
    cursor: pointer;
    user-select: none;
    line-height: 1.2;
}

.navbar-brand h1 span {
    color: var(--text-muted);
    font-weight: 400;
}

.ambient-toggle-btn {
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-dim);
    letter-spacing: 0.4px;
    text-transform: uppercase;
    cursor: pointer;
    transition: color 0.15s ease;
    user-select: none;
}

.ambient-toggle-btn:hover {
    color: var(--text-muted);
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 24px;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: color 0.15s;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.nav-link:hover,
.nav-link.active {
    color: var(--text);
}

.nav-link.disabled,
.btn.disabled,
#footer-config-btn.disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    filter: grayscale(1);
    pointer-events: none;
}

@media (max-width: 768px) {
    .navbar {
        padding: 12px 16px;
    }

    .navbar-nav {
        gap: 12px;
    }

    .nav-link span {
        display: none;
    }
}

/* User profile dropdown */
.user-nav-wrapper {
    position: relative;
}

.user-nav {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    transition: background 0.15s, border-color 0.15s;
}

.user-nav:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.18);
}

.user-nav img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.user-nav span {
    font-size: 13px;
    font-weight: 500;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #0f1420;
    border: 1px solid var(--border-h);
    border-radius: 12px;
    min-width: 160px;
    padding: 6px;
    display: none;
    flex-direction: column;
    gap: 2px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
    z-index: 1100;
}

.dropdown-menu.show {
    display: flex;
}

.dropdown-item {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.15s, color 0.15s;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

.dropdown-item--danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    text-decoration: none;
    border: 1px solid transparent;
}

.btn--outline {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

.btn--outline:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn--outline:active {
    background: rgba(255, 255, 255, 0.05);
}

.btn--danger {
    background: #ef4444 !important;
    color: white !important;
}

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

.btn--invite {
    background: var(--chromium);
    color: white !important;
    font-size: 11px;
    padding: 6px 12px;
    height: fit-content;
}

.btn--invite:hover {
    opacity: 0.9;
}

.btn--sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 8px;
}

/* Form inputs */
input[type="text"],
input[type="number"],
select {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
    font-family: inherit;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
    text-align: center;
}

input:focus,
select:focus {
    border-color: rgba(255, 255, 255, 0.25);
    background: var(--surface-2);
}

select {
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='rgba(100, 116, 139, 0.8)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

/* Toast notifications */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background: #0f1420;
    border: 1px solid var(--border-h);
    color: var(--text);
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    transform: translateY(12px);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
    pointer-events: auto;
}

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

.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
}

.toast--error .toast-icon {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.toast--success .toast-icon {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.toast--info .toast-icon {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 8, 15, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal-overlay.show {
    opacity: 1;
}

.modal-card {
    background: var(--surface);
    border: 1px solid var(--border-h);
    border-radius: 14px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

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

.modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.modal-icon {
    color: #f59e0b;
    width: 22px;
    height: 22px;
}

.modal-header h3 {
    font-size: 17px;
    font-weight: 600;
    margin: 0;
}

.modal-card p {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.5;
    margin: 0 0 20px 0;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Footer */
.footer {
    margin-top: 56px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-dim);
}

.footer a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.15s;
}

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

.footer__links {
    display: flex;
    gap: 20px;
}

/* Mass Spec Molecule Inspector */
.spec-readout {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10;
    pointer-events: auto;
    width: 215px;
    background: rgba(10, 14, 24, 0.78);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 10px 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 11px;
    color: var(--text);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    user-select: none;
    will-change: transform;
}

.spec-readout__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.spec-readout__title {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.spec-readout__close {
    cursor: pointer;
    color: var(--text-dim);
    font-size: 14px;
    line-height: 1;
    background: none;
    border: none;
    padding: 0 2px;
    transition: color 0.15s;
}

.spec-readout__close:hover {
    color: var(--text);
}

.spec-readout__formula {
    font-size: 15px;
    font-weight: 700;
    color: #38bdf8;
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}

.spec-readout__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 3px 0;
    color: var(--text-muted);
}

.spec-readout__val {
    color: var(--text);
    font-weight: 500;
}

.spec-readout__chart {
    margin-top: 8px;
    height: 22px;
    width: 100%;
    display: flex;
    align-items: flex-end;
    gap: 3px;
    padding-top: 4px;
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.spec-readout__peak {
    flex: 1;
    background: rgba(56, 189, 248, 0.35);
    border-radius: 1px 1px 0 0;
}

.spec-readout__peak.base {
    background: #38bdf8;
}
