:root {
    --brand-primary: #03264A;
    --brand-secondary: #82C473;
    --brand-accent-blue: #17C2C9;
    --brand-accent-blue-rgb: 23, 194, 201;
    --brand-accent-orange: #F15A29;
    --gray-dark: #5A5A5A;
    --gray-mid: #9B9B9B;
    --main-bg: #f2f5f9;
    --sidebar-bg: #f7f8fb;
    --sidebar-border: #dde3ea;
    --panel-bg: #ffffff;
    --control-bg: #ffffff;
    --line: #dbe3ec;
    --line-strong: #c9d4df;
    --text: #03264A;
    --muted: #5b6f88;
    --accent: var(--brand-accent-blue);
    --accent-deep: #03264A;
    --accent-soft: rgba(var(--brand-accent-blue-rgb), 0.14);
    --shadow: 0 10px 30px rgba(21, 34, 50, 0.08);
    --surface-hover: #f4f8fb;
    --menu-shadow: 0 12px 24px rgba(3, 38, 74, 0.16);
    --preview-bg: #eef3f8;
    --radius: 14px;
    --sidebar-width: 190px;
    --header-height: 66px;
    --row-h: 38px;
    --resource-role-col-width: 320px;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: Inter, Arial, Helvetica, sans-serif;
    background: var(--main-bg);
    color: var(--text);
}

input[type='text'],
input[type='search'],
input[type='number'],
input[type='email'],
input[type='password'],
input[type='date'],
input[type='month'],
input[type='tel'],
input[type='url'],
select,
textarea {
    border-color: var(--gray-mid);
    color: var(--brand-primary);
    transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

input[type='text']:hover,
input[type='search']:hover,
input[type='number']:hover,
input[type='email']:hover,
input[type='password']:hover,
input[type='date']:hover,
input[type='month']:hover,
input[type='tel']:hover,
input[type='url']:hover,
select:hover,
textarea:hover {
    border-color: var(--brand-accent-blue);
    background: #eef6ff;
}

input[type='text']:focus,
input[type='search']:focus,
input[type='number']:focus,
input[type='email']:focus,
input[type='password']:focus,
input[type='date']:focus,
input[type='month']:focus,
input[type='tel']:focus,
input[type='url']:focus,
select:focus,
textarea:focus {
    border-color: var(--brand-accent-blue);
    box-shadow: 0 0 0 3px rgba(var(--brand-accent-blue-rgb), 0.14);
    outline: none;
}

input[type='checkbox'],
input[type='radio'] {
    accent-color: var(--brand-accent-blue);
}

.app-shell {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1400;
}

.sidebar-top {
    padding: 18px 18px 12px;
}

.brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.brand-logo,.brand-icon {
    max-width: 150px;
    width: 100%;
    height: auto;
}

.brand-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 5px;
}

.brand-name {
    display: block;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -.3px;
}

.nav {
    padding: 10px 4px 18px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}


.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 44px;
    padding: 0 14px;
    border-radius: 12px;
    color: #4f5663;
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
}

.nav-item:hover {
    background: #edf1f6;
    color: var(--text);
}

.nav-item.active {
    background: transparent;
    color: var(--accent-deep);
    font-weight: 800;
}

.nav-icon {
    width: 18px;
    text-align: center;
    opacity: .8;
}

.sub-nav {
    margin: 0 0 8px 34px;
    display: grid;
    gap: 2px;
}

.sub-nav-item {
    display: block;
    border-radius: 8px;
    padding: 7px 10px;
    color: #64748b;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}

.sub-nav-item:hover {
    background: #edf1f6;
    color: var(--text);
}

.sub-nav-item.active {
    background: transparent;
    color: var(--accent-deep);
    font-weight: 800;
}


.sidebar-bottom {
    margin-top: auto;
    padding: 12px;
    border-top: 1px solid var(--sidebar-border);
}

.profile-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 8px 10px;
    color: var(--text);
    cursor: pointer;
}

.profile-trigger:hover,
.profile-trigger.open {
    background: #edf1f6;
    border-color: #e0e7ef;
}

.avatar {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    flex: 0 0 30px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--brand-accent-blue), #0c6a94 52%, #03264A);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    overflow: hidden;
}

.avatar-photo {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    border-radius: 999px;
}

.profile-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    line-height: 1.15;
    text-align: left;
}

.profile-name {
    font-size: 12px;
    font-weight: 700;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.profile-menu {
    display: none;
    position: absolute;
    left: calc(var(--sidebar-width) + 12px);
    bottom: 18px;
    width: 224px;
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 8px;
    z-index: 1500;
}

.profile-menu.open {
    display: block;
}

.profile-menu a,
.profile-menu button {
    width: 100%;
    display: flex;
    align-items: center;
    text-align: left;
    background: transparent;
    border: 0;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #4f5663;
    text-decoration: none;
    cursor: pointer;
}

.profile-menu a:hover,
.profile-menu button:hover {
    background: #edf1f6;
    color: var(--text);
}

.profile-divider {
    height: 1px;
    background: var(--line);
    margin: 8px 0;
}

.profile-email {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.main {
    margin-left: var(--sidebar-width);
    min-width: 0;
    flex: 1;
    background: var(--main-bg);
}

.topbar {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: rgba(255, 255, 255, .85);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(8px);
}

.page-title {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -.3px;
    color: var(--brand-primary);
}

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

.panel {
    background: var(--panel-bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.section-block {
    margin-bottom: 18px;
}

.panel.section-block {
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}

.index-page .bu-block .panel.section-block {
    background: var(--bu-section-bg, var(--panel-bg));
}

body.dark-theme.index-page .bu-block .panel.section-block {
    background: var(--panel-bg);
    border: 1px solid var(--bu-section-bg-dark, var(--gray-mid));
}

.index-page .bu-block .panel.section-block .section-title {
    color: var(--bu-section-title, var(--brand-primary));
}

.hero-panel {
    padding: 20px 22px;
}

.hero-panel-layout {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}

#indexPrpRoot .hero-grid,
#indexPfpRoot .hero-grid {
    margin-bottom: 18px;
}

#indexPrpRoot .hero-heading,
#indexPfpRoot .hero-heading {
    margin: 0;
    line-height: 1.2;
}

#indexPfpRoot .pfp-trend-grid {
    margin-bottom: 18px;
}

#indexPfpRoot .pfp-trend-canvas-wrap {
    position: relative;
    min-height: 300px;
    height: clamp(260px, 34vh, 380px);
}

#indexPfpRoot #pfpMonthlyFeeTrendChart {
    width: 100% !important;
    height: 100% !important;
}

.pfp-trend-budget-btn {
    gap: 6px;
    min-width: 122px;
}

.pfp-trend-budget-btn svg {
    width: 14px;
    height: 14px;
}

.pfp-budget-popover {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 12;
    width: min(360px, calc(100% - 20px));
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: var(--panel-bg);
    box-shadow: var(--menu-shadow);
    padding: 10px 12px;
}

.pfp-budget-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--text);
    font-size: 13px;
    line-height: 1.4;
}

.pfp-budget-row + .pfp-budget-row {
    margin-top: 8px;
}

.pfp-budget-row.pfp-budget-row-projected {
    margin-top: 20px;
}

.pfp-budget-row strong {
    font-weight: 600;
}

.pfp-budget-row.is-total,
.pfp-budget-row.is-total strong {
    font-weight: 800;
}

.btn,
.btn-primary,
.btn-secondary,
.btn-admin-only {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    border-radius: 10px;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
}

.btn,
.btn-primary {
    border: 1px solid var(--brand-primary);
    color: #fff;
    background: var(--brand-primary);
    opacity: 0.85;
    transition: opacity 120ms ease;
}

