/* DebtControl prototype — reference correction 18.10 + Opus5.5 type/palette refinement + reference Overview hierarchy
   + owner-screenshot correction (rail anchored to workspace, inline ring value, 3-column queue). Tokens in tokens.css. */
:root { --ws: 1440px; --rail-gap: 22px; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  font: 400 15px/1.45 var(--font); color: var(--ink);
  background-color: var(--canvas);
  background-image:
    radial-gradient(1200px 700px at 8% -10%, #F1EADC 0%, rgba(241, 234, 220, 0) 70%),
    radial-gradient(900px 800px at 100% 40%, var(--canvas-sage) 0%, rgba(221, 220, 207, 0) 70%),
    linear-gradient(180deg, #ECE6DA 0%, #E0DED5 100%);
  background-attachment: fixed;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, dl, dd, ol, ul { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
svg { flex: none; }
:focus-visible { outline: 2.5px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- floating icon rail ---------- */
.rail {
  /* Anchored to the centered workspace, not the viewport: on wide screens the rail sits
     inside .page's left padding instead of at the far window edge. */
  position: fixed; left: max(var(--rail-gap), calc((100vw - var(--ws)) / 2 + var(--rail-gap))); top: 50%; transform: translateY(-50%); z-index: 20;
  width: 52px; padding: 12px 0; border-radius: 26px; background: var(--black);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  box-shadow: 0 16px 34px -16px rgba(27, 28, 25, 0.6);
}
.rail-btn {
  position: relative; width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: transparent; color: #E9E6DD; cursor: pointer;
  display: grid; place-items: center;
  transition: background-color var(--dur-state) var(--ease-out), transform var(--dur-press) var(--ease-out);
}
.rail-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rail-btn:hover { background: rgba(255, 255, 255, 0.12); }
.rail-btn:active { transform: scale(0.94); }
.rail-btn[aria-current="page"], .rail-btn[aria-pressed="true"] { background: var(--panel); color: var(--black); }
.rail-btn:focus-visible { outline-color: #E9BF4A; }
.rail-btn::after {
  content: attr(data-tip); position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%);
  white-space: nowrap; padding: 6px 12px; border-radius: var(--r-pill);
  background: var(--black); color: #fff; font-size: 13px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity var(--dur-state) var(--ease-out);
}
.rail-btn:hover::after, .rail-btn:focus-visible::after { opacity: 1; }
.rail-sep { width: 22px; height: 1px; background: rgba(255, 255, 255, 0.2); margin: 6px 0; }
.rail-count {
  position: absolute; top: 2px; right: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--tone-yellow); color: var(--ink); font-size: 12px; font-weight: 650; line-height: 17px; text-align: center;
}

/* ---------- page frame ---------- */
.page { max-width: var(--ws); margin: 0 auto; padding: 22px 36px 48px 112px; }
/* Reference header grammar: brand row, then its own tabs row, then headline + metrics. */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 28px; margin-bottom: 26px; }
.top .brand { flex: 1; }
.top .pills { order: 3; flex: 1 1 100%; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.brand-mark { width: 36px; height: 36px; display: block; flex: none; }
.pills { display: flex; flex-wrap: wrap; gap: 4px; }
.pill {
  border: 0; background: transparent; padding: 8px 16px; border-radius: var(--r-pill);
  font-size: 14px; font-weight: 500; color: var(--ink); cursor: pointer;
  transition: background-color var(--dur-state) var(--ease-out), color var(--dur-state) var(--ease-out);
}
button.pill:hover { background: rgba(27, 28, 25, 0.07); }
.pill[aria-current="page"] { background: var(--black); color: #fff; }
.pill--planned { color: var(--ink-muted); cursor: default; }
.pill--planned small { font-size: 12px; margin-left: 4px; padding: 1px 7px; border-radius: var(--r-pill); border: 1px solid #B9B4A6; }
.demo-badge { padding: 7px 14px; border-radius: var(--r-pill); background: var(--tone-yellow); color: var(--ink); font-size: 13px; font-weight: 600; white-space: nowrap; }
.main { outline: none; }

/* ---------- headline ---------- */
/* Headline grouping: title | metrics on one row, the kind filter as its own control row below. */
.head { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 18px 48px; margin-bottom: 24px; }
.head-title h1 { font-family: var(--font-display); font-size: 40px; line-height: 1.04; font-weight: 500; letter-spacing: -0.035em; }
.head-title { max-width: 300px; }
.asof { margin-top: 8px; font-size: 13px; color: var(--ink-muted); }
.metrics { display: flex; gap: 20px 36px; flex-wrap: wrap; justify-content: flex-start; min-width: 0; }
.head > .seg { grid-column: 1 / -1; justify-self: start; }
.metric { display: flex; align-items: center; gap: 12px; min-width: 0; }
.metric-ico { width: 44px; height: 44px; border-radius: 50%; background: var(--panel); display: grid; place-items: center; flex: none; box-shadow: var(--shadow-panel); }
.metric-ico svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.metric-body { display: flex; flex-direction: column; min-width: 0; }
.metric-val { font-size: 26px; font-weight: 620; letter-spacing: -0.02em; line-height: 1.15; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.metric-val .of { font-size: 15px; font-weight: 500; color: var(--ink-muted); }
.metric-lbl { font-size: 14px; color: var(--ink-muted); }
.money { white-space: nowrap; }
.money .cur { font-size: max(12px, 0.62em); font-weight: 600; color: var(--ink-muted); letter-spacing: 0.02em; }
.money--risk { color: var(--rust-text); }
.money--risk .cur { color: var(--rust-text); }
.badge { font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: var(--r-pill); letter-spacing: 0; }
.badge--rust { background: var(--tone-rust); color: #fff; }

.seg { display: inline-flex; gap: 2px; padding: 4px; border-radius: var(--r-pill); background: var(--panel-sunk); }
.seg--wrap { flex-wrap: wrap; background: transparent; padding: 0; gap: 6px; }
.seg-btn {
  border: 0; background: transparent; padding: 7px 14px; border-radius: var(--r-pill); cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--ink); white-space: nowrap; display: inline-flex; align-items: center; gap: 7px;
  transition: background-color var(--dur-state) var(--ease-out), box-shadow var(--dur-state) var(--ease-out);
}
.seg-btn:hover { background: rgba(27, 28, 25, 0.06); }
.seg-btn[aria-pressed="true"] { background: var(--panel); box-shadow: 0 1px 3px rgba(27, 28, 25, 0.16); font-weight: 600; }
.seg--wrap .seg-btn { background: var(--panel-sunk); }
.seg--wrap .seg-btn[aria-pressed="true"] { background: var(--black); color: #fff; box-shadow: none; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot--rust { background: var(--tone-rust); } .dot--yellow { background: var(--tone-yellow); box-shadow: inset 0 0 0 1px #8A6D16; }
.dot--charcoal { background: var(--tone-charcoal); } .dot--green { background: var(--tone-green); } .dot--neutral { background: #B9B4A6; }

/* ---------- panels ---------- */
.panel {
  background: var(--panel); border-radius: var(--r-panel); padding: 22px 24px 24px;
  box-shadow: var(--shadow-panel); border: 1px solid rgba(255, 255, 255, 0.6); min-width: 0;
}
.panel h2 { font-size: 18px; font-weight: 560; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 6px; }
.sub { font-size: 13px; color: var(--ink-muted); margin-bottom: 16px; }
.tag { font-size: 13px; font-weight: 600; padding: 5px 12px; border-radius: var(--r-pill); background: var(--panel-sunk); }
.count { font-size: 12px; font-weight: 650; min-width: 24px; height: 22px; padding: 0 8px; border-radius: var(--r-pill); background: var(--panel-sunk); display: inline-grid; place-items: center; color: var(--ink); }
.circle {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid #D8D4C9; background: var(--panel); cursor: pointer;
  display: grid; place-items: center; transition: background-color var(--dur-state) var(--ease-out), transform var(--dur-press) var(--ease-out);
}
.circle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.circle:hover { background: var(--panel-sunk); } .circle:active { transform: scale(0.95); }
.btn-dark, .btn-light {
  border: 0; border-radius: var(--r-pill); padding: 9px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; transition: transform var(--dur-press) var(--ease-out), background-color var(--dur-state) var(--ease-out);
}
.btn-dark { background: var(--black); color: #fff; } .btn-dark:hover { background: #33342F; }
.btn-light { background: var(--panel-sunk); color: var(--ink); } .btn-light:hover { background: #DFDCD3; }
.btn-dark:active, .btn-light:active { transform: scale(0.97); }
.btn-dark svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.btn-dark[aria-pressed="true"] svg { fill: var(--tone-yellow); stroke: var(--tone-yellow); }
.empty { color: var(--ink-muted); padding: 12px 0; }
.unavailable { color: var(--rust-text); font-weight: 600; }

/* ---------- overview grid ----------
   Reference hierarchy (rapport Overview): broad chart panel, colored card grid,
   then a narrow tone panel with a ring beside a wide breakdown panel. */
.grid-ov { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.ov-row { display: grid; gap: 18px; min-width: 0; align-items: stretch; }
.ov-row--age { grid-template-columns: minmax(250px, 1fr) minmax(0, 2.7fr); }
.ov-row--checks { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.head-tools { display: flex; align-items: center; gap: 8px; }

/* ring (confirmed share), green tone panel */
.panel--ring { background: var(--tone-green); color: #fff; border-color: rgba(255, 255, 255, 0.08); display: flex; flex-direction: column; }
.panel--ring .money .cur { color: inherit; }
.ring { position: relative; width: 168px; max-width: 100%; aspect-ratio: 1; margin: 18px auto 14px; }
.ring svg { width: 100%; height: 100%; }
.ring circle { fill: none; stroke-width: 13; }
.ring-track { stroke: rgba(255, 255, 255, 0.16); }
.ring-arc { stroke: var(--tone-yellow); stroke-linecap: round; }
/* Number and percent sign are one inline run (single grid item), caption below. */
.ring-val { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.ring-fig { display: block; white-space: nowrap; font-size: 42px; line-height: 1; font-weight: 500; letter-spacing: -0.03em; }
.ring-fig small { font-size: 0.62em; font-weight: 500; margin-left: 2px; letter-spacing: 0; }
.ring-cap { font-size: 12px; color: var(--tone-green-muted); }
.ring-note { font-size: 15px; font-weight: 620; text-align: center; overflow-wrap: anywhere; }
.ring-sub { margin-top: 6px; font-size: 13px; color: var(--tone-green-muted); text-align: center; }

/* chart */
.big { font-size: 30px; font-weight: 620; letter-spacing: -0.025em; margin: 6px 0 8px; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; }
.big-note { font-size: 13px; font-weight: 400; color: var(--ink-muted); letter-spacing: 0; }
.big--sm { font-size: 24px; margin: 2px 0 16px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 13px; color: var(--ink-muted); margin-bottom: 14px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.lg { display: inline-block; width: 18px; height: 0; border-top: 2.5px solid var(--tone-green); }
.lg--promise { border-top: 2.5px dashed var(--tone-rust); }
.chart { position: relative; padding-left: 52px; padding-bottom: 34px; }
.chart-y { position: absolute; left: 0; top: 0; bottom: 34px; width: 46px; }
.chart-y span { position: absolute; right: 0; transform: translateY(50%); font-size: 12px; color: var(--ink-muted); }
.chart-plot { position: relative; height: 210px; }
.chart-plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.chart-plot .grid { stroke: #DAD7CD; stroke-width: 1; stroke-dasharray: 3 5; vector-effect: non-scaling-stroke; }
.chart-plot .area { fill: rgba(36, 90, 76, 0.12); }
.chart-plot .line { fill: none; stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.line--plan { stroke: var(--tone-green); }
.line--promise { stroke: var(--tone-rust); stroke-dasharray: 7 6; }
.chart-plot.has-guide::after { content: ""; position: absolute; top: 0; bottom: 0; left: var(--guide); border-left: 1px solid #9C978A; pointer-events: none; }
.chart-hit { position: absolute; inset: 0 -12px; display: grid; grid-template-columns: repeat(14, 1fr); }
.hit { border: 0; background: transparent; cursor: crosshair; padding: 0; border-radius: 8px; }
.hit:focus-visible { outline-offset: -2px; }
.tip {
  position: absolute; top: 4px; transform: translateX(-50%); z-index: 3; width: 196px;
  padding: 10px 12px; border-radius: 14px; background: #fff; color: var(--ink);
  box-shadow: 0 10px 26px -10px rgba(27, 28, 25, 0.4); display: flex; flex-direction: column; gap: 3px; font-size: 13px; pointer-events: none;
}
.tip[hidden] { display: none; }
.tip b { font-size: 13px; }
.tip span { display: flex; align-items: center; gap: 8px; }
.tip small { font-size: 12px; color: var(--ink-muted); }
.chart-x { position: absolute; left: 52px; right: 0; bottom: 0; height: 30px; }
.chart-x span { position: absolute; transform: translateX(-50%); font-size: 12px; font-weight: 600; text-align: center; line-height: 1.1; color: var(--ink); }
.chart-x small { display: block; font-weight: 400; color: var(--ink-muted); font-size: 12px; }
.chart-x .is-today { color: var(--tone-green); }
.foot { margin-top: 10px; font-size: 13px; color: var(--ink-muted); }

/* aging cells: bars left, breakdown right on wide panels */
.aging-body { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.age-sum { min-width: 0; }
.cells { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.cell { border: 0; background: transparent; padding: 0; cursor: pointer; display: flex; flex-direction: column; gap: 8px; text-align: center; }
.cell-track { position: relative; height: 132px; border-radius: var(--r-cell); background: var(--panel-sunk); overflow: hidden; display: flex; align-items: flex-end;
  transition: box-shadow var(--dur-state) var(--ease-out); }
.cell-bar { display: block; width: 100%; border-radius: var(--r-cell); background: var(--age-fill); }
.cell--current .cell-bar { background: var(--tone-green); }
.cell--d90_plus .cell-bar { background: var(--tone-rust); }
.cell.is-zero .cell-track::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: 0; height: 3px; border-radius: 2px; background: #B9B4A6; }
.cell:hover .cell-track { box-shadow: inset 0 0 0 2px var(--black); }
.cell-lbl { font-size: 13px; font-weight: 550; }
.age-list { margin-top: 0; }
.age-list li { display: grid; grid-template-columns: 12px 1fr auto auto; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.age-n { font-size: 13px; color: var(--ink-muted); }
.age-list b, .age-total b { font-weight: 620; min-width: 96px; text-align: right; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; background: var(--age-fill); }
.sw-current { background: var(--tone-green); } .sw-d90_plus { background: var(--tone-rust); }
.age-total { display: flex; justify-content: space-between; padding-top: 12px; font-size: 14px; font-weight: 600; }
.age-total--risk { padding-top: 4px; color: var(--rust-text); }
.age-total--risk .cur { color: var(--rust-text); }

/* ---------- action cards ---------- */
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.cards-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; margin-top: 16px; }
.cards-shown { font-size: 14px; color: var(--ink-muted); }
.cards-foot .btn-light svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.card {
  position: relative; display: flex; flex-direction: column; text-align: left; border: 0; cursor: pointer;
  border-radius: var(--r-card); padding: 18px 20px 18px; min-height: 232px; min-width: 0;
  transition: transform var(--dur-state) var(--ease-out), box-shadow var(--dur-state) var(--ease-out);
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.card:active { transform: scale(0.985); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; }
.card-more, .card-pin { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; letter-spacing: 1px; border: 1px solid currentColor; opacity: 0.85; }
.card-pin svg { width: 15px; height: 15px; fill: currentColor; stroke: none; }
.card-title { margin-top: 12px; font-size: 19px; font-weight: 560; line-height: 1.22; letter-spacing: -0.015em; }
.card-client { font-size: 14px; margin-top: 4px; overflow-wrap: anywhere; }
.card-bottom { margin-top: auto; padding-top: 16px; display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; }
.card-figs { display: flex; flex-direction: column; min-width: 0; }
.card-amount { font-size: 26px; font-weight: 620; letter-spacing: -0.02em; line-height: 1.15; }
.card .money .cur { color: inherit; }
.card-state { font-size: 13px; margin-top: 3px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 650; background: var(--panel); color: var(--ink); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5); }
.avatar--owner { background: var(--tone-yellow); color: var(--ink); }

.tone-rust { background: var(--tone-rust); color: #fff; }
.tone-rust .card-client, .tone-rust .card-state, .tone-rust .card-top { color: var(--tone-rust-muted); }
.tone-yellow { background: var(--tone-yellow); color: var(--ink); }
.tone-yellow .card-client, .tone-yellow .card-state, .tone-yellow .card-top { color: var(--tone-yellow-muted); }
.tone-yellow .avatar { background: var(--ink); color: #fff; }
.tone-charcoal { background: var(--tone-charcoal); color: #fff; }
.tone-charcoal .card-client, .tone-charcoal .card-state, .tone-charcoal .card-top { color: var(--on-dark-muted); }
.tone-green { background: var(--tone-green); color: #fff; }
.tone-green .card-client, .tone-green .card-state, .tone-green .card-top { color: var(--tone-green-muted); }
.tone-neutral { background: var(--panel-sunk); color: var(--ink); box-shadow: inset 0 0 0 1.5px #D3CDBE; }
.tone-neutral .card-client, .tone-neutral .card-state, .tone-neutral .card-top { color: var(--ink-muted); }
.tone-neutral .avatar { background: var(--panel); }

/* checks + sources */
.kv { margin-top: 10px; }
.kv > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { display: grid; grid-template-columns: 16px 1fr; column-gap: 10px; font-size: 14px; font-weight: 500; }
.kv dt small { grid-column: 2; font-size: 12px; color: var(--ink-muted); font-weight: 400; }
.kv dt:not(:has(svg)) { grid-template-columns: 1fr; }
.kv dt:not(:has(svg)) small { grid-column: 1; }
.kv dd { font-weight: 620; }
.src { margin-top: 10px; }
.src li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.src li:last-child { border-bottom: 0; }
.src small { grid-column: 1 / -1; font-size: 12px; color: var(--ink-muted); }
.panel--sources:focus-visible { outline-offset: 3px; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill); background: var(--panel-sunk); font-size: 12px; font-weight: 600; white-space: nowrap; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status--available { color: var(--green-text); } .status--partial { color: #6E5510; } .status--unavailable { color: var(--rust-text); }
.status--rust i { background: var(--tone-rust); } .status--yellow i { background: #B8901C; } .status--charcoal i { background: var(--tone-charcoal); }
.status--green i { background: var(--tone-green); } .status--neutral i { background: #9C978A; }

/* ---------- debts ---------- */
.panel--debts { padding: 18px 20px 20px; }
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.toolbar--2 { margin: 14px 0 18px; }
.search { position: relative; display: flex; align-items: center; flex: 1 1 260px; max-width: 360px; }
.search svg { position: absolute; left: 14px; width: 18px; height: 18px; fill: none; stroke: var(--ink-muted); stroke-width: 1.8; stroke-linecap: round; }
.search input { width: 100%; height: 42px; padding: 0 16px 0 42px; border-radius: var(--r-pill); border: 1px solid #D8D4C9; background: #fff; font: inherit; color: var(--ink); }
.search input::placeholder { color: var(--ink-muted); }
.view { margin-left: auto; display: inline-flex; gap: 2px; padding: 4px; border-radius: var(--r-pill); background: var(--panel-sunk); }
.chip { border: 1px solid #D3CDBE; background: var(--panel); border-radius: var(--r-pill); padding: 6px 14px; display: inline-flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 500; cursor: pointer; }
.chip svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.chip.is-on { background: var(--black); color: #fff; border-color: var(--black); }
.chip.is-on svg { stroke: var(--tone-yellow); }
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: start; }
.col { background: var(--panel-sunk); border-radius: 22px; padding: 12px; min-width: 0; }
.col-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 8px; padding: 2px 4px 12px; }
.col-head h3 { font-size: 14px; font-weight: 600; }
.col-sum { grid-column: 2 / -1; font-size: 13px; color: var(--ink-muted); }
.col-body { display: grid; gap: 10px; }
.col .card { min-height: 172px; padding: 14px 16px; }
.col .card-title { font-size: 16px; margin-top: 8px; }
.col .card-amount { font-size: 22px; }
.col-empty { font-size: 13px; color: var(--ink-muted); padding: 16px 6px; text-align: center; border: 1.5px dashed #CFC9BA; border-radius: 16px; }
.empty-box { padding: 32px; text-align: center; display: grid; gap: 14px; justify-items: center; color: var(--ink-muted); }

.table-wrap { width: 100%; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 13px; font-weight: 600; color: var(--ink-muted); padding: 8px 12px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tbody tr { cursor: pointer; transition: background-color var(--dur-state) var(--ease-out); }
.tbl tbody tr:hover { background: var(--panel-sunk); }
.tbl td small { display: block; font-size: 12px; color: var(--ink-muted); margin-top: 3px; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl td.num b { font-weight: 620; }
.sort { border: 0; background: transparent; padding: 4px 8px; margin: -4px -8px; border-radius: var(--r-pill); font-size: 13px; font-weight: 600; color: var(--ink-muted); cursor: pointer; display: inline-flex; gap: 6px; }
.sort.is-on { color: var(--ink); background: var(--panel-sunk); }
.link { border: 0; background: transparent; padding: 0; text-align: left; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--ink); }
.link:hover { text-decoration: underline; }

/* ---------- detail dialog ---------- */
.detail {
  width: min(580px, calc(100vw - 32px)); max-height: min(88vh, 860px); padding: 0; border: 0; border-radius: 30px;
  background: var(--panel); color: var(--ink); overflow: hidden; box-shadow: 0 30px 70px -20px rgba(27, 28, 25, 0.55);
}
.detail::backdrop { background: rgba(214, 208, 192, 0.55); backdrop-filter: blur(5px); }
.detail[open] { display: flex; flex-direction: column; animation: pop var(--dur-panel) var(--ease-out); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.985); } to { opacity: 1; transform: none; } }
.detail-head { flex: none; padding: 20px 24px 22px; border-radius: 30px 30px 26px 26px; }
.detail-top { display: flex; justify-content: space-between; align-items: center; }
.status--onTone { background: rgba(255, 255, 255, 0.92); color: var(--ink); }
.status--onTone i { background: var(--ink); }
.circle--onTone { background: rgba(255, 255, 255, 0.92); color: var(--ink); border-color: transparent; }
.detail-kind { margin-top: 14px; font-size: 13px; font-weight: 600; }
.detail-head h2 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; margin-top: 2px; }
.detail-amount { font-size: 34px; font-weight: 620; letter-spacing: -0.025em; margin-top: 10px; }
.detail-amount > span:last-child { font-size: 14px; font-weight: 500; margin-left: 8px; }
.detail-head .money .cur { color: inherit; }
.detail-state { font-size: 14px; }
.tone-rust .detail-kind, .tone-rust .detail-state, .tone-rust .detail-amount > span:last-child { color: var(--tone-rust-muted); }
.tone-green .detail-kind, .tone-green .detail-state, .tone-green .detail-amount > span:last-child { color: var(--tone-green-muted); }
.tone-charcoal .detail-kind, .tone-charcoal .detail-state, .tone-charcoal .detail-amount > span:last-child { color: var(--on-dark-muted); }
.tone-yellow .detail-kind, .tone-yellow .detail-state, .tone-yellow .detail-amount > span:last-child,
.tone-neutral .detail-kind, .tone-neutral .detail-state, .tone-neutral .detail-amount > span:last-child { color: var(--ink); }
.detail-body { padding: 20px 24px 24px; overflow-y: auto; min-height: 0; flex: 1; }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.facts > div { background: var(--panel-sunk); border-radius: 16px; padding: 10px 12px; }
.facts dt { font-size: 12px; color: var(--ink-muted); }
.facts dd { font-weight: 620; margin-top: 2px; font-size: 15px; }
.facts dd.risk { color: var(--rust-text); }
.todo { margin-top: 16px; padding: 14px 16px; border-radius: 18px; border: 1px solid var(--line); }
.todo-lbl { font-size: 12px; color: var(--ink-muted); font-weight: 600; }
.todo-act { font-size: 16px; font-weight: 600; margin-top: 2px; }
.todo-meta { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink-muted); margin-top: 8px; }
.todo-meta .avatar { background: var(--panel-sunk); box-shadow: none; }
.todo-warn { margin-top: 8px; font-size: 14px; }
.h-hist { font-size: 15px; font-weight: 600; margin: 20px 0 6px; }
.hist li { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.hist li:last-child { border-bottom: 0; }
.hist-ico { color: var(--ink); display: grid; place-items: center; }
.hist-main b { display: block; font-size: 14px; font-weight: 600; }
.hist-main small { font-size: 12px; color: var(--ink-muted); }
.hist-amt { font-weight: 620; font-size: 14px; }
.hist .is-broken b { color: var(--rust-text); }
.hist .is-future .hist-main b::after { content: ""; }
.note { margin-top: 14px; font-size: 13px; color: var(--ink-muted); padding: 10px 14px; border-radius: 14px; background: var(--panel-sunk); }
.detail-actions { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 50;
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 18px; border-radius: var(--r-pill);
  background: var(--black); color: #fff; font-size: 14px; box-shadow: 0 14px 34px -12px rgba(27, 28, 25, 0.6); max-width: calc(100vw - 32px);
}
.toast[hidden] { display: none; }
.toast svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.toast-undo { border: 0; border-radius: var(--r-pill); background: var(--tone-yellow); color: var(--ink); font-weight: 650; padding: 7px 16px; cursor: pointer; font-size: 14px; }
.toast-undo:focus-visible { outline-color: #fff; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .aging-body { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .age-list { margin-top: 16px; }
}
@media (max-width: 900px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-row--age, .ov-row--checks { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  body { font-size: 16px; }
  .page { padding: 16px 14px 104px; }
  .rail {
    left: 50%; top: auto; bottom: 14px; transform: translateX(-50%);
    width: auto; height: 56px; padding: 0 10px; flex-direction: row;
  }
  .rail-btn::after { left: 50%; top: auto; bottom: calc(100% + 10px); transform: translateX(-50%); }
  .rail-sep { width: 1px; height: 22px; margin: 0 4px; }
  .top { gap: 12px; margin-bottom: 16px; }
  .pill { padding: 8px 12px; }
  .demo-badge { font-size: 12px; padding: 6px 10px; }
  .head { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .head-title h1 { font-size: 30px; }
  .metrics { gap: 14px; flex-direction: column; }
  .metric-val { font-size: 22px; }
  .panel { padding: 18px 16px 18px; border-radius: 22px; }
  .big { font-size: 26px; }
  .chart { padding-left: 44px; }
  .chart-y { width: 40px; }
  .chart-x { left: 44px; }
  .chart-x span:nth-child(even) { visibility: hidden; }
  .chart-plot { height: 170px; }
  .cells { gap: 6px; }
  .cell-track { height: 92px; border-radius: 12px; }
  .cell-bar { border-radius: 12px; }
  .age-list li { grid-template-columns: 12px 1fr auto; }
  .age-n { grid-column: 2; grid-row: 2; }
  .age-list b { grid-column: 3; grid-row: 1 / span 2; min-width: 0; }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .card { min-height: 0; padding: 16px 18px; }
  .card-title { font-size: 18px; }
  .card-amount { font-size: 24px; }
  .cards-foot .btn-light { flex: 1 1 100%; justify-content: center; }
  .ring { width: 148px; }
  .ring-fig { font-size: 36px; }
  .big--sm { font-size: 22px; }
  .board { grid-template-columns: minmax(0, 1fr); }
  .search { max-width: none; flex-basis: 100%; }
  .view { margin-left: 0; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tbl thead tr { display: flex; justify-content: flex-end; gap: 16px; }
  .tbl thead th { border: 0; padding: 4px 0 8px; }
  .tbl thead th:not(.num) { display: none; }
  .tbl tbody tr { display: grid; grid-template-columns: 1fr auto; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .tbl td { border: 0; padding: 3px 0; }
  .tbl td:nth-child(1) { grid-column: 1; }
  .tbl td:nth-child(2) { grid-column: 2; grid-row: 2; }
  .tbl td:nth-child(3), .tbl td:nth-child(4) { grid-column: 1 / -1; }
  .tbl td:nth-child(5) { grid-column: 2; grid-row: 1; }
  .detail {
    width: 100vw; max-width: 100vw; max-height: 94vh; margin: auto 0 0; border-radius: 26px 26px 0 0;
  }
  .detail[open] { animation-name: sheet; }
  @keyframes sheet { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
  .toast { bottom: 84px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
}
