:root {
    --primary-color: #0044FF; /* Royal Blue MB Prime Tech */
    --primary-hover: #002299;
    --primary-light: #4D88FF;
    --bg-dark: #050B14; /* Deep Tech Blue */
    --bg-panel: #0A1128; /* Slightly lighter deep tech */
    --text-main: #ffffff; 
    --text-muted: #8e9bb0; 
    --border-color: #1A2B4C;
    --danger: #ef4444;
    --glass-bg: rgba(10, 17, 40, 0.7);
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    /* Subtle radial gradient for depth */
    background-image: radial-gradient(circle at top right, rgba(0, 68, 255, 0.1), transparent 40%),
                      radial-gradient(circle at bottom left, rgba(0, 191, 255, 0.05), transparent 40%);
    background-attachment: fixed;
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
}

h1, h2, h3, p {
    margin: 0;
}

.hidden {
    display: none !important;
}

/* Gradient Text */
.gradient-text {
    background: linear-gradient(90deg, #00BFFF, #0044FF);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
    letter-spacing: -0.5px;
}

/* Glassmorphism Panel */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* LOGIN SCREEN */
#login-container {
    width: 100%;
    max-width: 420px;
    text-align: center;
    animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

#login-container p {
    color: var(--text-muted);
    margin: 12px 0 24px;
    font-size: 0.95rem;
}

.input-group {
    text-align: left;
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    color: var(--text-muted);
}

.input-group input, .input-group textarea {
    width: 100%;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
}

.input-group input:focus, .input-group textarea:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(0, 68, 255, 0.15);
    background: rgba(0,0,0,0.4);
}

button {
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    border-radius: 12px;
    padding: 1rem 2rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    width: 100%;
    box-shadow: 0 4px 15px rgba(0, 68, 255, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 68, 255, 0.5);
    background: linear-gradient(135deg, var(--primary-light), var(--primary-color));
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

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

.error-msg {
    color: var(--danger) !important;
    margin-top: 1.5rem !important;
    font-size: 0.9rem;
    font-weight: 500;
}

/* DASHBOARD LAYOUT */
#dashboard-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
    animation: fadeIn 0.5s ease-out;
}

.mobile-topbar,
.mobile-sidebar-overlay {
    display: none;
}

.mobile-sidebar-header {
    display: none;
}

.sidebar {
    width: 280px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar .logo {
    padding: 2.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar nav {
    flex: 1;
    padding: 2rem 1.5rem;
    overflow-y: auto;
}

.nav-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 1rem 1.25rem;
    background: transparent;
    color: #a0aec0;
    border-radius: 12px;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.95rem;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
    transform: translateX(4px);
}

.nav-btn.active {
    background: linear-gradient(90deg, rgba(0, 68, 255, 0.15), transparent);
    color: var(--primary-light);
    font-weight: 700;
    border-left: 4px solid var(--primary-color);
    border-radius: 0 12px 12px 0;
}

.sidebar-footer {
    padding: 2rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

.sidebar-footer button {
    width: 100%;
}

.content-area {
    flex: 1;
    padding: 4rem 5rem;
    overflow-y: auto;
    position: relative;
}

.flex-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 2rem;
}

.content-area h2 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    letter-spacing: -1px;
}

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

/* CARDS */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
}