.btn:hover,
.btn-primary:hover {
    opacity: 1;
}

.btn-admin-only {
    border: 1px solid #b7dcb0;
    background: #fff;
    color: var(--brand-primary);
    transition: background-color 120ms ease, border-color 120ms ease;
}

.btn-admin-only:hover {
    background: #f6fcf8;
}

.btn-secondary {
    border: 1px solid var(--brand-primary);
    background: #fff;
    color: var(--brand-primary);
    transition: background-color 120ms ease, border-color 120ms ease;
}

.btn-secondary:link,
.btn-secondary:visited {
    color: var(--brand-primary);
    text-decoration: none;
}

.btn-secondary:hover {
    background: #eef6ff;
    border-color: var(--brand-primary);
}

.topbar-actions > a.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2200;
    background: rgba(8, 18, 28, 0.58);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay[hidden] {
    display: none !important;
}

#preferencesModalOverlay {
    position: absolute !important;
    inset: 0 !important;
    z-index: 2147483647 !important;
}

.code-modal {
    width: min(960px, 100%);
    border-radius: 12px;
    background: #fff;
    border: 1px solid var(--line-strong);
    box-shadow: 0 18px 40px rgba(3, 38, 74, 0.28);
    padding: 14px;
}

.code-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.code-modal-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--brand-primary);
}

.code-modal-close {
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--brand-primary);
    background: #fff;
    color: var(--brand-primary);
    font-size: 12px;
    font-weight: 700;
    padding: 0 10px;
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.code-modal-close:hover {
    background: #eef6ff;
    border-color: var(--brand-primary);
}

.code-modal.modal-surface {
    padding: 16px;
    border-radius: 14px;
}

.code-modal-head.modal-head-divider {
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e7eff6;
}

.code-modal-title.modal-title-lg {
    font-size: 16px;
    letter-spacing: 0.1px;
}

.code-modal-actions-divider {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #e7eff6;
}

.modal-panel-surface {
    border: 1px solid #dce7f2;
    border-radius: 10px;
    background: #f8fbff;
}

.modal-step-pill {
    border: 1px solid #d5e2ef;
    background: #f8fbff;
    color: #51697f;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.2px;
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
}

.modal-step-pill:hover {
    border-color: #aac6e0;
    background: #deeef9;
    color: #2f6fa8;
}

.modal-step-pill.is-active {
    border-color: #7aa8d0;
    background: #eaf5ff;
    color: #2f6fa8;
}

.modal-step-pill.is-complete {
    border-color: #9ec9b6;
    background: #edf9f3;
    color: #1f6a52;
}

.modal-step-pill.is-skipped {
    text-decoration: line-through;
    text-decoration-color: #aab8c4;
    color: #9aaab8;
    border-color: #dce7ef;
    background: #f5f8fb;
    cursor: default;
    pointer-events: none;
}

.preferences-modal {
    width: min(960px, 100%);
}

.preferences-steps-indicator {
    margin-bottom: 12px;
}

.preferences-modal-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
    gap: 14px;
}

.preferences-column {
    min-width: 0;
}

.preferences-column-theme {
    padding-left: 14px;
}

.preferences-section-title {
    margin: 0 0 8px;
}

.preferences-subsection-title {
    margin-top: 14px;
}

.preferences-column-main > .preferences-fieldset > .preferences-subsection-title:first-child {
    margin-top: 0;
}

.preferences-panel {
    padding: 14px;
    border: 1px solid #dce7f2;
    border-radius: 10px;
    background: #f8fbff;
}

.preferences-fieldset {
    border: 0;
    margin: 0;
    padding: 0;
}

.preferences-multiselect {
    display: grid;
    gap: 8px;
}

.preferences-multiselect-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
}

.preferences-multiselect-option input[type="checkbox"] {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    border: 1px solid #9fb6cc;
    background: #fff;
    flex: 0 0 auto;
    position: relative;
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease;
}

.preferences-multiselect-option input[type="checkbox"]::after {
    content: '';
    position: absolute;
    left: 7px;
    top: 3px;
    width: 4px;
    height: 8px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    opacity: 0;
    transition: opacity 120ms ease;
}

.preferences-multiselect-option input[type="checkbox"]:checked {
    border-color: var(--brand-accent-blue);
    background: var(--brand-accent-blue);
}

.preferences-multiselect-option input[type="checkbox"]:checked::after {
    opacity: 1;
}

.preferences-multiselect-option input[type="checkbox"]:focus-visible {
    outline: 2px solid rgba(var(--brand-accent-blue-rgb), 0.45);
    outline-offset: 2px;
}

.preferences-inline-toggle-wrap {
    margin-top: 12px;
    padding-top: 12px;
}

.preferences-theme-wrap {
    display: grid;
    gap: 10px;
}

.preferences-theme-note {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
}

.preferences-theme-toggle {
    display: block;
}

.preferences-theme-switch {
    border: 1px solid #c9d9e7;
    background: #f8fbff;
    color: #3f5d77;
    border-radius: 999px;
    min-height: 36px;
    padding: 6px 10px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.preferences-theme-switch-label {
    white-space: nowrap;
}

.preferences-theme-switch-track {
    width: 34px;
    height: 18px;
    border-radius: 999px;
    border: 1px solid #9fb6cc;
    background: #dbe8f4;
    display: inline-flex;
    align-items: center;
    padding: 1px;
}

.preferences-theme-switch-thumb {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
    transform: translateX(0);
    transition: transform 120ms ease;
}

.preferences-theme-switch.is-dark {
    background: #eaf5ff;
    border-color: #7aa8d0;
    color: #2f6fa8;
}

.preferences-theme-switch.is-dark .preferences-theme-switch-track {
    border-color: #2f6fa8;
    background: #2f6fa8;
}

.preferences-theme-switch.is-dark .preferences-theme-switch-thumb {
    transform: translateX(16px);
}

.preferences-theme-switch:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.preferences-actions-buttons {
    display: flex;
    justify-content: flex-end;
    margin-left: auto;
    gap: 8px;
}

.preferences-actions {
    display: flex;
    justify-content: flex-end;
}

.modal-section-title {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: #3a5a76;
}

.modal-input-control,
.total-fees-percent,
.total-fees-amount,
.upsert-project-text-input,
.upsert-project-date-input,
.upsert-rate-amount-input,
.upsert-proposal-item-input {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.modal-input-control:focus,
.total-fees-percent:focus,
.total-fees-amount:focus,
.upsert-project-text-input:focus,
.upsert-project-date-input:focus,
.upsert-rate-amount-input:focus,
.upsert-proposal-item-input:focus {
    border-color: rgba(var(--brand-accent-blue-rgb), .75);
    box-shadow: 0 0 0 3px rgba(var(--brand-accent-blue-rgb), .12);
}

.upsert-project-date-wrap {
    display: inline-flex;
    position: relative;
    width: min(240px, 100%);
}

.upsert-project-date-input {
    width: 100%;
    height: 36px;
    min-width: 0;
    border-radius: 9px;
    padding: 0 38px 0 12px;
    outline: none;
}

.upsert-project-date-input.input-invalid {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.upsert-project-date-trigger {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border: 0;
    background: transparent;
    color: #4d6278;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
}

.upsert-project-date-trigger:hover {
    color: #0f4a73;
}

.upsert-project-date-trigger svg {
    width: 18px;
    height: 18px;
}

.upsert-date-picker {
    position: absolute;
    z-index: 2147483647;
    width: 280px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 12px 24px rgba(3, 38, 74, 0.16);
    padding: 10px;
}

.upsert-date-picker-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.upsert-date-picker-nav,
.upsert-generic-date-picker-nav {
    width: 30px;
    height: 30px;
    border: 1px solid #d6e1ec;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.upsert-date-picker-nav:hover,
.upsert-generic-date-picker-nav:hover {
    background: #f4f8fb;
}

.upsert-date-picker-nav svg,
.upsert-generic-date-picker-nav svg {
    width: 14px;
    height: 14px;
}

.upsert-date-picker-title {
    flex: 1 1 auto;
    height: 30px;
    border: 1px solid #d6e1ec;
    border-radius: 8px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.upsert-date-picker-day-head,
.upsert-date-picker-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}

.upsert-date-picker-day-head {
    margin-bottom: 6px;
}

.upsert-date-picker-day-name {
    height: 24px;
    font-size: 11px;
    font-weight: 700;
    color: #6a7a8c;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.upsert-date-picker-day-empty {
    height: 30px;
}

.upsert-date-picker-day {
    height: 30px;
    border: 1px solid #d6e1ec;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.upsert-date-picker-day:hover {
    background: #f4f8fb;
}

.upsert-date-picker-day.is-today {
    border-color: rgba(var(--brand-accent-blue-rgb), 0.55);
}

.upsert-date-picker-day.is-selected {
    border-color: var(--brand-accent-blue);
    background: rgba(var(--brand-accent-blue-rgb), 0.16);
    color: #0d5b61;
}

.code-copy-note {
    font-size: 12px;
    color: #637487;
    margin-bottom: 8px;
    font-weight: 600;
}

.code-copy-note.is-success {
    color: #15803d;
}

.code-modal-content {
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f7fafc;
    color: #1f2d3d;
    padding: 12px;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.45;
    max-height: 68vh;
    overflow-y: auto;
    white-space: pre;
    cursor: copy;
}

.app-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    background: rgba(3, 38, 74, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.app-modal-overlay[hidden] {
    display: none;
}

.app-modal {
    width: min(520px, 100%);
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    box-shadow: 0 16px 36px rgba(3, 38, 74, 0.24);
    padding: 18px;
}

.app-modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--brand-primary);
    margin-bottom: 8px;
}

.app-modal-body {
    font-size: 13px;
    color: var(--text);
    margin-bottom: 24px;
}

.app-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.app-form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
}

.app-search-input {
    width: min(360px, 100%);
    height: 36px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    padding: 0 12px;
    color: var(--text);
    background: #ffffff;
}

.app-search-input:focus {
    outline: none;
    border-color: var(--brand-accent-blue);
    box-shadow: 0 0 0 3px rgba(var(--brand-accent-blue-rgb), 0.14);
}

.app-data-table {
    width: 100%;
    border-collapse: collapse;
}

.app-data-table th,
.app-data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    font-size: 13px;
    white-space: nowrap;
}

.app-data-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f8fbfd;
    color: var(--brand-primary);
    font-weight: 700;
}

