/* Reports — «التقارير» (V5: calm and simple).
   One column, lots of air: period chips and a compact ‹ label ›, two tiles (new debts · payments), the Pro row
   (in · spent · net), one chart, then two folded sections. Export / print sit in a small «⋯» menu.
   Colours: tokens only — red / teal are for money (debts, spending / payments), amber for Pro. */

.rp { max-width: 720px; padding-top: var(--sp-2); }
.rp-section { margin-top: var(--section-gap); }

/* ----- period: chips + ‹ label › ----- */
.rp-modes { display: flex; gap: var(--sp-2); }
.rp-mode {
  flex: 1 1 0; min-width: 0; min-height: 42px; padding: 0 10px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
  font-size: var(--fs-sm); font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background var(--dur), color var(--dur), border-color var(--dur), transform 80ms var(--ease);
}
@media (hover: hover) { .rp-mode:not(.active):hover { background: var(--surface-2); color: var(--text); } }
.rp-mode:active { transform: scale(.97); }
.rp-mode.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.rp-mode:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.rp-period { margin-top: var(--sp-5); }
.rp-nav { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: var(--sp-2); }
.rp-step {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%;
  background: transparent; color: var(--text-2); border: 1px solid var(--border);
  transition: background var(--dur), border-color var(--dur), color var(--dur), transform 80ms var(--ease);
}
@media (hover: hover) { .rp-step:hover:not(:disabled) { background: var(--brand-softer); border-color: color-mix(in srgb, var(--brand) 35%, var(--border)); color: var(--brand-strong); } }
.rp-step:active:not(:disabled) { transform: scale(.94); }
.rp-step:disabled { opacity: .3; cursor: default; }
/* "previous" points to where the line starts (left in English, right in Arabic/Kurdish) */
.rp-chev-prev { transform: scaleX(-1); }
[dir='rtl'] .rp-chev-prev { transform: none; }
.rp-label { position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0; padding: 4px 6px; border-radius: var(--r-md); text-align: center; cursor: pointer; }
.rp-label:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (hover: hover) { .rp-label:hover .rp-label-cal { color: var(--brand); } }
.rp-label-rel { font-size: var(--fs-sm); font-weight: 800; line-height: 1.4; color: var(--brand-strong); }
.rp-label-main { display: block; max-width: 100%; font-size: var(--fs-xl); font-weight: 800; line-height: 1.3; letter-spacing: -0.01em; text-wrap: balance; }
.rp-label-cal { display: inline-block; margin-inline-start: 6px; vertical-align: -1px; color: var(--text-3); transition: color var(--dur); }
.rp-now { display: flex; justify-content: center; margin-top: var(--sp-2); }
.rp-now .chip { min-height: 34px; padding: 0 14px; }

/* a native date field stretched invisibly over our own label (Latin digits, our wording) */
.rp-date-native {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0;
  opacity: 0; cursor: pointer; font-size: 16px; background: transparent; color: transparent; min-height: 0;
}
.rp-date-native::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; opacity: 0; cursor: pointer; }

.rp-range { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
.rp-date {
  position: relative; display: flex; flex-direction: column; justify-content: center; gap: 1px; min-height: 58px; padding: 6px 12px;
  border-radius: var(--r-md); border: 1.5px solid var(--border-strong); background: var(--surface); cursor: pointer;
  transition: border-color var(--dur);
}
.rp-date:hover { border-color: color-mix(in srgb, var(--brand) 55%, var(--border-strong)); }
.rp-date:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.rp-date-label { font-size: var(--fs-xs); font-weight: 700; color: var(--text-3); }
.rp-date-value { min-width: 0; padding-inline-end: 22px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-date-icon { position: absolute; inset-inline-end: 10px; top: 50%; transform: translateY(-50%); color: var(--brand); }
.rp-quick { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-2); margin-top: var(--sp-3); }
.rp-quick .chip { min-height: 36px; padding: 0 14px; }
/* A tapped chip keeps :hover on phones; the shared hover rule must not make the selected chip look unselected. */
.rp button.chip.active, .rp button.chip.active:hover { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

/* ----- the two tiles ----- */
.rp-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); margin-top: var(--sp-6); }
.rp-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; padding: var(--sp-4);
  border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--card-shadow);
  text-align: start; color: var(--text); transition: border-color var(--dur), transform 80ms var(--ease);
}
.rp-tile:not([aria-disabled='true']):active { transform: scale(.98); }
@media (hover: hover) { .rp-tile:not([aria-disabled='true']):hover { border-color: color-mix(in srgb, var(--brand) 35%, var(--border)); } }
.rp-tile[aria-disabled='true'] { cursor: default; }
.rp-tile:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.rp-tile-label { display: inline-flex; align-items: center; gap: 7px; font-size: var(--fs-sm); font-weight: 700; line-height: 1.4; color: var(--text-2); }
.rp-tile-label i, .rp-legend i { flex: 0 0 auto; }
.rp-tile-label i { width: 8px; height: 8px; border-radius: 50%; }
.rp-key-debt { background: var(--debt); }
.rp-key-pay { background: var(--payment); }
.rp-tile-value { max-width: 100%; margin-top: 2px; font-size: 24px; font-weight: 800; line-height: 1.3; letter-spacing: -0.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-tile-value.sz-md { font-size: 19px; }
.rp-tile-value.sz-sm { font-size: 17px; }
.rp-tile-value.sz-xs { font-size: 15px; }
@media (min-width: 390px) { .rp-tile-value.sz-md { font-size: 21px; } .rp-tile-value.sz-sm { font-size: 18px; } }
@media (min-width: 721px) { .rp-tile-value, .rp-tile-value.sz-md { font-size: 26px; } .rp-tile-value.sz-sm { font-size: 22px; } .rp-tile-value.sz-xs { font-size: 19px; } }
.rp-tile-sub { font-size: var(--fs-xs); line-height: 1.45; color: var(--text-3); }

/* ----- Pro: in · spent · net ----- */
.rp-biz { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: var(--sp-3); padding: var(--sp-3) 0; color: var(--text); text-decoration: none; transition: border-color var(--dur); }
.rp-biz:hover { text-decoration: none; }
@media (hover: hover) { .rp-biz:hover { border-color: color-mix(in srgb, var(--brand) 35%, var(--border)); } }
.rp-biz-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; padding: 2px var(--sp-2); text-align: center; }
.rp-biz-cell + .rp-biz-cell { border-inline-start: 1px solid var(--border); }
.rp-biz-label { font-size: var(--fs-xs); font-weight: 700; color: var(--text-3); }
.rp-biz-hint { font-size: 11px; font-weight: 600; color: var(--text-3); line-height: 1.3; }
.rp-biz-value { max-width: 100%; font-size: var(--fs-md); font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 380px) { .rp-biz-value { font-size: 14px; } }

