:root {
    color-scheme: dark;
    /* iOS 26 High-Fidelity Colors */
    --primary-color: #0A84FF;
    --primary-glow: rgba(10, 132, 255, 0.5);
    --success-color: #30D158;
    --warning-color: #FFD60A;
    --danger-color: #FF453A;

    /* Theme Tokens */
    --bg-body: #000000;
    --glass-base: rgba(30, 30, 30, 0.6);
    --glass-border: rgba(255, 255, 255, 0.15);
    --glass-highlight: rgba(255, 255, 255, 0.1);
    --text-primary: #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.75);
    --text-tertiary: rgba(255, 255, 255, 0.45);

    /* Refined Radius (Professional Standard) */
    --radius-xl: 16px;
    --radius-lg: 12px;
    --radius-md: 8px;

    --header-height: 72px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, "Inter", sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
    /* padding-top removed to let sticky elements push content down naturally */
}

main {
    /* No artificial padding needed with sticky positioning */
    flex: 1;
    position: relative;
    z-index: 1;
}

/* --- Marquee Bar --- */
.marquee-bar {
    width: 100%;
    background: linear-gradient(90deg, #001a4d, #000000, #001a4d);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #FFFFFF;
    height: 36px;
    display: flex;
    align-items: center;
    overflow: hidden;
    position: sticky;
    /* Sticky ensures it takes up space in the flow */
    top: 0;
    left: 0;
    z-index: 2002;
}

.marquee-content {
    display: inline-block;
    white-space: nowrap;
    animation: marquee 25s linear infinite;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
    padding-left: 100%;
}

@keyframes marquee {
    0% {
        transform: translate3d(0, 0, 0);
    }

    100% {
        transform: translate3d(-100%, 0, 0);
    }
}

/* --- Vivid Animated Background --- */
.background-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: #050505;
    overflow: hidden;
}

body::before,
body::after {
    content: "";
    position: fixed;
    width: 800px;
    height: 800px;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    opacity: 0.5;
}

body::before {
    top: -200px;
    left: -200px;
    background: radial-gradient(circle, #0044ff 0%, transparent 70%);
    animation: flowGlobal 20s infinite alternate;
}

body::after {
    bottom: -200px;
    right: -200px;
    background: radial-gradient(circle, #00C6FF 0%, transparent 70%);
    animation: flowGlobal 25s infinite alternate-reverse;
}

@keyframes flowGlobal {
    from {
        transform: translate(0, 0) scale(1);
    }

    to {
        transform: translate(50px, 50px) scale(1.1);
    }
}

/* --- Premium Glass Header --- */
header {
    height: var(--header-height);
    background: rgba(15, 15, 15, 0.85);
    /* Slightly darker for contrast */
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    /* Sticky ensures it takes up space below the marquee */
    /* Sticks at 36px (height of marquee) */
    top: 36px;
    left: 0;
    width: 100%;
    /* Ensure full width when fixed */
    z-index: 2001;
    /* Above content, below marquee */
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
    margin-top: 0;
    /* Reset */
}

.brand {
    font-size: 22px;
    font-weight: 800;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    letter-spacing: -0.5px;
}

.brand i {
    color: var(--primary-color);
    font-size: 26px;
    filter: drop-shadow(0 0 12px var(--primary-glow));
}

.controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

#mainNav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    padding: 8px 16px;
    border-radius: 20px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.nav-link.active {
    color: white;
    background: var(--primary-color);
    box-shadow: 0 4px 15px rgba(10, 132, 255, 0.4);
}

/* Form Controls (Language) */
.lang-select {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 6px;
    border-radius: 8px;
    cursor: pointer;
}

.lang-select option {
    background: #000;
    color: white;
}

/* --- Main Layout --- */
main {
    flex: 1;
    width: 100%;
    max-width: 1400px;
    /* Increased width to utilize space for side-by-side view */
    margin: 40px auto;
    padding: 0 24px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    align-items: stretch;
    /* Stretch to preserve equal heights if content allows */
}

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

    header {
        padding: 0 20px;
    }
}

/* --- Glass Cards --- */
.card {
    background: rgba(30, 30, 30, 0.6);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 32px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: hidden;
    /* Added ensure height matching logic via flex if strictly needed,
       but align-items: stretch on grid mostly handles outer containers. */
}

/* Top shiny edge */
.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
}

