/* Account statement (Balance + Account views, plan §6.7). The page IS the ledger visually: the accordion, tab
   rows, line tables, badges, amount colours and modal all come from
   admin-statements.css (included by the accounting pages) and its --stmt-* tokens.
   Only what the ledger has no equivalent for lives here. No hardcoded colours. */

.acct-page { padding: 24px 28px 64px; }

.acct-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.acct-head h1 { margin: 0; font-family: var(--stmt-font-mono); font-size: 1.5rem; color: var(--stmt-text-primary); font-weight: 600; }
.acct-meta { display: flex; gap: 12px; align-items: center; margin-top: 6px; font-size: 12px; color: var(--text-muted); }
.acct-warn { color: var(--accent-emphasis); font-weight: 600; }
.acct-intro { margin: 6px 0 0; font-size: 13px; color: var(--text-muted); max-width: 70ch; }
.acct-basis { text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }

/* Account statement: the Balance | Account selector, top right of the header. */
/* Right side of the header: the label selector (several labels only) then the view toggle. */
.acct-head-side { display: flex; align-items: center; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.acct-head-side .acct-toolbar { align-items: center; }
.acct-view-switch { display: inline-flex; flex-shrink: 0; border: 1px solid var(--stmt-border); border-radius: 8px; overflow: hidden; }
.acct-view-btn {
    background: transparent; border: 0; color: var(--stmt-text-secondary); cursor: pointer;
    padding: 8px 16px; font-family: var(--stmt-font-mono); font-size: 0.8rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
}
.acct-view-btn + .acct-view-btn { border-left: 1px solid var(--stmt-border); }
.acct-view-btn:hover { background: var(--stmt-bg-row-hover); color: var(--stmt-text-primary); }
.acct-view-btn.active { background: var(--stmt-bg-expanded); color: var(--stmt-accent); }
.acct-view-btn:focus-visible { outline: 2px solid var(--stmt-accent); outline-offset: -2px; }

/* Admin list: the ledger's label rows, account columns (label | credits | charges | paid | balance | lines). */
.acct-list .accordion-header-row,
.acct-list .label-row { grid-template-columns: 1fr 120px 120px 120px 130px 60px; }
.acct-list .label-row:focus-visible { outline: 2px solid var(--stmt-accent); outline-offset: -2px; }
.acct-list .label-row .acct-paid { font-size: 0.85rem; text-align: right; }
/* An opened label: its tabs straight under the row, figures in the row's columns
   (same right edge: the content has no right padding, the tab rows the row's 20px). */
.acct-list .label-content { padding: 4px 0 12px 32px; }
.acct-inline-tabs .cat-row { padding: 12px 20px; margin: 6px 0; }
.acct-page .filters-bar .search-input { flex: 2; }
.acct-page .filters-bar .filter-select { flex: 0.7; }
.acct-badge-new { border: 1px solid var(--stmt-accent); color: var(--stmt-accent); font-size: 0.6rem; font-weight: 700; letter-spacing: 0.05em; }
.acct-pagination { display: flex; justify-content: center; align-items: center; gap: 16px; padding: 24px; }
.acct-pagination .page-info { font-family: var(--stmt-font-mono); font-size: 0.85rem; color: var(--stmt-text-secondary); }
.acct-pagination .btn-page {
    background: var(--stmt-bg-card); border: 1px solid var(--stmt-border); border-radius: 6px;
    color: var(--stmt-text-primary); padding: 8px 14px; font-size: 0.85rem; cursor: pointer;
}
.acct-pagination .btn-page:hover:not([disabled]) { border-color: var(--stmt-accent); }
.acct-pagination .btn-page[disabled] { opacity: 0.45; cursor: not-allowed; }

.acct-toolbar { display: flex; gap: 8px; align-items: flex-start; }
.acct-search { position: relative; }
.acct-input, .acct-select {
    background: var(--bg-input, var(--bg-well)); color: var(--text-primary);
    border: 1px solid var(--bg-card-hover, #2a2d31); border-radius: 6px;
    padding: 7px 10px; font-size: 13px;
}
.acct-input { width: 220px; }
#acct-picker { position: absolute; z-index: 20; left: 0; right: 0; }
.acct-picker-list { background: var(--bg-card); border: 1px solid var(--bg-card-hover, #2a2d31); border-radius: 6px; margin-top: 6px; max-height: 260px; overflow: auto; }
.acct-picker-item { display: block; width: 100%; text-align: left; background: transparent; border: 0; color: var(--text-primary); padding: 8px 10px; cursor: pointer; }
.acct-picker-item:hover { background: var(--bg-card-hover, #1c1c1c); }

/* Ledger accordion, account columns: tab | credits | charges | paid | balance | docs.
   The header row and the tab rows share one grid so the figures line up. */
.acct-accordion .accordion-header-row,
.acct-accordion .cat-row { grid-template-columns: 1fr 120px 120px 120px 130px 60px; }
.acct-accordion .accordion-header-row { padding: 14px 32px; }
.acct-tabs { padding: 4px 16px 12px; }
.acct-accordion .cat-row .acct-paid { font-size: 0.85rem; }
.acct-accordion .cat-row:focus-visible { outline: 2px solid var(--stmt-accent); outline-offset: 2px; }

/* Lines. Every cell stays on one line: the figures never wrap, and the description
   gives way instead — it is the only flexible column (max-width: 0 + width: 100% is
   what lets a table cell shrink below its content and clip it). */
.acct-accordion .lines-table th,
.acct-accordion .lines-table td { white-space: nowrap; }
.acct-accordion .lines-table td.acct-desc-cell { width: 100%; max-width: 0; }
.acct-desc { display: flex; align-items: center; gap: 8px; min-width: 0; }
.acct-desc > * { flex: 0 0 auto; }
.acct-number { font-family: var(--stmt-font-mono); }
/* The free text: clipped with an ellipsis, slid fully into view while the row is hovered. */
.acct-desc > .acct-ref {
    flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis;
    container-type: inline-size;
    color: var(--stmt-text-muted); font-size: 0.8rem;
}
/* At rest the text is plain inline content, so the ellipsis clips it mid-sentence
   (an inline-block would be dropped whole). Hovered, it becomes a box that can be
   slid by its own overflow: 100% is its full width, 100cqw the room it has. */
.acct-accordion .lines-table tr:hover .acct-ref { text-overflow: clip; }
.acct-accordion .lines-table tr:hover .acct-ref-text {
    display: inline-block;
    transform: translateX(min(0px, calc(100cqw - 100%)));
    transition: transform 2.5s linear 0.2s;
}
@media (prefers-reduced-motion: reduce) {
    .acct-accordion .lines-table tr:hover .acct-ref-text { transition: none; }
}
.acct-col-actions { width: 110px; text-align: right; white-space: nowrap; }
.acct-col-actions a.btn-icon { text-decoration: none; }
.acct-products-head td {
    background: var(--stmt-bg-expanded); color: var(--stmt-text-secondary);
    font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}
/* The Products index of `main`, folded by default: its heading opens it. */
.acct-products-head { cursor: pointer; }
.acct-products-head:hover td { color: var(--stmt-text-primary); }
.acct-products-head:focus-visible { outline: 2px solid var(--stmt-accent); outline-offset: -2px; }
.acct-products-head .chevron-small { width: 12px; height: 12px; vertical-align: -2px; margin-right: 6px; transform: rotate(-90deg); transition: transform 0.2s ease; }
.acct-products-head.expanded .chevron-small { transform: none; }
.acct-accordion .total-reports-line { cursor: pointer; background: var(--stmt-bg-secondary); }
.acct-state {
    display: inline-block; padding: 2px 7px; border-radius: 4px;
    font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
    border: 1px solid var(--stmt-border); color: var(--stmt-text-muted);
}
.acct-state-not_paid, .acct-state-partial { color: var(--stmt-color-negative); border-color: currentColor; }
.acct-state-in_payment { color: var(--stmt-accent-blue); border-color: currentColor; }

.acct-muted { color: var(--stmt-text-muted); font-size: 0.85rem; margin: 0; }

.acct-empty, .acct-loading { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.acct-empty h2 { color: var(--text-primary); }

/* ── Invoice YOYAKU (label-invoice-view.js): the same ledger chrome, in blocks ── */
/* Native controls (the checkbox, the horizontal scrollbar) follow color-scheme, which
   the site never sets, so the browser drew them light on the dark theme. Dark is the
   default; body.label-light (theme-toggle.js) is the light theme. */
.linv-block {
    margin-bottom: 20px;
    color-scheme: dark;
    scrollbar-color: var(--stmt-border) transparent;
}
body.label-light .linv-block { color-scheme: light; }
.acct-accordion .accordion-header-row.linv-block-head {
    /* Title left, the » / « columns toggle (if any) right. */
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 20px;
}
/* Cells never wrap (see .acct-accordion .lines-table above) and .accordion-container
   clips its overflow, so a table wider than the block used to lose its right-hand
   columns (amounts, state, actions) with no scrollbar. Scroll instead of clipping. */
.linv-block-body { padding: 12px 16px 16px; overflow-x: auto; }
.linv-check { width: 28px; }
/* The global `input` rule (dashboard.css) gives every input 10px 14px padding
   and width:100%. Chrome ignores padding on a checkbox; Firefox draws the box
   inside it, so in a 28px cell it shrank to a dot. Size it explicitly. */
.linv-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    padding: 0;
    margin: 0;
    vertical-align: middle;
    cursor: pointer;
    accent-color: var(--stmt-accent);
}
.lines-table tr.linv-selected { background: var(--stmt-bg-expanded); }

/* A long state ("Difference vs <report>") used to widen the whole row; cut it with
   an ellipsis instead. The full text stays in the badge's title (hover). */
.linv-block .acct-state {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}
.linv-state-todo { color: var(--stmt-accent); border-color: currentColor; }
.linv-state-wait { color: var(--stmt-accent-blue); border-color: currentColor; }
.linv-state-hold { color: var(--stmt-color-negative); border-color: currentColor; }
.linv-state-done { color: var(--stmt-color-positive); border-color: currentColor; }

/* Invoice / queue tables (invoiceTable in label-invoice-view.js) open COMPACT so the
   first view fits without horizontal scrolling: Label, Number, Date, Total, Actions.
   Sales reports + Status (.linv-col-extra) appear with the » toggle, and the block
   then scrolls sideways if it has to (.linv-block-body overflow-x). */
.linv-compact .linv-col-extra { display: none; }
.linv-compact .linv-trunc {
    display: block;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.linv-compact button.linv-trunc { text-align: left; }
/* Several admin buttons may sit in Actions: let them wrap in the compact view
   instead of pushing the table past the block. */
.linv-compact td.linv-actions { white-space: normal; }
/* Folded (default): the header row + the first row only, so the "To invoice" block
   below stays in the first view. + in the title bar opens every row. */
.linv-rows-folded tr.linv-row-more { display: none; }
.linv-head-tools { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.linv-head-tools .linv-cols-toggle { margin-left: 0; }
/* Both title-bar toggles (+ / − rows, » / « columns) share one size. */
.linv-cols-toggle {
    margin-left: 6px;
    min-width: 32px;
    min-height: 26px;
    padding: 2px 10px;
    border: 1px solid var(--stmt-border);
    border-radius: 4px;
    background: transparent;
    color: var(--stmt-text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
}
.linv-cols-toggle:hover { color: var(--stmt-accent); border-color: currentColor; }
.linv-cols-toggle:focus-visible { outline: 2px solid var(--stmt-accent); outline-offset: 2px; }

/* Several badges in one cell (badgeGroup in label-invoice-view.js): the first one
   + a "…" badge; the rest open underneath on hover / focus. They open downwards,
   in the flow, so the column never widens and nothing is clipped by the block's
   horizontal scroll. */
.linv-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.linv-badges .linv-more { cursor: help; }
.linv-badges-extra { display: none; flex-basis: 100%; flex-direction: column; align-items: flex-start; gap: 4px; }
.linv-badges:hover .linv-badges-extra,
.linv-badges:focus-within .linv-badges-extra { display: flex; }
/* Hover only: hiding the "…" while it holds keyboard focus would drop the focus
   and close the group again. */
.linv-badges:hover .linv-more { display: none; }

.linv-how { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--stmt-border); }
.linv-how-total { display: flex; gap: 24px; align-items: baseline; font-size: 0.9rem; color: var(--stmt-text-secondary); margin-bottom: 12px; }
.linv-how-total strong { font-family: var(--stmt-font-mono); font-size: 1.05rem; color: var(--stmt-text-primary); }
.linv-how-total strong.positive { color: var(--stmt-color-positive); }
.linv-how-total strong.negative { color: var(--stmt-color-negative); }
.linv-how-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.linv-how-actions a.btn { text-decoration: none; }
.linv-disabled, .linv-how-actions button[disabled] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.linv-notice { margin: 12px 0 0; font-size: 0.8rem; line-height: 1.5; color: var(--stmt-text-muted); max-width: 90ch; white-space: normal; }
.linv-message { margin-bottom: 14px; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--stmt-color-negative); color: var(--stmt-text-primary); font-size: 0.85rem; }

.linv-actions { text-align: right; white-space: nowrap; }
.linv-action, .linv-label-link {
    background: transparent; border: 1px solid var(--stmt-border); border-radius: 6px; color: var(--stmt-text-primary);
    font-size: 0.75rem; padding: 4px 8px; margin-left: 6px; cursor: pointer;
}
.linv-action:hover { border-color: var(--stmt-accent); }
.linv-action[disabled] { opacity: 0.45; cursor: not-allowed; }
.linv-label-link { border: 0; margin: 0; padding: 0; color: var(--stmt-accent); font-size: inherit; }
.linv-label-link:hover { text-decoration: underline; }

/* Dialogs: the ledger's .modal-overlay / .modal-content */
.linv-dialog { max-width: 520px; }
.linv-dialog.linv-dialog-wide { max-width: 760px; }
.linv-qty { width: 90px; text-align: right; background: var(--stmt-bg-secondary); border: 1px solid var(--stmt-border); border-radius: 6px; color: var(--stmt-text-primary); padding: 4px 8px; font-family: var(--stmt-font-mono); }
.linv-qty:focus { outline: none; border-color: var(--stmt-accent); }
.linv-preview-title { margin: 16px 0 6px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--stmt-text-muted); }
.linv-preview-total { margin: 10px 0 0; font-size: 0.85rem; text-align: right; }
.linv-preview-total strong { font-family: var(--stmt-font-mono); }
.linv-dialog-sub { margin: 8px 0 0; font-size: 0.8rem; color: var(--stmt-text-secondary); line-height: 1.5; }
.linv-dialog-sub strong { font-family: var(--stmt-font-mono); color: var(--stmt-text-primary); }
.linv-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.linv-form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--stmt-text-muted); }
.linv-form .linv-form-file { grid-column: 1 / -1; }
.linv-form input, .linv-form textarea {
    background: var(--stmt-bg-secondary); border: 1px solid var(--stmt-border); border-radius: 6px;
    color: var(--stmt-text-primary); padding: 8px 10px; font-size: 0.9rem; font-family: inherit; text-transform: none; letter-spacing: 0;
}
.linv-form input:focus, .linv-form textarea:focus { outline: none; border-color: var(--stmt-accent); }
.linv-dialog-error { grid-column: 1 / -1; margin: 0; color: var(--stmt-color-negative); font-size: 0.85rem; }
