/* Blazor's <ValidationMessage>, still used next to inputs that Fluent's own field does not wrap. */
.validation-message {
    color: var(--app-intent-danger-fg);
}

.validation-message::before {
    position: relative;
    content: "!";
    font-weight: var(--fontWeightBold);
    padding: 0 var(--spacingHorizontalXS);
}

/* Fills its column. Fluent inputs take the class on their field wrapper, buttons on the element itself. */
.block {
    width: 100%;
}

.ignore-min-width,
.ignore-min-width fluent-dropdown {
    min-width: 0;
}

/* FocusOnNavigate (Routes.razor) focuses the page's h1 after each navigation so a screen reader announces the new
   page. The heading is not something to act on, so it shows no focus ring. */
h1:focus {
    outline: none;
}

/* fluent-tooltip ships with `contain: layout`, which makes it the containing block of its fixed-position
   panel. Inside a scrolling dialog the panel is then clipped by that scroll container, cutting off the top of
   a tall tooltip. Without it the panel is placed against the viewport again. */
fluent-tooltip.coverage-validity-tooltip {
    contain: none;
}

/* A partner autocomplete shows its selected value as a badge whose width grows with the text, expanding the
   Fact/PropertyBox value wrapper past its column and bleeding into the neighbouring field. Clip only the innermost
   wrapper that directly holds a .partner-field (:has) so the badge stays put; every other value keeps its default
   wrapping. */
