/* Zidos Trail · Subscriptions Component (v9) */
/* Logo row, receipt stack, "Чеки ↔ Список" toggle, detailed receipt cards */

/* Layer container. Mock .approved-receipts sits at top:44 of the 844 phone with its
   title at 66 and the first receipt row at 135; the product layer is inset:0, so the
   44px top inset comes back as padding (coordinator 18.10: the stack covers the header,
   its own title must not cross it). */
:is(.approved-receipts, .r6-subs-layer, .preview-subscriptions, .ztsw-layer){
  position: fixed;
  inset: 0;
  z-index: 60;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--ink);
  font: 400 14px/1.45 Onest, sans-serif;
  border: 0;
  background: transparent;
  width: 100vw;
  height: 100dvh;
  margin: 0;
  padding: 44px 0 0;
}

/* While the stack (or any ztsw layer) is open it owns the whole screen: the app header
   (brand row on top, glass tabs at the bottom on the phone, both inside header.app-topbar,
   z-index 80 > 60) steps aside instead of crossing the layer's own title. The header is
   back the moment the layer leaves the DOM. */
/* the return transition lives only while the header is away or coming back (.zt-chrome-back,
   js/web-r6-motion.js): a permanent opacity transition re-rasterises the header text on resize */
header.app-topbar.zt-chrome-back {
  transition: opacity var(--scrim-out) var(--ease), visibility 0s;
}
body:has(.ztsw-layer:not([hidden])) header.app-topbar {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--scrim-in) var(--ease), visibility 0s linear var(--scrim-in);
}
:is(.approved-receipts, .r6-subs-layer, .ztsw-layer)[hidden]{
  display: none !important;
}
/* the prepared-but-hidden layer is measured by js/web-r6-subs-layer.js before it opens: keep it laid out, invisible */
.r6-subs-layer[hidden][data-r6-prepared="true"]{ display: block !important; }
.r6-subs-layer[hidden],.r6-subs-layer[hidden] *{ visibility: hidden !important; pointer-events: none !important; }

/* Backdrop */
:is(.layer-backdrop, .r6-subs-backdrop, .ztsw-backdrop){
  position: absolute;
  inset: 0;
  /* непрозрачный тон холста: за слоем не должны проступать пятна страницы (серая «Серия», салатовая дымка) */
  background: var(--canvas);
  z-index: -1;
  border: 0;
  border-radius: 0;
  cursor: default;
  padding: 0;
}

