:root {
    --sidebar-width: 278px;
    --shell-surface: #ffffff;
    --shell-border: #e2e5ee;
    --shell-shadow: 0 8px 26px rgba(28, 29, 69, .06);
}

body.app-authenticated {
    min-width: 320px;
    background: #f4f5f9;
}

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
}

.app-sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 22px 14px 16px;
    overflow-y: auto;
    color: #e9e8ff;
    background:
        radial-gradient(circle at 8% 0%, rgba(247, 148, 0, .17), transparent 25%),
        linear-gradient(180deg, #0c0876 0%, #100a92 55%, #09065e 100%);
    box-shadow: 5px 0 22px rgba(12, 8, 103, .12);
    z-index: 30;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    min-height: 58px;
    padding: 3px 10px 19px;
    border-bottom: 1px solid rgba(255, 255, 255, .14);
}

.sidebar-brand img {
    width: 152px;
    height: auto;
    max-height: 50px;
    object-fit: contain;
    filter: brightness(0) invert(1) grayscale(1) contrast(3);
}

.sidebar-workspace {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 17px 8px 15px;
}

.sidebar-avatar,
.topbar-avatar {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 11px;
    font-weight: 800;
}

.sidebar-avatar {
    width: 40px;
    height: 40px;
    color: #100a92;
    background: linear-gradient(135deg, #ffd271 0%, #f79400 100%);
    box-shadow: 0 5px 14px rgba(0, 0, 0, .18);
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 1rem;
    line-height: 1;
}

.sidebar-workspace strong,
.sidebar-workspace span {
    display: block;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-workspace strong { color: #fff; font-size: .83rem; }
.sidebar-workspace span { margin-top: 1px; color: #c5c3ee; font-size: .71rem; }

.sidebar-close,
.sidebar-toggle { display: none; }

.sidebar-nav { display: grid; gap: 3px; }
.sidebar-nav-section { margin: 14px 9px 6px; color: #bab7e9; font-size: .65rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }

.sidebar-link {
    display: flex;
    gap: 11px;
    align-items: center;
    min-height: 43px;
    padding: 10px 11px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: #e9e8ff;
    font-size: .86rem;
    font-weight: 650;
    line-height: 1.2;
    text-decoration: none;
    transition: background .16s ease, color .16s ease, transform .16s ease;
}

.sidebar-link:hover { color: #fff; background: rgba(255, 255, 255, .11); transform: translateX(2px); }
.sidebar-link.is-active { border-color: rgba(255, 255, 255, .14); color: #100a92; background: #fff; box-shadow: 0 6px 16px rgba(0, 0, 0, .13); }
.sidebar-link .app-nav-icon { width: 19px; height: 19px; flex: 0 0 auto; }

.sidebar-footer {
    display: grid;
    gap: 10px;
    margin-top: auto;
    padding: 17px 8px 0;
    border-top: 1px solid rgba(255, 255, 255, .14);
}

.sidebar-security { color: #c7c5ed; font-size: .71rem; line-height: 1.45; }
.sidebar-security strong { display: block; margin-bottom: 2px; color: #fff; font-size: .73rem; }
.sidebar-logout { width: 100%; justify-content: flex-start; gap: 9px; color: #100a92; background: #fff; }
.sidebar-logout .app-nav-icon { width: 17px; height: 17px; }

.app-workspace { min-width: 0; }

.workspace-topbar {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 72px;
    padding: 12px clamp(20px, 3vw, 48px);
    border-bottom: 1px solid var(--shell-border);
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 2px 12px rgba(29, 32, 70, .035);
    backdrop-filter: blur(16px);
    z-index: 20;
}

.workspace-title { display: flex; align-items: center; gap: 12px; color: #4f5a70; font-size: .81rem; }
.workspace-title strong { display: block; color: #1f2b44; font-size: .93rem; }
.workspace-title span { display: block; margin-top: 1px; color: #778195; font-size: .73rem; }

.topbar-user { display: flex; align-items: center; gap: 9px; }
.topbar-user-copy { text-align: right; }
.topbar-user-copy strong,.topbar-user-copy span { display: block; }
.topbar-user-copy strong { color: #29354c; font-size: .8rem; }
.topbar-user-copy span { color: #737e91; font-size: .69rem; }
.topbar-avatar {
    width: 38px;
    height: 38px;
    color: #fff;
    background: linear-gradient(135deg, #2b22af 0%, #100a92 100%);
    box-shadow: 0 4px 10px rgba(16, 10, 146, .16);
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: .9rem;
    line-height: 1;
}

body.app-authenticated .container {
    width: 100%;
    max-width: 1680px;
    margin: 0 auto;
    padding: clamp(24px, 3vw, 42px) clamp(20px, 3vw, 48px) 48px;
}

body.app-authenticated .admin-hero,
body.app-authenticated .document-hero { border-radius: 20px; }
body.app-authenticated .admin-quick-actions { margin-bottom: 18px; }

.admin-workspace-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin: -1px 0 23px;
}

.admin-workspace-actions .button { min-height: 42px; }

.signature-filter-card { background: linear-gradient(145deg, #fff, #fbfbff); }
.signature-filter-form { display: grid; grid-template-columns: minmax(250px, 1.2fr) minmax(220px, 1fr) minmax(180px, .7fr) auto; gap: 14px; align-items: end; }
.signature-filter-actions { display: flex; gap: 8px; align-items: end; }
.signature-filter-actions .button { min-height: 42px; white-space: nowrap; }
.signature-stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin: 0 0 22px; }
.signature-stat-card { min-height: 130px; padding: 20px; border: 1px solid #e0e2ec; border-radius: 14px; background: #fff; box-shadow: 0 2px 8px rgba(19, 29, 59, .045); }
.signature-stat-card > span { display: block; color: #687489; font-size: .69rem; font-weight: 800; letter-spacing: .065em; text-transform: uppercase; }
.signature-stat-card strong { display: block; margin: 8px 0 3px; color: #202c45; font-size: 2rem; line-height: 1; }
.signature-stat-card small { display: block; color: #6d7789; font-size: .76rem; line-height: 1.35; }
.signature-stat-card.signed { border-color: #bfe5c5; background: linear-gradient(145deg, #fff, #f1fbf3); }
.signature-stat-card.signed strong,.signature-positive { color: #08751a; }
.signature-stat-card.attention { border-color: #f0d6a2; background: linear-gradient(145deg, #fff, #fffaf0); }
.signature-stat-card.attention strong { color: #a05d00; }
.signature-table td { vertical-align: middle; }
.signature-progress { display: inline-block; width: 92px; height: 8px; margin-right: 8px; overflow: hidden; border-radius: 99px; vertical-align: middle; background: #e9ebf1; }
.signature-progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #08bc12, #4bd555); }

.finance-hero { margin-bottom: 20px; background: linear-gradient(120deg, #16067e, #3800a8 58%, #6a219c); }
.finance-filter-card { margin-bottom: 18px; background: linear-gradient(145deg, #fff, #fafaff); }
.finance-filter-form { display: grid; grid-template-columns: minmax(160px, .5fr) minmax(160px, .5fr) minmax(230px, .8fr) 1.4fr; gap: 14px; align-items: end; }
.finance-filter-actions { display: flex; flex-wrap: wrap; gap: 8px; }.finance-filter-actions .button { min-height: 42px; }
.finance-filter-card .meta { margin: 13px 0 0; }
.finance-notice { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 19px; padding: 14px 16px; border: 1px solid #c7d6f2; border-radius: 12px; color: #314365; background: #f5f8ff; font-size: .85rem; line-height: 1.45; }
.finance-notice strong { color: #142d62; }.finance-notice.attention { border-color: #f0d6a2; color: #785412; background: #fffaf0; }.finance-notice.danger { border-color: #efc2c0; color: #8d2b26; background: #fff5f4; }
.finance-kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin: 0 0 22px; }.finance-kpi { min-height: 130px; padding: 20px; border: 1px solid #e0e2ec; border-radius: 14px; background: #fff; box-shadow: 0 2px 8px rgba(19, 29, 59, .045); }.finance-kpi > span,.finance-kpi small { display: block; }.finance-kpi > span { color: #687489; font-size: .69rem; font-weight: 800; letter-spacing: .065em; text-transform: uppercase; }.finance-kpi strong { display: block; margin: 8px 0 4px; color: #202c45; font-size: clamp(1.45rem, 2.1vw, 2rem); line-height: 1; }.finance-kpi small { color: #6d7789; font-size: .76rem; line-height: 1.35; }.finance-kpi.positive { border-color: #bfe5c5; background: linear-gradient(145deg, #fff, #f1fbf3); }.finance-kpi.positive strong,.finance-positive { color: #08751a; }.finance-kpi.attention { border-color: #f0d6a2; background: linear-gradient(145deg, #fff, #fffaf0); }.finance-kpi.attention strong,.finance-attention { color: #9a5b00; }
.finance-section-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }.finance-panel { margin-bottom: 18px; }.finance-section-grid .finance-panel { margin-bottom: 0; }.section-heading { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 16px; }.section-heading h2 { margin: 0; color: #202c45; font-size: 1.2rem; }.section-heading .eyebrow { margin-bottom: 7px; }.section-heading .meta { max-width:820px; margin:8px 0 0; }
.finance-source-label { display: inline-flex; align-items: center; min-height: 26px; padding: 4px 8px; border-radius: 99px; color: #4431a2; background: #eeedfb; font-size: .68rem; font-weight: 800; line-height: 1.15; }.finance-summary-table th,.finance-worker-table th,.finance-detail-table th { color: #56617a; background: #f6f6fc; font-size: .68rem; font-weight: 800; letter-spacing: .045em; text-align: left; text-transform: uppercase; }.finance-summary-table td,.finance-worker-table td,.finance-detail-table td { border-bottom: 1px solid #e5e6ef; }.finance-summary-table th,.finance-summary-table td,.finance-worker-table th,.finance-worker-table td,.finance-detail-table th,.finance-detail-table td { padding: 11px 10px; }.finance-summary-table td:last-child { text-align: right; font-weight: 800; }.finance-status { display: inline-flex; padding: 4px 8px; border-radius: 99px; color: #59439a; background: #eeedfb; font-size: .69rem; font-weight: 800; line-height: 1.1; }.finance-status.is-paid { color: #08751a; background: #e1f6e4; }.finance-status.is-pending { color: #985800; background: #fff1d9; }.finance-footnote,.finance-generated { color: #687489; font-size: .76rem; line-height: 1.45; }.finance-footnote { margin: 13px 0 0; }.finance-generated { margin: 20px 0 0; text-align: right; }
.finance-exceptions { margin-bottom: 18px; }.finance-exception-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; }.finance-exception-grid > div { padding: 13px; border: 1px solid #f0d6a2; border-radius: 10px; background: #fffaf0; }.finance-exception-grid strong,.finance-exception-grid span { display: block; }.finance-exception-grid strong { color: #995800; font-size: 1.6rem; line-height: 1; }.finance-exception-grid span { margin-top: 5px; color: #735419; font-size: .75rem; line-height: 1.35; }
.finance-worker-table,.finance-detail-table { min-width: 940px; }.finance-worker-table td,.finance-detail-table td { vertical-align: middle; }.finance-worker-table td:nth-child(n+3),.finance-detail-table td:nth-child(5) { white-space: nowrap; }.finance-detail-table { min-width: 1020px; }

.guest-topbar {
    min-height: 76px;
    border-bottom: 3px solid var(--tns-blue);
    background: #fff;
}

.guest-topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: min(100% - 40px, 1500px);
    min-height: 76px;
    margin: auto;
}

.guest-topbar .brand-logo { width: 176px; }
.guest-context { color: #526076; font-size: .73rem; font-weight: 800; letter-spacing: .085em; text-transform: uppercase; }

body.app-guest { background: #f6f6fa; }
.guest-main { width: min(100% - 40px, 1500px); margin: 30px auto; }
body.app-guest .access-page { min-height: calc(100vh - 138px); max-width: none; }

.mobile-bottom-nav { display: none; }

@media (max-width: 1120px) {
    :root { --sidebar-width: 252px; }
    body.app-authenticated .container { padding-inline: 28px; }
    .sidebar-brand img { width: 142px; }
}

@media (max-width: 900px) {
    .app-shell { display: block; }
    .app-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(84vw, 300px);
        transform: translateX(-104%);
        transition: transform .2s ease;
        box-shadow: 12px 0 38px rgba(9, 6, 94, .3);
    }
    body.sidebar-open { overflow: hidden; }
    body.sidebar-open .app-sidebar { transform: translateX(0); }
    body.sidebar-open::after { content: ''; position: fixed; inset: 0; z-index: 25; background: rgba(13, 17, 42, .44); }
    .sidebar-close {
        display: grid;
        position: absolute;
        top: 19px;
        right: 16px;
        width: 34px;
        height: 34px;
        place-items: center;
        padding: 0;
        border: 1px solid rgba(255, 255, 255, .2);
        border-radius: 9px;
        color: #fff;
        background: rgba(255, 255, 255, .11);
        cursor: pointer;
    }
    .sidebar-close .app-nav-icon { width: 18px; height: 18px; }
    .sidebar-toggle {
        display: grid;
        width: 39px;
        height: 39px;
        place-items: center;
        padding: 0;
        border: 1px solid #dedff0;
        border-radius: 10px;
        color: #100a92;
        background: #f7f6ff;
        cursor: pointer;
    }
    .sidebar-toggle .app-nav-icon { width: 20px; height: 20px; }
    .workspace-topbar { min-height: 64px; padding: 10px 16px; }
    .workspace-title { gap: 10px; }
    .workspace-title strong { font-size: .85rem; }
    body.app-authenticated .container { padding: 20px 16px 88px; }
    .guest-topbar-inner,.guest-main { width: min(100% - 28px, 1500px); }
    .signature-filter-form { grid-template-columns: 1fr 1fr; }
    .signature-filter-actions { grid-column: span 2; }
    .signature-stat-grid { grid-template-columns: 1fr 1fr; }
    .finance-filter-form { grid-template-columns: 1fr 1fr; }.finance-filter-actions { grid-column: span 2; }.finance-kpi-grid,.finance-exception-grid { grid-template-columns: 1fr 1fr; }.finance-section-grid { grid-template-columns: 1fr; }
    .guest-context { display: none; }
    .mobile-bottom-nav {
        position: fixed;
        right: 10px;
        bottom: 10px;
        left: 10px;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
        padding: 6px;
        border: 1px solid #e0e2ee;
        border-radius: 16px;
        background: rgba(255, 255, 255, .96);
        box-shadow: 0 12px 30px rgba(31, 36, 75, .16);
        backdrop-filter: blur(14px);
        z-index: 18;
    }
    .mobile-bottom-nav a {
        display: grid;
        gap: 2px;
        place-items: center;
        min-height: 48px;
        padding: 5px;
        border-radius: 11px;
        color: #677286;
        font-size: .65rem;
        font-weight: 750;
        text-decoration: none;
    }
    .mobile-bottom-nav a.is-active { color: #100a92; background: #eeedfb; }
    .mobile-bottom-nav .app-nav-icon { width: 19px; height: 19px; }
    .mobile-bottom-nav .sidebar-toggle {
        display: grid;
        width: auto;
        height: auto;
        gap: 2px;
        place-items: center;
        min-height: 48px;
        padding: 5px;
        border: 0;
        border-radius: 11px;
        color: #677286;
        background: transparent;
        font: 750 .65rem "Segoe UI", Arial, sans-serif;
    }
}

@media (max-width: 620px) {
    .topbar-user-copy { display: none; }
    body.app-authenticated .container { padding-inline: 12px; }
    .workspace-topbar { padding-inline: 12px; }
    .workspace-title span { display: none; }
    .guest-main { width: 100%; margin: 0; }
    .guest-topbar-inner { width: min(100% - 28px, 1500px); }
    .guest-topbar .brand-logo { width: 142px; }
    body.app-guest .access-page { min-height: calc(100vh - 76px); border-right: 0; border-left: 0; border-radius: 0; }
    .signature-filter-form,.signature-stat-grid { grid-template-columns: 1fr; }
    .signature-filter-actions { grid-column: span 1; flex-wrap: wrap; }
    .signature-stat-card { min-height: 105px; }
    .finance-filter-form,.finance-kpi-grid,.finance-exception-grid { grid-template-columns: 1fr; }.finance-filter-actions { grid-column: span 1; }.finance-kpi { min-height: 105px; }.section-heading { display: block; }.section-heading > .finance-source-label { margin-top: 10px; }
}