.fact-value:has(> .partner-field),
.property-box-value:has(> .partner-field) {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

/* A v5 listbox is a flex column of fixed height, and its options set min-height: 32px, which also lets them shrink to
   it: a long autocomplete list squeezed every two-line option (a customer's name and number) into one line's height
   and the lines ran into the next option. Options keep their own height; the list scrolls instead. */
fluent-listbox > fluent-option {
    flex-shrink: 0;
}

/* An autocomplete with nothing to list yet (the customer search, before anything is typed) opened as an empty box under
   the field, which app.js now does as soon as Tab reaches it. The list shows once it has something in it. */
fluent-popover-b:has(> .fluent-stack-vertical:only-child:empty) {
    display: none;
}

/* A v5 listbox picks an option only when the click lands on the <fluent-option> itself, so a click on an option
   template's content (a logo, a customer's name, a badge) picked nothing. Clicks pass through the template to the
   option, as in Fluent's own templated example. */
fluent-option > * {
    pointer-events: none;
}

.hidden {
    display: none !important; /* theming-allow: important — utility must beat component display rules */
}

.h-100-percent {
    height: 100%;
}

pre {
    margin: 0;
}

/* FluentText As="H1"…"H6"/"Paragraph" renders that tag inside its own element, and reboot.css gives the tag a bottom
   margin (12px for a heading, 16px for a paragraph) that FluentText's Margin parameter cannot reach. Without this the
   spacing after every such text was Margin plus reboot's; with it, Margin and the surrounding stack's gap are the only
   spacing, as with v4's FluentLabel. */
fluent-text > :is(h1, h2, h3, h4, h5, h6, p) {
    margin: 0;
}

/* FluentDialogBody puts an ActionTemplate in one wrapper, and v5's action row right-aligns that wrapper at its own
   width, so a FluentSpacer or a summary meant for the footer's left end (bulk assign) had no room and sat against the
   buttons. The wrapper takes the row; its content stays at the right end unless something takes the space. */
fluent-dialog-body > div[slot=action] {
    flex: 1;
    justify-content: flex-end;
}

/* Opt-in (FluentDialogBody Class="scroll-content"): a long dialog that scrolls its content, not itself. v5's <dialog>
   scrolls as a whole, title and actions with the content, so a sticky header in the content (the compare dialog's
   grid) stuck to the dialog's top edge, over its title. The body is held to the dialog's height (the screen's) and
   its content part takes the rows the title and the actions leave, scrolling within them. Not for every dialog: set
   on all of them, the coverage groups dialog (tabs of coverage tables) hung the page while it was open. */
fluent-dialog-body.scroll-content {
    box-sizing: border-box;
    max-height: 100dvh;
    grid-template-rows: auto minmax(0, 1fr) auto;
}

fluent-dialog-body.scroll-content::part(content) {
    min-height: 0;
    overflow-y: auto;
}

/* Opt-in (FluentDialogBody Class="fill-content"), for a dialog given a height: the content part is a flex column of
   exactly the height its title and actions leave, so a child that fills (Tabs Fill, an UpGrid FillHeight) has a
   definite height to fill and scrolls within it, a grid's pager in view under its rows. */
fluent-dialog-body.fill-content {
    box-sizing: border-box;
    height: 100%;
    grid-template-rows: auto minmax(0, 1fr) auto;
}

fluent-dialog-body.fill-content::part(content) {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* FluentDialogBody puts the content in one wrapper div; it takes the content part's height and hands it on. */
fluent-dialog-body.fill-content > div:not([slot]) {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

/* A badge is one line. Squeezed (a contact flow's name in its picker's selection) it wrapped, and the field clipped
   the second line. FluentBadge has no nowrap parameter. */
fluent-badge {
    white-space: nowrap;
}

/* In dark mode a tint badge is light semibold 12px text on a near-black tint, which Windows' ClearType drew jagged
   (Hasarsızlık, Web Servis). Regular weight renders clean there; light mode keeps Fluent's semibold. */
body[data-theme="dark"] fluent-badge[appearance="tint"] {
    font-weight: var(--fontWeightRegular);
}

.gradient-text-accent {
    color: transparent;
    background-clip: text;
    background-image: linear-gradient(to right, var(--colorNeutralForeground1), var(--colorBrandForeground1));
}

/*
 * A just-deleted policy is tombstoned client-side (see PolicyGrid.razor): the policies grid is served through Atlas
 * Search, which is eventual-consistent and can keep returning the row for a few seconds after deletion. The row's
 * Actions cell renders a [data-policy-deleting] marker; this rule hides that whole FluentDataGrid row so the deleted
 * policy disappears immediately. Global (not scoped) CSS because the <tr> is rendered by the shared
 * UpGrid/FluentDataGrid child, which a scoped ::deep rule cannot reliably reach with :has().
 */
tr[role="row"]:has([data-policy-deleting]) {
    display: none;
}

/* A v5 select draws its focus ring for :focus-within, so the focus a dialog gives its first field on opening (app.js)
   and a click both showed it, doubled over the field's border. The ring stays for focus from the keyboard. */
fluent-dropdown:focus-within:not(:has(:focus-visible)) {
    --colorStrokeFocus1: var(--colorTransparentStroke);
    --colorStrokeFocus2: var(--colorTransparentStroke);
}

/* A click on a dialog's empty space focuses its <dialog>, which then showed the browser's own outline. */
fluent-dialog::part(dialog):focus:not(:focus-visible) {
    outline: none;
}

/*
 * The accounting vocabulary shared by the policy list, the policy page's ledger and the accounting screens
 * (Components/Modules/Accounting). Global rather than scoped because sibling components share one set of chips,
 * cards and tables, and a scoped stylesheet belongs to a single component; no Fluent component carries a parameter
 * for these shapes. Tones are the panel's intent roles (tokens.css), so both themes hold; the status pills themselves
 * are the panel's StatusBadge.
 */

/* How the money travelled — the card terminal, the till, a cheque, the agency's own card — in a chip with the glyph of
   the thing. One shape wherever it appears: on an instalment in the ledger tab, on a movement, in the card that opens
   over a balance in the policy list. */
.ledger-how {
    display: inline-flex;
    align-items: center;
    gap: var(--spacingHorizontalXS);
    padding: var(--spacingVerticalXXS) var(--spacingHorizontalS) var(--spacingVerticalXXS) var(--spacingHorizontalSNudge);
    border-radius: var(--borderRadiusMedium);
    background: var(--app-surface-sunken);
    color: var(--colorNeutralForeground1);
    font-size: var(--fontSizeBase200);
    line-height: var(--lineHeightBase200);
    white-space: nowrap;
}

.ledger-how svg {
    flex: none;
    width: 14px;
    height: 14px;
    fill: var(--colorNeutralForeground3) !important;
}

/* The money and, under it, how what has already moved was paid. */
.ledger-account {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--spacingVerticalXXS);
    min-width: 0;
}

.ledger-account-start {
    align-items: flex-start;
}

/* The three debts a policy carries, stacked in one cell. */
.policy-balances {
    display: flex;
    flex-direction: column;
    gap: var(--spacingVerticalXXS);
    font-size: var(--fontSizeBase200);
}

/* Each line says it has more to give: the pointer changes and the figure is underlined the way a term with a
   definition is, so nobody has to discover the schedule by accident. */
.policy-balance {
    display: grid;
    grid-template-columns: 16px 1fr auto;
    align-items: center;
    gap: var(--spacingHorizontalSNudge);
    padding: var(--spacingVerticalXXS) var(--spacingHorizontalXS);
    border-radius: var(--borderRadiusMedium);
    cursor: help;
    white-space: nowrap;
}

.policy-balance:hover {
    background: var(--colorSubtleBackgroundHover);
}

.policy-balance-icon {
    width: 14px;
    height: 14px;
}

.policy-balance-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.policy-balance-amount {
    font-variant-numeric: tabular-nums;
    font-weight: var(--fontWeightSemibold);
    border-bottom: var(--strokeWidthThin) dotted currentColor;
}

/* Something is owed: worth reading. Nothing is: worth having, not worth looking at. */
.policy-balance-owed {
    color: var(--colorNeutralForeground1);
}

.policy-balance-clear {
    color: var(--colorNeutralForeground3);
}

.policy-balance-clear .policy-balance-amount {
    font-weight: var(--fontWeightRegular);
}

/* What a balance is waiting on, in the card that opens over it: whose debt it is at the head, in that party's own hue
   — the same three the ledger tab paints its arms in — then the plan, one instalment to a row, with what met it, how,
   and where that can be read. */
.policy-plan {
    --arm: var(--colorNeutralForeground3);
    display: flex;
    flex-direction: column;
    gap: var(--spacingVerticalSNudge);
    font-size: var(--fontSizeBase200);
}

.policy-plan-customer {
    --arm: var(--app-dataviz-1);
}

.policy-plan-company {
    --arm: var(--app-dataviz-7);
}

.policy-plan-commission {
    --arm: var(--app-dataviz-3);
}

/* The head: the party's glyph and name, what was put on the books and what has moved, and — where the eye goes first
   — what is left. A rule down the left in the party's hue says which debt this is before a word is read. */
.policy-plan-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--spacingVerticalXXS) var(--spacingHorizontalS);
    padding: var(--spacingVerticalXXS) 0 var(--spacingVerticalSNudge) var(--spacingHorizontalMNudge);
    border-left: var(--strokeWidthThicker) solid var(--arm);
    border-bottom: var(--strokeWidthThin) solid var(--colorNeutralStroke2);
}

