/* PATCH: hard-hide drawer when closed (fix right-side panel showing) */
:root {
    --accent: #f97316;
    --accent2: #fb923c;
    --hk: #1f4fa3;
    --hk2: #2b6cb0;
    --cy: #06b6d4;
    --bg1: #f6f9ff;
    --bg2: #eef3ff;
    --text: rgba(15,23,42,.92);
    --muted: rgba(15,23,42,.62);
    --border: rgba(31,79,163,.14);
    --card: rgba(255,255,255,.86);
    --shadow: 0 18px 55px rgba(2,6,23,.10);
    --shadow2: 0 10px 25px rgba(2,6,23,.08);
    --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
}

* {
    box-sizing: border-box
}

html, body {
    overflow-x: hidden; /* PATCH: prevent horizontal bar from off-canvas */
    height: 100%
}

body {
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    background: linear-gradient(140deg,var(--bg1),var(--bg2))
}

.bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(1100px 650px at 8% 10%, rgba(31,79,163,.18), transparent 60%), radial-gradient(1000px 600px at 90% 18%, rgba(6,182,212,.14), transparent 60%);
}

.container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 8px 16px 70px
}

/* Topbar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: rgba(255,255,255,.80);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(31,79,163,.10);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
}

.logo {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    padding: 6px;
    background: rgba(255,255,255,.92);
    border: 1px solid var(--border);
    box-shadow: 0 10px 25px rgba(2,6,23,.10)
}

.brandText {
    display: flex;
    flex-direction: column;
    gap: 2px
}

.brandName {
    font-weight: 900;
    letter-spacing: .2px
}

.brandSub {
    font-size: 12px;
    color: var(--muted)
}

/* Inline nav */
.navInline {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 2px 6px;
    scrollbar-width: thin;
}

    .navInline::-webkit-scrollbar {
        height: 8px
    }

    .navInline::-webkit-scrollbar-thumb {
        background: rgba(31,79,163,.18);
        border-radius: 999px
    }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: 999px;
    border: 1px solid rgba(31,79,163,.18);
    background: rgba(255,255,255,.62);
    box-shadow: 0 10px 22px rgba(2,6,23,.06);
    text-decoration: none;
    color: var(--text);
    font-weight: 900;
    font-size: 13px;
    letter-spacing: .25px;
    white-space: nowrap;
}


    .pill.active {
        background: var(--accent);
        border-color: rgba(249,115,22,.55);
        color: #fff;
        box-shadow: 0 16px 34px rgba(249,115,22,.25);
    }

        .pill.active .ico, .pill.active .lbl {
            color: #fff;
        }

.ico {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(31,79,163,.95)
}

    .ico svg {
        width: 20px;
        height: 20px;
        max-width: 20px;
        max-height: 20px;
        fill: currentColor
    }

.lbl {
    display: inline-block
}

/* Right */
.right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.userchip {
    min-width: 180px;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid rgba(31,79,163,.16);
    background: rgba(255,255,255,.62);
    box-shadow: 0 10px 22px rgba(2,6,23,.06);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    line-height: 1.05;
}

.userName {
    font-weight: 900;
    font-size: 13px
}

.userRole {
    margin-top: 2px;
    font-size: 11px;
    color: var(--muted);
    opacity: .9;
    letter-spacing: .2px
}

.userFirm {
    margin-top: 4px;
    font-size: 11px;
    color: rgba(31,79,163,.88);
    font-weight: 700;
}

.firmSwitch {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 16px;
    border: 1px solid rgba(31,79,163,.14);
    background: rgba(255,255,255,.62);
    box-shadow: 0 10px 22px rgba(2,6,23,.05);
}

.firmLabel {
    font-size: 11px;
    color: var(--muted);
    font-weight: 800;
    letter-spacing: .2px;
    white-space: nowrap;
}

.firmSelect {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding: 8px 32px 8px 12px;
    border-radius: 14px;
    border: 1px solid rgba(31,79,163,.18);
    background: rgba(255,255,255,.86);
    font-weight: 800;
    font-size: 12px;
    color: rgba(15,23,42,.9);
    max-width: 220px;
}

    .firmSelect:focus {
        outline: none;
        box-shadow: 0 0 0 4px rgba(31,79,163,.14);
    }