.app-data-table tbody tr:hover {
    background: #f8fbfd;
}

.content {
    padding: 24px;
}

.session-expiry-banner {
    position: fixed;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    z-index: 2300;
    width: min(760px, calc(100vw - 24px));
    border: 1px solid var(--brand-accent-orange);
    border-radius: 12px;
    background: #fff3eb;
    box-shadow: 0 14px 30px rgba(3, 38, 74, 0.16);
    padding: 12px 14px;
}

.session-expiry-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.session-expiry-copy {
    color: #5f4023;
    font-size: 13px;
    line-height: 1.35;
}

.session-expiry-copy strong {
    color: #8a4b00;
}

.session-expiry-countdown {
    display: inline-block;
    min-width: 124px;
    font-weight: 700;
    color: #7a3f00;
}

.session-expiry-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.session-expiry-actions .session-expiry-dismiss {
    border-color: var(--brand-accent-blue);
    background: #ffffff;
}

.session-expiry-actions .session-expiry-dismiss:hover {
    background: #eef6ff;
    border-color: var(--brand-accent-blue);
}

@media (max-width: 720px) {
    .session-expiry-banner {
        bottom: 10px;
        width: calc(100vw - 16px);
        padding: 10px;
    }

    .session-expiry-content {
        flex-direction: column;
        align-items: stretch;
    }

    .session-expiry-actions {
        justify-content: flex-end;
    }
}

.table-wrap {
    overflow-x: auto;
    overflow-y: hidden;
    position: relative;
}

.section-block .table-wrap {
    margin: 0 0 8px 0;
    padding-bottom: 5px;
}

.section-block .table-wrap .grid-table {
    width: 100%;
    margin: 0 0 3px;
}

.table-wrap,
.favorites-list {
    scrollbar-width: thin;
    scrollbar-color: #415C77 transparent;
}

.table-wrap::-webkit-scrollbar,
.favorites-list::-webkit-scrollbar {
    background: transparent;
}

.table-wrap::-webkit-scrollbar:horizontal,
.favorites-list::-webkit-scrollbar:horizontal {
    height: 12px;
}

.table-wrap::-webkit-scrollbar:vertical,
.favorites-list::-webkit-scrollbar:vertical {
    width: 12px;
}

.table-wrap::-webkit-scrollbar-track,
.favorites-list::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-corner,
.favorites-list::-webkit-scrollbar-corner {
    background: transparent;
}

.table-wrap::-webkit-scrollbar-thumb,
.favorites-list::-webkit-scrollbar-thumb {
    background: #415C77;
    border: 2px solid transparent;
    border-radius: 999px;
    background-clip: content-box;
}

.grid-table {
    width: 100%;
    min-width: 1320px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.grid-table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--gray-mid);
    border-bottom: 1px solid var(--gray-mid);
    border-right: 1px solid var(--gray-mid);
    padding: 10px 10px;
    text-align: center;
    color: #FFFFFF;
    white-space: nowrap;
}

.index-page .grid-table thead th.metric-header,
.index-page .grid-table thead th.month-col-header,
.index-page .resource-table thead th:nth-child(2) {
    text-align: center;
}

.index-page .grid-table thead th.metric-header {
    white-space: normal;
    min-width: 132px;
}

.index-page .grid-table thead th.metric-header > span {
    display: block;
    line-height: 1.2;
}

.index-page .grid-table thead th.metric-header > span + span {
    margin-top: 2px;
}

.index-page .grid-table thead th.month-col-header > span {
    display: inline;
    line-height: inherit;
}

.index-page .grid-table thead th.month-col-header > span + span {
    margin-top: 0;
    margin-left: 4px;
}

.index-page .grid-table thead th.month-col-planned,
.index-page .grid-table thead th.month-col-actual,
.index-page .grid-table tbody td.month-cell-planned,
.index-page .grid-table tbody td.month-cell-actual {
    width: 90px;
    min-width: 90px;
    max-width: 90px;
}

.grid-table tbody td {
    border-bottom: 1px solid var(--gray-mid);
    border-right: 1px solid var(--gray-mid);
    height: var(--row-h);
    padding: 0;
    background: #fff;
}

.grid-table tbody tr:hover td {
    background: #fbfdff;
}

.grid-table tbody tr.table-totals-row td,
.grid-table tbody tr.table-totals-row:hover td,
.grid-table tbody tr.table-totals-row td.sticky,
.grid-table tbody tr.table-totals-row td.month-cell-planned,
.grid-table tbody tr.table-totals-row td.month-cell-actual {
    background: #EBEBEB;
    font-weight: 700;
}

.table-totals-row .summary-key-cell {
    font-weight: 800;
}

.summary-row td {
    font-weight: 700;
}

.index-page .grid-table thead th.current-month {
    background: var(--gray-dark);
    border-bottom-color: var(--gray-dark);
    border-right-color: var(--gray-dark);
    box-shadow: inset -1px 0 0 var(--gray-dark);
    color: #ffffff;
}

