/* Zidos Trail v9 · Чеки (#/receipts). Scoped styles for phone and desktop. */

/* Hide topbar expense button on receipts */
body:has(#page-receipts.active) .shell-expense {
  display: none;
}

#page-receipts .page-head .h-sub {
  display: inline;
  font: 400 14px/1 var(--sans);
  color: var(--ink-2);
  letter-spacing: normal;
}

/* «?» — circular 44px button */
#page-receipts #rcHelp {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 0;
  background: var(--well);
  color: var(--ink);
  font: 500 16px/1 var(--sans);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

#page-receipts #rcHelp:hover {
  background: var(--well-deep);
}

#rcHelpPop {
  position: absolute;
  z-index: 100;
  max-width: 320px;
  padding: 16px;
  border-radius: 16px;
  background: var(--panel);
  color: var(--ink);
  font: 400 13px/18px var(--sans);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

/* Period toolbar */
#page-receipts .shell-toolbar {
  order: -1;
  width: 100%;
  display: flex;
  justify-content: center;
}

/* Segment «Траты / Чеки» — same toggle as on Transactions */
#page-receipts .shell-section-nav {
  display: flex;
  gap: 8px;
  width: 100%;
  order: 10;
}

#page-receipts .shell-section-nav a {
  min-height: 44px;
  min-width: 64px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--well);
  color: var(--ink-2);
  font: 500 13px/1 var(--sans);
  text-decoration: none;
}

#page-receipts .shell-section-nav a[aria-current="page"] {
  background: var(--panel);
  color: var(--ink);
}

/* Page head actions (Add receipt photo, Check mail) */
#page-receipts .page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  order: 11;
}

#page-receipts .page-actions button {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--well);
  color: var(--ink);
  font: 500 13px/1 var(--sans);
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

#page-receipts .page-actions button:hover {
  background: var(--well-deep);
}

/* Filters «Не найдена операция / Сопоставлены / Объединены» — capsules 44 px */
#page-receipts #rcChips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 12px 0 16px;
  max-width: 100%;
}

#page-receipts #rcChips .chip {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--well);
  color: var(--ink-2);
  font: 500 13px/1 var(--sans);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  white-space: nowrap;
}

#page-receipts #rcChips .chip[aria-pressed="true"] {
  background: var(--panel);
  color: var(--ink);
}

#page-receipts #rcChips .cnt {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--well-deep);
  color: var(--ink);
  font: 500 11px/20px var(--sans);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#page-receipts #rcChips .chip[aria-pressed="true"] .cnt {
  background: var(--well);
  color: var(--ink);
}

#page-receipts #rcChips .cnt.act,
#page-receipts #rcChips .chip .cnt.act,
#page-receipts #rcChips .chip[aria-pressed="true"] .cnt.act {
  background: var(--lime);
  color: var(--lime-ink);
}

/* Hint #rcHow — white card with dark capsule «Понятно» */
#page-receipts #rcHow,
#page-receipts .rc-how {
  background: var(--panel);
  border-radius: 20px;
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--ink);
}

#page-receipts .rc-how-t {
  font: 400 13px/1.4 var(--sans);
  color: var(--ink);
  flex: 1 1 auto;
}

#page-receipts .rc-how-x {
  flex: 0 0 auto;
}

#page-receipts .rc-how [data-rc-how-off] {
  min-height: 44px;
  min-width: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--panel);
  font: 500 13px/1 var(--sans);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  white-space: nowrap;
}

/* Saved rules details */
#page-receipts details.receipt-rules {
  border-radius: 16px;
  background: var(--panel);
  margin-bottom: 12px;
  color: var(--ink);
}

#page-receipts details.receipt-rules summary {
  min-height: 44px;
  padding: 12px 16px;
  font: 500 13px/1.4 var(--sans);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
}

#page-receipts details.receipt-rules .row2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  font: 400 13px/18px var(--sans);
  color: var(--ink);
}

#page-receipts details.receipt-rules button[data-rc-rule-delete] {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--well);
  color: var(--ink-2);
  border: 0;
  font: 500 12px/1 var(--sans);
  cursor: pointer;
}

/* Receipts list: cards-rows */
#page-receipts #rcList {
  background: transparent;
  padding: 0;
  border: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#page-receipts .rcrow {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 12px 16px;
  border-radius: 20px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  border: 0;
  width: 100%;
  box-sizing: border-box;
  text-decoration: none;
  outline: none;
}

#page-receipts .rcrow:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

#page-receipts .rcrow.open,
#page-receipts .rcrow[aria-current="true"] {
  background: var(--well);
}

/* Thumbnail 40–56 px on left with tinted base */
#page-receipts .rcrow .catic {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 14px;
  background: var(--well);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#page-receipts .rcrow.open .catic,
