/*
 * reports.css — what only the reports screen looks like.
 *
 * The heading, the row-shaped skeleton, `.client-section`/`.section-heading`
 * and `.state*` are all the base stylesheet's. This is the figure rows
 * themselves and the small rates note at the top.
 */

/* `tally:reports-dashboard` (2026-09-22) — heading and export share a row,
   the export itself sized to its own text rather than stretched full-width
   like a screen's primary action, since it is not one. */
.reports-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-block-end: 20px;
}

/* Below the 1024px tier, `.account` (styles.css) is a fixed 40px circle
   sitting inset-inline-end: 16px — the same corner this row's export button
   hugs. On a narrow phone #app has no side margin left to absorb it, so the
   button's own tail ends up under the circle. Reserving the circle's full
   16+40px footprint, plus its own 16px gap, keeps the button clear of it. */
@media (max-width: 1023.98px) {
  .reports-header { padding-inline-end: 72px; }
}

.reports-header .form-title { margin: 0; }

.reports-export {
  inline-size: auto;
  padding-inline: 16px;
  flex: none;
}

.reports-rates-note { margin-block-end: 20px; }

.reports-settings-link {
  color: var(--text);
  text-decoration: underline;
}

/* ---- The hero: net profit, income vs expenses at a glance --------------- */

.reports-hero { margin-block-end: 20px; }

.reports-hero__bars {
  margin-block-start: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reports-hero__bar-row { display: flex; flex-direction: column; gap: 4px; }

.reports-hero__bar-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8125rem;
  color: rgba(255, 255, 255, .75);
}

.reports-hero__bar-track {
  block-size: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  overflow: hidden;
}

.reports-hero__bar-fill {
  block-size: 100%;
  border-radius: inherit;
}