.index-page .grid-table tbody tr:not(.table-totals-row) td.month-cell-actual,
.index-page .grid-table tbody tr:not(.table-totals-row):hover td.month-cell-actual {
    background-color: #FBFDFF;
    background-image: radial-gradient(rgba(0, 0, 0, 0.12) 0.7px, transparent 0.7px);
    background-size: 10px 10px;
}

.index-page .grid-table tbody td.month-cell-out-of-range,
.index-page .grid-table tbody tr:hover td.month-cell-out-of-range {
    background: #e6e6e6;
    background-image: none;
}

.index-page .grid-table tbody td.month-cell-out-of-range .cell,
.index-page .grid-table tbody td.month-cell-out-of-range .month-input,
.index-page .grid-table tbody td.month-cell-out-of-range .month-actual-input {
    color: #8a8a8a;
}

.native-generic-select {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.custom-dd.custom-dd-generic {
    position: relative;
}

.custom-dd.custom-dd-generic .custom-dd-trigger {
    width: 100%;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
    padding: 0 12px;
    cursor: pointer;
}

.custom-dd.custom-dd-generic .custom-dd-label {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}

.custom-dd.custom-dd-generic .custom-dd-caret {
    flex: 0 0 auto;
    color: #6a7a8c;
    font-size: 11px;
}

.custom-dd.custom-dd-generic .custom-dd-trigger:hover,
.custom-dd.custom-dd-generic.is-open .custom-dd-trigger {
    border-color: rgba(var(--brand-accent-blue-rgb), .75);
    box-shadow: 0 0 0 3px rgba(var(--brand-accent-blue-rgb), .12);
}

.grid-table .custom-dd.custom-dd-generic .custom-dd-trigger {
    height: 30px;
    border-radius: 8px;
    font-size: 12px;
    padding: 0 8px;
    border: 1px solid transparent;
    background: transparent;
}

.grid-table .custom-dd.custom-dd-generic .custom-dd-trigger:hover,
.grid-table .custom-dd.custom-dd-generic.is-open .custom-dd-trigger {
    background: #f9fbfd;
    border-color: rgba(var(--brand-accent-blue-rgb), .4);
    box-shadow: none;
}

.grid-table .custom-dd.custom-dd-generic.custom-dd-generic-table {
    display: block;
    width: 100%;
    min-width: 100%;
}

.grid-table .custom-dd.custom-dd-generic.custom-dd-generic-table .custom-dd-trigger {
    width: 85px;
    min-width: 85px;
    max-width: 85px;
    margin: 0 auto;
}

.resource-table .custom-dd {
    position: relative;
}

.resource-table .custom-dd-trigger {
    width: 100%;
    height: 22px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
    padding: 0 8px;
    cursor: pointer;
}

.custom-dd.is-locked .custom-dd-trigger {
    background: #f7fafc;
    border-color: transparent;
    color: #6f8093;
    cursor: default;
}

.resource-table .custom-dd-trigger:disabled {
    background: #f7fafc;
    border-color: transparent;
    color: var(--text);
    cursor: default;
}

.resource-table .custom-dd-trigger:hover,
.resource-table .custom-dd.is-open .custom-dd-trigger {
    background: #f9fbfd;
    border-color: rgba(var(--brand-accent-blue-rgb), .4);
}

.resource-table .custom-dd-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.resource-table .custom-dd-caret {
    flex: 0 0 auto;
}

.index-page .resource-table tbody td {
    height: 56px;
}

.index-page .resource-table tbody td .cell {
    height: 56px;
}

.index-page .resource-table tbody tr.table-totals-row td,
.index-page .resource-table tbody tr.table-totals-row td .cell {
    height: var(--row-h);
}

.index-page .resource-table .resource-role-cell {
    display: grid;
    grid-template-rows: 1fr 1fr;
    align-content: center;
    gap: 2px;
    padding-top: 4px;
    padding-bottom: 4px;
}

.index-page .resource-table .resource-role-cell input,
.index-page .resource-table .resource-role-cell select {
    height: 22px;
    font-size: 12px;
}

.custom-dd-menu {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    z-index: 2147483647;
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    box-shadow: 0 10px 20px rgba(3, 38, 74, 0.14);
    overflow: hidden;
}

.custom-dd-menu .custom-dd-panels {
    width: 100%;
    display: grid;
    grid-template-columns: 100%;
    overflow: hidden;
}

.custom-dd-menu .custom-dd-panel {
    grid-column: 1;
    grid-row: 1;
    position: relative;
    left: 0;
    transition: left 400ms ease;
    will-change: left;
    width: 100%;
    background: #fff;
}

.custom-dd-menu .custom-dd-panel + .custom-dd-panel {
    left: 100%;
}

.custom-dd-menu .custom-dd-panel:first-child {
    left: 0;
}

.custom-dd-menu.is-search-mode .custom-dd-panel + .custom-dd-panel {
    left: 0;
}

.custom-dd-menu.is-search-mode .custom-dd-panel:first-child {
    left: -100%;
}

.custom-dd-menu .custom-dd-options {
    max-height: 160px;
    overflow: auto;
    padding: 4px;
}

.custom-dd-menu .custom-dd-group-divider {
    height: 1px;
    background: #e6edf4;
    margin: 0;
}

.custom-dd-menu .custom-dd-option,
.custom-dd-menu .custom-dd-empty {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    font-size: 12px;
    color: var(--text);
    padding: 7px 8px;
    border-radius: 6px;
}

.custom-dd-menu .custom-dd-option {
    cursor: pointer;
}

.custom-dd-menu .custom-dd-option:hover {
    background: #f1f7ff;
}

.custom-dd-menu .custom-dd-option.is-selected {
    background: #e8f6f7;
    color: #0f5e66;
    font-weight: 700;
}

.custom-dd-menu .custom-dd-empty {
    color: #8a97a6;
}

.custom-dd-menu .custom-dd-search-head {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    border-bottom: 1px solid #dce6f0;
    background: #fbfdff;
}

.custom-dd-menu .custom-dd-search-back,
.custom-dd-menu .custom-dd-open-search {
    height: 26px;
    border: 1px solid #d6e1ec;
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font-size: 12px;
    padding: 0 10px;
    cursor: pointer;
}

.custom-dd-menu .custom-dd-open-search {
    width: 100%;
}

.custom-dd-menu .custom-dd-search-back:hover,
.custom-dd-menu .custom-dd-open-search:hover {
    border-color: rgba(var(--brand-accent-blue-rgb), .5);
    background: #f4fbfc;
}

.custom-dd-menu .custom-dd-footer {
    border-top: 0;
    padding: 6px;
    background: #fbfdff;
}

.custom-dd-menu .custom-dd-search {
    width: 100%;
    height: 26px;
    border: 1px solid #d6e1ec;
    border-radius: 6px;
    background: #fff;
    font-size: 12px;
    padding: 0 8px;
    color: var(--text);
    outline: none;
}

.custom-dd-menu .custom-dd-search:focus {
    border-color: rgba(var(--brand-accent-blue-rgb), .5);
}

.custom-dd-menu .custom-dd-search:disabled {
    color: #8b99a8;
    background: #f5f8fb;
    cursor: default;
}

.date-range-picker-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.date-range-year-nav {
    width: 30px;
    height: 30px;
    border: 1px solid #d6e1ec;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.date-range-year-nav:hover {
    background: #f4f8fb;
}

.date-range-year-input {
    flex: 1 1 auto;
    height: 30px;
    border: 1px solid #d6e1ec;
    border-radius: 8px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    outline: none;
}

.date-range-year-input:focus {
    border-color: var(--brand-accent-blue);
}

.date-range-month-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.date-range-month-btn {
    height: 28px;
    border: 1px solid #d6e1ec;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.date-range-month-btn:hover {
    background: #f4f8fb;
}

.date-range-month-btn.is-selected {
    border-color: var(--brand-accent-blue);
    background: rgba(var(--brand-accent-blue-rgb), 0.16);
    color: #0d5b61;
}


body.dark-theme {
    --main-bg: #0B1220;
    --sidebar-bg: #111B2E;
    --sidebar-border: #2E405D;
    --panel-bg: #111B2E;
    --control-bg: #0B1220;
    --tr-bg: #111B2E;
    --gray-mid: #2E405D;
    --line: #2E405D;
    --line-strong: #3b4f70;
    --text: #E8EDF5;
    --muted: #a8b5c8;
    --accent-deep: #E8EDF5;
    --surface-hover: #1A2942;
    --preview-bg: #0B1220;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    background: var(--main-bg);
    color: var(--text);
}

body.dark-theme .main {
    background: var(--main-bg);
}

body.dark-theme .sidebar {
    background: var(--sidebar-bg);
    border-color: var(--sidebar-border);
}

body.dark-theme .profile-menu,
body.dark-theme .code-modal,
body.dark-theme .content-card,
body.dark-theme .panel,
body.dark-theme .card,
body.dark-theme .table-wrap,
body.dark-theme table,
body.dark-theme .admin-panel,
body.dark-theme .overview-card,
body.dark-theme .project-card,
body.dark-theme .fee-card {
    background: var(--panel-bg);
    color: var(--text);
    border-color: var(--gray-mid);
}

body.dark-theme .topbar {
    background: rgba(17, 27, 46, 0.9);
}

body.dark-theme .page-title,
body.dark-theme h1,
body.dark-theme h2,
body.dark-theme h3,
body.dark-theme h4,
body.dark-theme label,
body.dark-theme th,
body.dark-theme td,
body.dark-theme .profile-name,
body.dark-theme .code-modal-title {
    color: var(--text);
}

body.dark-theme .nav-item,
body.dark-theme .sub-nav-item,
body.dark-theme .profile-menu a,
body.dark-theme .profile-menu button,
body.dark-theme .profile-email,
body.dark-theme .code-copy-note {
    color: var(--muted);
}

body.dark-theme .nav-item:hover,
body.dark-theme .nav-item.active,
body.dark-theme .sub-nav-item:hover,
body.dark-theme .sub-nav-item.active,
body.dark-theme .profile-trigger:hover,
body.dark-theme .profile-trigger.open,
body.dark-theme .profile-menu a:hover,
body.dark-theme .profile-menu button:hover {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--gray-mid);
}

