:root {
    --lh-accent: #0d6efd;
    --lh-accent-rgb: 13, 110, 253;
    --hk-bg: #f7f7fb;
    --hk-line: #d7dee8;
    --hk-line-strong: #9aa8ba;
    --hk-table-soft: #f8fafc;
    --hk-remaining: #fff9d8;
    --hk-budget-sticky-top: 76px;
    --hk-budget-row-height: 28px;
    --hk-budget-header-height: calc(var(--hk-budget-row-height) + var(--hk-budget-row-height));
}

html[data-bs-theme="dark"] {
    --lh-accent: #6ea8ff;
    --lh-accent-rgb: 110, 168, 255;
    --hk-bg: #0f1115;
    --hk-line: rgba(255, 255, 255, .14);
    --hk-line-strong: rgba(255, 255, 255, .28);
    --hk-table-soft: #181d23;
    --hk-remaining: #332f18;
}

body {
    background: var(--hk-bg);
    font-size: 14px;
}

.lh-app-shell {
    max-width: 1680px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
}

html[data-lh-layout="wide"] .lh-app-shell {
    max-width: 1680px;
}

.navbar .lh-app-shell {
    padding-left: 1rem;
    padding-right: 1rem;
}

.navbar {
    box-shadow: 0 8px 20px rgba(0, 0, 0, .04);
}

.navbar-brand {
    margin-right: 1rem;
}

.hk-mobile-quick {
    margin-left: auto;
    margin-right: .75rem;
    color: var(--bs-body-color);
    font-size: .95rem;
    text-decoration: none;
    white-space: nowrap;
}

.hk-mobile-quick:hover,
.hk-mobile-quick:focus {
    color: var(--lh-accent);
}

.hk-logo-mark {
    display: inline-grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: .5rem;
    background: rgba(var(--lh-accent-rgb), .1);
    color: var(--lh-accent);
    font-weight: 800;
}

html[data-bs-theme="dark"] .navbar {
    background: rgba(20, 22, 28, .92) !important;
}

.lh-nav-pill > .nav-link,
.lh-nav-pill > .nav-link.dropdown-toggle {
    padding: .5rem .95rem;
    border-radius: 999px;
    background:
        radial-gradient(circle at top left, rgba(var(--lh-accent-rgb), .25), transparent 58%),
        linear-gradient(135deg, rgba(15, 23, 42, .92), rgba(30, 41, 59, .9));
    color: #fff !important;
    box-shadow: 0 8px 20px rgba(15, 23, 42, .14);
}

.lh-nav-pill > .nav-link:hover,
.lh-nav-pill > .nav-link:focus {
    color: #fff !important;
    background:
        radial-gradient(circle at top left, rgba(var(--lh-accent-rgb), .32), transparent 58%),
        linear-gradient(135deg, rgba(15, 23, 42, .96), rgba(30, 41, 59, .94));
}

.card {
    border: 0;
    border-radius: 1rem;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .06);
}

html[data-bs-theme="dark"] .card {
    box-shadow: 0 12px 28px rgba(0, 0, 0, .28);
}

.chip {
    border: 1px solid rgba(0, 0, 0, .08);
    border-radius: 999px;
    background: var(--bs-body-bg);
    color: inherit;
    padding: .28rem .55rem;
}

html[data-bs-theme="dark"] .chip {
    border-color: rgba(255, 255, 255, .12);
    background: rgba(255, 255, 255, .06);
}

.muted {
    color: rgba(0, 0, 0, .55);
}

html[data-bs-theme="dark"] .muted {
    color: rgba(255, 255, 255, .6);
}

.btn-rounded {
    border-radius: 999px;
}

.section-title {
    font-weight: 600;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.page-header h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.2;
}

.page-actions {
    display: flex;
    gap: .5rem;
}

.hk-filter-box {
    margin-bottom: 1rem;
}

.hk-filter-box[hidden] {
    display: none !important;
}

