/* Expenses (owner round 15, migration 045): the new expense sheet, the expense cards, one expense's page, custody, the monthly register and a property's expenses.
   The owner's order of importance: very easy for any team member to log an expense in a few taps (the amount first and big, the invoice photo prominent,
   the rest under "More details"), clear status tags, a clean monthly register. Phone first, then the tablet; colours from css/tokens.css only (so the company
   colours and the dark look follow). The markup is app/js/expenses.js and app/js/expense-register.js. */

/* ---------- the new expense sheet: the amount, then the photo, then the few choices ---------- */
.modal .field:has(> #exAmt){ text-align:center; margin-bottom:0 }
.modal .field:has(> #exAmt) > label{ display:block; margin:0 0 8px; color:var(--text-3); font-size:calc(13px * var(--dt,1)); font-weight:600; letter-spacing:.02em }
#exAmt{ text-align:center; font-size:calc(38px * var(--dt-cap,1)) !important; font-weight:700; letter-spacing:-.02em; font-variant-numeric:tabular-nums; min-height:calc(76px * var(--dt-cap,1)); border-radius:var(--r-lg); background:var(--surface-2); border:1.5px solid var(--line); direction:ltr }
#exAmt::placeholder{ color:var(--text-3); opacity:.45 }
.xp-cur{ display:table; margin:8px auto 16px; padding:3px 12px; border-radius:var(--r-pill); background:var(--surface-3); color:var(--text-3); font-size:calc(13px * var(--dt,1)); font-weight:600 }

/* the invoice photo or PDF: a card of its own, in the action colour, so it is the second thing the eye finds */
.xp-photo{ margin:0 0 18px; padding:14px 16px 12px; border:1.5px dashed color-mix(in srgb, var(--c-primary) 55%, transparent); border-radius:var(--r-lg); background:var(--c-primary-tint) }
.xp-photo > label:first-child{ display:flex; align-items:center; gap:8px; margin:0 0 10px; color:var(--c-primary-ink); font-size:calc(15px * var(--dt,1)); font-weight:700 }
.xp-photo > label:first-child::before{ content:""; flex:none; width:22px; height:22px; background:currentColor; -webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3z'/%3E%3Ccircle cx='12' cy='13' r='3.5'/%3E%3C/svg%3E") center/contain no-repeat; mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3z'/%3E%3Ccircle cx='12' cy='13' r='3.5'/%3E%3C/svg%3E") center/contain no-repeat }
.xp-photo label.filepick, .xp-addfile label.filepick{ display:flex; align-items:center; flex-wrap:wrap; gap:8px 12px; margin:0; font-weight:400 }   /* a label inside .field would otherwise stack its two parts */
.xp-photo .filepick-btn{ min-height:calc(52px * var(--dt,1)); padding:0 24px; background:var(--surface-2); color:var(--c-primary-ink); box-shadow:inset 0 0 0 1.5px var(--c-primary); font-size:calc(16px * var(--dt,1)); font-weight:700 }   /* outlined: Save stays the one solid button */
.xp-photo .filepick-name{ color:var(--text-3) }
.xp-photo .filepick.chosen .filepick-name{ color:var(--text); font-weight:600 }
.xp-addfile .filepick-btn{ background:var(--c-primary-tint); color:var(--c-primary-ink) }
.xp-photo > p{ margin:8px 0 0; color:var(--text-3); font-size:calc(13px * var(--dt,1)) }
#exMore{ margin-top:4px }

/* a tablet's sheet is wide: the four choices go two by two; the amount, the photo and More details keep the whole width */
@media(min-width:700px){
  .modal .body:has(#exAmt){ display:grid; grid-template-columns:1fr 1fr; column-gap:16px; align-content:start }
  .modal .body:has(#exAmt) > .field:has(> #exAmt), .modal .body:has(#exAmt) > .xp-cur, .modal .body:has(#exAmt) > .xp-photo, .modal .body:has(#exAmt) > #exMore{ grid-column:1 / -1 }
}

/* ---------- status tags: one colour each, and the word says it too (Approved and Paid were nearly the same green) ---------- */
:is(.ent[data-spopen], .xpcust, .xplist, [data-xpprop], .xp-tags) .tag{ padding:3px 10px; font-size:calc(12px * var(--dt,1)); font-weight:700; letter-spacing:.01em }
:is(.ent[data-spopen], .xplist, [data-xpprop], .xp-tags, .modal .xpfigs ~ .setrow) .t-part{ background:var(--warn-tint); color:var(--warn-ink) }                  /* waiting */
:is(.ent[data-spopen], .xplist, [data-xpprop], .xp-tags, .modal .xpfigs ~ .setrow) .t-paid{ background:var(--ok-tint); color:var(--ok-ink) }                      /* approved */
:is(.ent[data-spopen], .xplist, [data-xpprop], .xp-tags, .modal .xpfigs ~ .setrow) .t-adv{ background:var(--ok); color:var(--surface-2) }                         /* paid out: the solid one */
:is(.ent[data-spopen], .xplist, [data-xpprop], .xp-tags, .modal .xpfigs ~ .setrow) .t-unpaid{ background:var(--bad-tint); color:var(--bad-ink) }                  /* rejected */
:is(.ent[data-spopen], .xplist, [data-xpprop], .xp-tags, .modal .xpfigs ~ .setrow) .t-neutral{ background:var(--surface-3); color:var(--text-3) }                 /* reversed, removed, the type */

/* ---------- the expense cards: the whole card opens the expense ---------- */
.ent[data-spopen]{ cursor:pointer; transition:background .12s ease }
.ent[data-spopen]:active{ background:var(--surface-3) }
.ent[data-spopen] .ent-top{ align-items:flex-start }
.ent[data-spopen] .ent-top > span:first-child{ display:flex; flex-wrap:wrap; align-items:center; gap:6px 8px; min-width:0 }
.ent[data-spopen] .ent-top b{ font-size:calc(16px * var(--dt,1)); font-weight:700 }
.ent[data-spopen] .ent-amt{ flex:none; font-size:calc(18px * var(--dt-cap,1)); font-variant-numeric:tabular-nums; letter-spacing:-.01em }
.ent[data-spopen] .ent-meta .num[dir="ltr"], .xplist .num[dir="ltr"], [data-xpprop] .num[dir="ltr"]{ font-variant-numeric:tabular-nums; font-weight:600; letter-spacing:.02em; color:var(--text-2) }   /* the expense number (the date's digits are not LTR-marked) */
.ent[data-spopen] .ent-note{ color:var(--text-2) }
.ent[data-spopen] .ent-note:last-of-type{ margin-bottom:0 }
/* the decision buttons on a card are quiet (tinted); the screen's one solid button is New expense request */
.ent[data-spopen] .ent-act .btn.go, .ent[data-spopen] .ent-act .btn.primary{ background:var(--c-primary-tint); color:var(--c-primary-ink); box-shadow:none }
.ent[data-spopen] .ent-act .btn.text{ color:var(--c-primary-ink) }
.ent[data-spopen] .ent-act [data-sphide]{ margin-inline-start:auto; color:var(--text-3) }
.ent[data-spopen] .ent-meta.xpsrc{ margin-top:2px }
.xpclip{ display:inline-flex; align-items:center; gap:4px; color:var(--c-primary-ink); font-weight:600 }
.xpclip::before{ content:""; width:13px; height:13px; background:currentColor; -webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48'/%3E%3C/svg%3E") center/contain no-repeat; mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48'/%3E%3C/svg%3E") center/contain no-repeat }
html[dir="rtl"] .xpclip::before{ transform:scaleX(-1) }

/* ---------- one expense's page (the sheet) ---------- */
.xp-tags{ margin:0 0 12px; gap:8px }
.xp-tags .tag{ padding:5px 14px !important; font-size:calc(14px * var(--dt,1)) !important }   /* the status is the first thing the page says */
h4.xphead{ margin:18px 0 6px; color:var(--text-3); font-size:calc(12.5px * var(--dt,1)); font-weight:700; letter-spacing:.06em; text-transform:uppercase }
.modal .setrow .v b, .modal .setrow .v .num{ font-variant-numeric:tabular-nums }
.xp-nofiles{ margin:0; padding:12px 14px; border-radius:var(--r-sm); background:var(--surface-3); font-size:calc(14px * var(--dt,1)) }
.xp-addfile{ margin-top:12px }
.xp-addfile > label{ color:var(--text-3); font-size:calc(13px * var(--dt,1)); font-weight:600 }
.xp-actions{ margin-top:18px; gap:10px }
.xp-actions .btn{ flex:1 1 0; min-height:calc(46px * var(--dt,1)) }
#xpRev.btn.text.danger, #xpRev.btn.text.danger:hover{ flex:0 0 auto; color:var(--bad-ink); background:transparent; box-shadow:none }
#xpFix.btn{ background:var(--c-primary-tint); color:var(--c-primary-ink); box-shadow:none }

/* ---------- custody ---------- */
[data-xpcustody] .empty{ padding:16px 18px; font-size:calc(14px * var(--dt,1)) }
.xpcust .ent-top b{ font-size:calc(16px * var(--dt,1)); font-weight:700 }
.xpcust .ent-amt{ font-variant-numeric:tabular-nums }
.xpfigs{ display:grid; grid-template-columns:repeat(3, minmax(0, 1fr)); gap:8px; margin:10px 0 0 }
.xpfigs:has(> span:nth-child(4)){ grid-template-columns:repeat(2, minmax(0, 1fr)) }   /* with Waiting there are four: two by two */
.xpfigs > span{ display:flex; flex-direction:column; gap:2px; padding:8px 12px; border-radius:var(--r-sm); background:var(--surface-3); color:var(--text-3); font-size:calc(12.5px * var(--dt,1)); font-weight:600 }
.xpfigs > span b{ color:var(--text); font-size:calc(15px * var(--dt,1)); font-weight:700; font-variant-numeric:tabular-nums }
.xpfigs > span:nth-child(3) b{ color:var(--ok-ink) }   /* what is left */
.modal .xpfigs{ margin:0 0 14px }
.xpcust .ent-act{ align-items:center }
.xpcust .ent-act .btn.text{ color:var(--c-primary-ink) }
.xpcust .ent-act .btn.text[data-xpcclose]{ margin-inline-start:auto; color:var(--bad-ink) }

/* ---------- the monthly register ---------- */
body[data-view="expreg"] .tools{ display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:10px 14px }
body[data-view="expreg"] .tools .cfmonth{ margin:0 }
body[data-view="expreg"] .stats{ margin-bottom:14px }
.xrgrid{ display:grid; grid-template-columns:1fr; gap:14px; margin-bottom:14px }
.xrgrid > .panel{ margin-bottom:0 }
.xrgrid .tw table td:first-child{ font-weight:600 }
.xrgrid .tw table td:last-child{ text-align:end; white-space:nowrap; font-variant-numeric:tabular-nums }
.xplist td, .xplist th{ font-variant-numeric:tabular-nums }
.xplist tr[data-xpopen], [data-xpopen].setrow{ cursor:pointer; transition:background .12s ease }
.xplist tr[data-xpopen]:active, [data-xpopen].setrow:active{ background:var(--surface-3) }
.xplist tr.xpoff, .setrow.xpoff{ opacity:.62 }   /* waiting, rejected and reversed ones: listed, not counted */
.xplist tr.xpoff .tag, .setrow.xpoff .tag{ opacity:1 }

/* a phone reads the list as cards: the category and amount, the number, the date and the status, then where it went. (fixes.css stacks every table
   on a phone as label-and-value rows; this table says it better in its own grid, so the stack's labels are switched off here.) */
@media(max-width:700px){
  table.xplist.stack, table.xplist.stack tbody{ display:block; width:100% }
  table.xplist.stack thead{ display:none }
  table.xplist.stack tbody tr{ display:grid; grid-template-columns:7.8em minmax(0, 1fr) auto; align-items:center; column-gap:10px; row-gap:3px; margin:0; padding:12px 16px; border:0; border-top:1px solid var(--line-soft); border-radius:0; background:transparent }
  table.xplist.stack tbody tr:first-child{ border-top:0 }
  table.xplist.stack td{ display:block; padding:0; border:0; min-width:0; text-align:start; justify-content:flex-start }
  table.xplist.stack td[data-label]::before{ content:none }
  table.xplist.stack td:nth-child(4){ grid-column:1 / 3; grid-row:1; font-size:calc(16px * var(--dt,1)); font-weight:700; color:var(--text) }
  table.xplist.stack td:nth-child(5){ grid-column:3; grid-row:1; text-align:end; font-size:calc(16px * var(--dt,1)) }
  table.xplist.stack td:nth-child(1){ grid-column:1; grid-row:2; font-size:calc(13px * var(--dt,1)) }
  table.xplist.stack td:nth-child(2){ grid-column:2; grid-row:2; color:var(--text-3); font-size:calc(13px * var(--dt,1)) }
  table.xplist.stack td:nth-child(8){ grid-column:3; grid-row:2; justify-self:end }
  table.xplist.stack td:nth-child(3){ grid-column:1 / 4; grid-row:3; color:var(--text-2); font-size:calc(14px * var(--dt,1)) }
  table.xplist.stack td:nth-child(6){ grid-column:1; grid-row:4; color:var(--text-3); font-size:calc(12.5px * var(--dt,1)) }
  table.xplist.stack td:nth-child(7){ grid-column:2 / 4; grid-row:4; color:var(--text-3); font-size:calc(12.5px * var(--dt,1)) }
}
/* a tablet: the three small tables sit side by side */
@media(min-width:1000px){ .xrgrid{ grid-template-columns:repeat(3, minmax(0, 1fr)) } }

/* ---------- a property's expenses this month ---------- */
[data-xpprop] .cfmonth{ margin-bottom:6px }
.xptotal{ display:flex; align-items:baseline; justify-content:space-between; gap:12px; padding:2px 0 6px }
.xptotal > span{ color:var(--text-3); font-size:calc(14px * var(--dt,1)) }
.xptotal > b{ font-size:calc(22px * var(--dt-cap,1)); font-weight:700; letter-spacing:-.02em; font-variant-numeric:tabular-nums }
[data-xpprop] .setrow .k{ min-width:0 }
[data-xpprop] .setrow .v{ flex:none; font-variant-numeric:tabular-nums }

/* each expense is a card of its own, like a request on Team requests. From a tablet's width they sit two or three across (bold.css), where flat entries
   side by side read as a list that broke in two; on a phone (the sweep's look pass) the flat entries lay on the page's own background under a white
   heading, so the amount, the person and the two answers had no surface to belong to */
body[data-view="finance"] .content > .ent[data-spopen]{ background:var(--card); border-top:0; border-radius:20px; box-shadow:var(--sh-1) }
body[data-view="finance"] .content > .ent[data-spopen]:active{ background:var(--surface-3) }
/* on a phone the cards are one under the other, so they keep their own gaps (the tablet's grid has its gap) */
@media(max-width:699.98px){
  body[data-view="finance"] .content > .ent[data-spopen]{ margin:0 0 12px }
  body[data-view="finance"] .content > .ent[data-spopen] + :not(.ent){ margin-top:20px }
}

/* a pointer: the cards and rows lift a little, the same shapes as their press states */
@media(hover:hover) and (pointer:fine){
  .ent[data-spopen]:hover, body[data-view="finance"] .content > .ent[data-spopen]:hover, .xplist tr[data-xpopen]:hover, [data-xpopen].setrow:hover{ background:var(--surface-3) }
}
@media(prefers-reduced-motion:reduce){ .ent[data-spopen], .xplist tr[data-xpopen], [data-xpopen].setrow{ transition:none } }

/* "Show removed": a quiet toggle, not a boxed card */
.tools .check:has(> #spShowRemoved), .tools label:has(> #spShowRemoved){ background:none; border:0; box-shadow:none; padding:0 6px; min-height:calc(44px * var(--dt,1)); color:var(--text-3); font-size:calc(14px * var(--dt,1)) }

/* a wide screen: the expense list keeps a reading width (the register keeps the whole width for its tables); the number, date and amount never break */
@media(min-width:901px){ body[data-view="finance"] .content{ max-width:960px } }
@media(min-width:701px){ .xplist td:nth-child(1), .xplist td:nth-child(2), .xplist td:nth-child(5), .xplist td:nth-child(8){ white-space:nowrap } }

/* Reverse a spend and Close a custody cannot be undone from the sheet: their button is red, like the other destructive ones */
.modal:has(#rvWhy) #shSave, .modal:has(#ccWhy) #shSave{ background:var(--bad); border-color:var(--bad); color:var(--surface-2) }
