:root {
    /* Color Palette */
    --bg-dark: #0f172a;
    --sidebar-width: 280px;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --neon-blue: #3b82f6;
    --neon-purple: #a855f7;
    --accent-green: #10b981;
    --danger-red: #ef4444;
    --warning-yellow: #f59e0b;

    /* Glassmorphism System */
    --glass-bg: rgba(15, 23, 42, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shine: rgba(255, 255, 255, 0.03);

    --card-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
    --hover-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5);

    /* Fonts */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

/* LIGHT MODE THEME - Soft & Easy on Eyes */
[data-theme="light"] {
    --bg-dark: #f8fafc;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.08);
    --glass-shine: rgba(255, 255, 255, 0.3);
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    --hover-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] body {
    background-color: #f1f5f9;
    background-image:
        radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.03) 0%, transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(168, 85, 247, 0.03) 0%, transparent 25%);
    color: #1e293b;
}

[data-theme="light"] .sidebar {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-right: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .glass-card,
[data-theme="light"] .glass-panel {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .nav-link {
    color: #334155;
}

[data-theme="light"] .nav-link:hover,
[data-theme="light"] .nav-link.active {
    background: rgba(59, 130, 246, 0.08);
    color: #1d4ed8;
}

[data-theme="light"] .neon-input {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.1);
    color: #1e293b;
}

[data-theme="light"] .neon-input:focus {
    border-color: var(--neon-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

[data-theme="light"] .page-title,
[data-theme="light"] h1,
[data-theme="light"] h2,
[data-theme="light"] h3 {
    color: #0f172a;
}

[data-theme="light"] .text-muted {
    color: #64748b;
}

[data-theme="light"] .ticker-wrap {
    background: rgba(241, 245, 249, 0.9);
    border-bottom-color: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .ticker-item {
    color: #475569;
}

[data-theme="light"] .ticker-item strong {
    color: #0f172a;
}

[data-theme="light"] .btn-primary-glow {
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.25);
}

/* Base Reset & Typography */
* {
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-dark);
    /* Deep Starfield Gradient */
    background-image:
        radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.08) 0%, transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(168, 85, 247, 0.08) 0%, transparent 25%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
}

h1,
h2,
h3,
h4,
h5,
h6,
.brand-font {
    font-family: var(--font-heading);
}

/* --- LAYOUT --- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    /* Changed from sticky to fixed for stability */
    top: 0;
    left: 0;
    background: var(--bg-dark);
    /* Solid background to prevent see-through gaps */
    border-right: 1px solid var(--glass-border);
    z-index: 100;
    overflow-y: auto;
    /* Allow scrolling */
    overflow-x: hidden;
    scrollbar-width: none;
    /* Firefox */
}

/* Hide scrollbar for Chrome/Safari/Opera */
.sidebar::-webkit-scrollbar {
    display: none;
}

/* Universal Page Content */
.app-content {
    flex: 1;
    padding: 2rem 3rem;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    margin-left: var(--sidebar-width);
    /* Push content right */
}

@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        display: none;
    }

    /* Handled by Mobile Nav */
    .app-content {
        padding: 1.5rem;
        padding-bottom: 6rem;
        margin-left: 0;
        /* Reset margin for mobile */
    }

    /* Space for bottom nav */
}

/* --- COMPONENTS --- */

/* Glass Panel / Card */
.glass-panel,
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-panel:hover,
.glass-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--hover-shadow);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Headers */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.text-muted {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Brand Gradient Utilities */
.brand-gradient {
    background: linear-gradient(to right, #22d3ee, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(34, 211, 238, 0.3);
}

.logo-text {
    font-family: var(--font-heading);
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* Inputs (Neon Style) */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.neon-input,
.form-control,
select,
textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    background: rgba(0, 0, 0, 0.3) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 12px !important;
    color: white !important;
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: all 0.3s ease;
    box-sizing: border-box;
    /* Important fix */
}

.neon-input:focus,
.form-control:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--neon-blue) !important;
    background: rgba(0, 0, 0, 0.5) !important;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1) !important;
    transform: translateY(-1px);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 2.5rem;
    border-radius: 99px;
    /* Pill shape as requested in image */
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    font-size: 1rem;
    font-family: var(--font-heading);
}

.btn-primary,
.btn-primary-glow {
    background: #3b82f6;
    /* Matching the vibrant blue in image */
    color: white;
    box-shadow: 0 15px 35px -10px rgba(59, 130, 246, 0.5);
}

.btn-primary:hover,
.btn-primary-glow:hover {
    transform: translateY(-3px);
    background: #2563eb;
    box-shadow: 0 20px 40px -10px rgba(59, 130, 246, 0.7);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.02);
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    border-color: rgba(255, 255, 255, 0.1);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Data Tables (Generic) */
.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 1rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--glass-border);
    font-weight: 700;
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    color: var(--text-primary);
    font-size: 0.95rem;
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* --- DASHBOARD SPECIFICS --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 700;
    color: white;
    margin-top: 0.25rem;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    background: rgba(255, 255, 255, 0.05);
}