.policy-plan-head svg {
    width: 16px;
    height: 16px;
    flex: none;
    align-self: center;
}

.policy-plan-caption {
    font-weight: var(--fontWeightSemibold);
    color: color-mix(in srgb, var(--arm) 72%, var(--colorNeutralForeground1));
}

.policy-plan-of {
    font-size: var(--fontSizeBase100);
    color: var(--colorNeutralForeground3);
}

.policy-plan-remaining {
    margin-left: auto;
    font-weight: var(--fontWeightSemibold);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Which record a plan belongs to, where the policy has more than one. */
.policy-plan-record {
    margin-top: var(--spacingVerticalXXS);
    font-size: var(--fontSizeBase100);
    font-weight: var(--fontWeightSemibold);
    color: var(--colorNeutralForeground3);
}

.policy-plan-rows {
    border-collapse: collapse;
}

.policy-plan-rows td {
    padding: var(--spacingVerticalXXS) var(--spacingHorizontalMNudge) var(--spacingVerticalXXS) 0;
    vertical-align: middle;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.policy-plan-rows td:last-child {
    padding-right: 0;
}

.policy-plan-num {
    text-align: right;
}

/* A met instalment steps back so the open ones stand out; the tick and the day it was paid keep their own colour and
   carry the meaning. */
.policy-plan-settled td {
    color: var(--colorNeutralForeground3);
}

.policy-plan-note {
    color: var(--colorNeutralForeground3);
}

/* An instalment that is behind and part met: the pill says how late, the words beside it what is left. */
.policy-plan-state {
    display: inline-flex;
    align-items: center;
    gap: var(--spacingHorizontalSNudge);
}

.policy-plan-part {
    font-size: var(--fontSizeBase100);
    color: var(--colorNeutralForeground3);
}

/* Several things met one instalment: each chip and each way out on a line of its own. */
.policy-plan-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacingVerticalXXS);
}