/* ----- the one chart ----- */
.rp-chart .card-head { flex-wrap: wrap; row-gap: 8px; margin-bottom: 10px; }
.rp-chart-sub { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; margin: -2px 0 10px; }
.rp-chart-title { font-size: var(--fs-sm); font-weight: 800; color: var(--text-2); }
.rp-view { flex: 1 1 auto; }
.rp-view .seg { flex: 1 1 auto; padding: 0 8px; font-size: var(--fs-sm); }
.rp-legend { display: inline-flex; gap: 12px; font-size: var(--fs-xs); font-weight: 700; color: var(--text-2); }
.rp-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.rp-legend i { width: 10px; height: 10px; border-radius: 3px; }
.rp-legend-muted { font-size: var(--fs-xs); font-weight: 700; color: var(--text-3); }
.rp-chart-box { position: relative; width: 100%; }
.rp-svg { display: block; width: 100%; height: auto; overflow: visible; direction: ltr; -webkit-user-select: none; user-select: none; }
.rp-svg text { font-family: var(--font); }
.rp-gridline { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; }
.rp-axis { stroke: var(--border-strong); stroke-width: 1; }
.rp-max { fill: var(--text-3); font-size: 11px; font-weight: 700; }
.rp-bar-debt { fill: var(--debt); }
.rp-bar-pay { fill: var(--payment); }
.rp-slot { cursor: pointer; }
.rp-hit { fill: transparent; transition: fill var(--dur); }
.rp-slot:hover .rp-hit { fill: var(--surface-2); }
.rp-slot.today .rp-hit { fill: var(--brand-softer); }
.rp-slot.future { cursor: default; }
.rp-slot.future:hover .rp-hit { fill: transparent; }
.rp-xl { fill: var(--text-3); font-size: 11px; font-weight: 700; }
.rp-xl2 { font-size: 10.5px; font-weight: 600; }
.rp-slot.today .rp-xl { fill: var(--brand-strong); font-weight: 800; }
.rp-slot.future .rp-xl { opacity: .45; }
.rp-chart-empty { position: absolute; inset: 0 0 36px; display: flex; align-items: center; justify-content: center; padding: 0 12px; text-align: center; font-size: var(--fs-sm); font-weight: 600; color: var(--text-3); }
.rp-where { margin-top: var(--sp-3); }

/* ----- folded sections ----- */
.rp-folds { display: flex; flex-direction: column; gap: var(--sp-3); }
.rp-moves { scroll-margin-top: calc(var(--topbar-h) + var(--safe-t) + 10px); }
.rp-folds .acc-body { padding-top: var(--sp-4); }
.rp-list-tools { display: flex; flex-direction: column; gap: var(--sp-3); }
.rp-filters { padding-bottom: 2px; }
.rp-day { margin-top: var(--sp-5); }
.rp-day-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; margin: 0 4px 8px; font-size: var(--fs-sm); }
.rp-day-name { font-weight: 800; color: var(--text); }
.rp-day-date { font-weight: 600; color: var(--text-3); }
.rp-day-tot { display: inline-flex; gap: 10px; margin-inline-start: auto; font-weight: 800; white-space: nowrap; }
.rp-row { min-height: var(--row-min); }
.rp-row .list-trailing { gap: 1px; }
.rp-time { font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); }
.rp-more { margin-top: var(--sp-4); }
.rp-more-count { margin-top: 6px; text-align: center; font-size: var(--fs-xs); color: var(--text-3); }
.rp-empty { padding: var(--sp-6) var(--sp-4) var(--sp-5); }
.rp-folds > .rp-empty { border-radius: var(--r-lg); border: 1px dashed var(--border-strong); background: color-mix(in srgb, var(--surface) 60%, transparent); }

