/* Credit keeps its working desk in view; the USDC book and diagram live in the bottom disclosure. */
.credit-page main { display:grid; grid-template-columns:minmax(0,1fr); gap:12px; align-content:start; }
.credit-page main > * { grid-column:1 / -1; }
.credit-page main > .window { padding:16px 20px; margin:0; }
.credit-page .window h2 { font-size:clamp(20px,2.4vw,26px); line-height:1.3; margin-bottom:10px; }
.credit-page .window p { margin-top:8px; }
.credit-page .desk-head { min-height:0; margin:0; padding-block:8px; }
.credit-page .desk-line { min-height:0; font-size:14px; line-height:1.5; }
.credit-page .ledger { display:grid; grid-auto-flow:row; grid-template-columns:repeat(2,minmax(0,1fr)); gap:1px; margin:10px 0; border:1px solid var(--hair); background:var(--hair); }
.credit-page .ledger > div { display:grid; grid-template-rows:1fr auto; padding:8px 10px; border:0; box-shadow:none; background:var(--washi-hi); }
.credit-page .ledger dt { min-height:2.7em; white-space:normal; }
.credit-page .ledger dd { font-size:20px; font-weight:500; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
@media(min-width:900px) { .credit-page .credit-book .ledger { grid-template-columns:repeat(4,minmax(0,1fr)); } }

.credit-flow-sheet { margin:22px 0; border:1px solid var(--line); background:var(--washi-hi); box-shadow:inset 0 0 0 5px var(--washi-lo); }
.flow-sheet-heading { display:flex; justify-content:space-between; align-items:center; margin:16px 20px 0; border-bottom:1px solid var(--hair); padding-bottom:10px; }
.flow-register { font:500 12px/1.4 var(--sans); letter-spacing:.14em; color:var(--muted); }
.flow-sheet-seal { display:grid; place-items:center; width:30px; height:30px; border:1px solid var(--shu); color:var(--shu); font:600 21px/1 var(--serif); transform:rotate(-5deg); }
.credit-flow-diagram { display:block; width:100%; height:auto; }
.flow-mobile { display:none; }
.flow-paper { fill:var(--washi); stroke:var(--line); stroke-width:1.4; }
.flow-node-title { fill:var(--sumi); font:600 19px var(--serif); }
.flow-label { fill:var(--ai); font:500 16px var(--sans); }
.flow-note { fill:var(--muted); font:400 14px var(--sans); }
.flow-drawing { fill:none; stroke:var(--ai); stroke-width:1.8; stroke-linejoin:round; stroke-linecap:round; }
.flow-drawing .receipt { fill:var(--washi-hi); stroke:var(--shu); }
.flow-stamp { fill:var(--washi-hi); stroke:var(--shu); }
.flow-arrow { fill:none; stroke-width:2; stroke-linejoin:round; }
.flow-arrow.cash { stroke:var(--ai); }
.flow-arrow.claim { stroke:var(--shu); stroke-dasharray:3 3; }
.flow-arrow.inactive { stroke:var(--muted); stroke-dasharray:6 6; opacity:.65; }
.flow-marker-cash { fill:var(--ai); }
.flow-marker-claim { fill:var(--shu); }
.flow-marker-inactive { fill:var(--muted); }
.credit-flow-sheet figcaption { display:flex; flex-wrap:wrap; gap:8px 20px; border-top:1px solid var(--hair); padding:14px 20px 18px; font-size:12px; line-height:1.6; color:var(--muted); }
.credit-flow-sheet figcaption > span::before { content:""; display:inline-block; width:24px; margin:0 8px 3px 0; border-top:2px solid var(--ai); }
.credit-flow-sheet .flow-legend-claim::before { border-color:var(--shu); }
.credit-flow-sheet .flow-legend-inactive::before { border-style:dashed; border-color:var(--muted); }
.credit-policy { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; border-left:3px solid var(--shu); padding:12px 16px; background:var(--shu-wash); }
.credit-policy[hidden] { display:none; }
.credit-policy dt { font-size:12px; line-height:1.5; }
.credit-policy dd { margin:4px 0 0; font:600 24px/1.2 var(--numbers); }
.credit-policy > p { grid-column:1/-1; margin:0!important; font-size:13px; }
.credit-page main > .credit-market-plans { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; padding:10px; }
.credit-market-plan { min-width:0; align-self:start; border:1px solid var(--hair); background:var(--washi-hi); }
.credit-page .credit-market-plan:last-child { border-bottom:1px solid var(--hair); }
.credit-market-plan[hidden] { display:none; }
.credit-market-plan > summary { display:grid; grid-template-columns:22px minmax(0,1fr) 14px; align-items:center; gap:2px 8px; min-height:60px; padding:8px 10px; cursor:pointer; font:600 15px/1.35 var(--serif); list-style:none; }
.credit-market-plan > summary::-webkit-details-marker { display:none; }
.credit-market-plan > summary .desk-seal { grid-row:1 / 3; width:22px; height:24px; font-size:16px; }
.credit-market-plan > summary::after { content:"＋"; grid-column:3; grid-row:1 / 3; font-size:18px; color:var(--shu); }
.credit-market-plan[open] > summary::after { content:"−"; }
.credit-market-plan > summary small { grid-column:2; color:var(--muted); font:400 11px/1.4 var(--sans); }
.credit-page .credit-plan-body { padding:0 10px 10px; }
.credit-plan-actions { display:flex; flex-wrap:wrap; gap:8px 16px; margin-top:8px; font-size:13px; }
.credit-plan-actions a { display:inline-flex; align-items:center; min-height:44px; }
@media(max-width:700px) { .flow-wide { display:none; } .flow-mobile { display:block; } .flow-sheet-heading { margin:14px 14px 0; } }
.credit-policy > dl { margin:0; }

.credit-lending-row { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:8px 16px; padding:0 16px; border:1px solid var(--hair); background:var(--washi-hi); }
.credit-lending-row:has(#credit-operate[hidden]):not(:has(.credit-status)) { display:none; }
.credit-lending-row a { display:inline-flex; align-items:center; min-height:44px; font-size:14px; }
.credit-page main > .credit-how { padding:0; }
.credit-how > summary { min-height:44px; padding:12px 20px; cursor:pointer; color:var(--sumi); font-size:14px; }
.credit-how[open] > summary { border-bottom:1px solid var(--hair); }
.credit-how-body { padding:12px 20px 16px; }
.credit-book { margin-top:16px; padding-top:12px; border-top:1px solid var(--hair); }
.credit-book[hidden] { display:none; }
.credit-book h3 { margin:0; font-size:18px; }
.credit-book > .ledger:has(#credit-apr) { grid-template-columns:minmax(0,1fr); }
.credit-book > .ledger:has(#credit-apr) > div { display:flex; align-items:baseline; justify-content:space-between; gap:8px; }
.credit-book > .ledger:has(#credit-apr) dt { min-height:0; }

/* One form serves all six actions, keeping its result rows and note space in place. */
.jc-section[hidden] { display:none; }
.jc-head { display:flex; flex-wrap:wrap; align-items:center; gap:8px 12px; margin-bottom:8px; }
.jc-head h2 { margin:0!important; }
.jc-lede { margin:0!important; font-size:13px; line-height:1.6; }
.credit-page .credit-status { display:grid; grid-template-columns:minmax(0,1fr) 44px; gap:8px; align-items:center; flex:1 1 380px; margin-left:auto; }
.credit-page .credit-status > button { grid-row:1; justify-self:end; }
.jc-status { display:flex; flex-wrap:wrap; align-items:baseline; justify-content:flex-end; gap:2px 10px; margin:0; font-size:12px; line-height:1.5; }
.jc-status[hidden] { display:none; }
.credit-page .jc-status > p { margin:0; }
.jc-status > time, .credit-page #credit-read-time { display:inline; min-height:0; font:400 11px/1.5 var(--sans); color:var(--muted); }
.jc-ledger-title { margin:12px 0 6px; font-size:14px; }
.credit-page .jc-ledger { margin:0; }
.credit-page .jc-ledger dd { white-space:normal; }
.jc-body { margin-top:12px; }
.jc-card { margin:0; border:1px solid var(--line); background:var(--washi-lo); }
.jc-card .desk-stage { margin:8px; padding:10px 12px; }
.jc-card .stage-form { gap:10px; }
.jc-card .field-head { display:grid; grid-template-columns:minmax(0,1fr); row-gap:6px; }
.jc-card .field-head > .hint { justify-self:end; }
.jc-card .desk-stage dl.jc-result { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); margin:0; padding:8px 12px; }
.jc-card dl.jc-result > div { display:block; min-width:0; }
.jc-card dl.jc-result dd { white-space:nowrap; margin:4px 0 0; font-variant-numeric:tabular-nums; }
.credit-page .jc-note { min-height:4.8em; margin:0; font-size:13px; line-height:1.6; }
.jc-card #pending, .jc-card #notice { margin:0 8px 8px; }
.jc-card #notice:empty { display:none; }
.jc-risks { margin-top:10px; }
.jc-risks > summary { display:flex; align-items:center; min-height:44px; }
.jc-risks dd { margin:2px 0 10px; }
.jc-position { min-width:0; padding:10px 12px; border:1px solid var(--line); background:var(--washi-hi); }
.jc-position[hidden] { display:none; }
.jc-position > .jc-ledger-title { margin:0 0 8px; }
.jc-position > p:empty { display:none; }
@media(min-width:900px) {
  .credit-page .jc-market { grid-template-columns:repeat(6,minmax(0,1fr)); }
  .credit-page .lb-market { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .jc-body:has(> .jc-position:not([hidden])) { display:grid; grid-template-columns:minmax(0,1.2fr) minmax(0,1fr); gap:16px; align-items:stretch; }
  .jc-body > .jc-position { grid-column:2; grid-row:1; }
  .jc-body > .jc-card { grid-column:1; grid-row:1; }
}
@media(max-width:899px) { .jc-position { margin-bottom:10px; } }
@media(max-width:560px) {
  .credit-page main > .window { padding:12px; }
  .credit-page main > .credit-how { padding:0; }
  .credit-page .ledger > div { padding:6px 8px; }
  .credit-page .ledger dd { font-size:18px; }
  .credit-page .credit-status { flex-basis:100%; }
  .jc-status { justify-content:flex-start; }
  .jc-card .desk-stage { padding:10px; }
  .credit-page .jc-note { min-height:6.4em; }
  .jc-card .desk-stage dl.jc-result { grid-template-columns:minmax(0,1fr); gap:4px; }
  .jc-card dl.jc-result > div { display:flex; justify-content:space-between; align-items:baseline; gap:8px; padding:0; border-left:0; }
  .credit-page main > .credit-market-plans { padding:8px; gap:6px; }
  .credit-market-plan > summary { grid-template-columns:minmax(0,1fr) 12px; gap:2px 4px; padding:8px; font-size:13px; }
  .credit-market-plan > summary .desk-seal { display:none; }
  .credit-market-plan > summary small { grid-column:1; }
  .credit-market-plan > summary::after { grid-column:2; }
  .credit-how > summary { padding:12px; }
  .credit-how-body { padding:10px 12px 12px; }
}
@media(max-width:359px) { .credit-page .jc-note { min-height:8em; } }

/* KASANE Loopback: the JPYdf Credit desk's layout, with every tab's panel stacked in one grid cell so the card keeps the tallest one's height. */
.lb-panels { display:grid; }
.lb-panel { grid-area:1 / 1; min-width:0; }
.lb-panel[data-off] { visibility:hidden; }
.lb-field-label { font-size:13px; color:var(--sumi-2); }
.lb-card .field-head { grid-template-columns:minmax(0,1fr); }
.lb-terms { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:4px 14px; margin-top:12px; }
.lb-terms .inline-field { display:grid; grid-template-columns:minmax(0,1fr); gap:2px; min-width:0; }
.lb-terms .inline-field > label { font-size:12px; color:var(--muted); }
.lb-terms .inline-field > select { justify-self:stretch; min-width:0; }
.lb-target { display:flex; align-items:center; gap:4px; min-width:0; }
.lb-target input[type=range] { flex:1 1 auto; min-width:0; min-height:24px; padding:0; border:0; box-shadow:none; background:transparent; accent-color:var(--shu); }
.lb-target input:not([type=range]) { flex:0 0 2.6em; width:2.6em; }
.lb-table { width:100%; margin-top:14px; border-collapse:collapse; table-layout:fixed; font:12.5px/1.5 var(--numbers); font-variant-numeric:tabular-nums; }
.lb-table th, .lb-table td { padding:4px 4px 4px 0; border-bottom:1px solid var(--hair); text-align:right; overflow-wrap:anywhere; }
.lb-table :is(th, td):first-child { width:3.2em; text-align:left; }
.lb-table thead th { font:500 11px/1.35 var(--sans); color:var(--muted); vertical-align:bottom; }
.lb-table td[data-empty] { color:var(--muted); }
@media(max-width:560px) {
  .lb-terms { grid-template-columns:minmax(0,1fr) minmax(0,1fr); }
  .lb-terms .inline-field:first-child { grid-column:1 / -1; }
  .lb-table { font-size:11.5px; }
}
/* Nine market cells: the last one takes the whole row where the ledger has two columns. */
@media(max-width:899px) { .lb-section > .jc-ledger > div:last-child:nth-child(odd) { grid-column:1 / -1; } }
/* The note under the form changes with the tab; a fixed floor keeps the card's height. */
.lb-card .jc-note { min-height:6.6em; }
@media(max-width:560px) { .lb-card .jc-note { min-height:8.4em; } }

/* Reserve utilisation and rates form one hierarchy rather than equal ledger cells. */
.credit-page .jc-market { margin-top:12px; display:grid; grid-template-columns:minmax(0,1fr); gap:0; border:1px solid var(--hair); background:var(--washi-hi); }
.jc-market > :is(div,dl) { min-width:0; margin:0; padding:10px 14px; }
.jc-market dt, .jc-position-totals dt, .jc-position-facts dt { font:500 12px/1.5 var(--sans); letter-spacing:0; color:var(--muted); }
.jc-market dd { margin:3px 0 0; font:500 clamp(25px,3vw,32px)/1.2 var(--numbers); font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
.jc-utilisation > dl { display:flex; justify-content:space-between; align-items:baseline; gap:8px; margin:0 0 6px; }
.jc-market .jc-rates { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; border-block:1px solid var(--hair); }
.jc-market .jc-rates dd { font-size:clamp(28px,3vw,36px); }
.jc-rates > div { min-width:0; }
.jc-rates > div + div { padding-left:12px; border-left:1px solid var(--hair); }
.credit-gauge { display:block; width:100%; height:8px; }
.gauge-track { fill:var(--washi-lo); }
.gauge-fill { fill:var(--ai); }
.credit-page .jc-market-ratio { margin:6px 0 0; font:11px/1.5 var(--numbers); color:var(--muted); }
.jc-market-ratio > span:first-child { margin-right:6px; }
.credit-page .jc-price-line { margin:6px 0 0; font:12px/1.6 var(--numbers); color:var(--muted); }
.credit-page .jc-connect-prompt { margin:10px 0 0; font-size:13px; color:var(--sumi-2); }
.credit-page .jc-body { margin-top:10px; }

/* Same 0–100% LTV scale as Borrow, using only the current theme's tokens. */
.credit-health { padding-block:2px; }
.credit-health-head { display:flex; flex-wrap:wrap; align-items:baseline; gap:2px 8px; margin-bottom:6px; }
.credit-health-head > span { font:500 12px/1.5 var(--sans); color:var(--muted); }
.credit-health-head > strong { margin-left:auto; font:500 28px/1.2 var(--numbers); }
.credit-health-head > small { width:auto; text-align:right; font:12px/1.5 var(--sans); color:var(--sumi-2); }
.credit-page .credit-health .ltv-meter { height:8px; background:linear-gradient(to right,var(--washi-lo) 0 var(--max),var(--gold) var(--max) var(--liq),var(--shu-wash) var(--liq) 100%); }
.credit-page .credit-health .ltv-meter span { background:var(--ai); transition:none; }
.credit-health[data-state=warn] .ltv-meter span { background:var(--kincha); }
.credit-health[data-state=danger] .ltv-meter span { background:var(--shu); }
.credit-health[data-state=unknown] .ltv-meter span { background:var(--muted); }
.credit-page .credit-health .ltv-meter .max { background:var(--kincha); }
.credit-page .credit-health .ltv-meter .liq { background:var(--shu); }
.credit-health .meter-before { position:absolute; top:-4px; bottom:-4px; left:var(--before); border-left:2px dotted var(--sumi); }
.meter-labels { display:flex; flex-wrap:wrap; justify-content:space-between; gap:2px 8px; margin-top:6px; color:var(--muted); font:11px/1.5 var(--sans); }
.meter-limit { color:var(--kincha); }
.meter-liquidation { color:var(--shu); }
.meter-limit::before, .meter-liquidation::before { content:""; display:inline-block; height:8px; margin-right:4px; border-left:2px solid currentColor; }
.credit-page .jc-position-totals { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; margin:8px 0; padding-block:6px; border-block:1px solid var(--hair); }
.jc-position-totals dd { margin:4px 0 0; font:500 28px/1.2 var(--numbers); overflow-wrap:anywhere; }
.jc-position-facts { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px 12px; margin:8px 0 0; }
.jc-position-facts > div { min-width:0; }
.jc-position-facts dd { margin:3px 0 0; font:500 16px/1.3 var(--numbers); overflow-wrap:anywhere; }
.jc-borrow-room dd { color:var(--ai); font-size:20px; }
.credit-page .jc-position > .stage-line, .credit-page .jc-position-empty { margin:8px 0 0; font:12px/1.6 var(--sans); color:var(--muted); }
.credit-health-mini { padding:0; min-height:56px; }
.credit-health-mini .credit-health-head { flex-wrap:nowrap; margin-bottom:4px; }
.credit-health-mini .credit-health-head > strong { font-size:17px; white-space:nowrap; }
.credit-health-mini .meter-state { display:none; }

/* One selected action, with the same space reserved in every tab. */
.jc-card:not(.lb-card) .field-head { grid-template-columns:auto minmax(0,1fr); align-items:center; gap:8px; }
.jc-direction-label { display:flex; align-items:center; gap:8px; }
.jc-direction-label > select { width:auto; min-width:112px; min-height:40px; }
.jc-card:not(.lb-card) .field-head > .hint { min-width:0; margin-left:0; }
.credit-page .jc-card:not(.lb-card) .jc-note { min-height:3.2em; margin-top:0; }
#jc-form { gap:8px; }
.jc-card:not(.lb-card) .jc-result > div { display:block; }
.jc-card:not(.lb-card) .jc-result:has(> div[hidden]) > div:not([hidden]) { grid-column:1 / -1; }
.jc-card:not(.lb-card) .jc-result { min-height:64px; }
.jc-card .jc-result dd[data-empty] { color:var(--muted); }
.jc-card .actions { margin-top:0; }
.lb-cycle { margin:8px 0; padding:8px 12px; border-left:2px solid var(--ai); background:var(--washi-hi); }
.lb-cycle figcaption { font:12px/1.5 var(--sans); color:var(--muted); }
.lb-cycle > div { display:flex; align-items:center; justify-content:space-between; gap:4px; max-width:600px; font:500 16px/1.6 var(--numbers); }
.lb-cycle b { color:var(--ai); font-weight:400; }
.credit-page .lb-cycle p { margin:0; font:12px/1.5 var(--sans); color:var(--muted); }
.lb-market-details, .lb-wallet-details { margin-top:8px; font-size:12px; }
.lb-market-details > summary, .lb-wallet-details > summary { min-height:32px; cursor:pointer; }
@media(min-width:900px) {
  .credit-page .jc-market { grid-template-columns:minmax(0,1.15fr) minmax(0,1.5fr) minmax(0,1fr); align-items:stretch; }
  .jc-market .jc-rates { border-block:0; border-inline:1px solid var(--hair); align-content:center; }
  .jc-market > .jc-market-cash { align-content:center; }
  .credit-page .lb-market { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .lb-market > dl { border-left:1px solid var(--hair); }
}
@media(max-width:899px) {
  .jc-market > .jc-market-cash { padding-block:10px; }
  .jc-market-cash { display:flex; flex-wrap:wrap; justify-content:space-between; align-items:baseline; gap:4px 12px; }
  .lb-market > dl { border-top:1px solid var(--hair); }
}
@media(max-width:560px) {
  .jc-market > :is(div,dl) { padding:10px; }
  .jc-card:not(.lb-card) .field-head { grid-template-columns:minmax(0,1fr); gap:8px; }
  .jc-card:not(.lb-card) .field-head > .hint { min-height:24px; }
  /* Two figures side by side, as on desktop, so Lend's pair takes the same row as one figure elsewhere. */
  .jc-card:not(.lb-card) .desk-stage dl.jc-result { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .jc-card:not(.lb-card) dl.jc-result > div + div { padding-left:12px; border-left:1px solid #b0381f38; }
  .credit-page .jc-card:not(.lb-card) .jc-note { min-height:4.8em; }
  .credit-health-mini .credit-health-head { flex-wrap:wrap; }
  .credit-health-mini .credit-health-head > strong { font-size:16px; }
  .credit-health-mini { min-height:76px; }
  .lb-cycle > div { font-size:13px; }
  .meter-labels { font-size:10px; gap:2px 4px; }
}