/* The ways out of a row: the record that paid, and its entry in the journal, as two bare glyphs. */
.policy-plan-ways {
    display: inline-flex;
    gap: var(--spacingHorizontalXXS);
}

.policy-plan-way {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: var(--borderRadiusMedium);
    color: var(--colorBrandForeground1);
}

.policy-plan-way:hover {
    background: var(--colorSubtleBackgroundHover);
}

.policy-plan-way:focus-visible {
    outline: var(--strokeWidthThick) solid var(--colorStrokeFocus2);
    outline-offset: var(--strokeWidthThin);
}

.policy-plan-way svg {
    width: 14px;
    height: 14px;
    fill: currentColor !important;
}

/* ── the money dialogs opened from the policy list ─────────────────────────────────────────────── */

/* The policy the dialog is about, at the top of every one of them. */
.ledger-subject {
    display: flex;
    align-items: center;
    gap: var(--spacingHorizontalM);
    padding: var(--spacingVerticalMNudge) var(--spacingHorizontalM);
    margin-bottom: var(--spacingVerticalXS);
    border: var(--strokeWidthThin) solid var(--colorNeutralStroke2);
    border-radius: var(--borderRadiusLarge);
    background: var(--app-surface-canvas);
}

.ledger-subject-logo {
    max-width: 68px;
    max-height: 32px;
    flex: none;
}

.ledger-subject-who {
    display: flex;
    flex-direction: column;
    gap: var(--spacingVerticalXXS);
    min-width: 0;
}

.ledger-subject-number {
    font-size: var(--fontSizeBase400);
    font-weight: var(--fontWeightSemibold);
    font-variant-numeric: tabular-nums;
}

.ledger-subject-line {
    font-size: var(--fontSizeBase200);
    color: var(--colorNeutralForeground3);
}

/* Where the thing named has a state worth reading before the question below it — a payment that is still a piece of
   paper is a different conversation from one that has cleared. */
.ledger-subject-state {
    margin-left: auto;
}

/* Which endorsements the action is about. Rows rather than a select: each one carries what it is owed, which is the
   figure the choice is actually made on. */
.ledger-recs {
    display: flex;
    flex-direction: column;
    gap: var(--spacingVerticalSNudge);
    margin-top: var(--spacingVerticalS);
}

.ledger-rec {
    display: grid;
    grid-template-columns: 18px 1fr auto;
    align-items: center;
    gap: var(--spacingHorizontalMNudge);
    width: 100%;
    padding: var(--spacingVerticalS) var(--spacingHorizontalMNudge);
    border: var(--strokeWidthThin) solid var(--colorNeutralStroke1);
    border-radius: var(--borderRadiusLarge);
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.ledger-rec:hover:not(:disabled) {
    background: var(--colorSubtleBackgroundHover);
}

/* Tinted rather than filled: a solid light background is a light background in the dark theme too. */
.ledger-rec-on {
    border-color: var(--app-intent-info-border);
    background: var(--app-intent-info-bg);
}

.ledger-rec-box {
    display: grid;
    place-items: center;
    width: 16px;
    height: 16px;
    border: var(--strokeWidthThick) solid var(--colorNeutralStroke1);
    border-radius: var(--borderRadiusSmall);
    font-size: var(--fontSizeBase100);
    line-height: 1;
    color: var(--colorBrandForeground1);
}

.ledger-rec-round {
    border-radius: 50%;
}

.ledger-rec-who {
    display: flex;
    flex-direction: column;
    gap: var(--spacingVerticalXXS);
    min-width: 0;
}

.ledger-rec-who span {
    font-size: var(--fontSizeBase100);
    color: var(--colorNeutralForeground3);
}

.ledger-rec-amt {
    font-variant-numeric: tabular-nums;
    font-weight: var(--fontWeightSemibold);
    white-space: nowrap;
}

/* The answers to one question, side by side and stacking on a narrow window. */
.ledger-choices {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacingHorizontalS);
    margin-top: var(--spacingVerticalS);
}