body.dark-theme input[type='text'],
body.dark-theme input[type='search'],
body.dark-theme input[type='number'],
body.dark-theme input[type='email'],
body.dark-theme input[type='password'],
body.dark-theme input[type='date'],
body.dark-theme input[type='month'],
body.dark-theme input[type='tel'],
body.dark-theme input[type='url'],
body.dark-theme select,
body.dark-theme textarea,
body.dark-theme .custom-dd-toggle,
body.dark-theme .custom-dd-menu,
body.dark-theme .code-modal-content {
    background: var(--control-bg);
    border-color: var(--gray-mid);
    color: var(--text);
}

body.dark-theme input:hover,
body.dark-theme select:hover,
body.dark-theme textarea:hover,
body.dark-theme .custom-dd-trigger:hover,
body.dark-theme input:focus,
body.dark-theme select:focus,
body.dark-theme textarea:focus {
    background: var(--surface-hover);
}

body.dark-theme thead th,
body.dark-theme .table-header,
body.dark-theme .summary-header {
    background: var(--gray-mid);
    color: var(--text);
    border-color: var(--gray-mid);
}

body.dark-theme .grid-table tbody td {
    background: var(--tr-bg);
}

body.dark-theme .grid-table tbody tr:hover td {
    background: var(--brand-primary);
}

body.dark-theme .app-data-table tbody tr:hover {
    background: var(--brand-primary);
}

body.dark-theme .grid-table tbody tr.table-totals-row td,
body.dark-theme .grid-table tbody tr.table-totals-row:hover td,
body.dark-theme .grid-table tbody tr.table-totals-row td.sticky,
body.dark-theme .grid-table tbody tr.table-totals-row td.month-cell-planned,
body.dark-theme .grid-table tbody tr.table-totals-row td.month-cell-actual {
    background: var(--gray-mid);
}

body.dark-theme.index-page .grid-table tbody tr:not(.table-totals-row) td.month-cell-actual,
body.dark-theme.index-page .grid-table tbody tr:not(.table-totals-row):hover td.month-cell-actual {
    background-color: #1A2942;
    background-image: radial-gradient(rgba(255, 255, 255, 0.16) 0.7px, transparent 0.7px);
}

body.dark-theme .grid-table tbody td.month-cell-out-of-range,
body.dark-theme .grid-table tbody tr:hover td.month-cell-out-of-range {
    background: var(--gray-dark);
    background-image: none;
}

body.dark-theme .custom-dd.custom-dd-generic .custom-dd-trigger {
    background: transparent;
}

body.dark-theme .custom-dd.is-locked .custom-dd-trigger {
    background: #0B1220;
}

body.dark-theme .resource-table .custom-dd-trigger:disabled {
    background: #0B1220;
    color: var(--text);
}

body.dark-theme .grid-table .custom-dd.custom-dd-generic .custom-dd-trigger:hover,
body.dark-theme .grid-table .custom-dd.custom-dd-generic.is-open .custom-dd-trigger,
body.dark-theme .resource-table .custom-dd-trigger:hover,
body.dark-theme .resource-table .custom-dd.is-open .custom-dd-trigger {
    background: var(--surface-hover);
}

body.dark-theme .custom-dd-menu .custom-dd-panel {
    background: var(--control-bg);
}

body.dark-theme .custom-dd-menu .custom-dd-options {
    scrollbar-width: thin;
    scrollbar-color: #415C77 transparent;
}

body.dark-theme .custom-dd-menu .custom-dd-options::-webkit-scrollbar {
    background: transparent;
}

body.dark-theme .custom-dd-menu .custom-dd-options::-webkit-scrollbar:horizontal {
    height: 12px;
}

body.dark-theme .custom-dd-menu .custom-dd-options::-webkit-scrollbar:vertical {
    width: 12px;
}

body.dark-theme .custom-dd-menu .custom-dd-options::-webkit-scrollbar-track,
body.dark-theme .custom-dd-menu .custom-dd-options::-webkit-scrollbar-corner {
    background: transparent;
}

body.dark-theme .custom-dd-menu .custom-dd-options::-webkit-scrollbar-thumb {
    background: #415C77;
    border: 2px solid transparent;
    border-radius: 999px;
    background-clip: content-box;
}

body.dark-theme .custom-dd-menu .custom-dd-option:hover {
    background: transparent;
}

body.dark-theme .custom-dd-menu .custom-dd-option.is-selected {
    background: #1A2942;
    color: var(--text);
}

body.dark-theme .custom-dd-menu .custom-dd-search-head,
body.dark-theme .custom-dd-menu .custom-dd-footer {
    background: var(--control-bg);
}

body.dark-theme .custom-dd-menu .custom-dd-search-back,
body.dark-theme .custom-dd-menu .custom-dd-open-search {
    background: var(--control-bg);
    border-color: var(--gray-mid);
    color: var(--text);
}

body.dark-theme .date-range-year-nav,
body.dark-theme .date-range-month-btn {
    background: #0B1220;
    border-color: var(--gray-mid);
    color: var(--text);
}