/* Buttons */
.btnSmall {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 32px;
    padding: 0 12px;
    font-size: 14px;
    line-height: 1;
    font: inherit;
    border-radius: 999px;
    border: 1px solid rgba(31,79,163,.14);
    background: rgba(255,255,255,.72);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

button.btnSmall {
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
}

.btnSmall:hover {
    box-shadow: var(--shadow2);
    transform: translateY(-1px)
}

.btnSmall.primary {
    border-color: rgba(31,79,163,.35);
    background: linear-gradient(135deg, rgba(31,79,163,.26), rgba(6,182,212,.14))
}

.btnSmall.ghost {
    background: rgba(255,255,255,.45)
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 14px;
    border-radius: 16px;
    border: 1px solid rgba(31,79,163,.14);
    background: rgba(255,255,255,.72);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
}

    .btn:hover {
        box-shadow: var(--shadow2);
        transform: translateY(-1px)
    }

    .btn.primary {
        border-color: rgba(31,79,163,.35);
        background: linear-gradient(135deg, rgba(31,79,163,.26), rgba(6,182,212,.14))
    }

    .btn.ghost {
        background: rgba(255,255,255,.45)
    }

/* Cards */
.card {
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255,255,255,.88), rgba(255,255,255,.72));
    border-radius: 26px;
    box-shadow: var(--shadow);
    padding: 22px;
}

    .card h1 {
        margin: 0 0 8px;
        font-size: 28px
    }

    .card p {
        margin: 0 0 14px;
        color: var(--muted);
        line-height: 1.5
    }

.grid {
    display: grid;
    gap: 14px
}

.grid2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px
}

@media (max-width:680px) {
    .grid2 {
        grid-template-columns: 1fr
    }
}

label {
    font-size: 14px;
    color: var(--muted)
}

input {
    width: 100%;
    padding: 12px 12px;
    border-radius: 16px;
    border: 1px solid rgba(31,79,163,.16);
    background: rgba(255,255,255,.82);
    color: var(--text);
    outline: none;
}

    input:focus {
        border-color: rgba(31,79,163,.45);
        box-shadow: 0 0 0 4px rgba(31,79,163,.12)
    }

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px
}

.small {
    font-size: 12px;
    color: var(--muted)
}

.alert {
    border-radius: 16px;
    padding: 12px;
    border: 1px solid rgba(31,79,163,.14);
    margin-bottom: 12px;
    background: rgba(255,255,255,.70)
}

    .alert.bad {
        border-color: rgba(239,68,68,.35);
        background: rgba(239,68,68,.08)
    }

    .alert.ok {
        border-color: rgba(34,197,94,.35);
        background: rgba(34,197,94,.08)
    }

/* Burger + Drawer */
.burger {
    display: none;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 1px solid rgba(31,79,163,.18);
    background: rgba(255,255,255,.72);
    box-shadow: 0 10px 22px rgba(2,6,23,.06);
    cursor: pointer;
}

.shade {
    position: fixed;
    inset: 0;
    background: rgba(2,6,23,.45);
    opacity: 0;
    visibility: hidden; /* PATCH: hard-hide shade when closed */
    pointer-events: none;
    transition: opacity .18s ease;
    z-index: 80;
    display: none;
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: min(92vw, 420px);
    min-width: 320px;
    background: rgba(255,255,255,.96);
    backdrop-filter: blur(14px);
    border-left: 1px solid rgba(31,79,163,.14);
    transform: translateX(110%);
    visibility: hidden; /* PATCH: hard-hide drawer when closed */
    pointer-events: none;
    transition: transform .22s ease;
    z-index: 90;
    box-shadow: -20px 0 60px rgba(2,6,23,.18);
    display: flex;
    flex-direction: column;
}

.drawerHead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px;
    border-bottom: 1px solid rgba(31,79,163,.10)
}

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

.drawerLogo {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: 1px solid rgba(31,79,163,.14);
    background: rgba(255,255,255,.9);
    padding: 6px
}

.drawerTitle {
    font-weight: 900
}

.drawerSub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px
}

.close {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 1px solid rgba(31,79,163,.14);
    background: rgba(255,255,255,.76);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center
}

.drawerBody {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.drawerFirmSwitch {
    display: grid;
    gap: 6px;
    padding: 12px;
    border-radius: 16px;
    border: 1px solid rgba(31,79,163,.12);
    background: rgba(255,255,255,.78);
}

.drawerFirmLabel {
    font-size: 12px;
    color: var(--muted);
    font-weight: 900;
}

.drawerFirmSelect {
    width: 100%;
    padding: 12px 12px;
    border-radius: 16px;
    border: 1px solid rgba(31,79,163,.16);
    background: rgba(255,255,255,.92);
}

.drawerLink {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px;
    border-radius: 16px;
    border: 1px solid rgba(31,79,163,.12);
    background: rgba(255,255,255,.78);
    text-decoration: none;
    color: var(--text);
    font-weight: 900;
    width: 100%;
}

.drawerFoot {
    padding: 14px;
    border-top: 1px solid rgba(31,79,163,.10);
    display: grid;
    gap: 12px
}

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

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(31,79,163,.28), rgba(6,182,212,.14));
    border: 1px solid rgba(31,79,163,.18);
    font-weight: 900;
}

/* open state */
html.navOpen .shade {
    opacity: 1;
    visibility: visible;
    pointer-events: auto display: block;
}

html.navOpen .drawer {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto
}

/* responsive */
@media (max-width:900px) {
    .navInline {
        display: none
    }

    .burger {
        display: inline-flex;
        align-items: center;
        justify-content: center
    }

    .right .userchip {
        display: none
    }
}

