/* Reports, cash, stock, data and settings screens. Built on the tokens in core.css.
   Prefixes: ad- shared, rp- reports, cs- cash, sk- stock, dt- data, st- settings. */

/* ── shared ── */
.ad-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ad-print-only { display: none; }
.ad-lines { margin: 0; display: grid; }
.ad-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.ad-line:first-child { border-top: 0; }
.ad-line dt { color: var(--ink-2); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ad-line dd { margin: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ad-line.total { border-top: 2px solid var(--line-strong); padding-top: 12px; }
.ad-line.total dt { color: var(--ink); font-weight: 700; }
.ad-line.total .money { font-size: 1.25rem; font-weight: 700; }
.ad-sign { display: inline-block; width: 1.1em; color: var(--ink-3); direction: ltr; text-align: center; }
.ad-fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; margin: 0; display: grid; gap: 8px; min-width: 0; }
.ad-fieldset legend { padding: 0 6px; font-weight: 600; display: inline-flex; gap: 8px; align-items: center; }
.ad-radio { display: flex; gap: 9px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
.ad-radio input { margin-top: .45em; accent-color: var(--green); flex: none; }
.st-roles th[scope="row"] { text-align: start; font-weight: 500; padding: 11px 14px; border-top: 1px solid var(--line); background: transparent; color: var(--ink); white-space: normal; font-size: inherit; }
details.rp-note > summary { cursor: pointer; color: var(--green); font-size: .88rem; font-weight: 600; width: fit-content; border-radius: 6px; }
details.rp-note > summary:focus-visible { outline: 3px solid color-mix(in srgb, var(--green) 45%, transparent); outline-offset: 2px; }
details.rp-note > p { color: var(--ink-2); font-size: .88rem; margin-top: 4px; }
details.rp-note > .table-wrap { margin-top: 10px; }
details.rp-note[open] > summary { margin-bottom: 2px; }
.dt-facts { margin: 0; display: grid; gap: 0; }
.dt-facts > div { display: grid; grid-template-columns: minmax(120px, 190px) minmax(0, 1fr); gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.dt-facts > div:first-child { border-top: 0; }
.dt-facts dt { color: var(--ink-2); font-size: .9rem; }
.dt-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ── reports ── */
.rp-custom { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(140px, 200px)) auto; align-items: end; }
.rp-custom .notice { grid-column: 1 / -1; }
.rp-period { display: grid; gap: 4px; padding: 14px 18px; }
.rp-period-main { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.rp-period-main strong { font-size: 1.05rem; }
.rp-range { white-space: nowrap; }
.rp-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); align-items: start; }
.rp-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 8px; min-width: 0; }
.rp-card.is-open { border-color: var(--green); box-shadow: 0 0 0 2px var(--green-50); }
.rp-top { display: grid; gap: 2px; width: 100%; padding: 0; border: 0; background: none; text-align: start; cursor: pointer; border-radius: var(--radius-sm); color: inherit; }
.rp-top.static { cursor: default; }
button.rp-top:hover .rp-cta { text-decoration: underline; }
button.rp-top:focus-visible { outline: 3px solid color-mix(in srgb, var(--green) 45%, transparent); outline-offset: 4px; }
.rp-name { font-size: .9rem; font-weight: 600; color: var(--ink-2); }
.rp-value { display: block; text-align: end; line-height: 1.25; }
.rp-value .money { font-size: 1.6rem; font-weight: 700; }
.rp-cta { font-size: .84rem; font-weight: 600; color: var(--green); }
.rp-basis { font-size: .82rem; color: var(--ink-2); }
.rp-counts { margin: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; padding: 8px 0; border-block: 1px solid var(--line); }
.rp-counts dt { font-size: .76rem; color: var(--ink-3); }
.rp-counts dd { margin: 0; font-weight: 700; font-size: 1.1rem; text-align: start; direction: rtl; }
.rp-cmp { display: grid; gap: 0; border-top: 1px solid var(--line); padding-top: 4px; font-size: .86rem; }
.rp-cmp-row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; padding: 4px 0; flex-wrap: wrap; }
.rp-cmp-row .hint { font-size: .76rem; display: block; }
.rp-diff { display: inline-flex; gap: 8px; align-items: baseline; flex-wrap: wrap; justify-content: flex-end; }
.rp-pct { font-weight: 700; }
.rp-profit { background: var(--surface-2); border-style: dashed; }
.rp-profit .rp-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.rp-check { font-weight: 600; }
.rp-chart-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); padding: 6px 4px 0; }
.rp-svg { display: block; margin-inline: auto; max-width: none; }
.rp-bar { cursor: pointer; outline: none; }
.rp-hit { fill: transparent; }
.rp-bar:hover .rp-hit { fill: var(--green-50); }
.rp-bar:focus-visible .rp-hit { fill: var(--green-50); stroke: var(--green); stroke-width: 2; }
.rp-pos { fill: var(--green); }
.rp-neg { fill: var(--brass); }
.rp-zero { fill: none; stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 2.5 2; }
.rp-axis { stroke: var(--ink-2); stroke-width: 1; }
.rp-tick { font: 500 10.5px var(--font); fill: var(--ink-2); }
.rp-legend { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px 18px; flex-wrap: wrap; }
.rp-legend li { display: inline-flex; gap: 6px; align-items: center; }
.rp-key { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: none; }
.rp-key.pos { background: var(--green); } .rp-key.neg { background: var(--brass); }
.rp-key.zero { border: 1px dashed var(--ink-3); }
[data-detail] { outline: none; scroll-margin-top: 70px; }