h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 24px;
    color: white;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

/* --- Inputs --- */
textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    color: white;
    padding: 20px;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    /* Fixed size controlled by CSS height matches */
    transition: all 0.3s;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2);
    min-height: 250px;
    height: 380px;
    /* Taller input area to match log */
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.2);
}

/* --- Buttons --- */
.btn {
    width: 100%;
    height: 56px;
    border-radius: var(--radius-lg);
    border: none;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    background: linear-gradient(135deg, #2979FF, #0A84FF);
    color: white;
    box-shadow: 0 8px 20px rgba(10, 132, 255, 0.3);
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 12px 30px rgba(10, 132, 255, 0.5);
    filter: brightness(1.1);
}

.btn:active {
    transform: scale(0.98);
}

.btn i {
    font-size: 18px;
}

.check-group {
    display: flex;
    gap: 16px;
    margin-top: 20px;
}

/* --- Mode Selectors --- */
.mode-selector {
    background: rgba(0, 0, 0, 0.3);
    padding: 6px;
    border-radius: 16px;
    display: flex;
    gap: 4px;
    border: 1px solid var(--glass-border);
    margin: 20px 0;
}

.mode-btn {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    text-align: center;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
}

.mode-btn.active {
    background: var(--primary-color);
    /* Always colored when active */
    color: white;
    box-shadow: 0 2px 10px rgba(10, 132, 255, 0.4);
}

#fastMode.active {
    background: var(--primary-color);
    /* Uniform Blue for active state on both, or switch to Green if preferred */
    /* User request: "màu của ô slow... không hiện màu xanh mà là màu xám... chọn bên nào thì bên đó xanh"
       Interpreting as: Selected = Primary Blue/Green. Let's start with Primary Blue for consistency, or Green if requested specifically 'xanh'.
       'Xanh' usually means Blue or Green in Vietnamese. Primary-color is Blue (#0A84FF). Success is Green.
       I will set both to Primary Blue for a unified look, or keep Turbo as Green if specifically desired, but ensuring NEITHER is Grey.
    */
    background: var(--success-color);
    /* Keep turbo green to distinguish 'Fast' */
    box-shadow: 0 2px 15px rgba(48, 209, 88, 0.4);
    color: black;
}

/* --- Stats Cards (Top) --- */
.stats-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px 8px;
    text-align: center;
    transition: all 0.3s ease;
}

.stat-card:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-color: var(--primary-color);
}

.stat-value {
    font-size: 24px;
    font-weight: 800;
    display: block;
    color: white;
    margin-bottom: 2px;
    line-height: 1.2;
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-tertiary);
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Updated List Rows (Compact Bottom) */
.results-summary-area {
    margin-top: auto;
    /* Push to bottom */
    padding-top: 10px;
}

.result-row {
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s;
}

.result-row:last-child {
    border-bottom: none;
}

.result-row:hover {
    background: rgba(255, 255, 255, 0.07);
}

.label {
    font-size: 16px;
    /* Increased font size */
    font-weight: 600;
}

.actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stat-number {
    font-size: 24px;
    /* Increased font size */
    font-weight: 800;
    min-width: 40px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    margin-right: 12px;
}

/* Action Icons (Smaller) */
.action-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.action-btn:hover {
    background: white;
    color: black;
}

/* File Upload */
.file-upload {
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.3s;
    margin-top: 10px;
}

.file-upload:hover {
    background: rgba(10, 132, 255, 0.1);
    border-color: var(--primary-color);
}

.file-upload i {
    font-size: 24px;
    color: var(--primary-color);
    margin-bottom: 8px;
}

/* Footer */
footer {
    text-align: center;
    padding: 30px;
    margin-top: 40px;
    border-top: 1px solid var(--glass-border);
    color: var(--text-tertiary);
}