.reports-hero__bar-fill.is-income { background: linear-gradient(90deg, #5fd88f, #2f8f5b); }
.reports-hero__bar-fill.is-expense { background: linear-gradient(90deg, #ff9d94, #d0454f); }

/* ---- Expenses by category, as proportional bars -------------------------- */

.reports-bars {
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: var(--surface-blur);
  -webkit-backdrop-filter: var(--surface-blur);
  border: 1px solid rgba(255, 255, 255, .7);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.reports-bar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-block-end: 6px;
  font-size: 0.875rem;
}

.reports-bar__track {
  block-size: 8px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.reports-bar__fill {
  block-size: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.report-figures {
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: var(--surface-blur);
  -webkit-backdrop-filter: var(--surface-blur);
  border: 1px solid rgba(255, 255, 255, .7);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.report-figure {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-block-size: 52px;
  padding: 10px 16px;
}

.report-figure + .report-figure,
.report-figures__nested + .report-figure { border-block-start: 1px solid var(--border); }

.report-figure__label { color: var(--text-muted); display: flex; align-items: center; gap: 6px; }

.report-figure__value {
  font-weight: 500;
  color: var(--value);
}

.report-figure__value.is-positive { color: var(--pos); }
.report-figure__value.is-negative { color: var(--neg); }

/* ---- The collapsible "מיסים" row, `tally:taxes-collapsed` ---------------- */

.report-figure--toggle {
  inline-size: 100%;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: start;
}

.report-figure__chevron {
  inline-size: 16px;
  block-size: 16px;
  color: var(--text-muted);
  transform: rotate(90deg);
  transition: transform .15s ease;
  flex: none;
}

/* Points left at rest (RTL "collapsed, more this way"), down once open —
   drawn once as a right-pointing chevron and rotated by CSS both times
   rather than kept as two shapes to stay in sync with each other. */
[dir="rtl"] .report-figure__chevron { transform: rotate(180deg); }
[dir="rtl"] .report-figure__chevron.is-open { transform: rotate(90deg); }
.report-figure__chevron.is-open { transform: rotate(90deg); }

/* The two rates behind "מיסים" — indented and on a hair of tint, so they
   read as belonging to the row above them rather than as two more peers of
   הכנסות/הוצאות/רווח נקי. */
.report-figures__nested {
  background: rgba(27, 35, 51, .035);
}

.report-figures__nested .report-figure {
  padding-inline-start: 34px;
  min-block-size: 44px;
  font-size: 0.9375rem;
}

.report-figures__nested .report-figure + .report-figure { border-block-start: 1px solid var(--border); }

/* ---- Filters & insights, `tally:reports-filters` (2026-09-23) ----------- */

.reports-filters {
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: var(--surface-blur);
  -webkit-backdrop-filter: var(--surface-blur);
  border: 1px solid rgba(255, 255, 255, .7);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  margin-block-end: 14px;
}

.reports-filters__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px 12px;
}

.reports-filters__clear {
  inline-size: auto;
  margin-block-start: 12px;
  padding-inline: 14px;
  min-block-size: 34px;
}

/* Big-number tiles, the same reasoning `reportsHero_` already used for the
   headline figure above: a project's average/top/bottom profit is exactly
   the kind of number worth its own tile rather than another row in a list
   of labels. Wraps to as many per row as the width allows, same idea as
   the filter grid above it. */
.reports-insights {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-block-end: 10px;
}

.reports-insights__tile {
  border-radius: var(--radius-sm);
  /* `tally:perf-no-blur-lists` — up to six of these at once; see
     `--surface-solid`'s own comment in tokens.css. */
  background: var(--surface-solid);
  border: 1px solid rgba(255, 255, 255, .7);
  padding: 12px 14px;
}

.reports-insights__label {
  margin: 0 0 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.reports-insights__value {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--value);
}

.reports-insights__value.is-positive { color: var(--pos); }
.reports-insights__value.is-negative { color: var(--neg); }

.reports-insights__sub {
  margin: 4px 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reports-results-note {
  margin-block-end: 8px;
}

.reports-results {
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: var(--surface-blur);
  -webkit-backdrop-filter: var(--surface-blur);
  border: 1px solid rgba(255, 255, 255, .7);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  max-block-size: 420px;
  overflow-y: auto;
}

.reports-results__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
}

.reports-results__row + .reports-results__row { border-block-start: 1px solid var(--border); }

.reports-results__main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-inline-size: 0;
}

.reports-results__desc {
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reports-results__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reports-results__end {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex: none;
}

.reports-results__end .num { font-size: 0.875rem; font-weight: 500; }
.reports-results__end .num.is-positive { color: var(--pos); }
.reports-results__end .num.is-negative { color: var(--neg); }

.reports-results__date {
  font-size: 0.75rem;
  color: var(--text-muted);
  direction: ltr;
}

.reports-results__empty {
  padding: 20px 16px;
  text-align: center;
  color: var(--text-muted);
}

/* ---- `tally:reports-period` (2026-09-28) — one date frame for the screen */

.reports-period {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-block: 4px 12px;
}

.reports-period--small { margin-block: 0 12px; }

.reports-period__chip {
  min-block-size: 36px;
  padding-inline: 14px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: var(--surface);
  backdrop-filter: var(--surface-blur);
  -webkit-backdrop-filter: var(--surface-blur);
  box-shadow: var(--shadow-sm);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.reports-period--small .reports-period__chip { min-block-size: 32px; padding-inline: 12px; font-size: 0.8125rem; }

.reports-period__chip.is-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

#app.is-refreshing .reports-hero,
#app.is-refreshing .client-section { opacity: .55; transition: opacity .15s; }

.reports-table-wrap {
  overflow-x: auto;
  margin-inline: -4px;
  padding-inline: 4px;
}

.reports-table {
  inline-size: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.reports-table th,
.reports-table td {
  padding: 8px 6px;
  text-align: end;
  white-space: nowrap;
  border-block-end: 1px solid rgba(27, 35, 51, .07);
}

.reports-table th:first-child,
.reports-table td:first-child { text-align: start; }

.reports-table__sort {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.reports-table__sort.is-active { color: var(--accent); }

.reports-table td.is-positive { color: var(--pos); }
.reports-table td.is-negative { color: var(--neg); }

.reports-table tfoot td {
  font-weight: 700;
  border-block-end: none;
  border-block-start: 2px solid rgba(27, 35, 51, .12);
}

.reports-sort-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-block-end: 8px;
}

.reports-sort { inline-size: auto; min-inline-size: 170px; }

/* `tally:left-to-collect` (2026-09-29) — "who owes me": one row per job. */
.owes-row__label { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.owes-row__client { color: var(--text-muted); font-size: 0.8125rem; font-weight: 400; }

/* ---- Expenses split by what they went on, `tally:expense-groups` (2026-11-01) ---- */

.reports-bar__head--toggle {
  inline-size: 100%;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  padding: 0;
  cursor: pointer;
  text-align: start;
}
.reports-bar__label { display: flex; align-items: center; gap: 6px; }
.reports-sub {
  margin-block-start: 12px;
  padding-inline-start: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.reports-sub .reports-bar__head { font-size: 0.8125rem; color: var(--text-muted); margin-block-end: 4px; }
.reports-sub__count { opacity: .7; }
.reports-bar__track--sub { block-size: 5px; }
.reports-bar__track--sub .reports-bar__fill { opacity: .75; }
.reports-exp__project { margin-block-end: 10px; }
.reports-bars.is-refreshing { opacity: .55; transition: opacity .15s ease; }
.report-figures__nested--deep { background: rgba(27, 35, 51, .03); }
.report-figures__nested--deep .report-figure { padding-inline-start: 52px; font-size: 0.875rem; min-block-size: 40px; }
.report-figure__note-inline { opacity: .7; }

/* ---- Accountant monthly pack (`tally:accountant-pack`) ---- */
.reports-acct-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-block-start: 12px;
}
.reports-acct-btn {
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  font-size: 0.875rem;
}
.reports-acct-grid {
  margin-block-end: 4px;
}