.eyebrow {
    margin: 0 0 .25rem;
    color: var(--lh-accent);
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 2rem;
    padding: 0 .7rem;
    border: 1px solid rgba(0, 0, 0, .08);
    border-radius: 999px;
    background: var(--bs-body-bg);
    color: rgba(0, 0, 0, .62);
    font-size: .85rem;
}

.hk-app-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 0;
    padding-bottom: 1.25rem;
}

.table > thead.lh-table-head,
.table > thead.small.muted {
    --lh-table-head-bg: rgba(15, 23, 42, .04);
    --lh-table-head-border: rgba(15, 23, 42, .08);
    --lh-table-head-color: rgba(15, 23, 42, .78);
    background: linear-gradient(180deg, rgba(255, 255, 255, .88), rgba(248, 250, 252, .94));
    box-shadow: inset 0 -1px 0 var(--lh-table-head-border);
}

html[data-bs-theme="dark"] .table > thead.lh-table-head,
html[data-bs-theme="dark"] .table > thead.small.muted {
    --lh-table-head-bg: rgba(255, 255, 255, .04);
    --lh-table-head-border: rgba(255, 255, 255, .09);
    --lh-table-head-color: rgba(255, 255, 255, .78);
    background: linear-gradient(180deg, rgba(30, 41, 59, .9), rgba(17, 24, 39, .94));
}

.table > thead.lh-table-head th,
.table > thead.small.muted th {
    padding-top: .8rem;
    padding-bottom: .8rem;
    border-bottom-color: var(--lh-table-head-border);
    background: var(--lh-table-head-bg);
    color: var(--lh-table-head-color);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
    white-space: nowrap;
    vertical-align: middle;
}

.hk-admin-table td {
    border-bottom-color: rgba(15, 23, 42, .08);
}

.hk-click-row {
    cursor: pointer;
}

.hk-click-row:hover td {
    background: var(--bs-tertiary-bg);
}

.hk-id-pill {
    display: inline-flex;
    align-items: center;
    min-height: 1.9rem;
    padding: 0 .65rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 999px;
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.hk-admin-table .form-control,
.hk-admin-table .form-select {
    min-width: 0;
}

.hk-mobile-list {
    display: none;
}

.hk-mobile-card {
    display: grid;
    gap: .55rem;
    padding: .9rem;
    border: 1px solid var(--bs-border-color);
    border-radius: .85rem;
    background: var(--bs-body-bg);
    color: inherit;
    text-decoration: none;
}

.hk-mobile-card:hover,
.hk-mobile-card:focus {
    border-color: rgba(var(--lh-accent-rgb), .35);
    background: var(--bs-tertiary-bg);
    color: inherit;
}

.hk-mobile-card-head,
.hk-mobile-card-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: .75rem;
}

.hk-mobile-card-head strong,
.hk-mobile-card-row strong {
    min-width: 0;
    overflow-wrap: anywhere;
}

.hk-mobile-card-head span {
    color: var(--lh-accent);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

.hk-mobile-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}

.hk-mobile-card-meta span {
    padding: .15rem .45rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 999px;
    color: var(--bs-secondary-color);
    font-size: .78rem;
}

.hk-mobile-card-row span {
    color: var(--bs-secondary-color);
}

.hk-mobile-empty {
    padding: 1rem;
    color: var(--bs-secondary-color);
    text-align: center;
}

.nomenclature-tile {
    display: flex;
    min-height: 98px;
    flex-direction: column;
    justify-content: center;
    gap: .4rem;
    color: inherit;
    text-decoration: none;
}

.nomenclature-tile:hover,
.nomenclature-tile:focus {
    background: var(--bs-tertiary-bg);
    color: inherit;
}

.nomenclature-title {
    font-size: 1.02rem;
    font-weight: 700;
}

.nomenclature-description {
    color: var(--bs-secondary-color);
    font-size: .94rem;
}

.login-page {
    min-height: 100vh;
    background: var(--hk-bg);
}

.login-shell {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 1.25rem;
}

.login-card {
    width: min(100%, 390px);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1.25rem;
}

.brand-name {
    font-size: 1.15rem;
    font-weight: 700;
}

