.pf-ui-root {
    --pf-font-ui: "Segoe UI", Tahoma, Arial, sans-serif;
    --pf-font-number: Consolas, "Courier New", monospace;
    --pf-color-panel: #f4f6f8;
    --pf-color-surface: #ffffff;
    --pf-color-surface-alt: #f7f9fb;
    --pf-color-header: #e6ebf1;
    --pf-color-row: #ffffff;
    --pf-color-row-alt: #f1f6fb;
    --pf-color-row-highlight: #fff1a8;
    --pf-color-border: #b8c2cc;
    --pf-color-border-strong: #8f9aa6;
    --pf-color-text: #15202b;
    --pf-color-text-muted: #5d6975;
    --pf-color-focus: #2f6fa8;
    --pf-color-focus-soft: #e7f1fb;
    --pf-color-danger: #a53c31;
    --pf-input-height: 1.85rem;
    --pf-focus-ring: 0 0 0 2px rgba(47, 111, 168, 0.24);
    --pf-dialog-padding: 0.9rem;
    --pf-dialog-width-sm: min(26rem, calc(100vw - 2rem));
    --pf-dialog-width-md: min(34rem, calc(100vw - 2rem));
    --pf-dialog-width-lg: min(52rem, calc(100vw - 1rem));
    --pf-dialog-width-xl: min(78rem, calc(100vw - 1rem));
    --pf-report-width: min(90vw, calc(100vw - 1rem));
    --pf-report-height: min(90vh, calc(100vh - 1rem));
    --pf-shadow-dialog: 0 14px 30px rgba(16, 24, 32, 0.24);
    font-family: var(--pf-font-ui);
    color: var(--pf-color-text);
}

/* Dialog composition:
   .pf-ui-dialog provides base chrome only.
   Combine size, padding, body, and scroll helpers per dialog layout. */
.pf-ui-dialog {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    border: 1px solid var(--pf-color-border-strong);
    outline: 1px solid #ffffff;
    background: var(--pf-color-panel);
    color: var(--pf-color-text);
    font-family: var(--pf-font-ui);
    box-shadow: var(--pf-shadow-dialog);
    box-sizing: border-box;
    isolation: isolate;
    border-radius: 0;
}

.pf-ui-dialog-sm {
    width: var(--pf-dialog-width-sm);
}

.pf-ui-dialog-md {
    width: var(--pf-dialog-width-md);
}

.pf-ui-dialog-lg {
    width: var(--pf-dialog-width-lg);
}

.pf-ui-dialog-xl {
    width: var(--pf-dialog-width-xl);
}

.pf-ui-dialog-report {
    width: var(--pf-report-width);
    height: var(--pf-report-height);
    min-width: 0;
    min-height: 0;
}

.pf-ui-dialog-pad {
    padding: var(--pf-dialog-padding);
}

.pf-ui-dialog-compact {
    gap: 0.55rem;
    max-height: min(82vh, calc(100vh - 1rem));
    overflow: hidden;
}

.pf-ui-dialog-body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.pf-ui-dialog-body-scroll {
    overflow: auto;
}

.pf-ui-dialog-fill {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
}

.pf-ui-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--pf-dialog-padding);
    background: rgba(18, 24, 32, 0.58);
    z-index: 1100;
}

.pf-ui-window {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    background: var(--pf-color-panel);
    overflow: hidden;
    box-sizing: border-box;
}

.pf-ui-title {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.15;
    color: var(--pf-color-text);
}

.pf-ui-section {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.65rem;
    border: 1px solid var(--pf-color-border);
    background: var(--pf-color-surface-alt);
    box-sizing: border-box;
}

.pf-ui-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1f1f1f;
}

.pf-ui-readout,
.pf-ui-message {
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--pf-color-border);
    background: var(--pf-color-surface-alt);
    box-sizing: border-box;
}

.pf-ui-readout {
    font-family: var(--pf-font-number);
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

.pf-ui-message {
    font-size: 0.92rem;
    line-height: 1.3;
}

.pf-ui-grid {
    display: grid;
    gap: 0.6rem 0.75rem;
    min-width: 0;
}

.pf-ui-compact-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem 0.75rem;
    min-width: 0;
    padding: 0.55rem;
    border: 1px solid var(--pf-color-border);
    background: var(--pf-color-surface-alt);
    overflow-y: auto;
}