#page-receipts .rcrow[aria-current="true"] .catic {
  background: var(--panel);
}

#page-receipts .rcrow .catic svg {
  width: 22px;
  height: 22px;
  max-width: 24px;
  max-height: 24px;
  stroke: var(--ink);
  stroke-width: 2;
  flex-shrink: 0;
}

/* Merchant, date and items */
#page-receipts .rcrow .op-m {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#page-receipts .rcrow .op-m b {
  font: 500 15px/20px var(--sans);
  color: var(--ink);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  word-break: break-word;
}

#page-receipts .rcrow .op-m span {
  font: 400 12px/16px var(--sans);
  color: var(--ink-2);
  word-break: break-word;
}

/* Amount */
#page-receipts .rcrow .op-a {
  flex: 0 0 auto;
  font: 500 16px/20px var(--sans);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-align: right;
  white-space: nowrap;
  margin-left: auto;
}

/* Quiet status pill with dot */
#page-receipts .tag-p,
#page-receipts .rc-other,
#page-receipts .rc-why,
#page-receipts .rc-status,
#page-receipts .state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--well);
  color: var(--ink-2);
  font: 500 11px/16px var(--sans);
  vertical-align: middle;
}

#page-receipts .tag-p::before,
#page-receipts .rc-other::before,
#page-receipts .rc-why::before,
#page-receipts .rc-status::before,
#page-receipts .state::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

#page-receipts .state.ok,
#page-receipts .tag-p {
  color: var(--ok);
}

#page-receipts .state.miss {
  color: var(--problem);
}

#page-receipts .rc-why {
  color: var(--problem);
  align-self: flex-start;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 6px;
}

/* Empty list state */
#page-receipts #rcList .empty {
  padding: 48px 24px;
  text-align: center;
  font: 400 14px/20px var(--sans);
  color: var(--ink-2);
  background: var(--panel);
  border-radius: 20px;
}

/* Receipt paper card (#rcPaper) */
#page-receipts #rcPaper {
  background: var(--panel);
  border-radius: 24px;
  padding: 20px;
  color: var(--ink);
  border: 0;
  box-sizing: border-box;
}

#page-receipts #rcPaper:empty {
  display: none;
}

#page-receipts #rcPaper .ch {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-bottom: 16px;
}

#page-receipts #rcPaper .ch h2 {
  font: 500 20px/1.3 var(--sans);
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.4px;
}

#page-receipts #rcPaper .ch h2 .tail {
  font: 400 14px/1 var(--sans);
  color: var(--ink-2);
}

#page-receipts #rcPaper .rc-src {
  font: 400 12px/16px var(--sans);
  color: var(--ink-2);
  margin: 0;
}

#page-receipts #rcPaper [data-rc-back] {
  min-height: 44px;
  min-width: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--well);
  color: var(--ink);
  font: 500 13px/1 var(--sans);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  margin-bottom: 8px;
}

#page-receipts #rcPaper .paper {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#page-receipts .receipt-photo {
  max-width: 120px;
  max-height: 120px;
  border-radius: 12px;
  object-fit: cover;
}

#page-receipts #rcPaper .ln {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--well);
  color: var(--ink);
  font: 400 13px/18px var(--sans);
}

#page-receipts #rcPaper .ln .muted {
  color: var(--ink-2);
  font-size: 12px;
}

#page-receipts #rcPaper .ln .num {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  white-space: nowrap;
}

#page-receipts #rcPaper .ln.tot {
  background: var(--well-deep);
  font-weight: 500;
  font-size: 14px;
  padding: 10px 12px;
  margin-top: 4px;
}

#page-receipts #rcPaper .ln.tot b.num {
  font-size: 16px;
}

#page-receipts #rcPaper .receipt-rule-prompt {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--well);
  color: var(--ink);
  font: 400 13px/18px var(--sans);
}

#page-receipts #rcPaper .receipt-rule-prompt button {
  min-height: 44px;
  min-width: 44px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font: 500 13px/1 var(--sans);
  border: 0;
  cursor: pointer;
  align-self: flex-start;
}

#page-receipts .rc-inline {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

#page-receipts .rc-inline h3 {
  font: 500 14px/20px var(--sans);
  color: var(--ink);
  margin: 8px 0 4px;
}

#page-receipts .rc-candidate,
#rcCandidates .rc-candidate {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "main amt"
    "bind bind";
  gap: 8px 12px;
  align-items: start;
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 0;
  background: var(--well);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  box-sizing: border-box;
}

#page-receipts .rc-candidate:hover,
#rcCandidates .rc-candidate:hover {
  background: var(--well-deep);
}

#page-receipts .rc-c-main,
#rcCandidates .rc-c-main {
  grid-area: main;
  display: block;
  min-width: 0;
  font: 500 13px/18px var(--sans);
  color: var(--ink);
  overflow-wrap: anywhere;
}

