/* ==================================================
   TREASURY
   ================================================== */

.treasury-stack {
    display: grid;
    gap: 12px;
    min-width: 0;
}

/* Tighter padding for the always-visible top dashboard only (launcher,
   OVERVIEW, BUDGET PULSE); secondary sections keep the shared padding. */
.treasury-stack .sector.treasury-quick-log,
.treasury-stack .sector.treasury-overview,
.treasury-stack .sector.treasury-budget-pulse {
    padding: 14px 16px;
}

.treasury-stack > * {
    min-width: 0;
}

.treasury-locked-notice {
    border: 2px solid var(--accent);
    background: var(--signal-wash);
}

.treasury-locked-notice h3 {
    color: var(--accent);
}

.treasury-form-error {
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--signal-deep);
    background: var(--signal-wash);
    color: var(--danger-soft);
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.5;
}

/* ---- Badges ---- */

.treasury-badge {
    display: inline-block;
    flex: 0 0 auto;
    padding: 3px 7px;
    border: 1px solid var(--border);
    border-radius: var(--r-control);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.treasury-badge--reversed {
    border-color: var(--danger-soft);
    color: var(--danger-soft);
}

.treasury-badge--removed {
    border-color: var(--muted);
    color: var(--muted);
}

/* ---- SHOW REMOVED toggle (ALL MOVEMENTS) ---- */

.treasury-show-removed {
    display: flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    font-family: var(--font-display);
    text-transform: uppercase;
    cursor: pointer;
}

.treasury-show-removed__checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ---- Quick movement wizard ---- */

.treasury-quick-log__wizard .field,
.treasury-amend-form .field {
    min-width: 0;
}

.treasury-quick-log__launch {
    width: 100%;
    min-height: 52px;
    font-size: 1.05rem;
    letter-spacing: 0.1em;
}

.treasury-quick-log__wizard {
    display: grid;
    gap: 16px;
    min-width: 0;
}

.treasury-quick-log__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.treasury-quick-log__progress {
    margin: 0;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.treasury-quick-log__close {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
}

.treasury-quick-log__close:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.treasury-quick-log__step {
    display: grid;
    gap: 12px;
    min-width: 0;
}

.treasury-quick-log__actions {
    margin-top: 4px;
}

.treasury-quick-log__review .treasury-summary-list {
    margin-bottom: 4px;
}

/* ---- Inline "ADD MORE DETAILS" disclosure on REVIEW (not a wizard step) ---- */

.treasury-more-details {
    margin-top: 16px;
}

.treasury-more-details > summary {
    display: inline-block;
    list-style: none;
}

.treasury-more-details > summary::-webkit-details-marker {
    display: none;
}

.treasury-more-details[open] > summary {
    margin-bottom: 12px;
}

.treasury-more-details .field {
    min-width: 0;
    margin-top: 10px;
}

/* ---- Composite date field: typed DD/MM/YYYY + calendar button ---- */

.treasury-date-field {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.treasury-date-field__text {
    flex: 1 1 auto;
    min-width: 0;
}

.treasury-date-field__calendar {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--text);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.treasury-date-field__calendar:hover {
    border-color: var(--accent);
}

/* Visually hidden but still rendered (a real box, not display:none) so
   the browser's native showPicker()/focus() can still target it. */
.treasury-date-field__native {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

.treasury-field-help {
    margin: -4px 0 0;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.4;
}

.treasury-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.treasury-chip {
    min-height: 44px;
    max-width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--text);
    font-weight: 700;
    letter-spacing: 0.03em;
    font-family: var(--font-display);
    text-transform: uppercase;
    overflow-wrap: anywhere;
    cursor: pointer;
}

.treasury-chip:hover {
    border-color: var(--accent);
}

.treasury-chip--selected {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--bone);
}

/* ---- Micro secondary action (REMOVE/RESTORE FROM REPORTS, gauge EDIT) ----
   A real, self-contained button size — not a scaled-down shared button. */

.treasury-stack .treasury-action-micro {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    width: auto;
    min-height: 0;
    padding: 3px 4px;
    border: 1px solid var(--border);
    border-radius: var(--r-control);
    background: transparent;
    color: var(--muted);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1.4;
    font-family: var(--font-display);
    text-transform: uppercase;
    cursor: pointer;
}

.treasury-stack .treasury-action-micro:hover {
    border-color: var(--accent);
    color: var(--text);
}

.treasury-stack .treasury-action-micro--danger {
    border-color: var(--signal-deep);
    color: var(--danger-soft);
}

.treasury-stack .treasury-action-micro--danger:hover {
    border-color: var(--danger-soft);
    color: var(--danger-soft);
    background: var(--signal-wash);
}

/* ---- OVERVIEW: compact balance strip ---- */

.treasury-overview h3 {
    margin-bottom: 10px;
}

.treasury-overview-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.treasury-stack .treasury-overview-block {
    display: grid;
    gap: 4px;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-0);
    background: var(--background);
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.treasury-stack .treasury-overview-block:hover {
    border-color: var(--accent);
}

.treasury-overview-block__label {
    color: var(--muted);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.treasury-overview-block__amount {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.treasury-overview-block--negative .treasury-overview-block__amount {
    color: var(--danger-soft);
}

/* ---- BUDGET PULSE: weekly + monthly fuel gauges ---- */

.treasury-budget-pulse h3 {
    margin-bottom: 10px;
}

.treasury-budget-pulse__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.treasury-gauge {
    display: grid;
    gap: 4px;
    align-content: start;
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-0);
    background: var(--background);
}

.treasury-gauge--over {
    border-color: var(--signal-deep);
}

.treasury-gauge__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.treasury-gauge__label {
    font-weight: 700;
    letter-spacing: 0.1em;
}

.treasury-gauge__range {
    margin: 0;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.72rem;
}

.treasury-gauge__figure {
    margin: 4px 0 0;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 1.05rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.treasury-gauge__status {
    margin: 0;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.treasury-gauge__status--over {
    color: var(--danger-soft);
}

.treasury-gauge__bar {
    height: 6px;
    margin-top: 4px;
    border: 1px solid var(--border);
    border-radius: var(--r-control);
    background: var(--surface);
    overflow: hidden;
}

.treasury-gauge__fill {
    height: 100%;
    background: var(--accent);
}

.treasury-gauge__fill--over {
    background: var(--danger-soft);
}

.treasury-gauge__edit {
    display: grid;
    gap: 10px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.treasury-gauge__limit {
    display: grid;
    gap: 8px;
}

.treasury-gauge__edit .field {
    min-width: 0;
}

/* Used by TACTICAL BREAKDOWN's period line. */
.treasury-spending-limit__range {
    margin: -4px 0 12px;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.03em;
}

/* MONTHLY period mode/day controls, shown inside the gauge EDIT panel. */
.treasury-period-config {
    display: grid;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

/* ---- Collapsible secondary sectors (ALL MOVEMENTS, MONTHLY PLAN, ACCOUNTS, TREASURY LOG) ---- */

.treasury-collapsible > summary {
    cursor: pointer;
    list-style: none;
}

.treasury-collapsible > summary::-webkit-details-marker {
    display: none;
}

.treasury-collapsible__summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    color: var(--text);
    font-size: 1rem;
    letter-spacing: 0.1em;
    font-family: var(--font-display);
    text-transform: uppercase;
}

.treasury-collapsible__summary::before {
    content: "▶";
    color: var(--accent);
    font-size: 0.75rem;
}

.treasury-collapsible[open] > .treasury-collapsible__summary::before {
    content: "▼";
}

.treasury-collapsible[open] > .treasury-collapsible__summary {
    margin-bottom: 14px;
}

/* Compact preview stats shown in a collapsed section's own header
   (PLANNED EXPENSES) — keeps the closed state informative without
   opening the panel. */
.treasury-collapsible__stats {
    flex-basis: 100%;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: none;
    overflow-wrap: anywhere;
}

/* ---- TACTICAL BREAKDOWN ---- */

.treasury-tactical-list {
    display: grid;
    gap: 10px;
}

.treasury-tactical-row {
    display: grid;
    gap: 6px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-0);
    background: var(--background);
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.treasury-tactical-row:hover {
    border-color: var(--accent);
}

.treasury-tactical-row__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.treasury-tactical-row__label {
    font-weight: 700;
    letter-spacing: 0.04em;
}

.treasury-tactical-row__amount {
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.treasury-tactical-row__bar {
    height: 6px;
    border: 1px solid var(--border);
    border-radius: var(--r-control);
    background: var(--surface);
    overflow: hidden;
}

.treasury-tactical-row__fill {
    height: 100%;
    background: var(--accent);
}

/* ---- Plan item status badges (PLANNED / LOGGED / REVERSED) ---- */

.treasury-badge--plan-logged {
    border-color: var(--text);
    color: var(--text);
}

.treasury-badge--plan-reversed {
    border-color: var(--danger-soft);
    color: var(--danger-soft);
}

/* ---- ALL MOVEMENTS filter panel ---- */

.treasury-filter-panel {
    margin-bottom: 14px;
}

.treasury-filter-panel .field {
    min-width: 0;
    margin-top: 10px;
}

.treasury-filter-panel .treasury-show-removed {
    margin-top: 10px;
}

.treasury-filter-panel .button-row {
    margin-top: 12px;
}

.treasury-filter-count {
    margin: -6px 0 12px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    font-family: var(--font-display);
    text-transform: uppercase;
}

/* ---- DATA VAULT ---- */

.treasury-vault-preview-box {
    margin-top: 12px;
    padding: 14px;
    border: 1px solid var(--accent);
    border-radius: var(--r-0);
    background: var(--surface);
}

.treasury-vault-preview-list {
    margin: 8px 0 12px;
    padding: 0 0 0 18px;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.6;
}

/* ---- Summary rows (BALANCES, WEEKLY/MONTHLY SPENDING, review) ---- */

.treasury-summary-list {
    display: grid;
    gap: 10px;
    margin: 0;
}

.treasury-summary-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.treasury-summary-row dt {
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    font-family: var(--font-display);
    text-transform: uppercase;
}

.treasury-summary-row dd {
    margin: 0;
    color: var(--text);
    font-family: var(--font-mono);
    font-weight: 600;
}

/* ---- RECENT EXPENSES table ---- */

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

.treasury-section-header h3 {
    margin: 0;
}

.treasury-table-scroll {
    overflow-x: auto;
    border: 1px solid var(--border);
}

.treasury-table {
    width: 100%;
    min-width: 560px;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.treasury-table th,
.treasury-table td {
    padding: 10px 12px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.treasury-table thead th {
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    font-family: var(--font-display);
    text-transform: uppercase;
    background: var(--surface);
}

.treasury-table tbody tr:last-child td {
    border-bottom: none;
}

.treasury-table tbody tr:hover td {
    background: var(--surface);
}

.treasury-table__description {
    min-width: 180px;
    white-space: normal;
    overflow-wrap: anywhere;
    color: var(--text);
    font-weight: 700;
}

.treasury-table__date {
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.treasury-table__account,
.treasury-table__class {
    color: var(--muted);
}

.treasury-table__amount {
    text-align: right;
    color: var(--text);
    font-family: var(--font-mono);
    font-weight: 600;
}

/* AMOUNT stays reachable without scrolling all the way across — PAID FROM
   and TACTICAL CLASS are the columns meant to be reached by scroll. */
.treasury-table th:last-child,
.treasury-table td:last-child {
    position: sticky;
    right: 0;
    background: var(--background);
    box-shadow: -1px 0 0 var(--border);
}

.treasury-table thead th:last-child {
    background: var(--surface);
}

.treasury-table tbody tr:hover td:last-child {
    background: var(--surface);
}

/* ---- Movement list (ALL MOVEMENTS, PLANNED ITEMS) ---- */

.treasury-report-list {
    display: grid;
    gap: 12px;
    margin: 0 0 12px;
    padding: 0;
    list-style: none;
}

.treasury-report {
    display: grid;
    gap: 10px;
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--border);
    background: var(--background);
    overflow-wrap: anywhere;
}

.treasury-report--reversed {
    opacity: 0.7;
}

.treasury-report--reversed .treasury-report__label {
    text-decoration: line-through;
}

.treasury-report__header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.treasury-report__label {
    margin: 0;
    color: var(--text);
    font-weight: 700;
    line-height: 1.4;
}

.treasury-report__meta,
.treasury-report__change {
    margin: 0;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.5;
}

.treasury-report__note {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.treasury-report__history summary {
    color: var(--muted);
    font-family: var(--font-display);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    cursor: pointer;
}

.treasury-report__amendment {
    display: grid;
    gap: 4px;
    margin-top: 10px;
    padding-left: 12px;
    border-left: 1px solid var(--border);
}

/* ---- Amend form ---- */

.treasury-amend-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 6px;
    padding: 16px;
    border: 1px solid var(--accent);
    background: var(--surface);
}

.treasury-amend-form > h4,
.treasury-amend-form > .secondary-button,
.treasury-amend-form > .treasury-form-error,
.treasury-amend-form > .button-row {
    grid-column: 1 / -1;
}

.treasury-amend-form > .secondary-button {
    justify-self: start;
}

/* ---- Accounts list ---- */

.treasury-account-create {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.treasury-account-create .text-input {
    flex: 1 1 200px;
    min-width: 0;
}

.treasury-account-list {
    display: grid;
    gap: 12px;
    margin: 0 0 16px;
    padding: 0;
    list-style: none;
}

.treasury-account-item {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--border);
    background: var(--background);
}

.treasury-account-item__info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.treasury-account-item__name {
    font-weight: 700;
    letter-spacing: 0.03em;
    font-family: var(--font-display);
    text-transform: uppercase;
    overflow-wrap: anywhere;
}

/* ==================================================
   ROUNDED CORNERS (Treasury only — scoped under .treasury-stack so the
   rest of the app, including other chambers' reuse of the same shared
   .text-input/.select-input/.action-button/etc. classes, is untouched)
   ================================================== */

.treasury-stack .sector,
.treasury-report,
.treasury-account-item,
.treasury-amend-form,
.treasury-table-scroll {
    border-radius: var(--r-0);
}

.treasury-stack input,
.treasury-stack select,
.treasury-stack textarea,
.treasury-stack button {
    border-radius: var(--r-0);
}

.treasury-quick-log__close {
    border-radius: var(--r-0);
}

/* Corners this system deliberately leaves alone: chips/badges, micro
   actions, overview blocks and gauges keep their own radius set above;
   nothing here is turned into a pill/capsule shape. */

/* ---- Keyboard focus & interaction polish ---- */

.treasury-stack input:focus-visible,
.treasury-stack select:focus-visible,
.treasury-stack textarea:focus-visible,
.treasury-stack button:focus-visible,
.treasury-date-field__calendar:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (max-width: 760px) {
    .treasury-amend-form {
        grid-template-columns: 1fr;
    }

    .treasury-overview-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .treasury-budget-pulse__grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 440px) {
    .treasury-chip {
        flex: 1 1 100%;
    }

    .treasury-overview-block__amount {
        font-size: 0.98rem;
    }
}

/* ==================================================
   TREASURY 1.0
   ================================================== */

/* The launch sits on the page, not inside an empty box. */
.treasury-quick-log:has(> .treasury-quick-log__launchers) {
    padding: 0;
    border-color: transparent;
    background: none;
}

.treasury-quick-log__launch {
    width: auto;
    min-height: 48px;
    padding: 0 var(--s-6);
    font-size: var(--fs-md);
}

/* Balance cells are buttons: the strip keeps one hairline, hover marks
   the cell instead of doubling the border. */
.treasury-stack .treasury-overview-block {
    border: 0;
    box-shadow: 0 0 0 1px var(--rule);
}

.treasury-stack .treasury-overview-block:hover {
    background: var(--plate-raised);
    box-shadow: inset 0 0 0 1px var(--signal);
}

.treasury-gauge__label {
    font-family: var(--font-display);
    font-weight: 700;
}

.treasury-gauge__figure {
    font-family: var(--font-display-tight);
    font-size: var(--fs-xl);
    font-variant-numeric: tabular-nums;
}

/* Launchers: EXPENSE primary, INCOME secondary, rare types folded away. */
.treasury-quick-log__launchers {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-2) var(--s-3);
}

.treasury-quick-log__launch--secondary {
    padding: 0 var(--s-5);
}

.treasury-more-types {
    margin-left: auto;
}

.treasury-more-types__summary {
    padding: var(--s-2) 0;
    color: var(--steel);
    font-family: var(--font-display);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.1em;
}

.treasury-more-types__summary:hover {
    color: var(--bone);
}

.treasury-more-types__summary::marker {
    color: var(--signal);
}

.treasury-more-types__body {
    margin-top: var(--s-2);
}

@media (max-width: 760px) {
    .treasury-quick-log__launchers > .treasury-quick-log__launch {
        flex: 1 1 140px;
        padding: 0 var(--s-3);
        white-space: nowrap;
    }

    .treasury-more-types {
        flex-basis: 100%;
        margin-left: 0;
    }
}