.pf-ui-compact-row {
    display: grid;
    grid-template-columns: minmax(7.5rem, 0.8fr) minmax(9rem, 1fr);
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

.pf-ui-compact-check-row {
    display: grid;
    grid-template-columns: 1fr;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

.pf-ui-compact-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

.pf-ui-compact-form .pf-ui-compact-label {
    min-width: 0;
}

.pf-ui-compact-control {
    width: 100%;
    min-width: 0;
    min-height: var(--pf-input-height);
}

.pf-ui-compact-form .pf-ui-compact-control,
.pf-ui-compact-form .pf-ui-input,
.pf-ui-compact-form .pf-ui-select {
    min-width: 0;
}

.pf-ui-form {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    min-width: 0;
    padding: 0.55rem;
    border: 1px solid var(--pf-color-border);
    background: var(--pf-color-surface-alt);
    overflow-y: auto;
    box-sizing: border-box;
}

.pf-ui-form-row,
.pf-ui-form-row-extra,
.pf-ui-form-row-pair,
.pf-ui-form-row-wide {
    display: grid;
    align-items: center;
    gap: 0.35rem 0.55rem;
    min-width: 0;
}

.pf-ui-form-row {
    grid-template-columns: minmax(7.5rem, 0.35fr) minmax(10rem, 1fr);
}

.pf-ui-form-row-extra {
    grid-template-columns: minmax(7.5rem, 0.35fr) minmax(10rem, 1fr) auto;
}

.pf-ui-form-row-pair {
    grid-template-columns: minmax(7.5rem, 0.35fr) minmax(8rem, 0.75fr) minmax(6.5rem, 0.35fr) minmax(8rem, 0.75fr);
}

.pf-ui-form-row-wide {
    grid-template-columns: minmax(7.5rem, 0.25fr) minmax(18rem, 1fr);
    grid-column: 1 / -1;
}

.pf-ui-form-check-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

.pf-ui-form-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

.pf-ui-form-control {
    width: 100%;
    min-width: 0;
    min-height: var(--pf-input-height);
}

.pf-ui-form .pf-ui-form-control,
.pf-ui-form .pf-ui-input,
.pf-ui-form .pf-ui-select {
    min-width: 0;
}

.pf-ui-form-extra {
    justify-self: start;
}

.pf-ui-field {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    color: #333;
}

.pf-ui-field-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.pf-ui-field-label {
    min-width: 5.8rem;
    font-weight: 700;
}

.pf-ui-field-suffix {
    color: #555;
}

.pf-ui-field input[type="number"] {
    width: 4.75rem;
    padding: 0.22rem 0.35rem;
    border: 1px solid var(--pf-color-border);
    background: var(--pf-color-surface);
    color: var(--pf-color-text);
    box-sizing: border-box;
    font-family: var(--pf-font-number);
    font-variant-numeric: tabular-nums;
}

.pf-ui-field input[type="checkbox"] {
    margin: 0;
}

.pf-ui-button {
    border: 1px solid var(--pf-color-border-strong);
    background: linear-gradient(180deg, #ffffff 0%, var(--pf-color-header) 100%);
    color: var(--pf-color-text);
    padding: 0.34rem 0.9rem;
    cursor: pointer;
    font: inherit;
}

.pf-ui-button:hover:not(:disabled) {
    background: linear-gradient(180deg, #ffffff 0%, var(--pf-color-surface-alt) 100%);
}

.pf-ui-button:focus-visible,
.pf-ui-summary-card:focus-visible {
    outline: none;
    box-shadow: var(--pf-focus-ring);
}

.pf-ui-button:disabled {
    cursor: wait;
    opacity: 0.7;
}

.pf-ui-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

/* Global toolbar styling keeps the extracted finance toolbar consistent after CSS isolation boundaries. */
.pf-toolbar-shell {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0 0.25rem;
}

.pf-toolbar-tabs {
    display: flex;
    align-items: stretch;
    gap: 0.35rem;
    flex-wrap: wrap;
    padding: 0.1rem 0.1rem 0 0.1rem;
    border-bottom: 1px solid #bdbdbd;
}

button.pf-toolbar-tab {
    min-width: 6.25rem;
    padding: 0.42rem 0.95rem 0.48rem 0.95rem;
    border: 1px solid #a7a7a7;
    border-bottom: none;
    background: linear-gradient(180deg, #f8f8f8 0%, #e9e9e9 100%);
    color: #222;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    box-shadow: inset 1px 1px 0 #ffffff;
}

button.pf-toolbar-tab:hover {
    background: linear-gradient(180deg, #ffffff 0%, #ececec 100%);
}

button.pf-toolbar-tab.is-active {
    background: #ffffff;
    position: relative;
    top: 1px;
    z-index: 1;
    border-color: #8f8f8f;
    box-shadow: none;
}

.pf-toolbar-panel {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    padding: 0.55rem 0.5rem 0.5rem 0.5rem;
    border: 1px solid #bdbdbd;
    border-top: none;
    background: linear-gradient(180deg, #ffffff 0%, #f5f5f5 100%);
}

.pf-toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    min-height: 2.4rem;
}

label.pf-toolbar-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2.2rem;
    padding: 0.35rem 0.65rem;
    border: 1px solid #a7a7a7;
    background: linear-gradient(180deg, #ffffff 0%, #f3f3f3 100%);
    box-shadow: inset 1px 1px 0 #ffffff;
    color: #111;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.9rem;
    user-select: none;
}

.pf-toolbar-checkbox input {
    margin: 0;
}

.pf-toolbar-status {
    color: #4f5d6e;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.88rem;
}

.pf-toolbar-error {
    color: #b00020;
}

button.pf-add-transaction-button {
    min-width: 9rem;
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--pf-color-border-strong);
    background: linear-gradient(180deg, #ffffff 0%, var(--pf-color-header) 100%);
    color: var(--pf-color-text);
    cursor: pointer;
    font-family: var(--pf-font-ui);
    font-size: 0.88rem;
    transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease, color 120ms ease;
}

.pf-toolbar-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.pf-button-icon {
    width: 1rem;
    height: 1rem;
    flex: 0 0 auto;
    object-fit: contain;
}

.pf-button-text {
    line-height: 1.1;
}

button.pf-add-transaction-button:hover {
    background: linear-gradient(180deg, #ffffff 0%, var(--pf-color-surface-alt) 100%);
}

button.pf-add-transaction-button:focus-visible {
    outline: none;
    border-color: var(--pf-color-focus);
    box-shadow: var(--pf-focus-ring);
}

button.pf-add-transaction-button:disabled {
    cursor: not-allowed;
    opacity: 0.62;
}

.pf-ui-button-primary {
    border-color: var(--pf-color-focus);
    background: linear-gradient(180deg, #eff6fd 0%, var(--pf-color-focus-soft) 100%);
}

.pf-ui-button-compact {
    min-width: 2.8rem;
    padding: 0.25rem 0.5rem;
}

.pf-ui-step-row {
    display: grid;
    grid-template-columns: minmax(5rem, 1fr) auto auto minmax(3rem, auto);
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.pf-ui-step-value {
    text-align: right;
    font-family: var(--pf-font-number);
    font-variant-numeric: tabular-nums;
}

.pf-ui-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    min-width: 0;
}

.pf-ui-summary-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    min-height: 5.6rem;
    border: 1px solid var(--pf-color-border);
    background: linear-gradient(180deg, #ffffff 0%, var(--pf-color-surface-alt) 100%);
    padding: 0.55rem 0.7rem;
    color: var(--pf-color-text);
    cursor: pointer;
    text-align: left;
    font: inherit;
}

.pf-ui-summary-card[aria-pressed="true"],
.pf-ui-summary-card.is-active {
    border-color: var(--pf-color-focus);
    background: linear-gradient(180deg, #eff6fd 0%, var(--pf-color-focus-soft) 100%);
}

.pf-ui-summary-label {
    font-size: 0.86rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #666;
}

.pf-ui-summary-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    font-family: var(--pf-font-number);
    font-variant-numeric: tabular-nums;
}

.pf-ui-summary-detail {
    color: #555;
    font-size: 0.82rem;
    line-height: 1.15;
}

.pf-ui-panel {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    border: 1px solid var(--pf-color-border);
    background: var(--pf-color-surface);
}

.pf-ui-sf-grid .e-grid {
    border: 0;
    color: var(--pf-color-text);
    font-family: var(--pf-font-ui);
}

.pf-ui-sf-grid .e-grid .e-gridheader,
.pf-ui-sf-grid .e-grid .e-headercontent,
.pf-ui-sf-grid .e-grid .e-headercell {
    background: var(--pf-color-header) !important;
}

.pf-ui-sf-grid .e-grid .e-gridheader,
.pf-ui-sf-grid .e-grid .e-headercontent {
    border-color: var(--pf-color-border) !important;
}

.pf-ui-sf-grid .e-grid .e-headercell,
.pf-ui-sf-grid .e-grid .e-rowcell {
    border-color: var(--pf-color-border) !important;
}

.pf-ui-sf-grid .e-grid .e-headercelldiv {
    color: var(--pf-color-text);
    font-weight: 700;
}

.pf-ui-sf-grid .e-grid .e-rowcell {
    color: var(--pf-color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pf-ui-row-stripes.e-grid .e-row:nth-child(odd) .e-rowcell,
.pf-ui-row-stripes .e-grid .e-row:nth-child(odd) .e-rowcell,
.pf-ui-list-stripes .e-list-item:nth-child(odd) .pf-ui-list-row,
.pf-ui-table-stripes tbody tr:nth-child(odd) td {
    background-color: var(--pf-color-row);
}

.pf-ui-row-stripes.e-grid .e-row:nth-child(even) .e-rowcell,
.pf-ui-row-stripes .e-grid .e-row:nth-child(even) .e-rowcell,
.pf-ui-list-stripes .e-list-item:nth-child(even) .pf-ui-list-row,
.pf-ui-table-stripes tbody tr:nth-child(even) td {
    background-color: var(--pf-color-row-alt);
}

.pf-ui-row-base,
.pf-ui-list-row.pf-ui-row-base,
.pf-ui-table-row.pf-ui-row-base > td {
    background-color: var(--pf-color-row);
}

.pf-ui-row-alt,
.pf-ui-list-row.pf-ui-row-alt,
.pf-ui-table-row.pf-ui-row-alt > td {
    background-color: var(--pf-color-row-alt);
}

.pf-ui-row-highlight,
.pf-ui-table-row.pf-ui-row-highlight > td {
    background-color: var(--pf-color-row-highlight);
}

.pf-ui-table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
    table-layout: fixed;
}

.pf-ui-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--pf-color-header);
    border-bottom: 1px solid var(--pf-color-border);
    color: #333;
    text-align: left;
    font-weight: 700;
}

.pf-ui-table th,
.pf-ui-table td {
    padding: 0.32rem 0.45rem;
    border-bottom: 1px solid var(--pf-color-border);
    border-right: 1px solid var(--pf-color-border);
    vertical-align: top;
    min-width: 0;
}

.pf-ui-table th:last-child,
.pf-ui-table td:last-child {
    border-right: 0;
}

.pf-ui-cell {
    overflow: hidden;
}

.pf-ui-cell-text {
    display: block;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.pf-ui-text-clip,
.pf-ui-cell-clip {
    display: block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pf-ui-cell-emphasis .pf-ui-cell-text {
    font-weight: 700;
}

.pf-ui-input,
.pf-ui-select {
    width: 100%;
    min-width: 0;
    height: var(--pf-input-height);
    border: 1px solid var(--pf-color-border);
    border-radius: 0.15rem;
    padding: 0 0.25rem;
    background: var(--pf-color-surface);
    color: var(--pf-color-text);
    box-sizing: border-box;
    font: inherit;
}

.pf-ui-select {
    appearance: auto;
}

.pf-ui-input:focus,
.pf-ui-select:focus {
    outline: none;
    border-color: var(--pf-color-focus);
    box-shadow: var(--pf-focus-ring);
}

.pf-ui-check-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

.pf-ui-number {
    text-align: right;
    font-family: var(--pf-font-number);
    font-variant-numeric: tabular-nums;
}

.pf-ui-empty,
.pf-ui-status,
.pf-ui-error {
    padding: 1rem;
    font-family: var(--pf-font-ui);
}

.pf-ui-empty {
    color: #333;
}

.pf-ui-status {
    color: var(--pf-color-text-muted);
}

.pf-ui-error {
    color: var(--pf-color-danger);
}

@media (max-width: 720px) {
    .pf-ui-compact-form,
    .pf-ui-compact-row,
    .pf-ui-form-row,
    .pf-ui-form-row-extra,
    .pf-ui-form-row-pair,
    .pf-ui-form-row-wide {
        grid-template-columns: 1fr;
    }

    .pf-ui-form-row-wide {
        grid-column: auto;
    }

    .pf-ui-step-row {
        grid-template-columns: 1fr auto auto auto;
    }
}