.card {
    background: linear-gradient(145deg, var(--bg-panel), #080c1d);
    padding: 2rem;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 4px;
    background: linear-gradient(90deg, var(--primary-color), #00BFFF);
    opacity: 0;
    transition: opacity 0.4s;
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    border-color: rgba(0, 68, 255, 0.3);
}

.card:hover::before {
    opacity: 1;
}

.card h3 {
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.card textarea {
    width: 100%;
    margin-bottom: 1.5rem;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 1rem;
    border-radius: 12px;
    resize: vertical;
    transition: border-color 0.3s;
}
.card textarea:focus { border-color: var(--primary-color); }

.card button.btn-primary {
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
}

/* TABLES */
.table-container {
    background: var(--bg-panel);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    overflow-x: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 1.25rem 2rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: rgba(0,0,0,0.3);
    color: #a0aec0;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

tr:hover td {
    background: rgba(255,255,255,0.02);
}

td img {
    border-radius: 8px;
    display: block;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.action-btns button {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    margin-right: 0.5rem;
    border-radius: 8px;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

/* MODAL */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 5, 16, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    width: 100%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid rgba(0, 68, 255, 0.3);
    box-shadow: 0 25px 50px rgba(0,0,0,0.8), 0 0 0 1px rgba(255,255,255,0.05) inset;
}

.modal-content::-webkit-scrollbar { width: 8px; }
.modal-content::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

.modal-content h3 {
    margin-bottom: 2rem;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--primary-light);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2.5rem;
    border-top: 1px solid var(--border-color);
    padding-top: 2rem;
}

.modal-actions button {
    width: auto;
}

/* GLOBAL DIALOG (Custom alert/confirm) */
.app-dialog {
    position: fixed;
    inset: 0;
    background: rgba(2, 8, 23, 0.72);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 2000;
    animation: fadeIn 0.2s ease-out;
}

.app-dialog-panel {
    width: min(520px, 100%);
    background: linear-gradient(165deg, #0a1128, #060d1f);
    border: 1px solid rgba(77, 136, 255, 0.35);
    border-radius: 18px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255,255,255,0.04) inset;
    padding: 20px;
    transform: translateY(0);
}

.app-dialog-icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    margin-bottom: 12px;
    color: #fff;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.app-dialog-content h4 {
    margin: 0 0 6px;
    font-size: 1.2rem;
}

.app-dialog-content p {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.5;
}

.app-dialog-actions {
    margin-top: 18px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.app-dialog-actions .btn-primary,
.app-dialog-actions .btn-secondary {
    width: auto;
    min-width: 105px;
    padding: 0.75rem 1.2rem;
}

@media (max-width: 960px) {
    body {
        display: block;
        align-items: stretch;
        justify-content: initial;
        background-attachment: scroll;
    }

    body.mobile-nav-open {
        overflow: hidden;
    }

    .glass-panel {
        padding: 1.5rem;
    }

    #login-container {
        max-width: none;
        margin: 16px;
        width: auto;
    }

    #dashboard-container {
        display: block;
        min-height: 100vh;
    }

    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 14px;
        position: sticky;
        top: 0;
        z-index: 40;
        padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 12px;
        background: linear-gradient(180deg, rgba(5, 11, 20, 0.98), rgba(5, 11, 20, 0.9));
        backdrop-filter: blur(14px);
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
        box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
    }

    .mobile-menu-btn {
        width: 52px;
        height: 52px;
        padding: 0;
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 5px;
        background: rgba(255, 255, 255, 0.04);
        border: 1px solid var(--border-color);
        box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
    }

    .mobile-menu-btn span {
        width: 20px;
        height: 2px;
        border-radius: 999px;
        background: var(--text-main);
        display: block;
    }

    .mobile-brand {
        display: flex;
        flex-direction: column;
        min-width: 0;
        gap: 2px;
    }

    .mobile-brand strong {
        font-size: 1rem;
        line-height: 1.1;
    }

    .mobile-brand span {
        color: var(--text-muted);
        font-size: 0.8rem;
    }

    .mobile-sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(2, 8, 23, 0.72);
        backdrop-filter: blur(4px);
        z-index: 45;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(86vw, 320px);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 50;
        box-shadow: 20px 0 40px rgba(0, 0, 0, 0.45);
        border-right: 1px solid rgba(77, 136, 255, 0.18);
    }

    #dashboard-container.sidebar-open .sidebar {
        transform: translateX(0);
    }

    #dashboard-container.sidebar-open .mobile-sidebar-overlay {
        display: block;
    }

    .sidebar .logo {
        display: none;
    }

    .mobile-sidebar-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: calc(14px + env(safe-area-inset-top, 0px)) 1rem 1rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
        background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
    }

    .mobile-sidebar-brand {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .mobile-sidebar-brand strong {
        font-size: 1rem;
    }

    .mobile-sidebar-brand span {
        font-size: 0.78rem;
        color: var(--text-muted);
    }

    .mobile-menu-close {
        width: 42px;
        height: 42px;
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid var(--border-color);
        font-size: 1.5rem;
        line-height: 1;
        color: var(--text-main);
        box-shadow: none;
    }

    .sidebar nav {
        padding: 0.85rem;
    }

    .sidebar-footer {
        padding: 0.85rem;
    }

    .content-area {
        padding: 1.1rem 0.9rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
        overflow: visible;
    }

    .flex-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        margin-bottom: 1.5rem;
        padding-bottom: 1.25rem;
    }

    .flex-header > button,
    .flex-header .btn-primary {
        width: 100%;
    }

    .content-area h2 {
        font-size: 1.8rem;
        line-height: 1.1;
    }

    .content-area header p {
        font-size: 0.95rem;
    }

    .card-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .card {
        padding: 1.25rem;
        border-radius: 14px;
    }

    .card h3 {
        font-size: 1.08rem;
        line-height: 1.25;
    }

    th, td {
        padding: 0.9rem 0.85rem;
    }

    table {
        min-width: 680px;
    }

    .action-btns button {
        display: block;
        width: 100%;
        margin-bottom: 0.5rem;
        margin-right: 0;
    }

    .table-container {
        border-radius: 14px;
    }

    .modal {
        align-items: flex-end;
        padding: 10px;
    }

    .modal-content {
        max-height: calc(100vh - 20px);
        border-radius: 20px 20px 0 0;
        padding: 1.25rem;
    }

    .modal-content h3 {
        font-size: 1.35rem;
        margin-bottom: 1.25rem;
    }

    .modal-actions,
    .app-dialog-actions {
        flex-direction: column-reverse;
        gap: 0.75rem;
    }

    .modal-actions button,
    .app-dialog-actions .btn-primary,
    .app-dialog-actions .btn-secondary {
        width: 100%;
        min-width: 0;
    }

    .app-dialog {
        align-items: flex-end;
        padding: 10px;
    }

    .app-dialog-panel {
        width: 100%;
        padding: 18px;
        border-radius: 18px 18px 0 0;
    }
}

@media (max-width: 560px) {
    .input-group input,
    .input-group textarea,
    button {
        font-size: 16px;
    }

    .content-area h2 {
        font-size: 1.55rem;
    }

    .nav-btn {
        padding: 0.9rem 1rem;
        font-size: 0.92rem;
    }

    table {
        min-width: 620px;
    }

    .mobile-topbar {
        gap: 10px;
    }

    .mobile-menu-btn {
        width: 48px;
        height: 48px;
    }
}