@media (max-width: 560px) {
    .ledger-choices {
        grid-template-columns: 1fr 1fr;
    }
}

.ledger-choice {
    display: flex;
    flex-direction: column;
    gap: var(--spacingVerticalXXS);
    padding: var(--spacingVerticalS) var(--spacingHorizontalMNudge);
    border: var(--strokeWidthThin) solid var(--colorNeutralStroke1);
    border-radius: var(--borderRadiusLarge);
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.ledger-choice:hover:not(:disabled) {
    background: var(--colorSubtleBackgroundHover);
}

.ledger-choice:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.ledger-choice-on {
    border-color: var(--app-intent-info-border);
    background: var(--app-intent-info-bg);
}

/* A grid rather than a flex row: a two-word answer and a four-word one both keep the icon on the first line, where it
   is read as a heading mark instead of drifting into the middle of the words. */
.ledger-choice-head {
    display: grid;
    grid-template-columns: 16px 1fr;
    align-items: start;
    gap: var(--spacingHorizontalSNudge);
    font-size: var(--fontSizeBase300);
    line-height: var(--lineHeightBase200);
}

.ledger-choice-on .ledger-choice-head {
    color: var(--app-intent-info-fg);
}

.ledger-choice-icon {
    width: 16px;
    height: 16px;
}

/* What the answer does to the books. Quiet, because it is read once and then recognised; indented to line up under the
   label rather than under the icon (the icon's 16px, spacingHorizontalL, plus the head's gap). */
.ledger-choice-note {
    padding-left: calc(var(--spacingHorizontalL) + var(--spacingHorizontalSNudge));
    font-size: var(--fontSizeBase100);
    line-height: var(--lineHeightBase100);
    color: var(--colorNeutralForeground3);
}

/* A card with no icon: one column for the label, and a note with nothing to line up past. */
.ledger-choice-head.ledger-choice-plain {
    grid-template-columns: 1fr;
}

.ledger-choice-note.ledger-choice-plain {
    padding-left: 0;
}

.ledger-alloc {
    display: flex;
    flex-direction: column;
    gap: var(--spacingVerticalS);
}

/* A small table inside a dialog: the figures line up and nothing else competes with them. */
.ledger-mini {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fontSizeBase300);
}

.ledger-mini th {
    padding: var(--spacingVerticalXS) var(--spacingHorizontalS);
    border-bottom: var(--strokeWidthThin) solid var(--colorNeutralStroke2);
    font-size: var(--fontSizeBase100);
    font-weight: var(--fontWeightSemibold);
    color: var(--colorNeutralForeground3);
    text-align: left;
}

.ledger-mini td {
    padding: var(--spacingVerticalXS) var(--spacingHorizontalS);
    border-bottom: var(--strokeWidthThin) solid var(--colorNeutralStroke2);
    white-space: nowrap;
}

.ledger-mini tr:last-child td {
    border-bottom: 0;
}

.ledger-mini .ledger-num,
.ledger-mini th.ledger-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.ledger-quiet {
    color: var(--colorNeutralForeground3);
}

.ledger-alloc-input {
    max-width: 140px;
    margin-left: auto;
}

/* What the two balances will look like once the form is sent. */
.ledger-verdict {
    display: flex;
    flex-direction: column;
    gap: var(--spacingVerticalS);
    margin-top: var(--spacingVerticalS);
}

.ledger-verdict-arms {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacingHorizontalS);
}

