/* ========================================
   GRAYSCALE DESIGN SYSTEM UTILITIES
   ======================================== */

/* ===================
   BADGE OVERRIDES
   =================== */

/* Neutral badges with accent borders */
.badge-neutral {
    background-color: var(--active-bg);
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
    font-weight: 500;
}

/*
 * NOTE: We intentionally do NOT override Bootstrap badge colors globally.
 * Role badges (Superadmin, Admin, User) need distinct colors for clarity.
 * Use the badge-*-accent classes below when you want grayscale badges
 * with semantic accent borders.
 */

/* Semantic badges with left border accent */
.badge-success-accent {
    background-color: var(--hover-bg);
    color: var(--text-secondary);
    border-left: 3px solid #10b981;
}

.badge-warning-accent {
    background-color: var(--hover-bg);
    color: var(--text-secondary);
    border-left: 3px solid #f59e0b;
}

.badge-danger-accent {
    background-color: var(--hover-bg);
    color: var(--text-secondary);
    border-left: 3px solid #ef4444;
}

.badge-info-accent {
    background-color: var(--hover-bg);
    color: var(--text-secondary);
    border-left: 3px solid #3b82f6;
}

/* ===================
   ALERT OVERRIDES
   =================== */

/* Base neutral alert */
.alert-neutral {
    background-color: var(--hover-bg);
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
    border-left: 4px solid var(--text-muted);
}

/* Override Bootstrap alert colors */
.alert.alert-success {
    background-color: var(--hover-bg) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-default) !important;
    border-left: 4px solid #10b981 !important;
}

.alert.alert-warning {
    background-color: var(--hover-bg) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-default) !important;
    border-left: 4px solid #f59e0b !important;
}

.alert.alert-danger {
    background-color: var(--hover-bg) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-default) !important;
    border-left: 4px solid #ef4444 !important;
}

.alert.alert-info {
    background-color: var(--hover-bg) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-default) !important;
    border-left: 4px solid #3b82f6 !important;
}

.alert.alert-primary {
    background-color: var(--hover-bg) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-default) !important;
    border-left: 4px solid var(--text-primary) !important;
}

/* ===================
   CARD OVERRIDES
   =================== */

/* Standard grayscale card — depth (shadow/radius) comes from app.css tokens. */
.card {
    background-color: var(--content-bg);
    border: 1px solid var(--border-default);
}

.card-header {
    background-color: var(--hover-bg);
    border-bottom: 1px solid var(--border-default);
    color: var(--text-primary);
}

/* Override Bootstrap card header colors */
.card-header.bg-primary,
.card-header.bg-secondary,
.card-header.bg-success,
.card-header.bg-warning,
.card-header.bg-danger,
.card-header.bg-info {
    background-color: var(--hover-bg) !important;
    color: var(--text-primary) !important;
}

/* Metric cards with accent borders */
.metric-card {
    background-color: var(--content-bg);
    border: 1px solid var(--border-default);
    border-left: 4px solid var(--text-muted);
}

.metric-card.metric-success {
    border-left-color: #10b981;
}

.metric-card.metric-warning {
    border-left-color: #f59e0b;
}

.metric-card.metric-danger {
    border-left-color: #ef4444;
}

.metric-card.metric-info {
    border-left-color: #3b82f6;
}

.metric-card .metric-value {
    color: var(--text-primary);
    font-size: 2rem;
    font-weight: 700;
}

.metric-card .metric-label {
    color: var(--text-muted);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===================
   BUTTON OVERRIDES
   =================== */

/* Grayscale primary button */
.btn-grayscale-primary {
    background-color: var(--text-primary);
    border-color: var(--text-primary);
    color: var(--content-bg);
}

.btn-grayscale-primary:hover {
    background-color: var(--text-secondary);
    border-color: var(--text-secondary);
    color: var(--content-bg);
}

/* Grayscale outline button */
.btn-grayscale-outline {
    background-color: transparent;
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
}

.btn-grayscale-outline:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.btn-grayscale-outline.active {
    background-color: var(--active-bg);
    color: var(--text-primary);
    font-weight: 600;
}

/* Filter button group */
.btn-filter {
    background-color: var(--content-bg);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    padding: 0.375rem 0.75rem;
}

.btn-filter:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.btn-filter.active {
    background-color: var(--active-bg);
    color: var(--text-primary);
    border-color: var(--active-border);
    font-weight: 600;
}

/* ===================
   TEXT COLOR UTILITIES
   =================== */

/* Override Bootstrap text colors for consistency */
.text-primary {
    color: var(--text-primary) !important;
}

.text-secondary {
    color: var(--text-secondary) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

/* Semantic accent colors (use sparingly) */
.text-accent-success {
    color: #10b981 !important;
}

.text-accent-warning {
    color: #f59e0b !important;
}

.text-accent-danger {
    color: #ef4444 !important;
}

.text-accent-info {
    color: #3b82f6 !important;
}

/* ===================
   ICON STYLING
   =================== */

/* Neutral icon container */
.icon-neutral {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    background-color: var(--hover-bg);
    border-radius: 0.5rem;
    color: var(--text-secondary);
}

.icon-neutral.icon-sm {
    width: 2rem;
    height: 2rem;
    font-size: 0.875rem;
}

.icon-neutral.icon-lg {
    width: 3rem;
    height: 3rem;
    font-size: 1.25rem;
}

/* ===================
   TABLE STYLING
   =================== */

.table {
    border-color: var(--border-default);
}

.table thead th {
    background-color: var(--hover-bg);
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-default);
    font-weight: 600;
}

.table tbody tr:hover {
    background-color: var(--hover-bg);
}

/* ===================
   FORM STYLING
   =================== */

.form-control:focus,
.form-select:focus {
    border-color: var(--text-muted);
    box-shadow: 0 0 0 0.2rem rgba(55, 65, 81, 0.15);
}

/* ===================
   STATUS INDICATORS
   =================== */

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
}