.brand-version {
    color: var(--bs-secondary-color);
    font-size: .8rem;
}

.month-picker {
    position: relative;
}

.month-picker summary {
    display: inline-flex;
    align-items: center;
    min-height: 31px;
    min-width: 150px;
    padding: 0 .75rem;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-sm);
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    cursor: pointer;
    list-style: none;
}

.month-picker summary::-webkit-details-marker {
    display: none;
}

.month-picker summary::after {
    content: "";
    width: 0;
    height: 0;
    margin-left: auto;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--bs-secondary-color);
}

.month-picker[open] summary::after {
    border-top: 0;
    border-bottom: 6px solid var(--bs-secondary-color);
}

.month-picker-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: 1fr;
    gap: 2px;
    width: 210px;
    padding: .5rem;
    border: 1px solid var(--bs-border-color);
    border-radius: .75rem;
    background: var(--bs-body-bg);
    box-shadow: 0 8px 20px rgba(0, 0, 0, .08);
}

.budget-toolbar .month-picker-panel label {
    display: flex;
    align-items: center;
    gap: .5rem;
    min-height: 26px;
    margin: 0;
    padding: .25rem .5rem;
    border-radius: .4rem;
    font-size: .85rem;
}

.budget-toolbar .month-picker-panel .month-picker-toggle {
    margin-bottom: .25rem;
    border-bottom: 1px solid var(--bs-border-color);
    border-radius: 0;
    font-weight: 700;
    white-space: nowrap;
}

.budget-toolbar .month-picker-panel label:hover {
    background: rgba(13, 110, 253, .08);
}

.budget-toolbar .month-picker-panel input {
    flex: 0 0 auto;
    margin: 0;
}

.budget-toolbar {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: .6rem;
    margin-bottom: .85rem;
    padding: .75rem;
    width: 100%;
    text-align: left;
}

.toolbar-year {
    display: grid;
    min-height: 31px;
    min-width: 64px;
    place-items: center;
    padding: 0 .75rem;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-sm);
    background: var(--bs-body-bg);
}

.toolbar-link {
    display: inline-flex;
    align-items: center;
    min-height: 31px;
    padding: 0 .75rem;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-sm);
    background: var(--bs-body-bg);
    color: inherit;
    text-decoration: none;
}

.toolbar-link:hover {
    background: var(--bs-tertiary-bg);
}

.budget-board {
    border: 1px solid var(--hk-line);
    border-radius: 1rem;
    background: var(--bs-body-bg);
    box-shadow: 0 8px 20px rgba(0, 0, 0, .06);
    overflow: visible;
}

.budget-scroll {
    max-width: 100%;
    overflow-x: visible;
    overflow-y: visible;
    position: relative;
}

.budget-table {
    width: 100%;
    min-width: max-content;
    border-collapse: separate;
    border-spacing: 0;
    font-variant-numeric: tabular-nums;
}

.budget-table th,
.budget-table td {
    height: var(--hk-budget-row-height);
    padding: 0 4px;
    border: 1px solid var(--hk-line-strong);
    line-height: 1.1;
    white-space: nowrap;
}

.budget-table thead th {
    position: sticky;
    z-index: 7;
    background: var(--bs-tertiary-bg);
    text-align: center;
    font-weight: 700;
}

.budget-table thead tr:first-child th {
    top: var(--hk-budget-sticky-top);
}

.budget-table thead tr:nth-child(2) th {
    top: calc(var(--hk-budget-sticky-top) + var(--hk-budget-row-height));
}

.budget-table tbody th {
    position: sticky;
    left: 0;
    z-index: 3;
    width: 138px;
    min-width: 138px;
    max-width: 138px;
    background: var(--bs-body-bg);
    font-size: 12px;
    font-weight: 400;
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
}

.budget-table td {
    width: 48px;
    min-width: 48px;
    max-width: 48px;
    background: var(--hk-table-soft);
    font-size: 12px;
    text-align: right;
}

.budget-table .year-cell {
    position: sticky;
    top: var(--hk-budget-sticky-top);
    left: 0;
    z-index: 10;
    color: var(--lh-accent);
    font-size: 24px;
}