@media (max-width: 560px) {
    .ledger-verdict-arms {
        grid-template-columns: 1fr;
    }
}

.ledger-verdict-arm {
    display: flex;
    flex-direction: column;
    gap: var(--spacingVerticalXXS);
    padding: var(--spacingVerticalS) var(--spacingHorizontalMNudge);
    border-left: var(--strokeWidthThicker) solid var(--colorNeutralStroke1);
    border-radius: var(--borderRadiusLarge);
    background: var(--app-surface-canvas);
}

.ledger-verdict-arm[data-state="closed"] {
    border-left-color: var(--app-intent-success-strong);
}

.ledger-verdict-arm[data-state="deferred"] {
    border-left-color: var(--app-intent-info-strong);
}

.ledger-verdict-arm[data-state="open"] {
    border-left-color: var(--app-intent-warning-strong);
}

.ledger-verdict-who {
    font-size: var(--fontSizeBase100);
    color: var(--colorNeutralForeground3);
}

.ledger-verdict-what {
    font-size: var(--fontSizeBase300);
    font-weight: var(--fontWeightSemibold);
}

.ledger-verdict-why {
    font-size: var(--fontSizeBase200);
    line-height: var(--lineHeightBase200);
    color: var(--colorNeutralForeground1);
}

.ledger-verdict-foot {
    padding: var(--spacingVerticalSNudge) var(--spacingHorizontalMNudge);
    border-left: var(--strokeWidthThicker) solid var(--app-intent-success-strong);
    border-radius: var(--borderRadiusLarge);
    background: var(--app-surface-canvas);
    font-size: var(--fontSizeBase200);
}

.ledger-verdict-foot[data-state="listed"] {
    border-left-color: var(--app-intent-warning-strong);
}

/* ── the pages money moving has of its own ──────────────────────────────────────────────────────── */

/*
 * One remittance, one refund, one commission window, one policy document. Global rather than scoped because the four
 * pages are one shape — what the record is *about* takes the width, what is true *of* it stands in a rail beside it —
 * and a scoped stylesheet would have been that shape written out four times.
 */
.ledger-detail-columns {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: var(--spacingHorizontalL);
    align-items: start;
    width: 100%;
}

.ledger-detail-rail {
    display: flex;
    flex-direction: column;
    gap: var(--spacingVerticalL);
    min-width: 0;

    /* Written after the table and read before it: the markup leads with what the record is about, so a reader who
       cannot see the two columns meets that first. */
    order: -1;
}

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

    .ledger-detail-rail {
        order: 0;
    }
}

.ledger-mono {
    font-family: var(--fontFamilyMonospace);
    font-weight: var(--fontWeightMedium);
    font-variant-numeric: tabular-nums;
}

/* Said quietly under the thing it qualifies: which endorsement a policy number stands for. */
.ledger-sub {
    display: block;
    font-size: var(--fontSizeBase200);
    font-weight: var(--fontWeightRegular);
    color: var(--colorNeutralForeground3);
}

.ledger-detail-note {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--spacingHorizontalMNudge);
    width: 100%;
    padding: var(--spacingVerticalMNudge) var(--spacingHorizontalL);
    border-radius: var(--borderRadiusMedium);
    border-left: var(--strokeWidthThicker) solid var(--app-intent-info-strong);
    background: var(--app-surface-canvas);
    font-size: var(--fontSizeBase300);
}

/* Something that has been taken back, or could not be read, is the one fact on the page somebody can act on wrongly. */
.ledger-detail-note[data-tone="warn"] {
    border-left-color: var(--app-intent-warning-strong);
}

.ledger-detail-note[data-tone="bad"] {
    border-left-color: var(--app-intent-danger-strong);
}

.ledger-detail-rows {
    width: 100%;
    overflow-x: auto;
}

.ledger-detail-rows table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fontSizeBase300);
}

.ledger-detail-rows th {
    text-align: left;
    font-weight: var(--fontWeightSemibold);
    font-size: var(--fontSizeBase200);
    color: var(--colorNeutralForeground3);
    padding: var(--spacingVerticalS) var(--spacingHorizontalM);
    border-bottom: var(--strokeWidthThin) solid var(--colorNeutralStroke2);
    white-space: nowrap;
}