.status-dot.status-active {
    background-color: #10b981;
}

.status-dot.status-pending {
    background-color: #f59e0b;
}

.status-dot.status-inactive {
    background-color: #ef4444;
}

/* ===================
   PROGRESS INDICATORS
   =================== */

.progress {
    background-color: var(--hover-bg);
    border-radius: 0.25rem;
}

.progress-bar {
    background-color: var(--text-primary);
}

/* ===================
   TIMELINE FIXES
   =================== */

/* Hide timeline connector line that overlaps cards */
.timeline::before {
    display: none !important;
    content: none !important;
}


/* ===================
   EXPENSE OVERVIEW DRILL-DOWN
   =================== */

/* One line per movement. The columns are fixed so the dates and the amounts hold a column down
   the list; everything that can be long - the description, the route - shares what is left and
   is cut rather than wrapped, because a wrapped row breaks the alignment the list is for.
   Global rather than scoped to one component: the transaction list and the bank movement list
   are the same row wearing different contents, and two copies would drift. */
.drill-rows {
    list-style: none;
    margin: 0;
    padding: 0;
}

.drill-rows > li {
    position: relative;
    padding: 7px 10px 9px;
    border-bottom: 1px solid var(--border-default);
}

.drill-rows > li:last-child {
    border-bottom: 0;
}

.drill-rows > li:hover {
    background-color: var(--hover-bg);
}