.budget-table .month-cell {
    z-index: 8;
    color: var(--lh-accent);
    font-size: 18px;
}

.budget-table thead tr:nth-child(2) th {
    font-size: 11px;
}

.budget-table .summary-row th,
.budget-table .summary-row td {
    background: var(--bs-body-bg);
    font-weight: 700;
}

.budget-table .sticky-summary th,
.budget-table .sticky-summary td {
    position: sticky;
    z-index: 4;
}

.budget-table .sticky-summary th {
    left: 0;
    z-index: 8;
}

.budget-table .summary-row-1 th,
.budget-table .summary-row-1 td {
    top: calc(var(--hk-budget-sticky-top) + var(--hk-budget-header-height));
}

.budget-table .summary-row-2 th,
.budget-table .summary-row-2 td {
    top: calc(var(--hk-budget-sticky-top) + var(--hk-budget-header-height) + var(--hk-budget-row-height));
}

.budget-table .summary-row-3 th,
.budget-table .summary-row-3 td {
    top: calc(var(--hk-budget-sticky-top) + var(--hk-budget-header-height) + var(--hk-budget-row-height) + var(--hk-budget-row-height));
}

.budget-table .summary-row-4 th,
.budget-table .summary-row-4 td {
    top: calc(var(--hk-budget-sticky-top) + var(--hk-budget-header-height) + var(--hk-budget-row-height) + var(--hk-budget-row-height) + var(--hk-budget-row-height));
}

.budget-table thead th,
.budget-table .sticky-summary th,
.budget-table .sticky-summary td {
    background-clip: border-box;
}

.budget-table .final-row th,
.budget-table .final-row td {
    color: var(--lh-accent);
}

.budget-table td.remaining {
    background: var(--hk-remaining);
}

.budget-amount-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.budget-amount-link:hover,
.budget-amount-link:focus {
    color: var(--lh-accent);
    text-decoration: underline;
}

.budget-value-negative,
.budget-amount-link.budget-value-negative {
    color: #d97706 !important;
}

html[data-bs-theme="dark"] .budget-value-negative,
html[data-bs-theme="dark"] .budget-amount-link.budget-value-negative {
    color: #fbbf24 !important;
}

.budget-month-grid {
    display: none;
}

.budget-month-card {
    padding: 1rem;
    border-radius: 1rem;
    background: var(--bs-body-bg);
    box-shadow: 0 8px 20px rgba(0, 0, 0, .06);
}

.budget-month-card header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .85rem;
}

.budget-month-card h2 {
    margin: 0;
    color: var(--lh-accent);
    font-size: 1.05rem;
    font-weight: 700;
}

.budget-month-card header span {
    color: var(--bs-secondary-color);
    font-size: .85rem;
}

.budget-month-summary {
    display: grid;
    gap: .4rem;
    margin-bottom: .85rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--bs-border-color);
}

.budget-month-summary div,
.budget-month-row {
    display: grid;
    grid-template-columns: minmax(96px, 1fr) repeat(3, minmax(48px, auto));
    align-items: center;
    gap: .5rem;
}

.budget-month-summary div {
    min-height: 28px;
    font-weight: 700;
}

.budget-month-summary .is-final {
    color: var(--lh-accent);
}

