:root {
    --bg-color: #0d1117;
    --text-color: #c9d1d9;
    --text-muted: #8b949e;

    /* Brand Colors */
    --primary: #f59e0b;
    /* Amber */
    --primary-hover: #d97706;
    --secondary: #3b82f6;

    /* Glassmorphism */
    --glass-bg: rgba(22, 27, 34, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

    --radius-lg: 16px;
    --radius-md: 8px;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
    position: relative;
}

/* Background Animated Orbs */
.background-elements {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 10s infinite ease-in-out alternate;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(245, 158, 11, 0.2) 0%, rgba(0, 0, 0, 0) 70%);
    top: -10%;
    left: 20%;
}

.orb-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.15) 0%, rgba(0, 0, 0, 0) 70%);
    bottom: -20%;
    right: 10%;
    animation-delay: -5s;
}

.orb-3 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.1) 0%, rgba(0, 0, 0, 0) 70%);
    top: 40%;
    right: 40%;
    animation-duration: 15s;
}

@keyframes float {
    0% {
        transform: translateY(0) scale(1);
    }

    100% {
        transform: translateY(30px) scale(1.05);
    }
}

/* Layout */
.container {
    max-width: 1200px;
    width: 100%;
    padding: 2rem;
    z-index: 1;
}

/* Auth Navigation */
.auth-nav {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.user-badge {
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 500;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #f59e0b, #fed7aa);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.grid-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 1.5rem;
}

/* Glass Panels */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    padding: 1.5rem;
    transition: var(--transition);
}

.glass-panel:hover {
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Form Styles */
.form-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: white;
}

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

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

.form-row .form-group {
    flex: 1;
    min-width: 140px; /* Force wrap if too narrow */
}

input[type="date"] {
    padding: 0.6rem 0.4rem;
    font-size: 0.85rem;
}

.hidden {
    display: none !important;
}

label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

input,
select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: white;
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition);
}

select {
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23c9d1d9%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem top 50%;
    background-size: 0.65rem auto;
}

select option {
    background: var(--bg-color);
    color: white;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

/* Webkit Calendar Picker styling for dark mode */
::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

.map-hint {
    font-size: 0.85rem;
    color: var(--primary);
    text-align: center;
    margin-top: 1rem;
    margin-bottom: 1rem;
    display: block;
}

/* Strings Repeating Field */
.strings-wrapper {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.strings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.strings-header h3 {
    font-size: 1rem;
    color: white;
}

.string-item {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1rem;
    position: relative;
    transition: var(--transition);
}

.string-item:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.string-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.string-header h4 {
    font-size: 0.85rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-xs {
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
}

/* Efficiency Slots Styling */
.efficiency-wrapper {
    margin-top: 1rem;
    padding-top: 0.8rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.efficiency-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6rem;
}

.efficiency-header span {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.slot-item {
    display: grid;
    grid-template-columns: 1fr 1fr 75px auto;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.4rem;
    border-radius: var(--radius-md);
}

.slot-item select, 
.slot-item input {
    padding: 0.3rem 0.4rem;
    font-size: 0.8rem;
}

/* Hide spin buttons for efficiency input to save space */
.slot-efficiency::-webkit-inner-spin-button,
.slot-efficiency::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.slot-efficiency {
    appearance: none;
    -moz-appearance: textfield;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

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

/* Button */
.btn-primary {
    width: 100%;
    padding: 0.8rem;
    background: var(--primary);
    color: #000;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

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

.btn-primary:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loader */
.loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    border-top-color: #000;
    animation: spin 1s ease-in-out infinite;
}

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

/* Alerts */
.alert {
    margin-top: 1rem;
    padding: 0.8rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    text-align: center;
}

/* Right Section */
.visuals-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.map-container {
    height: 300px;
    padding: 0;
    overflow: hidden;
}

#map {
    height: 100%;
    width: 100%;
    border-radius: var(--radius-lg);
    background: #111;
}

/* Leaflet dark mode overrides */
.leaflet-layer,
.leaflet-control-zoom-in,
.leaflet-control-zoom-out,
.leaflet-control-attribution {
    filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}

.chart-container {
    flex: 1;
    min-height: 350px;
    position: relative;
    padding-bottom: 3.5rem;
    /* Space for the absolute checkboxes below */
}

canvas {
    width: 100% !important;
    height: 100% !important;
    max-height: 100%;
}

.chart-options {
    position: absolute;
    bottom: 0.5rem;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: nowrap;
    padding: 0.5rem 0;
}

.custom-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-color);
    cursor: pointer;
    white-space: nowrap;
    /* Prevent multiline text */
    transition: var(--transition);
}

.metrics-wrapper {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 20;
    align-items: flex-end;
}

.total-metric {
    padding: 0.8rem 1.2rem;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 140px;
    background: rgba(13, 17, 23, 0.85) !important;
}

.theoretical-placard {
    border-color: rgba(16, 185, 129, 0.3) !important;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.1);
}

.total-metric .metric-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary);
    margin-bottom: 0.2rem;
}

.theoretical-placard .metric-label {
    color: #10b981;
}

.total-metric .metric-value {
    font-size: 1.4rem;
    font-weight: 700;
}

.total-metric small {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.total-metric small {
    font-size: 0.8rem;
    color: var(--text-muted);
}

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

    .map-container {
        height: 250px;
    }

    .chart-container {
        height: 300px;
    }
}