body.dark-theme .date-range-year-nav:hover,
body.dark-theme .date-range-month-btn:hover,
body.dark-theme .date-range-month-btn.is-selected {
    background: #1A2942;
}

body.dark-theme .date-range-month-btn.is-selected {
    border-color: var(--brand-accent-blue);
    color: var(--text);
}

body.dark-theme tr,
body.dark-theme td,
body.dark-theme th,
body.dark-theme .profile-divider {
    border-color: var(--gray-mid);
}

body.dark-theme tbody tr {
    background: #373D49;
}

body.dark-theme .readonly-cell {
    color: var(--text);
}

body.dark-theme .btn,
body.dark-theme .btn-primary {
    background: transparent;
    border-color: var(--gray-mid);
    color: var(--text);
    opacity: 1;
}

body.dark-theme .btn:hover,
body.dark-theme .btn-primary:hover {
    background: transparent;
    border-color: rgba(var(--brand-accent-blue-rgb), .75);
    box-shadow: 0 0 0 3px rgba(var(--brand-accent-blue-rgb), .12);
}

body.dark-theme .btn-secondary,
body.dark-theme .btn-admin-only {
    background: transparent;
    color: var(--text);
}

body.dark-theme .btn-secondary {
    border-color: var(--brand-accent-blue);
}

body.dark-theme .btn-secondary:link,
body.dark-theme .btn-secondary:visited {
    color: var(--text);
    text-decoration: none;
}

body.dark-theme .btn-secondary:hover {
    background: rgba(var(--brand-accent-blue-rgb), 0.14);
}

body.dark-theme .btn-admin-only {
    border-color: #3DDC84;
}

body.dark-theme .btn-admin-only:hover {
    background: rgba(61, 220, 132, 0.16);
}

body.dark-theme .code-modal-close {
    background: transparent;
    border-color: var(--brand-primary);
    color: var(--text);
}

body.dark-theme .code-modal-close:hover {
    background: rgba(var(--brand-accent-blue-rgb), 0.14);
    border-color: var(--brand-primary);
}

body.dark-theme .code-modal-head.modal-head-divider,
body.dark-theme .code-modal-actions-divider {
    border-color: var(--gray-mid);
}

body.dark-theme .code-modal-close.modal-close-secondary {
    background: transparent;
    color: var(--text);
    border-color: var(--brand-accent-blue);
}

body.dark-theme .code-modal-close.modal-close-secondary:hover {
    background: rgba(var(--brand-accent-blue-rgb), 0.14);
    border-color: var(--brand-accent-blue);
}

body.dark-theme .modal-panel-surface,
body.dark-theme #upsertProjectModalOverlay .upsert-project-options,
body.dark-theme #upsertProjectModalOverlay .upsert-project-tree-wrap,
body.dark-theme #upsertProjectModalOverlay .upsert-project-fees-display,
body.dark-theme #upsertProjectModalOverlay .upsert-date-picker {
    background: var(--panel-bg);
    border-color: var(--gray-mid);
}

body.dark-theme .preferences-panel {
    background: var(--panel-bg);
    border-color: var(--gray-mid);
}

body.dark-theme .preferences-column-theme {
    border-left-color: var(--gray-mid);
}

body.dark-theme .preferences-multiselect-option input[type="checkbox"] {
    background: rgba(var(--brand-accent-blue-rgb), 0.08);
    border-color: var(--gray-mid);
}

body.dark-theme .preferences-multiselect-option input[type="checkbox"]:checked {
    background: var(--brand-accent-blue);
    border-color: var(--brand-accent-blue);
}

body.dark-theme .preferences-theme-switch {
    background: rgba(var(--brand-accent-blue-rgb), 0.08);
    border-color: var(--gray-mid);
    color: var(--text);
}

body.dark-theme .preferences-theme-switch-track {
    border-color: var(--gray-mid);
    background: rgba(var(--brand-accent-blue-rgb), 0.2);
}

body.dark-theme .preferences-theme-switch-thumb {
    background: #ffffff;
}

body.dark-theme .preferences-theme-switch.is-dark {
    background: rgba(var(--brand-accent-blue-rgb), 0.08);
    border-color: var(--gray-mid);
    color: var(--text);
}

body.dark-theme .preferences-theme-switch.is-dark .preferences-theme-switch-track {
    border-color: var(--gray-mid);
    background: rgba(var(--brand-accent-blue-rgb), 0.2);
}

body.dark-theme .modal-step-pill {
    background: transparent;
    color: var(--muted);
    border-color: var(--gray-mid);
}

body.dark-theme .modal-step-pill:hover,
body.dark-theme .modal-step-pill.is-active,
body.dark-theme .modal-step-pill.is-complete {
    background: var(--surface-hover);
    color: var(--text);
    border-color: rgba(var(--brand-accent-blue-rgb), .75);
}

body.dark-theme .modal-step-pill.is-skipped {
    background: transparent;
    color: var(--muted);
    border-color: var(--gray-mid);
}

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

    .preferences-column-theme {
        padding-left: 0;
        border-left: 0;
        padding-top: 12px;
        border-top: 1px solid #d7e5f1;
    }

    body.dark-theme .preferences-column-theme {
        border-top-color: var(--gray-mid);
    }
}

body.dark-theme .modal-section-title,
body.dark-theme #upsertProjectModalOverlay :is(
    .upsert-project-scopes-description-heading,
    .upsert-project-scopes-rate-heading,
    .upsert-project-progress-note,
    .upsert-project-fee-name,
    .upsert-project-fee-amount,
    .upsert-project-tree-label,
    .upsert-currency-prefix,
    .upsert-date-picker-day-name,
    .upsert-project-date-trigger,
    .upsert-project-option-field > label
) {
    color: var(--text);
}

body.dark-theme #upsertProjectModalOverlay :is(
    .upsert-project-text-input,
    .upsert-project-date-input,
    .upsert-rate-amount-input,
    .upsert-proposal-item-input,
    .upsert-date-picker-title,
    .upsert-date-picker-nav,
    .upsert-date-picker-day,
    .upsert-currency-input-wrap
) {
    background: transparent;
    border-color: var(--gray-mid);
    color: var(--text);
}

body.dark-theme #upsertProjectModalOverlay :is(
    .upsert-project-text-input:disabled,
    .upsert-rate-amount-input:disabled,
    .upsert-proposal-item-input:disabled
) {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--gray-mid);
    color: var(--muted);
}

body.dark-theme #upsertProjectModalOverlay :is(
    .upsert-project-text-input:hover,
    .upsert-project-date-input:hover,
    .upsert-rate-amount-input:hover,
    .upsert-proposal-item-input:hover,
    .upsert-currency-input-wrap:hover,
    .upsert-project-text-input:focus,
    .upsert-project-date-input:focus,
    .upsert-rate-amount-input:focus,
    .upsert-proposal-item-input:focus,
    .upsert-currency-input-wrap:focus-within
) {
    background: transparent;
    border-color: rgba(var(--brand-accent-blue-rgb), .75);
    box-shadow: 0 0 0 3px rgba(var(--brand-accent-blue-rgb), .12);
}

body.dark-theme #upsertProjectModalOverlay :is(
    .upsert-date-picker-nav:hover,
    .upsert-date-picker-day:hover,
    .upsert-generic-date-picker-nav:hover
) {
    background: transparent;
    border-color: rgba(var(--brand-accent-blue-rgb), .75);
    box-shadow: 0 0 0 3px rgba(var(--brand-accent-blue-rgb), .12);
}

body.dark-theme #upsertProjectModalOverlay .upsert-date-picker {
    background: var(--panel-bg);
    border-color: var(--gray-mid);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