.ticker-wrap {
    width: 100%;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.8);
    border-bottom: 1px solid var(--glass-border);
    padding: 0.75rem 0;
    margin: -2rem -3rem 2rem -3rem;
    backdrop-filter: blur(10px);
}

.ticker {
    display: flex;
    white-space: nowrap;
    animation: ticker 30s linear infinite;
}

.ticker-item {
    display: inline-flex;
    align-items: center;
    padding: 0 2rem;
    font-size: 0.9rem;
    color: #cbd5e1;
}

.ticker-item strong {
    color: white;
    margin: 0 0.5rem;
    font-family: var(--font-heading);
}

@keyframes ticker {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-50%);
    }
}

/* --- EDITOR & FORM SPECIFICS --- */
.editor-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    display: inline-block;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.toggle-slider {
    background-color: var(--neon-purple);
}

input:checked+.toggle-slider:before {
    transform: translateX(20px);
}

/* Editor Table */
.items-wrapper {
    margin-top: 2rem;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.01);
}

.items-header {
    display: grid;
    grid-template-columns: 3fr 0.5fr 1fr 1fr 1fr 0.3fr;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.item-row {
    display: grid;
    grid-template-columns: 3fr 0.5fr 1fr 1fr 1fr 0.3fr;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    align-items: start;
    gap: 1rem;
    transition: background 0.2s;
}

.item-row:hover {
    background: rgba(59, 130, 246, 0.02);
}

.items-footer {
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
}

.table-input {
    border-color: transparent !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0.5rem !important;
}

.table-input:focus {
    border-color: var(--neon-blue) !important;
    background: rgba(0, 0, 0, 0.5) !important;
}

.btn-add {
    background: transparent;
    border: 1px dashed rgba(255, 255, 255, 0.2);
    color: var(--text-secondary);
    padding: 0.75rem 2rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.btn-add:hover {
    border-color: var(--neon-blue);
    color: var(--neon-blue);
    background: rgba(59, 130, 246, 0.05);
}

.btn-remove {
    color: var(--danger-red);
    background: rgba(239, 68, 68, 0.1);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 5px;
}

.btn-remove:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: scale(1.1);
}

/* Summary & AI */
.summary-card {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.7), rgba(15, 23, 42, 0.8));
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    color: #cbd5e1;
    font-size: 0.9rem;
}

.summary-row.total {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 700;
    color: white;
    font-size: 1.1rem;
}

.total-display {
    font-size: 1.8rem;
    font-family: var(--font-heading);
    background: linear-gradient(135deg, #60a5fa 0%, #c084fc 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.ai-card {
    background: rgba(168, 85, 247, 0.05);
    border: 1px solid rgba(168, 85, 247, 0.2);
    margin-top: 1.5rem;
}

.ai-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #d8b4fe;
    font-weight: 600;
    margin-bottom: 1rem;
    font-family: var(--font-heading);
}

/* Badges */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-neutral {
    background: rgba(148, 163, 184, 0.15);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.badge-optional {
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
}

/* Helpers */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
}

.grid-responsive {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

@media (max-width: 768px) {

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }
}

/* Avatar */
.avatar-lg {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 800;
    color: white;
    box-shadow: 0 10px 20px -5px rgba(59, 130, 246, 0.5);
    margin: 0 auto 1.5rem auto;
    border: 4px solid rgba(15, 23, 42, 0.8);
}

/* Mobile Bottom Nav */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(16px);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}

.mobile-nav-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: 4rem;
    align-items: center;
}

.mobile-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 500;
}

.mobile-link:hover,
.mobile-link.active {
    color: var(--neon-blue);
}

.mobile-fab {
    position: relative;
    top: -1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background: var(--neon-blue);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
    border: 4px solid var(--bg-dark);
    text-decoration: none;
}

@media (max-width: 768px) {
    .mobile-nav {
        display: block;
    }
}

/* --- MODALS --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--glass-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    padding: 2rem;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--danger-red);
}

/* --- AUTH & PORTAL --- */
.auth-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100%;
    position: relative;
    overflow: hidden;
    padding: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 3rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 10;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--neon-blue), transparent);
}

.brand-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.logo-lg {
    height: 60px;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 15px rgba(59, 130, 246, 0.4));
}

.auth-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Ambient Orbs */
.ambient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    z-index: 0;
    animation: float 10s infinite ease-in-out;
}

.orb-blue {
    width: 500px;
    height: 500px;
    background: var(--neon-blue);
    top: -20%;
    left: -10%;
    animation-delay: 0s;
}

.orb-purple {
    width: 400px;
    height: 400px;
    background: var(--neon-purple);
    bottom: -10%;
    right: -5%;
    animation-delay: -5s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(30px, 50px);
    }
}

/* Helpers */
.text-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.text-link:hover {
    color: var(--neon-blue);
}

.auth-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
    text-align: center;
}