:root {
    --bg-color: #0b0f19;
    --bg-gradient: linear-gradient(135deg, #0b0f19 0%, #1a1025 100%);
    --glass-bg: rgba(20, 20, 30, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --primary-neon: #00f0ff;
    --secondary-neon: #a020f0;
    --profit-green: #00ff88;
    --loss-red: #ff3366;
    --text-main: #ffffff;
    --text-muted: #8b9bb4;
}

html {
    background-color: var(--bg-color);
    min-height: 100%;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    background-image: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
    background-attachment: scroll;
}

/* Subtle background glow grid */
body::before {
    content: "";
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background-image: 
      linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 40px 40px;
    z-index: -1;
    pointer-events: none;
}

/* Fix mobile scaling + add hint / nav styles */
.cost-hint {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-left: 0.5rem;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    transition: 0.3s;
}

.nav-link:hover, .nav-link.active {
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
}

.btn-danger {
    background: rgba(255, 51, 102, 0.1) !important;
    color: var(--loss-red) !important;
    border: 1px solid var(--loss-red) !important;
    box-shadow: none !important;
}

.btn-danger:hover {
    background: var(--loss-red) !important;
    color: #fff !important;
    box-shadow: 0 0 15px rgba(255, 51, 102, 0.5) !important;
}

.archive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.archive-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.archive-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
    background: rgba(0,0,0,0.3);
    padding: 1rem;
    border-radius: 12px;
}

.archive-stat {
    display: flex;
    flex-direction: column;
    flex: 1 1 40%;
}

.login-body {
    justify-content: center;
    align-items: center;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(255, 255, 255, 0.02);
}

.login-box {
    text-align: center;
    width: 90%;
    max-width: 400px;
    animation: fadeInScale 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeInScale {
    0% { opacity: 0; transform: scale(0.95) translateY(20px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

.neon-text {
    font-weight: 800;
    letter-spacing: 2px;
    color: #fff;
    text-shadow: 0 0 10px var(--primary-neon), 0 0 20px rgba(0, 240, 255, 0.5);
    margin-bottom: 0.5rem;
}

.logo.neon-text {
    font-size: 1.5rem;
    margin: 0;
}
.logo .light {
    color: var(--primary-neon);
    font-weight: 300;
}

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

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

input[type="password"], input[type="number"], input[type="text"], select {
    -webkit-appearance: none;
    appearance: none;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    padding: 1rem;
    border-radius: 12px;
    font-size: 1.1rem;
    outline: none;
    transition: all 0.3s ease;
    width: 100%;
}

input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Fix iOS select dropdown styling */
select {
    background: rgba(0, 0, 0, 0.5) url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") no-repeat right 1rem center;
    background-size: 1em;
    padding-right: 3rem;
}

input[type="password"] {
    text-align: center;
    letter-spacing: 0.5rem;
    font-size: 1.5rem;
}

input:focus, select:focus {
    border-color: var(--primary-neon);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);
    background: rgba(0, 0, 0, 0.7);
}

.btn-glow {
    background: linear-gradient(90deg, #00f0ff 0%, #0099ff 100%);
    color: #0b0f19;
    font-weight: 800;
    border: none;
    padding: 1rem;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
    text-transform: uppercase;
    -webkit-appearance: none;
}

.btn-glow:hover {
    box-shadow: 0 0 30px rgba(0, 240, 255, 0.6);
    transform: translateY(-2px);
}

.error-msg {
    color: var(--loss-red);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    text-shadow: 0 0 10px rgba(255, 51, 102, 0.5);
}

/* App Layout */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 5%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logout-btn {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: 0.3s;
}
.logout-btn:hover {
    color: var(--loss-red);
}

.container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    padding: 2rem 5%;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.form-panel h2, .dashboard-panel h2 {
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: #fff;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
}

.form-panel h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #fff;
}

.input-group {
    margin-bottom: 1.2rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

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

.master-switches {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.radio-label, .checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-main);
    margin-bottom: 1rem;
    transition: 0.3s;
    user-select: none;
}
.radio-label:hover, .checkbox-label:hover {
    color: #fff;
}

.radio-label input, .checkbox-label input {
    display: none;
}

.radio-custom, .chk-custom {
    width: 24px;
    height: 24px;
    border: 2px solid var(--text-muted);
    position: relative;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.radio-custom {
    border-radius: 50%;
}
.chk-custom {
    border-radius: 6px;
}

.radio-label input:checked + .radio-custom {
    border-color: var(--primary-neon);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
    background: rgba(0, 240, 255, 0.1);
}
.radio-label input:checked + .radio-custom::after {
    content: "";
    position: absolute;
    width: 12px; height: 12px;
    background: var(--primary-neon);
    border-radius: 50%;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}

.checkbox-label input:checked + .chk-custom {
    border-color: var(--secondary-neon);
    background: rgba(160, 32, 240, 0.3);
    box-shadow: 0 0 10px rgba(160, 32, 240, 0.4);
}
.checkbox-label input:checked + .chk-custom::after {
    content: "✓";
    position: absolute;
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}

.checkbox-label.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Dashboard Elements */
.dashboard-panel {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.dash-item {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 1.5rem;
    border-radius: 16px;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: 0.4s ease;
}

.dash-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(5px);
}

.dash-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.dash-value {
    font-size: 2rem;
    font-weight: 800;
    color: #fff;
    transition: color 0.3s;
}

.box-highlight {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.15);
    position: relative;
    overflow: hidden;
}

.mt-more {
    margin-top: 1.5rem;
}

.value-positive { color: var(--profit-green) !important; text-shadow: 0 0 15px rgba(0, 255, 136, 0.4); }
.value-negative { color: var(--loss-red) !important; text-shadow: 0 0 15px rgba(255, 51, 102, 0.4); }

.profit-bar-container {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    margin-top: 1rem;
    overflow: hidden;
}
.profit-fill {
    height: 100%;
    width: 0%;
    transition: width 1s cubic-bezier(0.2, 0.8, 0.2, 1), background-color 0.5s;
}

.dashboard-details {
    margin-top: 2rem;
    padding: 1rem;
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
}
.dashboard-details p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 0.8rem;
}
.dashboard-details ul {
    list-style: none;
    font-size: 0.95rem;
    color: var(--text-main);
}
.dashboard-details li {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px dashed rgba(255,255,255,0.1);
}

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

@media (max-width: 768px) {
    body, html {
        background-color: #0b0f19 !important; /* Force explicit dark core */
    }

    .top-nav {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
        padding-top: 1.5rem;
    }

    .nav-links {
        display: flex;
        flex-direction: row;
        width: 100%;
        justify-content: center;
        gap: 2rem;
        margin-top: 0.5rem;
    }

    .nav-link {
        font-size: 1.1rem;
        font-weight: 600;
        padding: 0.5rem 1rem;
        border-radius: 8px;
        background: rgba(255,255,255,0.05);
    }

    .glass-panel {
        padding: 1.5rem;
        background: rgba(20, 20, 30, 0.8); /* Stronger background to overpower iOS white render bugs */
        backdrop-filter: blur(25px);
        -webkit-backdrop-filter: blur(25px);
    }
    
    .dash-value {
        font-size: 1.6rem;
    }
}