#page-receipts .rc-c-main small,
#rcCandidates .rc-c-main small {
  display: block;
  margin-top: 2px;
  font: 400 11px/15px var(--sans);
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

#page-receipts .rc-other,
#rcCandidates .rc-other {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--well-deep);
  color: var(--ink-2);
  font: 500 11px/16px var(--sans);
  vertical-align: middle;
  white-space: nowrap;
}

#page-receipts .rc-c-amt,
#rcCandidates .rc-c-amt {
  grid-area: amt;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font: 500 14px/18px var(--sans);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--ink);
  text-align: right;
  flex-shrink: 0;
}

#page-receipts .rc-c-amt small,
#rcCandidates .rc-c-amt small {
  display: block;
  font: 400 11px/15px var(--sans);
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

#page-receipts .rc-bind,
#rcCandidates .rc-bind {
  grid-area: bind;
  justify-self: end;
  min-height: 44px;
  min-width: 44px;
  padding: 0 16px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 500 12px/1 var(--sans);
  flex-shrink: 0;
  white-space: nowrap;
}

#page-receipts .rc-bind.btn-dark {
  background: var(--ink);
  color: var(--panel);
}

#page-receipts .rc-bind.btn-ghost {
  background: var(--panel);
  color: var(--ink);
}

#page-receipts .rc-confirm {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--well-deep);
  color: var(--ink);
  font: 400 13px/18px var(--sans);
  margin-bottom: 8px;
}

#page-receipts .rc-confirm-a {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#page-receipts .rc-confirm-a button {
  min-height: 44px;
  min-width: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 0;
  font: 500 12px/1 var(--sans);
  cursor: pointer;
}

#page-receipts .rc-confirm-a [data-rc-force] {
  background: var(--ink);
  color: var(--panel);
}

#page-receipts .rc-confirm-a [data-rc-cancel] {
  background: var(--panel);
  color: var(--ink);
}

#page-receipts #rcPaper .page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

#page-receipts #rcPaper .page-actions button {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 0;
  font: 500 13px/1 var(--sans);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#page-receipts #rcPaper .page-actions .btn-dark {
  background: var(--ink);
  color: var(--panel);
}

#page-receipts #rcPaper .page-actions .btn-ghost,
#page-receipts #rcPaper .page-actions .more {
  background: var(--well);
  color: var(--ink);
}

#page-receipts #rcPaper .page-actions button:hover {
  background: var(--well-deep);
}

#page-receipts button[data-rc-all] {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 0;
  background: var(--well);
  color: var(--ink);
  font: 500 13px/1 var(--sans);
  cursor: pointer;
  align-self: flex-start;
}

/* ========================================================
   Desktop 1024px – 1920px (Mosaic 12 columns like Transactions)
   ======================================================== */
@media (min-width: 1024px) {
  body:has(#page-receipts.active) .shell-expense {
    display: none;
  }

  #page-receipts .page-inner {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 16px;
    align-content: start;
    width: 100%;
    min-width: 0;
  }

  #page-receipts .page-inner > * {
    min-width: 0;
    margin: 0;
  }

  #page-receipts #rcHelp {
    order: 1;
  }

  #page-receipts .page-head .shell-section-nav {
    order: 3;
    width: auto;
  }

  #page-receipts #rcChips {
    grid-column: 1 / -1;
    margin: 0 0 8px;
  }

  #page-receipts #rcHow {
    grid-column: 1 / -1;
    margin: 0 0 16px;
  }

  #page-receipts #receiptRules {
    grid-column: 1 / -1;
    margin: 0 0 8px;
  }

  /* An empty rules host must not allocate a blank grid row. Populated rules stay visible. */
  #page-receipts #receiptRules:empty { display: none; }

  #page-receipts .rc-split {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
    margin: 0;
  }

  #page-receipts #rcList {
    grid-column: 1 / 8;
    max-height: min(640px, calc(100dvh - 180px));
    overflow: auto;
  }

  #page-receipts #rcPaper {
    grid-column: 8 / 13;
    align-self: start;
    position: sticky;
    top: 16px;
    /* карточка ниже шапки main (84) и блока вкладок над списком (160); минус нижний отступ main (24): страница без своей прокрутки, длинный чек прокручивается внутри */
    max-height: calc(100dvh - 296px);
    overflow: auto;
    margin: 0;
  }

  #page-receipts #rcPaper:empty {
    display: none;
  }

  #page-receipts .rc-split:has(#rcPaper:empty) #rcList {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1280px) {
  #page-receipts .rc-candidate,
  #rcCandidates .rc-candidate {
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas: "main amt bind";
    align-items: center;
  }

  #page-receipts .rc-bind,
  #rcCandidates .rc-bind {
    justify-self: auto;
  }
}