.budget-month-summary span,
.budget-month-row span {
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

.budget-month-values-head {
    display: grid;
    grid-template-columns: minmax(96px, 1fr) repeat(3, minmax(48px, auto));
    align-items: center;
    gap: .5rem;
    color: var(--bs-secondary-color);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.budget-month-values-head span:not(:first-child) {
    text-align: right;
}

.budget-month-rows {
    display: grid;
    gap: .15rem;
}

.budget-month-row {
    min-height: 28px;
    padding: .25rem 0;
    border-bottom: 1px solid rgba(15, 23, 42, .06);
}

.budget-month-row:last-child {
    border-bottom: 0;
}

.budget-month-row strong {
    min-width: 0;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.decision-notes {
    margin-top: 1rem;
}

.decision-notes article,
.panel,
.timeline-entry {
    padding: 1rem;
    border: 0;
    border-radius: 1rem;
    background: var(--bs-body-bg);
    box-shadow: 0 8px 20px rgba(0, 0, 0, .06);
}

.help-grid,
.timeline {
    display: grid;
    gap: 1rem;
}

.help-grid {
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.timeline-entry header {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
}

@media (max-width: 760px) {
    .lh-app-shell {
        padding-left: .75rem;
        padding-right: .75rem;
    }

    .page-header {
        align-items: center;
        flex-direction: row;
    }

    .page-actions {
        width: auto;
        margin-left: auto;
    }

    .page-actions .btn,
    .page-actions button {
        flex: 0 0 auto;
    }

    .page-header > .btn,
    .page-header > button {
        margin-left: auto;
        flex: 0 0 auto;
    }

    .hk-table-view {
        display: none;
    }

    .hk-mobile-list {
        display: grid;
        gap: .75rem;
    }

    .nomenclature-tile {
        min-height: 88px;
    }

    .month-picker,
    .month-picker summary {
        width: 100%;
    }

    .month-picker-panel {
        width: 100%;
    }

    :root {
        --hk-budget-sticky-top: 76px;
        --hk-budget-row-height: 30px;
    }

    body {
        font-size: 15px;
    }

    .navbar .lh-app-shell {
        padding-top: .65rem !important;
        padding-bottom: .65rem !important;
    }

    .hk-logo-mark {
        width: 40px;
        height: 40px;
        font-size: 1.05rem;
    }

    .navbar-toggler {
        min-width: 44px;
        min-height: 44px;
        border-color: var(--bs-border-color);
        border-radius: 999px;
        box-shadow: 0 8px 18px rgba(15, 23, 42, .08);
    }

    .navbar-nav {
        gap: .35rem;
        padding-top: .75rem;
    }

    .navbar .nav-link,
    .dropdown-item {
        min-height: 44px;
        display: flex;
        align-items: center;
        padding: .65rem .9rem;
        border-radius: .75rem;
        font-size: 1rem;
        font-weight: 600;
    }

    .dropdown-menu {
        padding: .4rem;
        border: 0;
        border-radius: 1rem;
        box-shadow: 0 14px 32px rgba(15, 23, 42, .16);
    }

    .dropdown-item.active,
    .dropdown-item:active {
        background: var(--lh-accent);
    }

    .hk-mobile-quick {
        display: inline-flex;
        align-items: center;
        min-height: 40px;
        padding: 0 .85rem;
        border: 1px solid rgba(var(--lh-accent-rgb), .28);
        border-radius: 999px;
        background: rgba(var(--lh-accent-rgb), .08);
        color: var(--lh-accent);
        font-size: .98rem;
        font-weight: 700;
    }

    .btn-sm,
    .toolbar-link,
    .month-picker summary,
    .toolbar-year {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 44px;
        padding-left: 1rem;
        padding-right: 1rem;
        font-size: 1rem;
        font-weight: 700;
    }

    .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 44px;
        font-weight: 700;
    }

    .btn-primary,
    .btn-outline-secondary,
    .toolbar-link,
    .month-picker summary {
        box-shadow: 0 8px 18px rgba(15, 23, 42, .08);
    }

}

@media (max-width: 1400px) {
    .budget-board {
        display: none;
    }

    .budget-month-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
        gap: 1rem;
    }
}

@media (max-width: 760px) {
    .budget-month-grid {
        grid-template-columns: 1fr;
        gap: .85rem;
    }

    .budget-month-card {
        padding: .85rem;
    }

    .budget-month-row strong {
        white-space: normal;
    }

    .budget-month-summary div,
    .budget-month-row,
    .budget-month-values-head {
        grid-template-columns: minmax(86px, 1fr) repeat(3, minmax(42px, auto));
        gap: .35rem;
    }

    .budget-month-summary span,
    .budget-month-row span {
        font-size: .86rem;
    }
}
