:root {
    /* Color Palette - Premium Dark Mode */
    --bg-main: #0f172a;
    --bg-panel: rgba(30, 41, 59, 0.7);
    --bg-panel-hover: rgba(30, 41, 59, 0.9);
    --border-color: rgba(148, 163, 184, 0.1);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;

    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --accent-color: #10b981;
    --accent-hover: #059669;
    --danger-color: #ef4444;

    --font-family: 'Inter', system-ui, -apple-system, sans-serif;

    --glass-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --glass-blur: blur(12px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-main);
    background-image: radial-gradient(circle at top right, #1e293b 0%, #0f172a 100%);
    color: var(--text-primary);
    font-family: var(--font-family);
    min-height: 100vh;
    overflow-x: hidden;
}

h1,
h2,
h3,
h4 {
    font-weight: 600;
    color: var(--text-primary);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-hover);
}

/* Layout Components */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
}

.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    height: 100vh;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--glass-shadow);
}

/* Typography & Spacing */
.mb-3 {
    margin-bottom: 1rem;
}

.mb-4 {
    margin-bottom: 1.5rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-3 {
    margin-top: 1rem;
}

.p-4 {
    padding: 1.5rem;
}

.w-100 {
    width: 100%;
}

.flex-row {
    display: flex;
    flex-direction: row;
}

.align-center {
    align-items: center;
}

.gap-4 {
    gap: 1.5rem;
}

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-accent {
    background: var(--accent-color);
    color: white;
}

.btn-accent:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group-row {
    display: flex;
    gap: 1rem;
}

.form-group-row .half {
    flex: 1;
}

label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
    width: 100%;
    padding: 0.6rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.error-text {
    color: var(--danger-color);
    font-size: 0.85rem;
}

/* Sidebar Specifics */
.logo h2 {
    font-size: 1.4rem;
    margin-bottom: 2.5rem;
    background: linear-gradient(90deg, #3b82f6, #10b981);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

nav ul {
    list-style: none;
}

nav li {
    margin-bottom: 0.5rem;
}

nav a {
    display: block;
    padding: 0.7rem 1rem;
    border-radius: 8px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

nav a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

nav a.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary-color);
    font-weight: 500;
}

.user-info {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Login View */
.login-box {
    max-width: 400px;
    margin: 4rem auto;
    background: var(--bg-panel);
    padding: 2.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.login-box h2 {
    text-align: center;
    margin-bottom: 1.5rem;
}

/* Dashboard Specifics */
.params-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.param-card {
    background: rgba(15, 23, 42, 0.4);
    padding: 1.25rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.param-card h4 {
    font-size: 0.95rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem 0;
}

.metrics-dashboard {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.metric-card {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-top: 3px solid var(--accent-color);
}

.metric-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 600;
}

.chart-container {
    height: 350px;
    padding: 10px;
    width: 100%;
}

.plotly-chart {
    height: 100%;
    width: 100%;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.toast-container.hidden {
    opacity: 0;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid var(--danger-color);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    gap: 1rem;
}

.toast.error .toast-icon {
    color: var(--danger-color);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
}

.toast-close:hover {
    color: white;
}

/* Custom file input */
input[type="file"]::file-selector-button {
    border: 1px solid var(--border-color);
    padding: .4em .8em;
    border-radius: .2em;
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    transition: 1s;
    cursor: pointer;
    margin-right: 15px;
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    width: 90%;
    max-width: 800px;
    padding: 2rem;
    border-radius: 12px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

/* Signal Lab Sliders */
.slider-lab {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: #1e293b;
    outline: none;
    margin-top: 4px;
}

.slider-lab::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 0 6px rgba(59, 130, 246, 0.5);
    transition: transform 0.1s;
}

.slider-lab::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider-lab::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
}