.drill-rows .row-line {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.drill-rows .row-date {
    flex: none;
    /* "dd/MM/yy", the one movement date format (Utils/MovementDate.cs). */
    width: 48px;
    font-size: 11px;
    color: var(--text-subtle);
    font-variant-numeric: tabular-nums;
}

.drill-rows .row-main {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 9px;
    color: inherit;
    text-decoration: none;
}

.drill-rows .row-label {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 58%;
}

.drill-rows .row-label.unknown {
    font-weight: 400;
    font-style: italic;
    color: var(--text-muted);
}

.drill-rows .row-main:hover .row-label {
    text-decoration: underline;
}

.drill-rows .row-route {
    flex: 1;
    min-width: 0;
    font-size: 11.5px;
    color: var(--text-subtle);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* A bank movement has no route, so its empty slot must not hold 42% of the line back from the
   label. An operation's description is a full phrase - what was bought and from whom - and it
   was being cut at "Consultoria de dese…" beside an empty gap. */
.drill-rows .row-route:empty {
    display: none;
}

.drill-rows .row-label:has(+ .row-route:empty) {
    max-width: 100%;
}

/* The chip a bank movement wears instead of a route. */
.drill-rows .row-cat {
    flex: none;
    font-size: 11px;
    color: var(--text-muted);
    border: 1px solid var(--border-default);
    border-radius: 5px;
    padding: 1px 6px;
    white-space: nowrap;
}

.drill-rows .row-jumps {
    flex: none;
    display: flex;
    gap: 4px;
}

/* The jump to the bank movement, and the jump to the document. Shown only when there is one to
   go to, so an empty slot says "nothing behind this row" rather than "button broken". */
.drill-rows .jump {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 22px;
    border: 1px solid var(--border-default);
    border-radius: 6px;
    background-color: var(--content-bg);
    color: var(--text-muted);
    font-size: 11px;
    text-decoration: none;
}

.drill-rows .jump:hover {
    background-color: var(--hover-bg);
    border-color: var(--text-subtle);
    color: var(--text-primary);
}

.drill-rows .jump:focus-visible {
    outline: 2px solid var(--sigo-primary);
    outline-offset: 1px;
}

.drill-rows .row-amt {
    flex: none;
    /* A floor, not a width: a five-digit amount in a long currency format was cut to "10 81…"
       on a phone when the column was fixed. */
    min-width: 104px;
    white-space: nowrap;
    text-align: right;
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.drill-rows .row-share {
    flex: none;
    width: 32px;
    text-align: right;
    font-size: 11px;
    color: var(--text-subtle);
    font-variant-numeric: tabular-nums;
}

/* How much of the clicked bar this one row is, drawn where a third line of text used to be. */
.drill-rows .share-rule {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 3px;
    height: 2px;
    border-radius: 2px;
    background-color: var(--hover-bg);
}

.drill-rows .share-rule > i {
    display: block;
    height: 100%;
    border-radius: 2px;
    opacity: .55;
}

/* MovementRow with a host that opens the row in place (the allocation panel) rather than
   following a link: the line is a button, dressed as the link it replaces. */
.drill-rows button.row-main {
    border: 0;
    background: none;
    padding: 0;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.drill-rows button.row-main:focus-visible {
    outline: 2px solid var(--sigo-primary);
    outline-offset: 2px;
    border-radius: 3px;
}

/* The row whose panel is open, and rows that wait for nothing (transfers, settled outside). */
.drill-rows > li.is-open {
    background-color: var(--hover-bg);
    box-shadow: inset 3px 0 0 var(--sigo-primary);
}

.drill-rows > li.is-quiet .row-label {
    font-weight: 400;
    color: var(--text-muted);
}

/* The chips a row carries between its name and its jumps: its documents and its funds in the
   movements list, its category elsewhere. They wrap among themselves rather than push the
   amount off the line. */
.drill-rows .row-chips {
    flex: 0 1 auto;
    min-width: 0;
    /* Never more than half the line: a long document name once took all of it and left the
       movement without a name. */
    max-width: 50%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.drill-rows .row-chips > .ui-hover {
    max-width: 100%;
}

/* On a phone the line breaks in two: what the row is on top, and its chips, jumps and amount
   under it. One line had room for the date and the amount, and the name was squeezed to nothing. */
@media (max-width: 575.98px) {
    .drill-rows .row-line {
        flex-wrap: wrap;
        row-gap: 5px;
    }

    .drill-rows .row-main {
        flex: 1 1 calc(100% - 100px);
    }

    .drill-rows .row-label {
        max-width: 100%;
    }

    .drill-rows .row-route {
        display: none;
    }

    .drill-rows .row-chips {
        flex: 1 1 auto;
        max-width: 100%;
    }

    .drill-rows .row-amt {
        min-width: 0;
        margin-left: auto;
    }
}

/* The bank movement list's fund strip, layout switches and details. The strip replaces the share
   rule's single colour with the funds the row's money went to, in the chart's column colours. */
.drill-rows .jump.mv-no-doc { position: relative; border-color: #e0a100; background-color: #fff6db; color: #a86b00; }
.drill-rows .jump.mv-pending { border-color: #93c5fd; background-color: #eff6ff; color: #1d4ed8; }
.drill-rows .jump:disabled { cursor: default; }
/* A slot kept empty in a fund tree row (ShareList's open button), so the others stay in their columns. */
.drill-rows .jump.is-blank { visibility: hidden; }
.drill-rows .jump.mv-no-doc b { position: absolute; top: -6px; right: -6px; width: 13px; height: 13px; border-radius: 50%; background: #e0a100; color: #fff; font-size: 9px; line-height: 13px; text-align: center; }
.mv-body { display: flex; flex-direction: column; gap: 8px; }
.mv-list { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.mv-bar { display: flex; gap: 2px; height: 26px; }
.mv-seg { border: 0; padding: 0 6px; min-width: 0; min-height: 0; border-radius: 3px; cursor: pointer; background: var(--c); color: #fff; font-size: 11px; font-weight: 600; text-align: left; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; transition: opacity .15s; }
/* The UiHover around each piece takes the piece's share of the bar; the button fills it. */
.mv-seg-slot { display: flex; min-width: 0; }
.mv-seg-slot > .mv-seg { flex: 1 1 auto; }
.mv-seg > span { display: block; overflow: hidden; text-overflow: ellipsis; }
.mv-seg.is-unk, .mv-strip i.is-unk, .mv-mark.is-unk { background-image: repeating-linear-gradient(135deg, transparent 0 4px, rgba(255, 255, 255, .45) 4px 7px); }
.mv-bar.has-sel .mv-seg:not(.on) { opacity: .3; }
.mv-seg:focus-visible { outline: 2px solid var(--text-primary); outline-offset: 2px; }
.drill-rows.mv-dim > li:not(.mv-hit) { opacity: .3; }
.drill-rows .mv-strip { height: 4px; background: transparent; }
/* ShareList: the drill-down rows outside a drill-down. A fold button or an icon where the date goes,
   children indented under their parent, and the bar a little apart from the rows. */
.sl-bar { margin-bottom: 6px; }
.drill-rows .sl-fold { width: 34px; flex-shrink: 0; border: 0; background: transparent; color: var(--text-muted); font-size: 11px; cursor: pointer; padding: 0; text-align: left; }
.drill-rows .sl-toggle { border: 0; background: transparent; padding: 0; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.drill-rows .sl-icon { width: 34px; flex-shrink: 0; color: var(--text-muted); font-size: 13px; }
.drill-rows .sl-icon.is-warn { color: #d97706; }
.drill-rows .sl-note { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }
/* On a phone a long note ("32 sem fundo · 2 alocação pendente · 5 sem documento") left the row's
   name no width at all. There the note goes under the name, across the row. */
@media (max-width: 576px) {
    .drill-rows .row-line:has(> .sl-note) { flex-wrap: wrap; row-gap: 2px; }
    .drill-rows .row-line > .sl-note { order: 1; flex-basis: 100%; white-space: normal; padding-left: 45px; }
}
.drill-rows > li.sl-child .row-line, .drill-rows > li.sl-child .mv-strip { margin-left: var(--sl-indent, 0); }
.drill-rows .mv-strip > span { display: flex; gap: 1px; height: 100%; }
.drill-rows .mv-strip i { display: block; height: 100%; border-radius: 1px; }
.mv-details { display: flex; flex-direction: column; gap: 6px; padding: 6px 0 8px 50px; font-size: 12.5px; }
.mv-details table { border-collapse: collapse; max-width: 460px; }
.mv-details td { padding: 2px 12px 2px 0; border-bottom: 1px dashed var(--border-default); }
.mv-details td:first-child { display: flex; align-items: center; gap: 8px; }
.mv-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mv-muted { color: var(--text-muted); }
.mv-mark { display: inline-block; width: 4px; height: 14px; border-radius: 2px; flex: none; }
.mv-allocate { align-self: flex-start; font: inherit; font-weight: 600; font-size: 12.5px; border: 1px solid var(--sigo-primary); color: var(--sigo-primary); background: none; border-radius: 6px; padding: 3px 10px; cursor: pointer; }
.mv-allocate:hover { background: var(--sigo-primary); color: #fff; }
.mv-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; }
/* MovementTransferBox: link a movement to its other leg on another bank. */
.mvt { display: flex; flex-direction: column; gap: 6px; }
.mvt-linked { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.mvt-desc { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mvt-btn { font: inherit; font-size: 12.5px; font-weight: 600; border: 1px solid var(--border-default); border-radius: 6px; padding: 3px 10px; background: var(--content-bg); color: var(--text-primary); cursor: pointer; }
.mvt-btn.is-go { border-color: var(--sigo-primary); background: var(--sigo-primary); color: #fff; }
.mvt-btn:disabled { opacity: .55; cursor: default; }
.mvt-pick { border: 1px solid var(--border-default); border-radius: 8px; padding: 8px 10px; max-width: 560px; }
.mvt-head { font-weight: 600; margin-bottom: 4px; }
.mvt-list { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.mvt-list label { display: grid; grid-template-columns: auto auto auto minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; cursor: pointer; margin: 0; }
.mvt-list label.is-on { background: var(--hover-bg); }
.mvt-bank { font-weight: 600; white-space: nowrap; }
.mvt-warn { grid-column: 2 / -1; font-size: 11px; color: #b45309; }
.mvt-actions { display: flex; justify-content: flex-end; gap: 6px; }
@media (prefers-reduced-motion: reduce) { .mv-seg { transition: none; } }

/* The list and the graphs beside it. The rail keeps its width and the list takes the rest; on a
   narrow window the rail drops under the list rather than squeezing both. */
.drill-grid {
    display: grid;
    /* Three parts list to two parts graphs. The rail used to be a fixed 328px, which read as an
       afterthought beside a list twice its width; the graphs are the other half of the answer
       and are sized like it. */
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: 16px;
    align-items: start;
    margin-top: 12px;
}

@media (max-width: 1100px) {
    .drill-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* The Options button and the panel it opens. The backdrop is a transparent sheet under the
   panel and over everything else, so a click anywhere outside closes it without a document
   listener to unsubscribe. */
.opts-menu {
    position: relative;
}

.opts-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1040;
}

.opts-pop {
    position: absolute;
    right: 0;
    top: calc(100% + 7px);
    z-index: 1050;
    width: 300px;
    padding: 6px;
    background-color: var(--content-bg);
    border: 1px solid var(--border-default);
    border-radius: 10px;
    box-shadow: var(--shadow-card);
}

.opts-pop:focus {
    outline: none;
}

.opts-group + .opts-group {
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px solid var(--border-default);
}

.opts-cap {
    padding: 6px 10px 2px;
    font-size: 11px;
    color: var(--text-subtle);
}

/* A switch and its explanation, as one row of the panel. */
.opts-switch {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 7px;
}

.opts-switch:hover {
    background-color: var(--hover-bg);
}

.opts-switch .form-check {
    margin: 0;
    min-height: 0;
}

.opts-switch .opts-text b {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.opts-switch .opts-text span {
    display: block;
    font-size: 11.5px;
    color: var(--text-muted);
}

.opts-action {
    padding: 4px 10px 8px;
}

/* The panel charts' tooltip. Lives on the body, not inside the card, so a list of ten
   movements is never cut off by a 150px pie or by the rail around it. */
.fund-tip {
    position: fixed;
    z-index: 1080;
    min-width: 230px;
    max-width: min(460px, 92vw);
    padding: 9px 11px 10px;
    background-color: var(--content-bg);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    box-shadow: var(--shadow-card);
    pointer-events: none;
    opacity: 0;
    transition: opacity .1s;
}

.fund-tip .h {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    padding-bottom: 6px;
    margin-bottom: 5px;
    border-bottom: 1px solid var(--border-default);
    font-size: 12px;
    color: var(--text-muted);
}

.fund-tip .h b {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.fund-tip ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fund-tip li {
    display: flex;
    align-items: baseline;
    gap: 9px;
    font-size: 11.5px;
    padding: 1.5px 0;
}

.fund-tip .d {
    flex: none;
    /* "dd/MM/yy", the one movement date format (Utils/MovementDate.cs). */
    width: 46px;
    color: var(--text-subtle);
    font-variant-numeric: tabular-nums;
}

.fund-tip .l {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
}

.fund-tip .a {
    flex: none;
    font-variant-numeric: tabular-nums;
}

.fund-tip .a.pos { color: #008300; }

/* A hover row waiting for an approval: the row component's yellow transaction mark, at the tooltip's size. */
.fund-tip .tx-wait { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 16px; border: 1px solid #e0a100; border-radius: 4px; background-color: #fde68a; color: #92400e; font-size: 9px; }

/* A bank bar's categories in its hover, above its movements and ruled off from them. */
.fund-tip ul.fund-tip-cats {
    padding-bottom: 5px;
    margin-bottom: 5px;
    border-bottom: 1px solid var(--border-default);
}

.fund-tip ul.fund-tip-cats .k {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    margin-right: 6px;
}
.fund-tip .a.neg { color: #e02d2d; }

/* The expense overview's hover panel (drawPanel in charts.js): a colour key before its heading,
   a line under it (a reading's date), and a note when its rows are still loading or empty. */
.fund-tip .h .k {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 6px;
    border-radius: 2px;
    vertical-align: baseline;
}

.fund-tip > .s {
    margin: -2px 0 4px;
    font-size: 11.5px;
    color: var(--text-muted);
}

.fund-tip > .m {
    font-size: 11.5px;
    color: var(--text-subtle);
}

/* UiHover's panel (Layout/Components/Ui/UiHover.razor): the same box as the charts' tooltip, but
   drawn by Blazor inside the hovered element, shown while it exists, and able to hold links. */
.ui-hover {
    display: inline-flex;
    min-width: 0;
}

.fund-tip.ui-hover-tip {
    opacity: 1;
    pointer-events: auto;
    text-align: left;
    white-space: normal;
    cursor: auto;
}

/* A sentence, not a table: no minimum width for one line of text. */
.fund-tip.ui-hover-tip.is-text {
    min-width: 0;
    max-width: min(320px, 92vw);
    padding: 6px 9px;
}

.fund-tip .ui-hover-text {
    display: block;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;
    color: var(--text-primary);
    white-space: pre-line;
}

[data-bs-theme="dark"] .fund-tip .a.pos { color: #34c759; }
[data-bs-theme="dark"] .fund-tip .a.neg { color: #ff5a5a; }

/* The monthly-spend tooltip: one large rectangle in two parts. Above, what the hovered column
   or pie is made of, the hovered category marked; below, that category's own movements. The
   rule between them is the whole of the layout - it is what says the lower list belongs to
   one line of the upper one. */
.fund-tip.fund-tip-split {
    width: min(400px, 92vw);
    padding: 0;
    overflow: hidden;
}

.fund-tip-split .sec {
    padding: 10px 12px;
}

.fund-tip-split .sec-rows {
    border-top: 1px solid var(--border-default);
    background-color: var(--hover-bg);
}

.fund-tip-split li {
    font-size: 12px;
    padding: 2px 6px;
    margin: 0 -6px;
    border-radius: 4px;
    color: var(--text-primary);
}

.fund-tip-split li.on {
    background-color: var(--hover-bg);
    font-weight: 600;
}

.fund-tip-split li.on .l {
    color: var(--text-primary);
}

.fund-tip-split .k {
    flex: none;
    align-self: center;
    width: 9px;
    height: 9px;
    border-radius: 2px;
}

.fund-tip-split .m {
    margin-top: 3px;
    font-size: 11px;
    color: var(--text-subtle);
}

/* The mark a movement or a transaction wears when it belongs to an operation. The only coloured
   chip on the row on purpose: the jumps beside it are neutral because they are navigation, and
   this one is a statement about the row - it is part of a larger payment. Not scoped to
   .drill-rows, because the transaction table wears the same mark. */
.op-mark {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--sigo-primary);
    border-radius: 999px;
    background-color: transparent;
    color: var(--sigo-primary);
    font-size: 10px;
    line-height: 1;
    cursor: pointer;
    vertical-align: middle;
}

.op-mark:hover,
.op-mark.is-open {
    background-color: var(--sigo-primary);
    color: var(--content-bg);
}

.op-mark:focus-visible {
    outline: 2px solid var(--sigo-primary);
    outline-offset: 1px;
}

/* The operation's story, opened under the row that wears the mark. */
.op-story {
    margin: 6px 0 4px;
    padding: 8px 10px;
    border-left: 3px solid var(--sigo-primary);
    border-radius: 0 6px 6px 0;
    background-color: var(--hover-bg);
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--text-secondary);
    white-space: normal;
    text-align: left;
}

.op-story-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 3px;
    font-size: 11px;
    color: var(--sigo-primary);
}

.op-story-head strong {
    font-size: 12.5px;
    color: var(--text-primary);
}

/* Editing an operation's text in place, inside its story. */
.op-story-edit { margin-left: auto; font: inherit; font-size: 11px; background: none; border: 0; padding: 0; color: var(--sigo-primary); cursor: pointer; }
.op-story-form { display: flex; flex-direction: column; gap: 6px; }
.op-story-form label { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--text-muted); }
.op-story-form input, .op-story-form textarea { font: inherit; font-size: 12.5px; color: var(--text-primary); background: var(--content-bg); border: 1px solid var(--border-default); border-radius: 5px; padding: 4px 6px; }
.op-story-actions { display: flex; gap: 6px; }
.op-story-error { color: var(--bs-danger, #c0392b); font-size: 12px; }

/* Marks a description or context written by AI rather than typed by a person. */
.op-ai { display: inline-block; margin-right: 4px; padding: 0 5px; border: 1px solid var(--border-default); border-radius: 8px; font-size: 10px; font-style: normal; line-height: 1.5; color: var(--text-muted); vertical-align: 1px; }

.op-story-empty {
    font-style: italic;
    color: var(--text-subtle);
}

/* An operation nobody has confirmed, or one still missing a kind of record. Warning colour and a
   dashed ring, so it cannot be mistaken for a settled one in a column of marks. */
.op-mark.is-pending {
    border-style: dashed;
    border-color: #c77700;
    color: #c77700;
}

.op-mark.is-pending:hover,
.op-mark.is-pending.is-open {
    background-color: #c77700;
    color: var(--content-bg);
}

.op-story.is-pending {
    border-left-color: #c77700;
}

.op-story.is-pending .op-story-head {
    color: #c77700;
}

.op-flag {
    padding: 0 6px;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-size: 10.5px;
    white-space: nowrap;
}

/* The documents of a row's operation, on hovering its document button. Fixed at the pointer so the
   scrolling drill-down list cannot clip it. */
.op-docs-hover {
    display: inline-flex;
}

.op-docs-pop {
    position: fixed;
    z-index: 1080;
    display: flex;
    width: 660px;
    max-width: calc(100vw - 16px);
    height: 420px;
    border: 1px solid var(--border-default);
    border-radius: 10px;
    background-color: var(--content-bg);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
    overflow: hidden;
    text-align: left;
    white-space: normal;
    animation: op-docs-pop-in 140ms ease-out;
}

@keyframes op-docs-pop-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .op-docs-pop { animation: none; }
}

.op-docs-pop__list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 260px;
    flex: none;
    padding: 10px;
    border-right: 1px solid var(--border-default);
    overflow-y: auto;
}

.op-docs-pop__title {
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-subtle);
}

.op-docs-pop__item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 7px 8px;
    border: 1px solid transparent;
    border-radius: 7px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 12.5px;
}

.op-docs-pop__item:hover,
.op-docs-pop__item.is-current {
    border-color: var(--border-default);
    background-color: var(--hover-bg);
}

.op-docs-pop__head {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.op-docs-pop__head strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.op-docs-pop__meta {
    font-size: 11.5px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.op-docs-pop__what {
    font-size: 11.5px;
    color: var(--text-secondary);
}

.op-docs-pop__preview {
    flex: 1;
    min-width: 0;
    display: flex;
    background-color: var(--hover-bg);
}

.op-docs-pop__preview iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

.op-docs-pop__nofile {
    margin: auto;
    font-size: 12px;
    color: var(--text-subtle);
}

/* The answer tiles at the top of the Time page and the Community tab, in the look of the Financial
   tab's AccountPositionTiles (named th- so the two never collide). A tile that is a link lifts on hover. */
.th-tiles {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: stretch;
    gap: 8px;
    margin-top: 8px;
}

.th-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    min-height: 44px;
    min-width: 150px;
    padding: 6px 11px 7px;
    border-radius: var(--radius, 10px);
    border: 1px solid transparent;
    background: var(--hover-bg);
    color: var(--text-primary);
}

.th-cap {
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    opacity: .85;
}

.th-val {
    font-size: 17px;
    font-weight: 650;
    letter-spacing: -.015em;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}

.th-sub {
    font-size: 10.5px;
    font-variant-numeric: tabular-nums;
    opacity: .8;
}

.th-tile.warn {
    background: #FFFBEB;
    border-color: #F59E0B;
    color: #92400E;
}

[data-bs-theme="dark"] .th-tile.warn {
    background: rgba(245, 158, 11, .15);
    border-color: #F59E0B;
    color: #FCD34D;
}

a.th-tile {
    text-decoration: none;
    max-width: 260px;
    transition: box-shadow .15s ease, border-color .15s ease;
}

a.th-tile:hover {
    border-color: var(--border-default);
    box-shadow: var(--shadow-lift);
}

a.th-tile:focus-visible {
    outline: 2px solid var(--sigo-primary);
    outline-offset: 2px;
}

.th-val.th-val-text {
    font-size: 14px;
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* A movement row the reader was sent to (js/movementJump.js): three short pulses, then back to
   normal. With reduced motion, a still outline for the same two seconds instead. */
@keyframes mv-flash {
    0%, 100% { background-color: transparent; box-shadow: inset 0 0 0 0 transparent; }
    50% { background-color: rgba(31, 79, 168, .14); box-shadow: inset 0 0 0 2px #1f4fa8; }
}

.drill-rows > li.mv-flash {
    animation: mv-flash .6s ease-in-out 3;
}

[data-bs-theme="dark"] .drill-rows > li.mv-flash {
    animation-name: mv-flash-dark;
}

@keyframes mv-flash-dark {
    0%, 100% { background-color: transparent; box-shadow: inset 0 0 0 0 transparent; }
    50% { background-color: rgba(110, 168, 254, .18); box-shadow: inset 0 0 0 2px #6ea8fe; }
}

@media (prefers-reduced-motion: reduce) {
    .drill-rows > li.mv-flash,
    [data-bs-theme="dark"] .drill-rows > li.mv-flash {
        animation: none;
        outline: 2px solid #1f4fa8;
        outline-offset: -2px;
    }
}

/* Latest concerns: the column beside the bank movements, transactions between funds over the
   time entries. */
.lc-side { display: flex; flex-direction: column; gap: 12px; height: 100%; min-height: 0; }
.lc-side > .ui-card, .lc-side .card { margin: 0; }
/* Two rectangles, each scrolling on its own: the column's height is shared between them, the
   time entries taking only what they need up to half of it. On one column they each get a
   bounded height of their own. */
.lc-side > .sigo-card { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.lc-side > .sigo-card > :last-child { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: auto; }
.lc-side > .sigo-card:first-child { flex: 1 1 0; }
.lc-side > .sigo-card + .sigo-card { flex: 0 1 auto; max-height: 50%; }
@media (max-width: 1100px) {
    .lc-side { height: auto; }
    .lc-side > .sigo-card, .lc-side > .sigo-card:first-child { flex: none; max-height: 520px; }
    .lc-side > .sigo-card + .sigo-card { max-height: 520px; }
}
/* A transaction between funds that arrived since the last read (an approved time entry) flashes. */
.ifc-rows > li.ifc-new { animation: ifc-in 1.6s ease-out; }
@keyframes ifc-in { 0% { transform: translateY(40px); background: #fff6db; } 30% { transform: none; } 100% { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .ifc-rows > li.ifc-new { animation: none; } }
/* The question a row's Approve or Reject asks before it acts (ConfirmAction): fixed, placed under
   the button by uiHover.place, over a transparent backdrop that takes the click outside. */

.pab-backdrop { position: fixed; inset: 0; z-index: 1089; background: transparent; }
.pab-pop { position: fixed; z-index: 1090; visibility: hidden; width: max-content; max-width: min(300px, calc(100vw - 16px)); padding: 10px 12px; border: 1px solid var(--border-default); border-radius: 8px; background: var(--content-bg, #fff); box-shadow: 0 10px 28px rgba(17, 24, 39, .16); font-size: 13px; color: var(--text-primary); white-space: normal; }
.pab-pop .pab-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }


/* ==========================================================================================
   OperationLine (Components/Rows/OperationLine.razor): THE row of the Financial tab. One grid,
   one set of breakpoints, for every list: the date, the operation's mark, the title, the meta
   (category or note), the allocation, the three action slots, the amount, the share. The list
   (ul.drill-rows) is the container its width is read from; a hover's list (.pa-rows) is sized
   by its content, so it takes the default layout.
   ========================================================================================== */
.drill-rows:has(> li > .op-grid):not(.pa-rows) { container-type: inline-size; }

/* Default (a list 441 to 859px wide): the title and the amount on top; the meta, the allocation
   and the slots under them. The meta column has one width on every row, so the allocations
   start in one column too. */
.drill-rows .op-grid {
    display: grid;
    grid-template-columns: 48px 22px 8.5em minmax(0, 1fr) 84px 104px 34px;
    grid-template-areas:
        "date mark main  main  main  amt   trail"
        ".    .    meta  alloc alloc slots slots";
    align-items: center;
    column-gap: 10px;
    row-gap: 5px;
}
.drill-rows .op-grid > .row-date { grid-area: date; }
.drill-rows .op-grid > .ui-hover:has(> .op-mark), .drill-rows .op-grid > .op-mark { grid-area: mark; }
.drill-rows .op-grid > .row-main { grid-area: main; min-width: 0; }
.drill-rows .op-grid .row-label { max-width: 100%; }
.drill-rows .op-grid > .row-meta { grid-area: meta; min-width: 0; display: flex; align-items: center; overflow: hidden; }
.drill-rows .op-grid > .row-alloc { grid-area: alloc; min-width: 0; }
.drill-rows .op-grid > .row-slots { grid-area: slots; justify-self: end; display: inline-flex; gap: 4px; align-items: center; }
.drill-rows .op-grid > .row-amt { grid-area: amt; min-width: 0; margin: 0; }
.drill-rows .op-grid > .row-trail { grid-area: trail; display: flex; justify-content: flex-end; }

/* Wide (860px and more): everything on one line. */
@container (min-width: 860px) {
    .drill-rows .op-grid {
        grid-template-columns: 48px 22px minmax(0, 1fr) 10em minmax(0, 15em) 84px 104px 34px;
        grid-template-areas: "date mark main meta alloc slots amt trail";
    }
}

/* Narrow (440px and less, a phone): the title on its own line; the meta with the amount and
   the share; the slots (under the date and the mark, exactly their width) with the allocation. */
@container (max-width: 440px) {
    .drill-rows .op-grid {
        grid-template-columns: 48px 22px minmax(0, 1fr) auto auto;
        grid-template-areas:
            "date  mark  main  main  main"
            ".     .     meta  amt   trail"
            "slots slots alloc alloc alloc";
    }
    .drill-rows .op-grid > .row-slots { justify-self: start; }
}

/* The category chip, with its colour as a dot. */
.drill-rows .op-grid .row-cat {
    display: inline-block;
    max-width: 100%;
    height: 22px;
    line-height: 20px;
    padding: 0 8px;
    border: 1px solid var(--border-default);
    border-radius: 999px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    color: var(--text-muted);
}
.drill-rows .op-grid .row-cat-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.drill-rows .op-grid .row-note { font-size: 11.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The allocation: one compact group per share, "Abel Dantas → 100%" with the bank written small
   above the arrow; cut with an ellipsis when long. */
.drill-rows .op-grid > .row-alloc {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    min-width: 0;
    font-size: 11.5px;
    line-height: 1.3;
    color: var(--text-primary);
}
/* A group: one line per fund, its name and share, then its own arrow with the bank written small
   over it; the arrows in one column (a two-column grid). A split stacks its lines, full names, a
   long one wrapping rather than cut, so the row grows; the arrow and the bank keep their own
   width and are never cut. */
.drill-rows .ra-part { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
.drill-rows .ra-list { display: inline-grid; grid-template-columns: minmax(0, auto) auto; align-items: center; column-gap: 6px; row-gap: 2px; }
.drill-rows .ra-item { display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 0 4px; min-width: 0; }
.drill-rows .ra-fund { overflow-wrap: anywhere; }
.drill-rows .ra-item.is-nofund .ra-fund { color: #b45309; font-style: italic; }
.drill-rows .ra-pct { color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* "From → To" flows as text, so a narrow line wraps after the arrow, never before it. */
.drill-rows .ra-part.ra-between { display: block; white-space: normal; }
.drill-rows .ra-between > .ra-fund { display: inline; }
.drill-rows .ra-between > .ra-arrow { display: inline; margin: 0 4px; min-width: 0; padding: 0; }
.drill-rows .ra-arrow {
    flex: none;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 1.8em;
    padding: 0 1px;
    line-height: 1;
    color: var(--text-muted);
}
.drill-rows .ra-arrow small { display: block; font-size: 8.5px; line-height: 10px; font-weight: 700; letter-spacing: .03em; color: var(--text-subtle); white-space: nowrap; }
.drill-rows .ra-arrow > span { font-size: 12px; line-height: 12px; }
/* A split's row: its line grows with the stack, the other cells centred against it. */
.drill-rows .op-grid:has(> .row-alloc.is-split) { align-items: center; }

/* The three slots, always there: a greyed one says why on hover; a pending transaction is yellow. */
.drill-rows .op-grid .jump.is-off { opacity: .35; cursor: default; }
.drill-rows .op-grid .jump.is-off:hover { background-color: var(--content-bg); border-color: var(--border-default); color: var(--text-muted); }
.drill-rows .op-grid button.jump { padding: 0; font: inherit; cursor: pointer; }
.drill-rows .op-grid .jump.is-pending { border-color: #e0a100; background-color: #fde68a; color: #92400e; }
.drill-rows .op-grid .jump.is-pending:hover { background-color: #fcd34d; }
.drill-rows .op-grid .slot-doc { position: relative; display: inline-flex; }
.drill-rows .op-grid .slot-extra { position: absolute; left: 100%; top: 50%; transform: translate(2px, -50%); font-size: 10px; color: var(--text-muted); }

/* A group's own line: the same columns, tinted, the label larger. It has no date and no
   operation, so its title takes their place and starts at the row's left edge, where the strip
   under it starts too. */
.drill-rows > li.op-row.is-header { background-color: var(--hover-bg); border-top: 2px solid var(--border-default); }
.drill-rows > li.op-row.is-header .row-label { font-size: 14px; font-weight: 700; }
.drill-rows > li.op-row.is-header .op-grid > .row-date { display: none; }
.drill-rows > li.op-row.is-header .op-grid > .row-main { grid-area: auto; grid-row: 1; grid-column: 1 / 6; }
@container (min-width: 860px) { .drill-rows > li.op-row.is-header .op-grid > .row-main { grid-column: 1 / 4; } }
@container (max-width: 440px) { .drill-rows > li.op-row.is-header .op-grid > .row-main { grid-column: 1 / 6; } }

/* Under an open row: the host's actions, then what waits for an approval. */
.drill-rows .op-details { display: flex; flex-direction: column; gap: 8px; padding: 6px 0 8px 80px; font-size: 12.5px; }
@container (max-width: 440px) { .drill-rows .op-details { padding-left: 0; } }
.drill-rows .op-pending { border: 1px solid #fcd34d; background: #fffbeb; border-radius: 8px; padding: 8px 10px; max-width: 560px; }
.drill-rows .op-pending-head { display: flex; align-items: center; gap: 6px; font-weight: 600; color: #92400e; margin-bottom: 4px; }
.drill-rows .op-pending ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.drill-rows .op-pending li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 8px; align-items: center; }
.drill-rows .op-pending-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drill-rows .op-pending-amt { font-variant-numeric: tabular-nums; }
.drill-rows .op-pending .btn { padding: 1px 8px; font-size: 12px; line-height: 1.5; }