@media (max-width:380px) {
    .drawer {
        min-width: 0;
        width: 96vw
    }
}


.select {
    width: 100%;
    padding: 12px;
    border-radius: 16px;
    border: 1px solid rgba(31,79,163,.16);
    background: rgba(255,255,255,.82);
}


.btn.danger {
    background: linear-gradient(180deg,#ff5f6d,#ff3b30);
    color: #fff;
    border: 1px solid rgba(255,59,48,.35);
    box-shadow: 0 10px 24px rgba(255,59,48,.18)
}

    .btn.danger:hover {
        filter: brightness(.98)
    }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 900;
    font-size: 12px;
    border: 1px solid rgba(31,79,163,.18);
    background: rgba(255,255,255,.75)
}

    .badge.ok {
        background: rgba(46,204,113,.12);
        border-color: rgba(46,204,113,.28)
    }

    .badge.warn {
        background: rgba(255,159,67,.14);
        border-color: rgba(255,159,67,.30)
    }

.btn.danger {
    background: linear-gradient(135deg,#ff4757,#ff6b81);
    color: #fff;
    border: none
}

    .btn.danger:hover {
        filter: brightness(.98)
    }

.alert.warn {
    background: rgba(255,159,67,.14);
    border: 1px solid rgba(255,159,67,.30);
    color: #7a4b00
}


/* Company tabs */
.tabs {
    display: flex;
    gap: 8px;
    margin: 10px 0 14px;
    flex-wrap: wrap;
}

.tab {
    padding: 10px 12px;
    border: 1px solid rgba(0,0,0,.12);
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    background: rgba(255,255,255,.6);
}

    .tab.active {
        background: rgba(255,159,67,.14);
        border-color: rgba(0,0,0,.25);
        font-weight: 700;
    }

/* Cards & grids helpers */
.grid-1 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.grid-6 {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
}

@media (max-width: 1100px) {
    .grid-6 {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

    .grid-3 {
        grid-template-columns: 1fr;
    }
}

.subcard {
    border: 1px solid rgba(0,0,0,.10);
    border-radius: 14px;
    padding: 12px;
    margin: 10px 0;
    background: #fff;
}

.subhead {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.inline {
    display: flex;
    gap: 8px;
    align-items: center;
}

.pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-top: 1px solid rgba(0,0,0,.08);
    flex-wrap: wrap;
}

.pager-links {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.pill {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    border: 1px solid rgba(0,0,0,.12);
}

    .pill.ok {
        background: rgba(0,128,0,.08);
    }

    .pill.warn {
        background: rgba(255,165,0,.10);
    }

.table-wrap {
    overflow: auto;
}

.rowlink {
    cursor: pointer;
}

    .rowlink:hover {
        background: rgba(0,0,0,.03);
    }

.textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,.15);
}

.alert {
    padding: 12px;
    border-radius: 12px;
    margin: 10px 0;
}

    .alert.error {
        background: rgba(255,0,0,.07);
        border: 1px solid rgba(255,0,0,.18);
    }

.card.soft {
    border: 1px dashed rgba(0,0,0,.18);
}

.ded-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

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


/* --- PATCH: tabs row layout + active checkbox alignment --- */
.tabs-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: nowrap;
}

    .tabs-row .tabs {
        flex: 1 1 auto;
        min-width: 0;
    }

    .tabs-row .backlink {
        flex: 0 0 auto;
        margin-left: auto;
        white-space: nowrap;
    }

.chk {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    line-height: 1;
    user-select: none;
}

    .chk input[type="checkbox"] {
        margin: 0;
        width: 16px;
        height: 16px;
    }

    .chk span {
        margin: 0;
        white-space: nowrap;
    }

@media (max-width: 820px) {
    .tabs-row {
        flex-wrap: wrap;
    }

        .tabs-row .backlink {
            margin-left: 0;
        }
}

.flash-stack {
    display: grid;
    gap: 10px;
    margin: 12px 0
}

.flash {
    border-radius: 14px;
    padding: 10px 12px;
    border: 1px solid rgba(0,0,0,.08);
    background: rgba(255,255,255,.65);
    box-shadow: 0 10px 25px rgba(0,0,0,.06)
}

.flash-success {
    border-color: rgba(16,185,129,.35)
}

.flash-error {
    border-color: rgba(239,68,68,.35)
}

.flash-warning {
    border-color: rgba(245,158,11,.35)
}

.flash-info {
    border-color: rgba(59,130,246,.35)
}

.flash-msg {
    font-weight: 600;
    color: #0f172a
}

/* --- END PATCH --- */


/* Company Documents: file + upload button on one line */
.hk-upload-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

    .hk-upload-inline input[type="file"] {
        flex: 1 1 auto;
        min-width: 0;
    }

.hk-upload-btn {
    white-space: nowrap;
}

.aLink {
    color: inherit;
    text-decoration: none;
    font-weight: 600;
}

    .aLink:hover {
        text-decoration: underline;
    }