/* who owes the most */
.rp-top-list .list-row { min-height: var(--row-min); padding: 10px 0; }
.rp-share { display: block; width: 100%; max-width: 180px; height: 5px; margin-top: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.rp-share > span { display: block; height: 100%; border-radius: inherit; background: color-mix(in srgb, var(--debt) 72%, transparent); }
.rp-late {
  display: flex; align-items: center; gap: 10px; width: 100%; margin-top: var(--sp-3); padding: 12px; border-radius: var(--r-md);
  background: var(--surface-2); color: var(--text); text-align: start; transition: background var(--dur);
}
.rp-late:hover { background: var(--surface-3); }
.rp-late-icon { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-strong); flex: 0 0 auto; }
.rp-late > .grow { display: flex; flex-direction: column; gap: 1px; }
.rp-late-title { font-size: var(--fs-sm); font-weight: 800; }
.rp-late-sub { font-size: var(--fs-xs); color: var(--text-3); }
.rp-calm { display: flex; align-items: center; gap: 10px; padding: 6px 2px; font-weight: 700; color: var(--text-2); }
.rp-top-all { display: flex; justify-content: center; margin-top: var(--sp-3); }

/* ----- «⋯» menu ----- */
.rp-menu-wrap { position: relative; }
.rp-menu {
  position: absolute; top: calc(100% + 6px); inset-inline-end: 0; z-index: 40; min-width: 232px; padding: 6px;
  border-radius: var(--r-lg); background: var(--bg-elevated); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  animation: rp-menu-in 160ms var(--ease);
}
@keyframes rp-menu-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.rp-menu-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 50px; padding: 0 12px; border-radius: 12px; font-weight: 700; color: var(--text); text-align: start; }
.rp-menu-item > .icon { color: var(--text-2); flex: 0 0 auto; }
@media (hover: hover) { .rp-menu-item:hover { background: var(--surface-2); } }
.rp-menu-item:active { background: var(--surface-3); }
.rp-pro-tag { padding: 1px 8px; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent-ink); font-size: 11px; font-weight: 800; }
@media (prefers-reduced-motion: reduce) { .rp-menu { animation: none; } }

/* ----- print: shop name + period on top, every section open, every transaction, no controls ----- */
.rp-print-head { display: none; }
@media print {
  .main:has(.rp) { background: #fff !important; padding: 0 !important; }
  .rp {
    max-width: none !important; padding: 0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact;
    --surface: #fff; --surface-2: #F3F6F5; --surface-3: #E3EAE7; --border: #D3DCD9; --border-strong: #B5C4BF;
    --text: #0E1E1B; --text-2: #3E504C; --text-3: #5B6D69; --brand: #0F766E; --brand-strong: #0B5E57; --brand-soft: #D2EBE6; --brand-softer: #E7F3F0;
    --debt: #B42318; --debt-soft: #FBE4E1; --payment: #0F766E; --payment-soft: #D2EBE6; --accent-soft: #FBEFD5; --accent-strong: #B45309; --accent-ink: #78350F;
    --card-shadow: none; color: var(--text);
  }
  .rp .debt-color { color: #B42318 !important; }
  .rp .payment-color { color: #0F766E !important; }
  .rp-print-head { display: block; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 2px solid #0E1E1B; }
  .rp-print-shop { font-size: 20px; font-weight: 800; }
  .rp-print-title { font-size: 15px; font-weight: 700; }
  .rp-print-period { font-size: 15px; font-weight: 800; color: #0B5E57; }
  .rp-print-date { font-size: 12px; color: #5B6D69; }
  .rp-head, .rp-list-tools, .rp-more, .rp-menu, .rp-top-all, .rp-late > .icon:last-child, .rp-view, .rp .acc-chevron, .rp .acc-icon { display: none !important; }
  .rp-tiles { margin-top: 0; }
  .rp-section { margin-top: 14px; }
  .rp .card, .rp .acc, .rp-tile { box-shadow: none !important; border-color: #D3DCD9 !important; }
  .rp-tiles, .rp-biz, .rp-chart, .rp-top { break-inside: avoid; }
  .rp .acc { border: 0 !important; background: none !important; overflow: visible; }
  .rp .acc-head { min-height: 0; padding: 0 0 6px; }
  .rp .acc-title { font-size: 16px; }
  .rp .acc-body { border-top: 0; padding: 0; }
  .rp-svg { width: auto; max-width: 100%; }
  .rp-day { margin-top: 8px; }
  .rp-day-head { break-after: avoid; }
  .rp .list-row { min-height: 0; padding: 6px 10px; break-inside: avoid; }
  .rp .type-dot { width: 28px; height: 28px; border-radius: 8px; }
  .rp-share { display: none; }
}