.ledger-detail-rows td {
    padding: var(--spacingVerticalMNudge) var(--spacingHorizontalM);
    border-bottom: var(--strokeWidthThin) solid var(--colorNeutralStroke2);
    vertical-align: top;
}

.ledger-detail-rows tbody tr:last-child td {
    border-bottom: 0;
}

.ledger-detail-rows .num {
    text-align: right;
    white-space: nowrap;
}

/* The sum of the shares is the movement itself, so it is set apart from the rows it comes from. */
.ledger-detail-rows tfoot td {
    border-top: var(--strokeWidthThick) solid var(--colorNeutralStroke2);
    border-bottom: 0;
    font-weight: var(--fontWeightSemibold);
    font-size: var(--fontSizeBase400);
    background: var(--app-surface-canvas);
}

/* A row that no longer counts is still on the list — struck through rather than hidden, because the entry it wrote is
   still in the journal. */
.ledger-detail-rows tr[data-void="true"] td {
    color: var(--colorNeutralForeground3);
    text-decoration: line-through;
}

.ledger-detail-rows tr[data-void="true"] td.keep {
    text-decoration: none;
}

/* The figures a record comes down to, side by side: what was worked out, what moved it, what arrived, what is left.
   Tiles rather than a table because they are read against each other, not down a column. */
.ledger-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacingHorizontalM);
    width: 100%;
}

.ledger-stat {
    display: flex;
    flex-direction: column;
    gap: var(--spacingVerticalXXS);
    padding: var(--spacingVerticalMNudge) var(--spacingHorizontalM);
    border: var(--strokeWidthThin) solid var(--colorNeutralStroke2);
    border-left: var(--strokeWidthThicker) solid var(--colorNeutralStroke1);
    border-radius: var(--borderRadiusLarge);
    background: var(--app-surface-raised);
    min-width: 0;
    text-align: left;
    font: inherit;
    color: inherit;
}

button.ledger-stat {
    cursor: pointer;
}

button.ledger-stat:hover {
    background: var(--colorSubtleBackgroundHover);
}

.ledger-stat[data-on="true"] {
    background: var(--app-intent-info-bg);
    border-color: var(--app-intent-info-border);
}

.ledger-stat[data-tone="good"] {
    border-left-color: var(--app-intent-success-strong);
}

.ledger-stat[data-tone="info"] {
    border-left-color: var(--app-intent-info-strong);
}

.ledger-stat[data-tone="warn"] {
    border-left-color: var(--app-intent-warning-strong);
}

.ledger-stat[data-tone="bad"] {
    border-left-color: var(--app-intent-danger-strong);
}

.ledger-stat .k {
    font-size: var(--fontSizeBase200);
    color: var(--colorNeutralForeground3);
}

.ledger-stat .v {
    font-size: var(--fontSizeBase500);
    font-weight: var(--fontWeightSemibold);
    font-variant-numeric: tabular-nums;
}

.ledger-stat .s {
    font-size: var(--fontSizeBase200);
    color: var(--colorNeutralForeground3);
}

/* A file format described where the file is picked: a few quiet sentences around the one line that has to be copied
   exactly, which is set apart and scrolls sideways rather than wrapping — a wrapped heading line reads as two lines,
   and a file with two heading lines is not in the format. */
.ledger-format {
    display: flex;
    flex-direction: column;
    gap: var(--spacingVerticalSNudge);
    padding: var(--spacingVerticalMNudge) var(--spacingHorizontalM);
    border: var(--strokeWidthThin) solid var(--colorNeutralStroke2);
    border-radius: var(--borderRadiusLarge);
    font-size: var(--fontSizeBase200);
    color: var(--colorNeutralForeground3);
}

.ledger-format code {
    display: block;
    padding: var(--spacingVerticalSNudge) var(--spacingHorizontalS);
    overflow-x: auto;
    white-space: nowrap;
    border-radius: var(--borderRadiusMedium);
    background: var(--app-surface-sunken);
    color: var(--colorNeutralForeground1);
}