body.dark-theme .upsert-date-picker {
    background: var(--panel-bg);
    border-color: var(--gray-mid);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

body.dark-theme .upsert-date-picker :is(
    .upsert-date-picker-title,
    .upsert-date-picker-nav,
    .upsert-date-picker-day
) {
    background: transparent;
    border-color: var(--gray-mid);
    color: var(--text);
}

body.dark-theme .upsert-date-picker .upsert-date-picker-day-name {
    color: var(--text);
}

body.dark-theme .upsert-date-picker :is(
    .upsert-date-picker-nav:hover,
    .upsert-date-picker-day:hover
) {
    background: transparent;
    border-color: rgba(var(--brand-accent-blue-rgb), .75);
    box-shadow: 0 0 0 3px rgba(var(--brand-accent-blue-rgb), .12);
}

body.dark-theme #upsertProjectModalOverlay .upsert-date-picker-day.is-selected {
    background: rgba(var(--brand-accent-blue-rgb), 0.16);
    border-color: var(--brand-accent-blue);
    color: var(--text);
}

body.dark-theme .upsert-date-picker .upsert-date-picker-day.is-selected {
    background: rgba(var(--brand-accent-blue-rgb), 0.16);
    border-color: var(--brand-accent-blue);
    color: var(--text);
}

body.dark-theme #upsertProjectModalOverlay .upsert-date-picker-day.is-today {
    border-color: rgba(var(--brand-accent-blue-rgb), .75);
}

body.dark-theme .upsert-date-picker .upsert-date-picker-day.is-today {
    border-color: rgba(var(--brand-accent-blue-rgb), .75);
}

body.dark-theme #upsertProjectModalOverlay :is(
    .upsert-project-options .rate-dependency-option:hover,
    .upsert-project-options .rate-dependency-option.is-selected,
    #upsertProposalStatusGroup .rate-dependency-option:hover,
    #upsertProposalStatusGroup .rate-dependency-option.is-selected
) {
    background: var(--surface-hover);
    border-color: rgba(var(--brand-accent-blue-rgb), .75);
    color: var(--text);
}

body.dark-theme #upsertProjectModalOverlay :is(
    .upsert-project-options .rate-dependency-icon,
    #upsertProposalStatusGroup .rate-dependency-icon,
    #upsertProposalStatusGroup .rate-dependency-icon svg
) {
    color: var(--muted);
    stroke: currentColor;
}

body.dark-theme #upsertProjectModalOverlay :is(
    .upsert-project-options .rate-dependency-option:hover .rate-dependency-icon,
    .upsert-project-options .rate-dependency-option.is-selected .rate-dependency-icon,
    #upsertProposalStatusGroup .rate-dependency-option:hover .rate-dependency-icon,
    #upsertProposalStatusGroup .rate-dependency-option:hover .rate-dependency-icon svg,
    #upsertProposalStatusGroup .rate-dependency-option.is-selected .rate-dependency-icon,
    #upsertProposalStatusGroup .rate-dependency-option.is-selected .rate-dependency-icon svg
) {
    color: var(--brand-accent-blue);
    stroke: currentColor;
}

body.dark-theme #upsertProjectModalOverlay .upsert-bu-rate-display {
    background: var(--surface-hover);
    border-color: var(--gray-mid);
    color: var(--muted);
}

body.dark-theme #upsertProjectModalOverlay :is(
    .upsert-project-tree-item-scope.is-locked .upsert-project-tree-label,
    .upsert-project-tree-item-scope.is-disabled .upsert-project-tree-label,
    .upsert-project-tree-toggle[disabled],
    .upsert-project-tree-toggle.is-locked,
    .upsert-project-tree-toggle.is-disabled
) {
    color: var(--muted);
}

body.dark-theme #upsertProjectModalOverlay .upsert-project-success-text {
    color: var(--text);
}

body.dark-theme .planned-fee-under-budget {
    color: #3DDC84 !important;
}

body.dark-theme .planned-fee-over-budget {
    color: #FF5C5C !important;
}

body.dark-theme hr,
body.dark-theme .divider {
    border-color: var(--gray-mid);
}

body.dark-theme code,
body.dark-theme pre,
body.dark-theme kbd,
body.dark-theme samp {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--gray-mid);
}

body.dark-theme mark,
body.dark-theme .pill,
body.dark-theme .badge,
body.dark-theme .tag {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--gray-mid);
}

body.dark-theme option,
body.dark-theme optgroup {
    background: var(--control-bg);
    color: var(--text);
}

body.dark-theme::selection {
    background: rgba(61, 220, 132, 0.28);
    color: var(--text);
}

:is(.fee-matrix-export-menu, .pfp-export-menu, .prp-export-menu) {
    min-width: 150px;
    padding: 6px;
    background: var(--panel-bg);
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    box-shadow: var(--menu-shadow);
    z-index: 2147483647;
}

:is(.pfp-tools-menu, .prp-tools-menu, .fee-matrix-tools-menu, .pfp-tools-submenu, .prp-tools-submenu, .fee-matrix-tools-submenu) {
    min-width: 170px;
    padding: 6px;
    background: var(--panel-bg);
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    box-shadow: var(--menu-shadow);
    z-index: 2147483647;
}

:is(.pfp-tools-option, .prp-tools-option, .fee-matrix-tools-option) {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--brand-primary);
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

:is(.pfp-tools-option, .prp-tools-option, .fee-matrix-tools-option):hover {
    background: rgba(var(--brand-accent-blue-rgb), 0.12);
}

:is(.pfp-tools-option, .prp-tools-option, .fee-matrix-tools-option).is-disabled,
:is(.pfp-tools-option, .prp-tools-option, .fee-matrix-tools-option)[disabled] {
    color: #8a97a6;
    cursor: not-allowed;
}

:is(.pfp-tools-option, .prp-tools-option, .fee-matrix-tools-option).is-disabled:hover,
:is(.pfp-tools-option, .prp-tools-option, .fee-matrix-tools-option)[disabled]:hover {
    background: transparent;
}

:is(.pfp-tools-menu-wrap, .prp-tools-menu-wrap, .fee-matrix-tools-menu-wrap),
:is(.pfp-tools-submenu-wrap, .prp-tools-submenu-wrap, .fee-matrix-tools-submenu-wrap) {
    position: relative;
}

:is(.pfp-tools-menu, .prp-tools-menu, .fee-matrix-tools-menu) {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
}

:is(.pfp-tools-submenu, .prp-tools-submenu, .fee-matrix-tools-submenu) {
    position: absolute;
    top: -6px;
    left: calc(100% + 8px);
}

:is(.pfp-tools-trigger, .prp-tools-trigger, .fee-matrix-tools-trigger) {
    min-width: 116px;
    justify-content: space-between;
}

:is(.pfp-tools-divider, .prp-tools-divider, .fee-matrix-tools-divider) {
    width: 1px;
    align-self: stretch;
    background: var(--line-strong);
    opacity: 0.9;
}

:is(.pfp-tools-caret, .prp-tools-caret, .fee-matrix-tools-caret) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
}

:is(.pfp-tools-caret, .prp-tools-caret, .fee-matrix-tools-caret) svg {
    width: 14px;
    height: 14px;
}

.history-modal {
    width: min(940px, 92vw);
    max-height: 88vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.history-filters {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(var(--brand-accent-blue-rgb), 0.06), transparent);
}

.history-filters label {
    display: grid;
    gap: 6px;
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 700;
}

.history-filters input,
.history-filters select {
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--line);
    padding: 0 10px;
    font-size: 13px;
    background: #fff;
}

.history-list {
    padding: 14px 16px 18px;
    overflow: auto;
}

.history-entry {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    padding: 10px 12px;
}

.history-entry + .history-entry {
    margin-top: 10px;
}

.history-entry-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: baseline;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 8px;
}