/* Table - Detailed Log (Expanded) */
.table-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    /* Strict dimensions to prevent expansion */
    height: 380px !important;
    max-height: 380px !important;
    min-height: 380px !important;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Contain inner scroll */
}

/* Make table scrollable while header stays fixed */
.table-container table {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.table-container thead {
    flex: 0 0 auto;
    display: table;
    width: 100%;
    table-layout: fixed;
}

.table-container tbody {
    flex: 1 1 auto;
    overflow-y: scroll;
    /* Force scrollbar */
    display: block;
}

.table-container tr {
    display: table;
    width: 100%;
    table-layout: fixed;
}

.table-container th,
.table-container td {
    display: table-cell;
    width: 65%;
    /* Email column */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-container th:last-child,
.table-container td:last-child {
    width: 35%;
    /* Status column */
}

th {
    background: rgba(20, 20, 20, 0.8);
    backdrop-filter: blur(10px);
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 700;
}

/* Ensure corners of the container are respected */
.table-container th:first-child {
    border-top-left-radius: 12px;
}

.table-container th:last-child {
    border-top-right-radius: 12px;
}

td {
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 13px;
    font-family: monospace;
    vertical-align: middle;
}

/* Status Text (No Badge Background) to match Results */
.count-badge {
    padding: 0;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.bg-success {
    color: var(--success-color);
}

.bg-warning {
    color: var(--warning-color);
}

.bg-danger {
    color: var(--danger-color);
}

.bg-neutral {
    color: var(--text-secondary);
}

/* Pulse Live Indicator */
.live-indicator {
    font-size: 12px;
    color: var(--success-color);
    display: flex;
    align-items: center;
    gap: 6px;
}

.pulse {
    width: 6px;
    height: 6px;
    background: var(--success-color);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--success-color);
}


/* Progress Bar (Legacy Style restored) */
.progress-container {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 20px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #0A84FF, #5E5CE6);
    width: 0%;
    transition: width 0.3s;
}

.progress-text {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 5px;
}

/* Helper Utilities */
.hidden {
    display: none !important;
}

.helper-text {
    background: rgba(10, 132, 255, 0.15);
    padding: 10px;
    border-radius: 10px;
    color: #4da3ff;
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    gap: 8px;
}

.helper-link {
    color: white;
    text-decoration: underline;
    cursor: pointer;
}

/* 2FA/Notepad Fixes */
.secret-input {
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.3) !important;
    text-align: center;
    font-family: monospace;
    font-size: 20px;
    letter-spacing: 1px;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* --- Mobile Bottom Navigation (Taskbar Fix) --- */
@media (max-width: 768px) {
    body {
        padding-bottom: 90px;
        /* Space for bottom bar + safe area */
    }

    /* Transform Inline Nav to Bottom Bar */
    #mainNav {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background: rgba(20, 20, 20, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid var(--glass-border);
        display: flex;
        justify-content: space-around;
        align-items: center;
        z-index: 5000;
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(65px + env(safe-area-inset-bottom));
        box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.5);
        gap: 0;
    }

    .nav-link {
        flex: 1;
        flex-direction: column;
        justify-content: center;
        padding: 6px 0;
        border-radius: 0;
        font-size: 10px;
        gap: 4px;
        color: var(--text-tertiary);
        background: transparent !important;
        /* Remove desktop pill background */
        box-shadow: none !important;
    }

    .nav-link i {
        font-size: 20px;
        margin-bottom: 2px;
        display: block;
    }

    .nav-link.active {
        color: var(--primary-color);
        background: transparent !important;
    }

    .nav-link:hover {
        background: transparent;
        color: var(--text-primary);
    }

    /* Header Cleanup for Mobile */
    header {
        padding: 0 15px;
        background: rgba(15, 15, 15, 0.95) !important;
    }

    .brand {
        font-size: 18px;
    }

    .brand i {
        font-size: 22px;
    }

    /* Hide Controls gap since nav is gone from flow */
    .controls {
        gap: 0;
    }
}