/* Title Header */
:is(.layer-title, .r6-subs-content > header, .ztsw-title){
  padding: 22px 28px 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
:is(.layer-title h2, .layer-title h3, .r6-subs-content h2, .ztsw-title h3){
  font-size: 26px;
  margin: 0 0 4px;
  letter-spacing: -0.6px;
  font-weight: 500;
  line-height: 1.15;
}
:is(.layer-title p, .r6-subs-content > header p, .ztsw-title p){
  color: var(--ink-2);
  font-size: 13px;
  margin: 0;
}

/* список по центру колонкой 640: шапка слоя встаёт в ту же колонку */
@media (min-width: 1024px) {
  .r6-subs-content > header { width: min(640px, 100%); margin-inline: auto; box-sizing: border-box; padding-inline: 0; }
}

/* Body */
:is(.layer-body, .r6-subs-content, .ztsw-body){
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

/* Receipt Scene */
:is(.scene, [data-r6-subs-axis], .ztsw-scene){
  position: absolute;
  left: 28px;
  right: 28px;
  top: 14px;
  height: 430px;
}
:is(.scene[hidden], [data-r6-subs-axis][hidden], .ztsw-scene[hidden]){
  display: none !important;
}

/* Service Brand Tile (.sv) */
.sv{
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  font-weight: 600;
  font-size: 15px;
  font-style: normal;
  color: var(--c, var(--brand));
  background: color-mix(in srgb, var(--c, var(--brand)) var(--tint, 14%), var(--panel));
  letter-spacing: -0.02em;
  flex: none;
}
.sv.big{
  width: 60px;
  height: 60px;
  border-radius: 20px;
  background: var(--c, var(--brand));
  color: #fff;
  font-size: 21px;
  font-weight: 600;
}
:is([data-theme="dark"], .dark) .sv.big{
  color: #101315;
}
.sv.big.logo{
  background: var(--brand);
  overflow: hidden;
}
.sv.big.logo img{
  display: block;
  width: 58%;
  height: 58%;
  object-fit: contain;
  filter: brightness(0) invert(1);
  pointer-events: none;
}
.sv.big.logo.list{
  width: 40px;
  height: 40px;
  flex: none;
}

/* Receipt Card with Zig-Zag edge */
:is(.receipt, .ztsw-receipt){
  position: absolute;
  align-items: stretch;
  text-align: left;
  background: var(--panel);
  border-radius: 18px;
  padding: 16px 16px 23px;
  gap: 8px;
  justify-content: flex-start;
  rotate: var(--tilt, var(--ztsw-tilt, 0deg));
  box-shadow: 0 8px 24px rgba(17, 17, 17, .08);
  transform-origin: 50% 50%;
  clip-path: polygon(
    0 0, 100% 0, 100% calc(100% - 7px),
    95.5% 100%, 91% calc(100% - 7px), 86.5% 100%, 82% calc(100% - 7px),
    77.5% 100%, 73% calc(100% - 7px), 68.5% 100%, 64% calc(100% - 7px),
    59.5% 100%, 55% calc(100% - 7px), 50.5% 100%, 46% calc(100% - 7px),
    41.5% 100%, 37% calc(100% - 7px), 32.5% 100%, 28% calc(100% - 7px),
    23.5% 100%, 19% calc(100% - 7px), 14.5% 100%, 10% calc(100% - 7px),
    5.5% 100%, 1% calc(100% - 7px), 0 100%
  );
  transition: rotate var(--mid) var(--ease);
  color: var(--ink);
}
:is(.receipt:hover, .receipt:focus-visible, .ztsw-receipt:hover, .ztsw-receipt:focus-visible){
  rotate: 0deg;
}
:is(.receipt .r-top, .ztsw-receipt .ztsw-r-top){
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
:is(.receipt .r-top :is(.sv.big, .ztsw-icon), .ztsw-receipt .ztsw-r-top .ztsw-icon){
  width: 44px;
  height: 44px;
  border-radius: 14px;
  font-size: 16px;
}
:is(.receipt .r-top .amt, .ztsw-receipt .ztsw-amount, .ztsw-receipt .ztsw-r-top .ztsw-amount){
  font-size: 17px;
  font-weight: 500;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex: none;
}
:is(.receipt .r-name, .ztsw-receipt .ztsw-r-name){
  display: block;
  min-width: 0;
  margin-top: 4px;
}
:is(.receipt .r-name b, .ztsw-receipt .ztsw-r-name b){
  display: block;
  font-size: 14px;
  line-height: 1.25;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
:is(.receipt .r-name small, .ztsw-receipt .ztsw-r-name small){
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  line-height: 1.35;
  margin-top: 2px;
  font-size: 11px;
  color: var(--ink-2);
}
:is(.receipt .r-foot, .ztsw-receipt .ztsw-r-foot){
  margin-top: auto;
  display: flex;
  justify-content: flex-start;
  align-items: baseline;
  gap: 8px;
}

/* Merchant tile inside a receipt/list icon: the brand plate fills the icon, the mark
   (an <img> silhouette) sits at the mock's 58% — every receipt carries its logo. */
:is(.receipt, .ztsw-receipt, .srow, .ztsw-list-row) :is(.ztsw-icon, .ztsw-icon.logo, .sv) .ops-merchant{
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  font-style: normal;
}

.subscription-brand{
  display: block;
  width: 58%;
  height: 58%;
  object-fit: contain;
  filter: brightness(0) invert(1);
  pointer-events: none;
}
:is(.receipt .r-foot small, .ztsw-receipt .ztsw-r-foot small){
  line-height: 1.3;
  font-size: 11px;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Subscriptions List Mode */
:is(.subs-list, [data-r6-subs-list], .ztsw-list){
  position: absolute;
  inset: 0;
  width: min(640px, 100%);
  margin-inline: auto;
  box-sizing: border-box;
  padding: 8px 20px 110px;
  overflow-y: auto;
  scrollbar-width: none;
}
/* запас под плавающую капсулу «Чеки/Список» и ссылку «Управлять»; (0,2,0) — выше .ztsw-list из desktop.css */
.ztsw-layer .ztsw-list { padding-bottom: 168px; }
:is(.subs-list[hidden], [data-r6-subs-list][hidden], .ztsw-list[hidden]){
  display: none !important;
}
:is(.subs-list h4, .r6-subs-group h3, .ztsw-list-h, .ztsw-list h4){
  margin: 14px 8px 8px;
  font-size: 12px;
  font-weight: 400;
  color: var(--ink-2);
}
:is(.srow, .r6-subs-group li, .ztsw-list-row){
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  background: var(--panel);
  border: 0;
  border-radius: 18px;
  text-align: left;
  margin-bottom: 6px;
  color: var(--ink);
  cursor: pointer;
}
:is(.srow .sv, .r6-subs-list-icon, .ztsw-list-row .ztsw-icon){
  width: 40px;
  height: 40px;
  font-size: 14px;
  border-radius: 12px;
}
:is(.srow .rc, .r6-subs-group li > span:nth-child(2), .ztsw-list-row .ztsw-l-main){
  flex: 1;
  min-width: 0;
}
:is(.srow b, .r6-subs-group li b, .ztsw-list-row b){
  display: block;
  font-weight: 500;
  font-size: 14px;
}
:is(.srow small, .r6-subs-group li time, .ztsw-list-row small){
  display: block;
  color: var(--ink-2);
  font-size: 12px;
}
:is(.srow .amt, .r6-subs-group li .num, .ztsw-list-row .ztsw-amount){
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}

/* Glass Switcher: «Чеки ↔ Список» (mock .layer-actions: bottom 30) */
:is(.layer-actions, .r6-subs-actions, .ztsw-actions){
  position: absolute;
  left: 50%;
  bottom: max(30px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 6px;
  display: flex;
  gap: 4px;
  border-radius: 99px;
  white-space: nowrap;
  background: var(--glass, rgba(247, 247, 245, .88));
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  z-index: 10;
}
:is([data-theme="dark"], .dark) :is(.layer-actions, .r6-subs-actions, .ztsw-actions){
  background: rgba(40, 45, 51, .9);
}
:is(.layer-actions button, .r6-subs-actions button, .ztsw-actions button){
  padding: 10px 14px;
  border: 0;
  background: transparent;
  font: 500 13px Onest, sans-serif;
  border-radius: 99px;
  min-height: 40px;
  color: var(--ink);
  cursor: pointer;
}
:is(.layer-actions [aria-pressed="true"], .r6-subs-actions [aria-pressed="true"], .ztsw-actions [aria-pressed="true"]){
  background: var(--lime);
  color: var(--lime-ink);
}
:is(.layer-actions .x, [data-r6-subs-close], .ztsw-actions [data-close]){
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  font-size: 18px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  border-radius: 99px;
  color: var(--ink);
  cursor: pointer;
}

:is(.ztsw-layer, .ph-subs, .approved-receipts) .ztsw-manage,
.ztsw-manage {
  position: absolute;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%);
  padding: 0 16px;
  min-height: 44px;
  background: transparent;
  border: 0;
  font-size: 13px;
  color: var(--ink);
  white-space: nowrap;
  z-index: 4;
  cursor: pointer;
}


/* Axis item & logos for r6-subs */
.r6-subs-item{
  position: absolute;
  width: 120px;
  margin-left: -60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  transform-origin: 50% 26px;
  font-size: 12px;
  line-height: 20px;
}
.r6-subs-icon{
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.r6-subs-labels{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
}
.r6-subs-axis-tick{
  position: absolute;
  transform: translateX(-50%);
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--well);
  color: var(--ink-2);
  white-space: nowrap;
  font-size: 11px;
}
.r6-subs-axis-labels{
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-2);
  font-size: 12px;
}
.r6-subs-group{
  margin-bottom: 28px;
}
.r6-subs-list-icon{
  width: 40px;
  height: 40px;
  border-radius: 12px;
  flex: none;
}
.r6-subs-empty{
  padding: 40px 8px;
  color: var(--ink-2);
}
.r6-subs-selection{
  position: absolute;
  top: 6px;
  left: 6px;
  height: 40px;
  border-radius: 999px;
  background: var(--lime);
  pointer-events: none;
}
.r6-subs-selected-label{
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--lime-ink);
  pointer-events: none;
}

/* Wide windows: the switcher and «Управлять» dock under the scrolling body instead of floating
   over receipt amounts (a short window otherwise parks the pill on top of a charge). */
@media (min-width: 600px) {
  :is(.ztsw-layer) :is(.ztsw-manage, .ztsw-actions) {
    position: relative;
    left: auto;
    bottom: auto;
    transform: none;
    flex: none;
    align-self: center;
  }
  .ztsw-layer .ztsw-body { overflow-y: auto; overscroll-behavior: contain; }
  .ztsw-layer .ztsw-actions { margin: 0 0 max(16px, env(safe-area-inset-bottom)); }
}

/* P8 · subscriptions tab (variant A: list first, calendar beside), using the product palette. */
html[data-subs="a"] #bSubsWrap {
  --sp-gap: 16px;
  max-width: none;
  width: 100%;
  margin: 0;
  gap: var(--sp-gap);
}
html[data-subs] :is(#bSubsWrap, #mHelp) :is(.sp-row, .sp-day) {
  color: var(--ink);
  font: 400 14px/1.4 var(--sans);
  border: 0;
  cursor: pointer;
  min-height: 44px;
}
html[data-subs] :is(#bSubsWrap, #mHelp) :is(button, summary, a):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
html[data-subs] #bSubsWrap :is(.sp-summary, .sp-empty) { color: var(--ink-2); font-variant-numeric: tabular-nums; }
html[data-subs] #bSubsWrap .sp-summary { font-size: 12px; line-height: 1.5; }
html[data-subs] #bSubsWrap :is(.sp-list, .sp-tools) { display: grid; gap: 8px; min-width: 0; }
html[data-subs] #bSubsWrap :is(.sp-list-layout, .sp-tools) { display: grid; gap: var(--sp-gap); min-width: 0; }
html[data-subs] #bSubsWrap .sp-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 16px;
  background: var(--panel);
  border-radius: 24px;
  text-align: left;
}
html[data-subs] #bSubsWrap .sp-row:hover { background: var(--well); }
html[data-subs] :is(#bSubsWrap, #mHelp) .sp-logo { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--well); overflow: hidden; flex: none; }
html[data-subs] :is(#bSubsWrap, #mHelp) .sp-logo .ops-merchant { display: grid; place-items: center; width: 100%; height: 100%; background: transparent; border-radius: inherit; }
html[data-subs] :is(#bSubsWrap, #mHelp) .sp-logo img { width: 60%; height: 60%; object-fit: contain; }
html[data-subs] #bSubsWrap .sp-copy { min-width: 0; }
html[data-subs] #bSubsWrap .sp-name { display: block; font-weight: 500; overflow-wrap: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html[data-subs] #bSubsWrap .sp-copy small { display: block; color: var(--ink-2); font: 400 12px/1.45 var(--sans); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html[data-subs] #bSubsWrap .sp-price { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 500; }
html[data-subs] #bSubsWrap h2 { font: 500 14px/1.4 var(--sans); }
html[data-subs] :is(#bSubsWrap, #mHelp) .sp-calendar { min-width: 0; padding: 16px; background: var(--panel); border-radius: 24px; }
html[data-subs] :is(#bSubsWrap, #mHelp) .sp-cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
html[data-subs] :is(#bSubsWrap, #mHelp) .sp-cal-head h2 { font: 500 16px/1.4 var(--sans); margin: 0; }
html[data-subs] :is(#bSubsWrap, #mHelp) .sp-cal-range { color: var(--ink-2); font-size: 12px; white-space: nowrap; }
html[data-subs] :is(#bSubsWrap, #mHelp) :is(.sp-week, .sp-days) { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
html[data-subs] :is(#bSubsWrap, #mHelp) .sp-week { color: var(--ink-2); font-size: 12px; text-align: center; margin-bottom: 8px; }
html[data-subs] :is(#bSubsWrap, #mHelp) .sp-day { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 4px; min-width: 0; min-height: 64px; padding: 6px 0; border-radius: 16px; background: transparent; font-variant-numeric: tabular-nums; }
html[data-subs] :is(#bSubsWrap, #mHelp) .sp-day-out { color: var(--ink-2); }
html[data-subs] :is(#bSubsWrap, #mHelp) .sp-month { display: block; font: 400 10px/1.2 var(--sans); color: var(--ink-2); }
html[data-subs] :is(#bSubsWrap, #mHelp) .sp-day-date { display: flex; flex-direction: column-reverse; justify-content: end; min-height: 30px; }
html[data-subs] :is(#bSubsWrap, #mHelp) .sp-day[aria-current="date"] { font-weight: 500; background: var(--well); }
html[data-subs] :is(#bSubsWrap, #mHelp) .sp-day-logos { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; }
html[data-subs] :is(#bSubsWrap, #mHelp) .sp-day .sp-logo { width: 20px; height: 20px; }
/* The subscription card lives in #mHelp, outside the #bSubsWrap rules of limits.css: ledger, actions and rebate disclosure need their own layout there. */
html[data-subs] #mHelp .subscription-fact { display: grid; gap: 4px; min-width: 0; }
html[data-subs] #mHelp .subscription-fact > span, html[data-subs] #mHelp .subscription-fact > small { font: 400 13px/1.4 var(--sans); color: var(--ink-2); overflow-wrap: anywhere; }
html[data-subs] #mHelp .subscription-fact > b { font: 500 20px/1.3 var(--sans); color: var(--ink); font-variant-numeric: tabular-nums; }
html[data-subs] #mHelp .subscription-charge { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-block: 4px; font-variant-numeric: tabular-nums; }
html[data-subs] #mHelp .subscription-review .page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
html[data-subs] #mHelp .r30-rebate > summary { display: flex; align-items: center; gap: 8px; min-height: 44px; list-style: none; cursor: pointer; }
html[data-subs] #mHelp .r30-rebate > summary::-webkit-details-marker { display: none; }
html[data-subs] #mHelp .r30-rebate > summary::after { content: ''; width: 16px; height: 16px; flex: none; margin-left: auto; background: currentColor; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; }
html[data-subs] #mHelp .r30-rebate[open] > summary::after { transform: rotate(180deg); }
@media (max-width: 599px) {
  html[data-subs] #bSubsWrap .sp-row { grid-template-columns: 36px minmax(0, 1fr) auto; gap: 8px; padding: 12px; }
  html[data-subs][lang|="es"] #bSubsWrap .sp-row { padding-inline: 10px; gap: 6px; }
  html[data-subs] #bSubsWrap .sp-row > .sp-logo { width: 36px; height: 36px; }
  html[data-subs] #bSubsWrap .sp-price { font-size: 13px; }
  html[data-subs] :is(#bSubsWrap, #mHelp) .sp-days { gap: 0; }
  html[data-subs] :is(#bSubsWrap, #mHelp) .sp-calendar { padding: 12px 4px; }
}
@media (min-width: 1024px) {
  html[data-subs="a"] #bSubsWrap .sp-list-layout { grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr); align-items: start; }
  html[data-subs] #bSubsWrap .sp-tools { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}

/* Server-only forecast/installment evidence has no demo counterpart. Keep its
   facts and actions readable within A's existing tools and detail sheet. */
html[data-subs] #page-budgets #bSubsWrap .sp-tools :is([data-forecast-key], [data-obligation-key], [data-forecast-group]) { display: grid; gap: 8px; min-width: 0; }
html[data-subs] #page-budgets #bSubsWrap .sp-tools :is([data-forecast-key], [data-obligation-key]) > span { grid-column: auto; min-width: 0; text-align: left; }
html[data-subs] #bSubsWrap .sp-tools :is([data-forecast-key], [data-obligation-key]) small,
html[data-subs] #mHelp [data-server-sub-detail] small { display: block; }
html[data-subs] #bSubsWrap .sp-tools [data-forecast-key] .sub-actions { display: flex; flex-wrap: wrap; gap: 8px; }
