/* Finance: money flow, requisitions, daily cash and the financial position.
   Owned by public/js/finance.js and loaded after /styles.css. Class names here belong to this module;
   a look shared by several modules goes in /styles.css (npm run check-styles enforces this). */

/* ---------- money flow ---------- */
.money-chain { display: flex; align-items: stretch; gap: .5rem; flex-wrap: wrap; }
.money-chain .money-tile { flex: 1 1 180px; text-align: left; font: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: inherit; }
.money-chain .money-tile.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.chain-arrow { align-self: center; color: var(--copper); font-weight: 800; font-size: 1.2rem; }
@media (max-width: 700px) { .chain-arrow { display: none; } }
.toolbar .spacer { flex: 1; }
/* The money cards (GAKA 1.52.0): one card per amount. A coloured edge shows its stage at a glance: blue waiting for
   confirmation, amber for verification, violet for the CEO, green approved. */
.money-cards { display: grid; gap: .75rem; }
.money-cards-total { display: flex; justify-content: space-between; align-items: baseline; padding: .1rem .25rem; }
.money-cards-total strong { font-size: 1.15rem; }
/* Select all (GAKA 1.105.0): one button per step this person can take on the list */
.money-select-all { display: flex; flex-wrap: wrap; gap: .4rem; padding: .1rem .25rem .5rem; }
.money-select-all .btn.active { background: var(--accent-soft, #e7f0ff); border-color: var(--accent, #2563eb); }
/* An amount waiting longer than the limit for its next step, and the count on its stage tile */
.badge.money-late { background: var(--danger-soft, #fde8e8); color: var(--danger, #b42318); font-weight: 600; }
.money-tile-late { color: var(--danger, #b42318); font-weight: 600; }
/* The Approved section folded to its count (GAKA 1.106.0) */
.money-fold-end { display: inline-flex; align-items: center; }
.money-section .money-cards-total .btn { margin-left: .75rem; }
/* The daily reminders line under the page title */
.money-remind { margin-top: .35rem; line-height: 1.9; }
.money-remind .ic { vertical-align: -.15em; margin-right: .2rem; }
.money-remind .btn { margin-left: .35rem; }
.money-card { --stage: var(--accent); position: relative; display: grid; gap: .85rem; padding: 1rem 1.1rem 1rem 1.25rem; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.money-card::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--stage); }
.money-card.stage-received { --stage: #5d93f2; }
.money-card.stage-confirmed { --stage: #f5a623; }
.money-card.stage-verified { --stage: #8b5cf6; }
.money-card.stage-approved { --stage: var(--ok); }
.money-card:hover { border-color: color-mix(in srgb, var(--stage) 45%, var(--border)); }
.money-card.picked { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
/* An amount acted on during this visit: stays in place, tinted green, until the page is opened again */
.money-card.money-done { background: color-mix(in srgb, var(--ok) 9%, var(--surface)); }
/* Head: tick box, what and when, the amount */
.money-card-head { display: grid; grid-template-columns: auto 1fr auto; gap: .75rem; align-items: start; }
.money-pick { width: 1.15rem; height: 1.15rem; margin-top: .2rem; accent-color: var(--accent); cursor: pointer; }
.money-pick-gap { width: 1.15rem; }
.money-card-title { display: grid; gap: .15rem; min-width: 0; }
.money-what { font-weight: 700; font-size: 1.02rem; color: var(--text); overflow-wrap: anywhere; }
a.money-what:hover { color: var(--accent); }
.money-amount { display: grid; justify-items: end; gap: .15rem; text-align: right; }
.money-amount strong { font-size: 1.35rem; line-height: 1.1; letter-spacing: -.01em; }
.money-amount .money-zig { font-size: .98rem; color: var(--text, inherit); opacity: .85; }
.money-method { font-size: .78rem; font-weight: 600; color: var(--muted); padding: .05rem .5rem; border-radius: 999px; background: var(--surface-2); }
.money-amount small { max-width: 18rem; }
/* Body: customer, driver and truck, proof (side by side on a computer) */
.money-card-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .75rem 1.25rem; padding-left: 1.9rem; }
.money-fact { display: flex; gap: .6rem; align-items: flex-start; min-width: 0; }
.money-fact-icon { flex: none; display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 10px; color: var(--stage); background: color-mix(in srgb, var(--stage) 14%, transparent); }
.money-fact-icon svg { width: 17px; height: 17px; }
.money-fact-text { display: grid; gap: .1rem; min-width: 0; }
.money-fact-text > small:first-child { font-size: .68rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.money-driver { font-size: 1rem; color: var(--text); }
.money-qty { color: var(--text); }   /* bricks (or m³) the money is for */
.money-route .route-arrow { color: var(--copper); font-weight: 700; }
/* Foot: the steps, who did what, the buttons */
.money-card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.25rem; padding: .75rem 0 0 1.9rem; border-top: 1px dashed var(--border); }
.money-stage { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .75rem; }
.money-trail { flex: 1 1 14rem; line-height: 1.45; }
.money-trail .money-note { margin-top: .2rem; font-style: italic; color: var(--text); }
.money-actions { display: flex; gap: .35rem; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
/* The three steps: a joined bar, ticked when done (who and when on hover), the next one outlined */
.money-progress { list-style: none; display: flex; align-items: center; margin: 0; padding: 0; font-size: .74rem; color: var(--muted); white-space: nowrap; }
.money-progress li { display: inline-flex; align-items: center; gap: .3rem; }
.money-progress li + li::before { content: ''; width: 1.4rem; height: 2px; margin: 0 .4rem; border-radius: 2px; background: var(--border); }
.money-progress li.done + li::before { background: var(--ok); }
.money-progress .dot { width: 1.05rem; height: 1.05rem; border-radius: 50%; border: 1.5px solid var(--border); display: inline-grid; place-items: center; font-size: .62rem; line-height: 1; }
.money-progress li.done { color: var(--ok); }
.money-progress li.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.money-progress li.now { color: var(--text); font-weight: 600; }
.money-progress li.now .dot { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
/* Phones: the amount goes under the title, everything lines up with the tick box */
@media (max-width: 600px) {
  .money-card { padding: .9rem .9rem .9rem 1.05rem; }
  .money-card-head { grid-template-columns: auto 1fr; }
  .money-amount { grid-column: 2; justify-items: start; text-align: left; }
  .money-card-body, .money-card-foot { padding-left: 0; }
  .money-actions { margin-left: 0; width: 100%; }
  .money-actions .btn { flex: 1; }
  .money-progress li + li::before { width: .8rem; margin: 0 .25rem; }
}
/* Approve / Complete all: the Driver cash the approval settles (driver, truck, load, amount) */
.money-settle { flex: 1 1 100%; width: 100%; border: 1px solid var(--border); border-left: 4px solid var(--ok); border-radius: 10px; padding: .55rem .75rem; margin-bottom: .5rem; background: var(--surface); }
.money-settle ul { margin: .3rem 0; padding-left: 1.1rem; }
/* ---------- requisitions, cash position, debtors ---------- */
.check-banner.bad { background: #fde7e7; color: #8f1d1d; border-left: 4px solid var(--danger); font-weight: 400; }
.check-banner.bad strong { display: block; margin-bottom: .2rem; }
@media (prefers-color-scheme: dark) { .check-banner.bad { background: #3a1416; color: #ffb3b3; } }
.stat.neg-stat strong { color: var(--danger); }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.two-col > .card { margin: 0; }
.declare-form { display: flex; flex-wrap: wrap; gap: .2rem 1rem; }
.declare-form .field { flex: 1 1 180px; }
.declare-form .form-actions { flex-basis: 100%; }
/* Today's declaration, shown once it is made */
.declare-done { margin: 0 0 .6rem; padding: .55rem .8rem; border-radius: 8px; color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); font-weight: 600; }
tr.personal-row td { background: var(--second-soft); }
.req-chain { white-space: normal; max-width: 22rem; }

/* Verify and Approve windows: each amount with its trail */
.money-step-list { width: 100%; flex: 1 1 100%; list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .5rem; max-height: 40vh; overflow-y: auto; }
.money-step-list > li { border: 1px solid var(--border); border-radius: 10px; padding: .55rem .75rem; background: var(--surface); }
.money-step-main { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.money-step-trail { color: var(--ok, var(--accent)); }

/* Just acted on (GAKA 1.82.10): where it went, then it slides out; Everything in sections by status */
.money-moved { font-weight: 700; color: var(--ok); font-size: .9rem; }
.money-card.money-leaving { opacity: 0; transform: translateX(24px); transition: opacity .3s ease, transform .3s ease; }
.money-section { display: grid; gap: .6rem; margin-bottom: 1.4rem; }
.money-section h2 { margin: 0; font-size: 1.05rem; }
@media (prefers-reduced-motion: reduce) { .money-card.money-leaving { transition: none; } }

/* Money flow (GAKA 1.86.4): the search box beside the chips, and the whole transaction under each amount */
/* Search and filters in one panel (GAKA 1.144.0): the search on top, then pill filters, Late only and the filtered total */
.money-search-row { display: grid; gap: .65rem; margin: .3rem 0 .9rem; padding: .8rem; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.money-search { width: 100%; max-width: none; }
.money-filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.money-filter { position: relative; display: inline-flex; min-width: 0; }
.money-filter select { appearance: none; -webkit-appearance: none; max-width: 15rem; min-height: 2.25rem; padding: .4rem 2rem .4rem .9rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-size: .88rem; font-weight: 600;
  text-overflow: ellipsis; white-space: nowrap; overflow: hidden; cursor: pointer; transition: border-color .15s, background-color .15s; }
.money-filter::after { content: ''; position: absolute; right: .85rem; top: 50%; width: .4rem; height: .4rem; margin-top: -.3rem; pointer-events: none;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); }
.money-filter select:hover { border-color: var(--accent); }
.money-filter select:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
.money-filter.on select { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--surface)); }
.money-filter.on::after { border-color: var(--accent); }
/* A long list (drivers, companies) becomes GAKA's type-to-search picker: the same pill, its list floating under it */
.money-filter:has(.pickbox)::after { display: none; }
.money-filter .pickbox { position: relative; width: 15rem; max-width: 100%; }
.money-filter .pickbox-input { width: 100%; min-height: 2.25rem; padding: .4rem .9rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); font-size: .88rem; font-weight: 600; }
.money-filter .pickbox-chosen { min-height: 2.25rem; padding: .15rem .25rem .15rem .9rem; border-radius: 999px; border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--surface)); font-size: .88rem; }
.money-filter .pickbox-list { position: absolute; z-index: 30; left: 0; top: calc(100% + 4px); min-width: 100%; width: max-content; max-width: min(22rem, 90vw); box-shadow: 0 10px 28px rgba(0, 0, 0, .3); }
.money-late-only { min-height: 2.25rem; font-weight: 600; }
.money-late-only:not(.active) { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.money-filter-sum { display: inline-flex; align-items: center; gap: .6rem; margin-left: auto; font-size: .9rem; }
@media (max-width: 640px) {
  .money-filters { display: grid; grid-template-columns: 1fr 1fr; }
  .money-filter select, .money-filter .pickbox { max-width: none; width: 100%; }
  .money-filter { display: flex; }
  .money-filter-sum { grid-column: 1 / -1; margin-left: 0; justify-content: space-between; }
}
.money-fig { display: block; text-align: right; }
.money-fig span { white-space: nowrap; }

/* What the CEO took in himself, waiting (GAKA 1.128.0) */
.money-own { border-left: 4px solid var(--ok); }
.money-own-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .6rem 1rem; }
.money-own-head h2, .money-own-head p { margin: 0; }
.money-own summary { cursor: pointer; margin-top: .5rem; color: var(--link); font-size: .9rem; }
.money-own-list { list-style: none; margin: .5rem 0 0; padding: 0; max-height: 18rem; overflow-y: auto; }
.money-own-list li { display: grid; grid-template-columns: 1fr 1fr auto; gap: .3rem 1rem; padding: .35rem 0; border-top: 1px solid var(--border); font-size: .9rem; }
@media (max-width: 600px) { .money-own-list li { grid-template-columns: 1fr auto; } .money-own-list li .muted { grid-column: 1 / -1; grid-row: 2; } }
/* A card with no note: its pencil (seen under the mouse) takes no room */
@media (min-width: 701px) { .money-card > .ln-empty { position: absolute; top: 3.9rem; left: 3.4rem; margin: 0; } }