/* ── cash ── */
.cs-cols { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: start; }
.cs-drawer h3, .cs-outside h3 { margin-bottom: 6px; }
.cs-outside { background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); padding: 14px 16px; display: grid; gap: 8px; }
.cs-open-row { display: grid; gap: 12px; grid-template-columns: minmax(0, 260px) auto; align-items: end; justify-content: start; }

/* ── stock ── */
.sk-actions { flex-wrap: nowrap; gap: 6px; }
.sk-table td { white-space: nowrap; }
.sk-table td:nth-child(2) { white-space: normal; min-width: 150px; }

/* ── data ── */
.dt-cols { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: start; }
.dt-counts { margin: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.dt-counts > div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 14px; }
.dt-counts dt { font-size: .82rem; color: var(--ink-2); }
.dt-counts dd { margin: 0; font-size: 1.4rem; font-weight: 700; text-align: start; direction: rtl; }
.dt-conflict p { font-weight: 500; }
.dt-hash { font-size: .82rem; overflow-wrap: anywhere; word-break: break-all; }

/* ── settings ── */
.st-search { max-width: 460px; }
/* Keep intrinsic table/select widths inside their own scrollable card on phones. */
.st > *, .st [data-main] > *, .st-card > *, .st-card form > *, .st-field { min-width: 0; }
.st-card > h2 { margin-bottom: 0; }
.st-check { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; cursor: pointer; padding-top: 4px; }
.st-check input { width: 18px; height: 18px; margin-top: .25em; accent-color: var(--green); flex: none; }
.st-integrations { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); align-items: start; }
.st-int { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; display: grid; gap: 8px; background: var(--surface); }
.st-missing { margin: 4px 0 0; padding-inline-start: 1.2em; display: grid; gap: 4px; color: var(--ink-2); font-size: .9rem; }
.st-roles td, .st-roles thead th { text-align: center; }
.st-roles thead th:first-child { text-align: start; }
.st-roles th[scope="row"] { min-width: 210px; }
.st-yes { font-weight: 700; color: var(--ok); }
.st .field:disabled { background: var(--surface-2); color: var(--ink-3); cursor: not-allowed; }

@media (max-width: 720px) {
  .cs-cols, .dt-cols { grid-template-columns: 1fr; }
  .rp-custom { grid-template-columns: 1fr 1fr; }
  .rp-custom .btn { grid-column: 1 / -1; }
  .rp-cards { grid-template-columns: 1fr; }
  .cs-open-row { grid-template-columns: 1fr; }
  .dt-facts > div { grid-template-columns: 1fr; gap: 2px; }
  .rp-value .money { font-size: 1.45rem; }
}

@media print {
  .ad-print-only { display: block; margin-bottom: 8px; }
  .rp .page-head p { display: none; }
  .rp-cards { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .rp-card, .st-int { break-inside: avoid; border-color: #999; }
  .rp-card.is-open { box-shadow: none; }
  .rp-value .money { font-size: 1.2rem; }
  details.rp-note > summary { color: inherit; }
  .table-wrap { overflow: visible; border-color: #999; }
  .tbl th, .tbl td { padding: 5px 8px; }
  .cs-cols { grid-template-columns: 1.7fr 1fr; }
  .cs-outside { background: none; }
}