.history-entry-line {
    font-size: 13px;
    color: var(--text);
    line-height: 1.45;
}

.history-tree-line {
    display: block;
    font-size: 13px;
    line-height: 1.45;
}

.history-tree-line.level-0 {
    padding-left: 0;
}

.history-tree-line.level-1 {
    padding-left: 14px;
}

.history-tree-line.level-2 {
    padding-left: 28px;
}

.history-tree-line.level-3 {
    padding-left: 42px;
}

.history-empty {
    border: 1px dashed var(--line-strong);
    border-radius: 10px;
    padding: 18px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

.collaborator-list-plain {
    list-style: none;
    margin: 0;
    padding: 0;
}

.collaborator-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 2px;
    border-bottom: 1px solid var(--line);
}

.collaborator-list-item:last-child {
    border-bottom: 0;
}

.collaborator-list-name {
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
}

.collaborator-list-item .collaborator-remove-btn {
    border: 0;
    background: transparent;
    padding: 0;
    min-height: 0;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
}

.collaborator-list-item .collaborator-remove-btn:hover {
    color: #b42318;
    text-decoration: underline;
}

:is(.fee-matrix-export-option, .pfp-export-option, .prp-export-option) {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--brand-primary);
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
}

:is(.fee-matrix-export-option, .pfp-export-option, .prp-export-option):hover {
    background: rgba(var(--brand-accent-blue-rgb), 0.12);
}

:is(.fee-matrix-export-option, .pfp-export-option, .prp-export-option).is-disabled,
:is(.fee-matrix-export-option, .pfp-export-option, .prp-export-option)[disabled] {
    color: #8a97a6;
    cursor: not-allowed;
}

:is(.fee-matrix-export-option, .pfp-export-option, .prp-export-option).is-disabled:hover,
:is(.fee-matrix-export-option, .pfp-export-option, .prp-export-option)[disabled]:hover {
    background: transparent;
}

:is(.fee-matrix-export-preview-surface, .pfp-export-preview-surface, .prp-export-preview-surface) {
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    background: var(--preview-bg);
    display: grid;
    grid-template-rows: auto 1fr;
}

:is(.fee-matrix-export-preview-toolbar, .pfp-export-preview-toolbar, .prp-export-preview-toolbar) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #d4deea;
    background: var(--panel-bg);
}

:is(.fee-matrix-export-preview-title, .pfp-export-preview-title, .prp-export-preview-title) {
    font-size: 13px;
    font-weight: 700;
    color: #22384f;
}

:is(.fee-matrix-export-preview-note, .pfp-export-preview-note, .prp-export-preview-note) {
    font-size: 12px;
    color: var(--text);
}

:is(.fee-matrix-export-preview-close, .pfp-export-preview-close, .prp-export-preview-close) {
    height: 30px;
    border-radius: 8px;
    border: 1px solid #c7d5e4;
    background: var(--panel-bg);
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    padding: 0 12px;
    cursor: pointer;
}

:is(.fee-matrix-export-preview-close, .pfp-export-preview-close, .prp-export-preview-close):hover {
    background: var(--surface-hover);
}

:is(.fee-matrix-export-preview-canvas, .pfp-export-preview-canvas, .prp-export-preview-canvas) {
    overflow: auto;
    padding: 16px;
}

:is(.fee-matrix-export-render-host, .pfp-export-render-host, .prp-export-render-host) {
    position: fixed;
    left: 0;
    top: 0;
    opacity: 0;
    pointer-events: none;
    z-index: -1;
    background: var(--panel-bg);
}

:is(.fee-matrix-export-snapshot, .pfp-export-snapshot, .prp-export-snapshot) {
    background: var(--panel-bg);
    color: var(--text);
}

:is(.fee-matrix-export-snapshot, .pfp-export-snapshot, .prp-export-snapshot) .panel {
    box-shadow: none;
}

body.dark-theme :is(
    .fee-matrix-export-menu,
    .pfp-export-menu,
    .prp-export-menu,
    .fee-matrix-export-preview-toolbar,
    .prp-export-preview-toolbar,
    .pfp-export-preview-surface,
    .prp-export-preview-surface,
    .fee-matrix-export-preview-surface,
    .pfp-export-render-host,
    .prp-export-render-host,
    .fee-matrix-export-render-host,
    .pfp-export-snapshot,
    .prp-export-snapshot,
    .fee-matrix-export-snapshot,
    .pfp-export-preview-canvas .pfp-export-snapshot,
    .prp-export-preview-canvas .prp-export-snapshot,
    .fee-matrix-export-preview-canvas .fee-matrix-export-snapshot,
    .kpis,
    .section-block,
    .panel.section-block,
    .resource-table,
    .resource-table td,
    .resource-table th,
    .grid-table,
    .grid-table td,
    .grid-table th,
    .custom-dd-menu,
    .custom-dd-menu .custom-dd-panel,
    .custom-dd-menu .custom-dd-options,
    .custom-dd-menu .custom-dd-empty,
    .task-picker-menu,
    .task-picker-option,
    .month-rate-menu,
    .month-rate-editor,
    .month-rate-save-menu,
    .month-rate-save-future,
    .month-rate-tooltip,
    .date-range-picker,
    .date-range-year-nav,
    .date-range-year-input,
    .date-range-month-btn,
    .global-range-field .date-range-cell
) {
    background: var(--panel-bg);
    border-color: var(--gray-mid);
    color: var(--text);
}

body.dark-theme :is(
    .fee-matrix-export-option,
    .pfp-export-option,
    .prp-export-option,
    .fee-matrix-export-preview-close,
    .pfp-export-preview-close,
    .prp-export-preview-close,
    .custom-dd-menu .custom-dd-option,
    .task-picker-option,
    .month-rate-action,
    .month-rate-save-future,
    .date-range-month-btn,
    .date-range-year-nav
) {
    color: var(--text);
}

body.dark-theme :is(
    .fee-matrix-export-option,
    .pfp-export-option,
    .prp-export-option,
    .fee-matrix-export-preview-close,
    .pfp-export-preview-close,
    .prp-export-preview-close,
    .custom-dd-menu .custom-dd-option,
    .task-picker-option,
    .month-rate-action,
    .month-rate-save-future,
    .date-range-month-btn,
    .date-range-year-nav
):hover {
    background: var(--surface-hover);
}

body.dark-theme :is(.fee-matrix-export-preview-title, .pfp-export-preview-title, .prp-export-preview-title) {
    color: var(--text);
}

body.dark-theme :is(.fee-matrix-export-preview-note, .pfp-export-preview-note, .prp-export-preview-note) {
    color: var(--muted);
}

body.dark-theme :is(.month-rate-save, .month-rate-save-caret) {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--gray-mid);
}

body.dark-theme .resource-table td .cell-indicator > span,
body.dark-theme .index-page .grid-table td .cell .cell-indicator > span,
body.dark-theme .admin-rates-value-cell .cell-indicator > span,
body.dark-theme .admin-rates-percent-cell .cell-indicator > span {
    text-shadow: 0 0 0 1px var(--panel-bg);
}

.theme-toggle-btn {
    gap: 10px;
    justify-content: flex-start !important;
}

.theme-toggle-btn:disabled {
    cursor: wait;
    opacity: 0.7;
}

.theme-toggle-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 18px;
}

.theme-toggle-icon svg {
    width: 18px;
    height: 18px;
    display: block;
}

input::placeholder,
textarea::placeholder,
select::placeholder,
body.dark-theme input::placeholder,
body.dark-theme textarea::placeholder,
body.dark-theme select::placeholder,
body.dark-theme .custom-dd-menu .custom-dd-search::placeholder {
    color: var(--text);
    opacity: 1;
}
