:root {
    --bg-main: #0b0f19;
    --bg-card: #1a1f2e;
    --text-primary: #e2e8f0;
    --text-sec: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --border: #2e364f;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    padding-bottom: 3rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
    animation: fadeInDown 0.8s ease-out;
}

.global-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(26, 31, 46, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
    flex-wrap: wrap;
    gap: 1rem;
}

.nav-left, .nav-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.user-chip {
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-sec);
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-logout {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    min-width: max-content;
}

.btn-logout:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

header h1 {
    font-size: clamp(2.2rem, 5vw + 1rem, 3.5rem);
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

header h1 i {
    -webkit-text-fill-color: #60a5fa;
    margin-right: 10px;
}

header p {
    color: var(--text-sec);
    font-size: 1.1rem;
    letter-spacing: 0.5px;
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-group i {
    position: absolute;
    left: 15px;
    color: var(--text-sec);
    font-size: 1.1rem;
}

input[type="text"], input[type="email"], input[type="password"], input[type="tel"] {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.85rem 1rem 0.85rem 2.8rem;
    border-radius: 12px;
    font-size: 1.05rem;
    width: 100%;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus, input[type="tel"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 0.85rem 1.8rem;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-secondary:hover:not(:disabled) {
    background: rgba(255,255,255,0.05);
    border-color: var(--text-sec);
}

.ip-link {
    color: var(--accent);
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 4px;
    border-radius: 4px;
}

.ip-link:hover {
    color: #8b5cf6;
    background: rgba(139, 92, 246, 0.1);
    text-decoration: none;
}

.ip-link i {
    font-size: 0.7rem;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.ip-link:hover i {
    opacity: 1;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: white;
    border: none;
    padding: 0.85rem 1.8rem;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px -2px rgba(59, 130, 246, 0.4);
}

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

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    background: var(--border);
    box-shadow: none;
}

.connection-status {
    text-align: center;
    margin-bottom: 2rem;
    font-size: 0.95rem;
    color: var(--text-sec);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    word-break: break-all;
}
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--danger);
    transition: all 0.3s ease;
}
.status-dot.connected {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.progress-section {
    margin-bottom: 2.5rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.progress-bar {
    background: var(--bg-card);
    border-radius: 99px;
    height: 10px;
    overflow: hidden;
    margin-bottom: 0.8rem;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.progress-fill {
    background: linear-gradient(90deg, #3b82f6, #a78bfa, #f472b6);
    background-size: 200% 200%;
    height: 100%;
    width: 0%;
    transition: width 0.4s ease-out;
    animation: gradientMove 3s ease infinite;
}

@keyframes gradientMove {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

#statusText {
    text-align: center;
    color: var(--text-sec);
    font-size: 1rem;
    font-weight: 500;
}

.results {
    animation: fadeInUp 0.8s ease-out;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

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

th {
    background: #23293b;
    color: var(--text-sec);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(46, 54, 79, 0.5);
}

td {
    transition: background 0.2s;
}

.font-mono {
    font-family: 'Consolas', 'Courier New', monospace;
    color: #a78bfa;
}

.status-badge {
    padding: 0.35rem 0.85rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    display: inline-block;
}

.status-active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

tbody tr {
    animation: fadeInUp 0.4s ease-out forwards;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 10005; /* Always on top of everything */
}

.toast {
    background: var(--bg-card);
    border-left: 4px solid var(--accent);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    line-height: 1.4;
    word-break: break-word; /* Prevents long URLs from stretching the container */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: slideInRight 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    box-sizing: border-box;
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(120%); }
    to { opacity: 1; transform: translateX(0); }
}

/* Modals */
.auth-wrapper {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #0b0f19; display: flex; align-items: center; justify-content: center;
    z-index: 10000; /* Behind nav and toasts */
}
.auth-card {
    background: var(--bg-main); padding: 2.5rem 2rem; border-radius: 16px;
    border: 1px solid var(--border); box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    width: 95%; max-width: 420px; text-align: center;
    animation: fadeInUp 0.4s ease-out;
}
.auth-card h2 { color: var(--accent); margin-bottom: 0.5rem; }
.auth-card p { color: var(--text-sec); margin-bottom: 2rem; font-size: 0.9rem;}

.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(5px);
    display: none; align-items: center; justify-content: center;
    z-index: 10000;
}
.modal-overlay.active { display: flex; }
.modal-content {
    background: var(--bg-main); width: 90%; max-width: 900px;
    border-radius: 16px; border: 1px solid var(--border);
    padding: 2rem; box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    animation: fadeInUp 0.4s ease-out;
}
.diagram-box {
    max-width: 1100px;
    width: 95%;
}

/* Global Navigation & Common Utilities */
.global-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 10002; /* Above the auth screen */
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}

.nav-left, .nav-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Custom Select Dropdown */
.custom-select {
    position: relative;
    min-width: 180px;
    width: auto;
    user-select: none;
}

.select-trigger {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-primary);
    font-weight: 500;
}

.select-trigger:hover {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

.select-trigger i {
    font-size: 0.9rem;
    transition: transform 0.3s ease;
}

.custom-select.active .select-trigger {
    border-color: var(--accent);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.custom-select.active .select-trigger i:last-child {
    transform: rotate(180deg);
}

.select-options {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #111827;
    border: 1px solid var(--accent);
    border-top: none;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    overflow: hidden;
    display: none;
    animation: slideDown 0.3s ease-out;
    z-index: 100;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.custom-select.active .select-options {
    display: block;
}

.option {
    padding: 0.8rem 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-sec);
}

.option:hover {
    background: var(--accent);
    color: white;
    padding-left: 1.5rem;
}

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

/* Internet Status Widget */
.internet-status {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 30px;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #64748b;
    box-shadow: 0 0 8px #64748b;
    transition: all 0.3s ease;
}

.internet-status.up .status-indicator {
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
}

.internet-status.down .status-indicator {
    background: var(--danger);
    box-shadow: 0 0 10px var(--danger);
}

/* Port Results Grid */
.port-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 15px;
    max-height: 350px;
    overflow-y: auto;
    padding: 10px;
}

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

.port-card.open {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.port-card i {
    font-size: 1.5rem;
    margin-bottom: 8px;
    display: block;
}

.port-num {
    font-family: 'JetBrains Mono', monospace;
    font-weight: bold;
    font-size: 1.1rem;
}

.port-service {
    font-size: 0.8rem;
    color: var(--text-sec);
}

/* Clickable Results */
#resultsBody tr {
    cursor: pointer;
    transition: background 0.2s ease;
}

#resultsBody tr:hover {
    background: rgba(59, 130, 246, 0.08) !important;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-sec);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close-btn:hover { color: white; }

.container { margin-top: 100px; }

@media (max-width: 1024px) {
    .custom-select { min-width: 140px; }
    .internet-status span { display: none; }
    .global-nav { padding: 0.8rem 1rem; }
}

/* Original Responsive Overrides */
@media (max-width: 1024px) {
    .container {
        padding: 1rem;
    }
    
    header {
        margin-top: 2.5rem;
    }
    
    header h1 {
        flex-direction: column;
        line-height: 1.25;
        gap: 8px;
    }
    
    header p {
        font-size: 0.95rem;
    }
    
    .top-bar {
        justify-content: center;
    }
    
    .lang-switcher {
        width: max-content;
        padding: 6px 12px;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .input-group {
        width: 100%;
    }
    
    input[type="text"], input[type="email"], input[type="password"], input[type="tel"] {
        width: 100%;
        font-size: 1rem;
    }
    
    .btn-primary {
        width: 100%;
        justify-content: center;
        padding: 0.85rem;
    }
    
    table, thead, tbody, th, td, tr {
        display: block;
    }
    
    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    tr {
        margin-bottom: 1rem;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: rgba(35, 41, 59, 0.4);
    }
    
    td {
        border: none;
        border-bottom: 1px solid rgba(46, 54, 79, 0.5);
        position: relative;
        padding-left: 50% !important;
        text-align: right !important;
        min-height: 3rem;
        display: flex;
        align-items: center;
        justify-content: flex-end;
    }
    
    td:last-child {
        border-bottom: 0;
    }
    
    td:before {
        position: absolute;
        left: 1rem;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: 700;
        color: var(--text-sec);
        text-transform: uppercase;
        font-size: 0.75rem;
        content: attr(data-label);
    }
    
    .results {
        overflow-x: visible;
        margin: 0;
        padding: 0;
    }

    table {
        min-width: 100%;
        background: transparent;
        box-shadow: none;
    }
    
    th, td {
        padding: 1rem;
    }
    
    .toast-container {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }
    
    .toast {
        width: 100%;
    }
}
/* --- SERVICE BADGES --- */
.service-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.svc-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-sec);
    display: flex;
    align-items: center;
    gap: 4px;
    animation: fadeIn 0.3s ease forwards;
}

.svc-badge i { font-size: 0.65rem; }
.svc-badge.open { border-color: var(--success); color: var(--success); background: rgba(16, 185, 129, 0.1); }
.svc-badge.web { border-color: var(--accent); color: var(--accent); background: rgba(59, 130, 246, 0.1); }
.svc-badge.secure { border-color: #a78bfa; color: #a78bfa; background: rgba(167, 139, 250, 0.1); }

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

/* ============================
   NETWORK MANAGER CARD
   ============================ */
.network-manager-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    animation: fadeInUp 0.6s ease-out;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.nm-header {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.nm-header i { color: var(--accent); font-size: 1.2rem; }
.nm-header span { flex: 1; }

.nm-badge {
    padding: 4px 12px;
    border-radius: 99px;
    font-size: 0.78rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nm-badge-checking { background: rgba(100, 116, 139, 0.2); color: #94a3b8; border: 1px solid #334155; }
.nm-badge-connected-wifi { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); }
.nm-badge-connected-eth { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }
.nm-badge-disconnected { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }

.nm-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 1.2rem;
    background: rgba(0,0,0,0.2);
    padding: 4px;
    border-radius: 12px;
    width: fit-content;
}

.nm-tab {
    background: transparent;
    border: none;
    color: var(--text-sec);
    padding: 0.5rem 1.2rem;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 7px;
}

.nm-tab.active {
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.nm-tab:not(.active):hover { color: var(--text-primary); background: rgba(255,255,255,0.06); }

.nm-panel { animation: fadeIn 0.3s ease; }

.nm-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 700px) { .nm-row { grid-template-columns: 1fr; } }

.nm-select-group label {
    display: block;
    color: var(--text-sec);
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

.nm-select {
    flex: 1;
    background: var(--bg-main);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.65rem 1rem;
    border-radius: 10px;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s;
    cursor: pointer;
}

.nm-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.2); }

.nm-input {
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-main);
    display: flex;
    align-items: center;
}

.nm-input input {
    border: none;
    background: transparent;
    border-radius: 0;
    padding-left: 2.5rem;
}

.nm-input input:focus { box-shadow: none; border: none; }

.btn-icon {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    color: var(--text-sec);
    border-radius: 10px;
    padding: 0.65rem 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-icon:hover { background: rgba(59,130,246,0.15); color: var(--accent); border-color: var(--accent); }
.btn-icon.spinning i { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.adapter-list { display: flex; flex-direction: column; gap: 10px; }

.adapter-card {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem 1.2rem;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: all 0.2s;
}

.adapter-card.connected { border-color: rgba(16,185,129,0.4); background: rgba(16,185,129,0.07); }
.adapter-card.ethernet-icon { color: #60a5fa; }
.adapter-card-icon { font-size: 1.5rem; }
.adapter-card-info { flex: 1; }
.adapter-card-name { font-weight: 700; font-size: 0.95rem; color: var(--text-primary); }
.adapter-card-ip { font-size: 0.82rem; color: var(--text-sec); font-family: monospace; margin-top: 2px; }
.adapter-card-badge { font-size: 0.75rem; padding: 3px 10px; border-radius: 99px; border: 1px solid; font-weight: 600; }
.badge-connected { background: rgba(16,185,129,0.15); color: #10b981; border-color: rgba(16,185,129,0.3); }
.badge-disconnected { background: rgba(239,68,68,0.15); color: #ef4444; border-color: rgba(239,68,68,0.3); }
