:root {
    --navy: #102746;
    --navy-light: #173b68;
    --blue: #2864a6;
    --text: #172b45;
    --muted: #718096;
    --border: #e4eaf1;
    --background: #f3f6fa;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    color: var(--text);
}

.login-body {
    min-height: 100vh;
    background: #edf2f7;
    display: grid;
    place-items: center;
    padding: 30px;
}

.login-shell {
    width: min(100%, 1020px);
    min-height: 620px;
    display: grid;
    grid-template-columns: 43% 57%;
    background: white;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 24px 70px rgba(16,39,70,.13);
}

.login-brand {
    background: linear-gradient(150deg, #102746, #1c4778);
    color: white;
    padding: 44px;
    display: flex;
    flex-direction: column;
}

.brand-logo {
    width: 48px;
    height: 48px;
    border-radius: 13px;
    background: #ffffff;
    color: var(--navy);
    display: grid;
    place-items: center;
    font-size: 26px;
    font-weight: 800;
}

.brand-name {
    margin-top: 17px;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 1.5px;
}

.brand-name span { color: #a9c9ef; }
.brand-subtitle, .eyebrow {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 2px;
}

.brand-subtitle { color: #b6c9df; margin-top: 5px; }
.brand-message { margin-top: auto; margin-bottom: auto; }
.brand-line { width: 42px; height: 3px; background: #78a9e2; border-radius: 5px; }
.brand-message h1 { font-size: 31px; line-height: 1.3; margin: 22px 0 12px; }
.brand-message p { color: #d0dceb; line-height: 1.7; font-size: 14px; max-width: 280px; }
.brand-footer { color: #a9bfd9; font-size: 12px; }

.login-panel {
    padding: 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-card { width: 100%; max-width: 360px; margin: auto; }
.mobile-brand { display: none; color: var(--navy); font-weight: 800; margin-bottom: 32px; }
.login-card .eyebrow { color: #6683a6; }
.login-card h2 { font-size: 30px; margin: 12px 0 8px; color: var(--navy); }
.login-description { color: var(--muted); font-size: 14px; margin: 0 0 30px; }

.login-card label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin: 18px 0 8px;
}

.login-card input {
    width: 100%;
    height: 48px;
    border: 1px solid #dce4ee;
    border-radius: 8px;
    padding: 0 13px;
    font-size: 15px;
    outline: none;
}

.login-card input:focus {
    border-color: #477eb9;
    box-shadow: 0 0 0 3px rgba(71,126,185,.12);
}

.login-button {
    width: 100%;
    height: 49px;
    border: 0;
    border-radius: 8px;
    margin-top: 26px;
    background: var(--navy-light);
    color: white;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.login-button:hover { background: #0d2b50; }
.login-button span { margin-left: 8px; font-size: 18px; }
.login-security { text-align: center; margin-top: 26px; color: #8290a1; font-size: 11px; }
.security-dot { display: inline-block; width: 7px; height: 7px; background: #28a477; border-radius: 50%; margin-right: 5px; }
.copyright { text-align: center; color: #99a4b2; font-size: 11px; }
.error, .notice { padding: 11px 13px; border-radius: 7px; font-size: 13px; margin-bottom: 15px; }
.error { background: #fff0f0; color: #a32d36; }
.notice { background: #edf5ff; color: #24558b; }

.dashboard-body { min-height: 100vh; background: var(--background); }
.sidebar {
    width: 250px;
    height: 100vh;
    height: 100dvh;
    box-sizing: border-box;
    background: var(--navy);
    color: white;
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    padding: 25px 16px;
    overflow: hidden;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #587493 var(--navy);
}

.sidebar::-webkit-scrollbar {
    width: 7px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--navy);
}

.sidebar::-webkit-scrollbar-thumb {
    background: #587493;
    border-radius: 8px;
}

.sidebar-brand,
.sidebar-bottom {
    flex-shrink: 0;
}

.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 32px; }

.sidebar-nav-scroll {
    flex: 1 1 0;
    height: 0;
    min-height: 0;
    width: 100%;
    overflow-y: scroll;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #587493 var(--navy);
}
.sidebar-nav-scroll::-webkit-scrollbar { width: 7px; }
.sidebar-nav-scroll::-webkit-scrollbar-thumb { background: #587493; border-radius: 8px; }
.sidebar-nav-scroll::-webkit-scrollbar-track { background: var(--navy); }

.brand-logo.small { width: 39px; height: 39px; font-size: 21px; border-radius: 10px; }
.sidebar-brand strong { display: block; font-size: 16px; letter-spacing: 1px; }
.sidebar-brand span { display: block; font-size: 9px; letter-spacing: 2px; color: #b7cce5; margin-top: 3px; }
.nav-caption { color: #91a8c3; font-size: 9px; font-weight: 800; letter-spacing: 1.5px; padding: 12px 12px 8px; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #d4dfec;
    padding: 11px 12px;
    border-radius: 7px;
    font-size: 13px;
    margin: 2px 0;
}
.nav-link span { width: 18px; text-align: center; font-size: 16px; }
.nav-link:hover, .nav-link.active { background: #24466f; color: white; }
.sidebar-bottom { margin-top: auto; border-top: 1px solid #2b4565; padding-top: 17px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 5px 7px 14px; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #d6e6f8; color: var(--navy); font-weight: 800; }
.user-info strong, .user-info span { display: block; }
.user-info strong { font-size: 12px; }
.user-info span { color: #aebfd2; font-size: 10px; margin-top: 3px; }
.logout-button { width: 100%; border: 0; background: transparent; color: #d4dfec; text-align: left; padding: 10px; cursor: pointer; font-size: 12px; }
.logout-button:hover { color: white; }

.dashboard-main { margin-left: 250px; padding: 34px 38px; max-width: 1600px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 27px; }
.topbar h1 { font-size: 25px; margin: 6px 0 0; color: var(--navy); }
.topbar .eyebrow { color: #7890aa; }
.topbar-user { color: #65758a; font-size: 12px; }
.welcome-banner {
    min-height: 155px;
    background: linear-gradient(110deg, #173b68, #28629b);
    color: white;
    border-radius: 13px;
    padding: 27px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
}
.banner-label { color: #b9d3ee; font-size: 9px; font-weight: 800; letter-spacing: 1.7px; }
.welcome-banner h2 { font-size: 23px; margin: 11px 0 7px; }
.welcome-banner p { color: #d2e1f0; font-size: 13px; margin: 0; }
.banner-mark { font-size: 110px; font-weight: 900; color: rgba(255,255,255,.10); padding-right: 30px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; margin-top: 23px; }
.stat-card, .content-card { background: white; border: 1px solid var(--border); border-radius: 11px; }
.stat-card { padding: 20px; }
.stat-label { color: #7c8da1; font-size: 9px; font-weight: 800; letter-spacing: 1px; }
.stat-value { color: var(--navy); font-size: 27px; font-weight: 800; margin: 12px 0 5px; }
.stat-note { color: #99a5b3; font-size: 11px; }
.content-card { margin-top: 22px; padding: 23px; }
.content-card-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 17px; }
.content-card h3 { margin: 0 0 6px; color: var(--navy); font-size: 16px; }
.content-card p { margin: 0; color: #8492a3; font-size: 12px; }
.status-pill { color: #167a59; background: #e8f7f0; padding: 6px 10px; border-radius: 20px; font-size: 9px; font-weight: 800; }
.setup-row { border-top: 1px solid #edf0f4; padding: 13px 2px; font-size: 12px; color: #52647a; }
.check-mark { color: #15966a; font-weight: 900; margin-right: 9px; }
.pending-mark { color: #d49a32; font-weight: 900; margin-right: 12px; }
.dashboard-footer { color: #98a5b4; font-size: 10px; padding: 25px 0; }

@media (max-width: 900px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 650px) {
    .login-body { padding: 12px; }
    .login-shell { display: block; min-height: auto; }
    .login-brand { display: none; }
    .login-panel { min-height: 590px; padding: 35px 25px; }
    .mobile-brand { display: block; }
    .sidebar { width: 205px; }
    .dashboard-main { margin-left: 205px; padding: 22px 15px; }
    .topbar-user { display: none; }
    .welcome-banner { padding: 20px; }
    .welcome-banner h2 { font-size: 19px; }
    .banner-mark { display: none; }
    .stats-grid { grid-template-columns: 1fr; }
}


/* ===== KNDS MOBILE RESPONSIVE LAYOUT ===== */
@media (max-width: 650px) {
    html, body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .sidebar {
        position: relative;
        inset: auto;
        width: 100%;
        height: auto;
        max-height: none;
        padding: 12px;
        overflow: visible;
        z-index: 10;
    }

    .sidebar-brand {
        padding: 0 6px 12px;
    }

    .sidebar-nav-scroll {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 6px;
        width: 100%;
        height: auto;
        min-height: 0;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 4px 0 9px;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar-nav-scroll .nav-caption {
        display: none;
    }

    .sidebar-nav-scroll .nav-link {
        flex: 0 0 auto;
        white-space: nowrap;
        margin: 0;
        padding: 10px 12px;
        font-size: 12px;
    }

    .sidebar-bottom {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        margin-top: 5px;
        padding-top: 10px;
    }

    .sidebar-user {
        min-width: 0;
        padding: 0;
    }

    .user-info {
        min-width: 0;
    }

    .user-info strong {
        overflow-wrap: anywhere;
    }

    .sidebar-bottom form {
        flex: 0 0 auto;
    }

    .logout-button {
        width: auto;
        padding: 9px;
    }

    .dashboard-main {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        margin-left: 0;
        padding: 18px 12px;
    }

    .topbar {
        gap: 10px;
        flex-wrap: wrap;
    }

    .topbar h1 {
        font-size: 21px;
    }

    .welcome-banner {
        min-height: auto;
        padding: 20px 16px;
    }

    .welcome-banner h2 {
        font-size: 19px;
        line-height: 1.35;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .stat-card {
        min-width: 0;
        padding: 14px;
    }

    .stat-value {
        font-size: 22px;
        overflow-wrap: anywhere;
    }

    .content-card,
    .panel {
        min-width: 0;
        padding: 15px;
    }

    .page-header {
        gap: 12px;
    }

    .page-header h1 {
        font-size: 21px;
    }

    .form-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .form-actions {
        flex-wrap: wrap;
    }

    .form-actions .btn,
    .page-header .btn {
        min-height: 42px;
    }

    .search-bar {
        flex-wrap: wrap;
    }

    .search-bar .search-input {
        max-width: 100%;
        min-width: 0;
    }

    .table-wrap {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 700px;
    }

    input, select, textarea, button {
        max-width: 100%;
    }
}

@media (max-width: 380px) {
    .stats-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .dashboard-main {
        padding-left: 10px;
        padding-right: 10px;
    }
}


/* ===== MOBILE HAMBURGER NAVIGATION ===== */
.sidebar-menu-toggle {
    display: none;
}

@media (max-width: 650px) {
    .sidebar-menu-toggle {
        display: flex;
        width: 100%;
        min-height: 44px;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        gap: 5px;
        margin: 2px 0 5px;
        padding: 9px;
        border: 1px solid rgba(255,255,255,.2);
        border-radius: 7px;
        background: #173b68;
        cursor: pointer;
    }

    .sidebar-menu-toggle span {
        display: block;
        width: 24px;
        height: 2px;
        border-radius: 2px;
        background: #fff;
    }

    .sidebar-nav-scroll {
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        width: 100%;
        height: auto;
        max-height: 65vh;
        overflow-x: hidden;
        overflow-y: auto;
        padding: 5px 0;
        border-top: 1px solid rgba(255,255,255,.15);
        -webkit-overflow-scrolling: touch;
    }

    .sidebar-nav-scroll.is-open {
        display: flex;
    }

    .sidebar-nav-scroll .nav-caption {
        display: block;
        padding: 12px 10px 5px;
    }

    .sidebar-nav-scroll .nav-link {
        flex: 0 0 auto;
        width: 100%;
        white-space: normal;
        padding: 11px 12px;
        margin: 1px 0;
    }
}


/* ===== CSS ONLY HAMBURGER FIX ===== */
.sidebar-menu-checkbox {
    display: none !important;
}

@media (max-width: 650px) {
    .sidebar-menu-toggle {
        display: flex;
    }

    .sidebar-nav-scroll {
        display: none;
    }

    .sidebar-menu-checkbox:checked ~ .sidebar-nav-scroll {
        display: flex;
    }
}

/* ===== HAMBURGER POSITION AND VISIBILITY FIX ===== */
@media (max-width: 650px) {
    .sidebar-menu-toggle {
        width: 48px !important;
        min-width: 48px !important;
        height: 44px !important;
        min-height: 44px !important;
        margin: 2px 0 8px !important;
        align-self: flex-start !important;
        justify-content: center !important;
    }

    .sidebar-menu-checkbox {
        position: absolute !important;
        opacity: 0 !important;
        width: 1px !important;
        height: 1px !important;
        pointer-events: none !important;
    }

    .sidebar-menu-checkbox:checked ~ .sidebar-nav-scroll {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .sidebar-menu-checkbox:not(:checked) ~ .sidebar-nav-scroll {
        display: none !important;
    }
}

/* ===== NATIVE DETAILS MOBILE NAVIGATION ===== */
.sidebar-mobile-details {
    width: 100%;
}

.sidebar-mobile-details > summary {
    list-style: none;
}

.sidebar-mobile-details > summary::-webkit-details-marker {
    display: none;
}

@media (max-width: 650px) {
    .sidebar-mobile-details {
        display: block;
    }

    .sidebar-mobile-details > .sidebar-menu-toggle {
        display: flex !important;
        width: 48px !important;
        height: 44px !important;
        min-height: 44px !important;
        margin: 2px 0 8px !important;
        padding: 9px !important;
        align-items: center !important;
        justify-content: center !important;
        flex-direction: column !important;
        gap: 5px !important;
        cursor: pointer;
    }

    .sidebar-mobile-details > .sidebar-nav-scroll {
        display: none !important;
        width: 100%;
        height: auto;
        max-height: 65vh;
        overflow-y: auto;
        flex-direction: column;
        align-items: stretch;
    }

    .sidebar-mobile-details[open] > .sidebar-nav-scroll {
        display: flex !important;
    }
}

@media (min-width: 651px) {
    .sidebar-mobile-details {
        display: contents;
    }

    .sidebar-mobile-details > .sidebar-menu-toggle {
        display: none !important;
    }

    .sidebar-mobile-details > .sidebar-nav-scroll {
        display: block !important;
    }
}

/* ===== NATIVE DETAILS MOBILE NAVIGATION ===== */
.sidebar-mobile-details {
    width: 100%;
}

.sidebar-mobile-details > summary {
    list-style: none;
}

.sidebar-mobile-details > summary::-webkit-details-marker {
    display: none;
}

@media (max-width: 650px) {
    .sidebar-mobile-details {
        display: block;
        width: 100%;
    }

    .sidebar-mobile-details > .sidebar-menu-toggle {
        display: flex !important;
        width: 48px !important;
        min-width: 48px !important;
        height: 44px !important;
        min-height: 44px !important;
        margin: 2px 0 8px !important;
        padding: 9px !important;
        align-items: center !important;
        justify-content: center !important;
        flex-direction: column !important;
        gap: 5px !important;
        cursor: pointer;
    }

    .sidebar-mobile-details > .sidebar-nav-scroll {
        display: none !important;
        width: 100%;
        height: auto;
        max-height: 65vh;
        overflow-y: auto;
        flex-direction: column;
        align-items: stretch;
    }

    .sidebar-mobile-details[open] > .sidebar-nav-scroll {
        display: flex !important;
    }
}

@media (min-width: 651px) {
    .sidebar-mobile-details {
        display: contents;
    }

    .sidebar-mobile-details > .sidebar-menu-toggle {
        display: none !important;
    }

    .sidebar-mobile-details > .sidebar-nav-scroll {
        display: block !important;
    }
}

/* ===== FINAL HAMBURGER LEFT ALIGNMENT ===== */
@media (max-width: 650px) {
    .sidebar-mobile-details > .sidebar-menu-toggle {
        align-self: flex-start !important;
        margin-left: 0 !important;
        margin-right: auto !important;
    }
}

/* ===== FINAL DESKTOP AND MOBILE SIDEBAR LAYOUT ===== */

/* Desktop: restore original vertical sidebar layout */
@media (min-width: 651px) {
    .sidebar-mobile-details {
        display: flex !important;
        flex: 1 1 0 !important;
        flex-direction: column !important;
        width: 100% !important;
        height: 0 !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    .sidebar-mobile-details > .sidebar-menu-toggle {
        display: none !important;
    }

    .sidebar-mobile-details > .sidebar-nav-scroll {
        display: block !important;
        flex: 1 1 0 !important;
        width: 100% !important;
        height: 0 !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }
}

/* Mobile: logo, hamburger, then collapsible navigation */
@media (max-width: 650px) {
    .sidebar-mobile-details {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    .sidebar-mobile-details > .sidebar-menu-toggle {
        display: flex !important;
        width: 48px !important;
        min-width: 48px !important;
        height: 44px !important;
        min-height: 44px !important;
        margin: 2px 0 8px !important;
        align-self: flex-start !important;
    }

    .sidebar-mobile-details > .sidebar-nav-scroll {
        display: none !important;
        flex: none !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: 65vh !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        flex-direction: column !important;
    }

    .sidebar-mobile-details[open] > .sidebar-nav-scroll {
        display: flex !important;
    }
}

/* ===== DESKTOP SIDEBAR DEFINITIVE FIX ===== */
@media (min-width: 651px) {
    .sidebar-mobile-details {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 0 !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    .sidebar-mobile-details > .sidebar-nav-scroll {
        display: block !important;
        flex: 1 1 0 !important;
        height: 0 !important;
        min-height: 0 !important;
        width: 100% !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    .sidebar-mobile-details > summary {
        display: none !important;
    }
}

/* ===== PLAIN BUTTON NAVIGATION: FINAL LAYOUT ===== */
.sidebar-menu-toggle {
    display: none !important;
}

@media (min-width: 651px) {
    .sidebar-nav-scroll {
        display: block !important;
        flex: 1 1 0 !important;
        height: 0 !important;
        min-height: 0 !important;
        width: 100% !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }
}

@media (max-width: 650px) {
    .sidebar-menu-toggle {
        display: flex !important;
        width: 48px !important;
        min-width: 48px !important;
        height: 44px !important;
        min-height: 44px !important;
        margin: 2px 0 8px !important;
        padding: 9px !important;
        align-self: flex-start !important;
        align-items: center !important;
        justify-content: center !important;
        flex-direction: column !important;
        gap: 5px !important;
        border: 1px solid rgba(255,255,255,.2) !important;
        border-radius: 7px !important;
        background: #173b68 !important;
        cursor: pointer;
    }

    .sidebar-menu-toggle span {
        display: block !important;
        width: 24px !important;
        height: 2px !important;
        background: #fff !important;
    }

    .sidebar-nav-scroll {
        display: none !important;
        flex: none !important;
        width: 100% !important;
        height: auto !important;
        max-height: 65vh !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .sidebar-nav-scroll.is-open {
        display: flex !important;
    }

    .sidebar-nav-scroll .nav-caption {
        display: block !important;
    }

    .sidebar-nav-scroll .nav-link {
        display: flex !important;
        width: 100% !important;
        white-space: normal !important;
    }
}

/* ===== MOBILE LOGO AND HAMBURGER SAME ROW ===== */
@media (max-width: 650px) {
    .sidebar {
        position: relative !important;
    }

    .sidebar-brand {
        position: relative !important;
        padding-right: 60px !important;
    }

    .sidebar-menu-toggle {
        position: absolute !important;
        top: 20px !important;
        right: 16px !important;
        left: auto !important;
        margin: 0 !important;
        z-index: 100 !important;
    }
}
