/* ── Reset & base ── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: #e0f2fe;
    color: #0c2a4a;
    min-height: 100vh;
}

/* ── Nav ── */
nav {
    background: #0369a1;
    padding: .75rem 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-logo {
    margin-right: auto;
    display: flex;
    align-items: center;
}

.nav-logo img {
    max-width: 100%;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

nav {
    position: relative;
    z-index: 20;
}

.nav-item {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    padding: 0.2rem 0;
}

nav a {
    color: #e0f2fe;
    text-decoration: none;
    font-weight: 500;
}

nav a:hover {
    color: #fff;
}

.nav-link {
    display: inline-block;
    padding: 0.3rem 0;
    cursor: pointer;
    color: #e0f2fe;
    font-weight: 500;
}

.submenu {
    position: absolute;
    top: calc(100% + 0.15rem);
    left: 0;
    display: none;
    flex-direction: column;
    min-width: 180px;
    background: #ffffff;
    border: 1px solid #bae6fd;
    border-radius: 10px;
    box-shadow: 0 8px 18px rgba(3, 105, 161, 0.12);
    overflow: hidden;
    z-index: 50;
    pointer-events: auto;
}

.submenu a {
    color: #0369a1;
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid #e0f2fe;
    background: #ffffff;
}

.submenu a:hover {
    background: #e0f2fe;
    color: #024a70;
}

.submenu a:last-child {
    border-bottom: none;
}

.nav-item:hover .submenu,
.nav-item:focus-within .submenu {
    display: flex;
}

/* ── Main layout ── */
main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.home-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.home-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: #fff;
    border: 1px solid #bae6fd;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(3, 105, 161, 0.08);
    padding: 1rem;
}

.sidebar-section h2 {
    margin: 0 0 0.75rem;
    color: #0369a1;
    font-size: 1.1rem;
}

.sidebar-home-link {
    color: #0369a1;
    text-decoration: none;
    font-weight: 700;
}

.sidebar-home-link:hover {
    color: #024a70;
}

.sidebar-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.sidebar-menu li {
    border-left: 3px solid transparent;
    border-radius: 6px;
    transition: all .15s ease;
}

.sidebar-menu li a {
    display: block;
    color: #0369a1;
    text-decoration: none;
    padding: 0.55rem 0.75rem;
    border-radius: 6px;
    font-weight: 600;
}

.sidebar-menu li:hover {
    background: #e0f2fe;
    border-left-color: #0369a1;
}

.sidebar-menu li a:hover {
    color: #024a70;
}

.home-main {
    flex: 1;
}

/* ── Card ── */
.card {
    background: #ffffff;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 2px 12px rgba(3, 105, 161, 0.12);
    border: 1px solid #bae6fd;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.card h1,
.card h2 {
    font-size: 1.5rem;
    color: #0369a1;
}

.card h2 {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ── Form ── */
form {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    max-width: 360px;
}

label {
    font-size: .875rem;
    font-weight: 600;
}

input[type="text"],
input[type="password"] {
    padding: .6rem .75rem;
    border: 1px solid #7dd3fc;
    border-radius: 6px;
    font-size: 1rem;
    width: 100%;
}

input:focus {
    outline: 2px solid #0369a1;
    border-color: transparent;
}

/* ── Buttons ── */
button {
    padding: .55rem 1.25rem;
    background: #0369a1;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}

button:hover {
    background: #075985;
}

#logout-btn {
    background: #ef4444;
    align-self: flex-start;
}

#logout-btn:hover {
    background: #dc2626;
}

/* ── Table ── */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: .95rem;
}

.table-card {
    overflow-x: auto;
}

th {
    background: #e0f2fe;
    text-align: left;
    padding: .6rem .75rem;
    color: #0369a1;
}

td {
    padding: .6rem .75rem;
    border-top: 1px solid #bae6fd;
}

tr:hover td {
    background: #f0f9ff;
}

/* ── IP display ── */
.ip-card {
    align-items: center;
    text-align: center;
    padding: 3rem 2rem;
}

.ip-label {
    font-size: .9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #0284c7;
}

.ip-address {
    font-size: 3rem;
    font-weight: 700;
    color: #0369a1;
    font-family: 'Courier New', monospace;
    word-break: break-all;
}

.ip-location {
    font-size: 1.1rem;
    font-weight: 500;
    color: #0369a1;
}

.ip-note {
    font-size: .875rem;
    color: #7dd3fc;
}

.page-card {
    min-height: 300px;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.tool-card {
    max-width: 760px;
    margin: 0 auto;
    width: 100%;
}

.tool-form {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    margin-top: 1rem;
}

.tool-form input,
.tool-form select {
    width: 100%;
    padding: .75rem .85rem;
    border-radius: 8px;
    border: 1px solid #7dd3fc;
    font-size: 1rem;
    background: #fff;
}

.tool-message {
    margin-top: 1rem;
    padding: .8rem 1rem;
    border-radius: 8px;
    background: #fef2f2;
    color: #991b1b;
}

.tool-output {
    margin-top: 1rem;
    background: #f8fbff;
    border: 1px solid #bae6fd;
    border-radius: 10px;
    padding: 1rem;
    overflow-x: auto;
}

.tool-output pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'Courier New', monospace;
    font-size: .9rem;
    line-height: 1.5;
}

.auth-shell {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 2rem 1rem;
}

.auth-card {
    width: min(100%, 460px);
    background: #fff;
    border: 1px solid #bae6fd;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(3, 105, 161, 0.12);
    overflow: hidden;
}

.auth-tabs {
    display: flex;
    background: #e0f2fe;
    border-bottom: 1px solid #bae6fd;
}

.auth-tab {
    flex: 1;
    padding: 0.9rem 1rem;
    background: transparent;
    color: #0369a1;
    border: none;
    cursor: pointer;
    font-weight: 700;
}

.auth-tab.active {
    background: #0369a1;
    color: #fff;
}

.auth-form {
    display: none;
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem;
}

.auth-form.active {
    display: flex;
}

.auth-form h1 {
    font-size: 1.8rem;
    color: #0369a1;
    margin-bottom: .25rem;
}

.auth-form label {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    font-weight: 600;
    color: #0c2a4a;
}

.auth-form input {
    padding: .75rem .85rem;
    border-radius: 8px;
    border: 1px solid #7dd3fc;
    font-size: 1rem;
}

.auth-form button {
    margin-top: .35rem;
}

/* ── Utilities ── */
.hidden {
    display: none !important;
}

.error {
    color: #dc2626;
    font-size: .9rem;
}

@media (max-width: 600px) {
    nav {
        padding: .75rem 1rem;
        flex-wrap: wrap;
        gap: .75rem;
    }

    .nav-logo {
        min-width: 0;
    }

    .nav-logo img {
        width: 140px;
        height: auto;
    }

    .nav-links {
        display: flex;
        flex-basis: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        width: 100%;
    }

    .nav-links a,
    .nav-item {
        padding: .7rem 0;
        border-top: 1px solid rgba(255, 255, 255, 0.15);
    }

    .nav-item {
        position: relative;
        z-index: auto;
    }

    .submenu {
        position: static;
        display: none;
        min-width: 0;
        margin-top: .5rem;
        border-radius: 0;
        box-shadow: none;
        background: rgba(255, 255, 255, 0.06);
        border: 1px solid rgba(255, 255, 255, 0.15);
        z-index: auto;
    }

    .submenu a {
        color: #e0f2fe;
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }

    .nav-item:hover .submenu,
    .nav-item:focus-within .submenu {
        display: flex;
    }

    main {
        margin: 1rem auto;
        padding: 0 .75rem;
        gap: 1rem;
    }

    .home-layout {
        flex-direction: column;
    }

    .home-sidebar {
        width: 100%;
    }

    .card {
        padding: 1.25rem;
        gap: .75rem;
    }

    .card h1,
    .card h2 {
        font-size: 1.25rem;
    }

    .card h2 {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: .75rem;
    }

    .ip-card {
        padding: 2rem 1rem;
    }

    .ip-address {
        font-size: clamp(2rem, 12vw, 3rem);
    }

    table {
        min-width: 420px;
    }
}