/* Partner cabinet. White, flat and calm in the colours of «верни всё»: blue for actions, a status always carries an icon
   and a word. Mobile first (ui-ux-pro-max): 16px text, 48px touch targets, visible labels, errors next to the field,
   safe areas around the fixed bars, 150ms feedback, reduced motion respected. */
:root {
  --paper: #fff; --surface: #f5f6f8; --surface-2: #eceef2; --ink: #14151c; --muted: #5f6370; --line: #e7e9ee; --line-strong: #d3d7df;
  --blue: #3155ee; --blue-press: #2645cf; --blue-ink: #2448d7; --blue-soft: #eef1ff;
  --green: #19744c; --green-soft: #ebf6ef; --orange: #8f5517; --orange-soft: #fff4e7; --red: #b73b3b; --red-soft: #fff0f0;
  --radius: 16px; --radius-s: 12px; --touch: 48px; --quick: 150ms;
  --tabs: calc(64px + env(safe-area-inset-bottom)); --gutter: max(16px, env(safe-area-inset-left));
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--paper); }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/1.5 Manrope, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; line-height: 1.2; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 18px; line-height: 1.3; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 16px; font-weight: 700; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .45; }
a { color: var(--blue-ink); }
[hidden] { display: none !important; }
.sprite { position: absolute; }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid #92a5ff; outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--paper); padding: 10px 14px; border-radius: 10px; z-index: 50; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.nowrap { white-space: nowrap; }

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.brand b { color: var(--blue); font-weight: 800; }
.brand img { border-radius: 9px; }
.brand.big { font-size: 24px; }
.brand.big img { border-radius: 13px; }
.pill { font-style: normal; font-size: 12px; font-weight: 700; color: var(--blue-ink); background: var(--blue-soft); padding: 2px 9px; border-radius: 999px; letter-spacing: 0; }

/* Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px var(--gutter); }
.login-card { width: min(400px, 100%); display: grid; gap: 16px; }
.login-card .brand { margin-bottom: 8px; }

/* Fields and buttons */
.field { display: grid; gap: 6px; }
.field > span { font-size: 14px; font-weight: 600; color: var(--ink); }
input:not([type=checkbox]) { width: 100%; min-height: var(--touch); padding: 11px 14px; border: 1.5px solid var(--line-strong); border-radius: var(--radius-s); background: var(--paper);
  font-size: 16px; transition: border-color var(--quick); }
input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
input[aria-invalid="true"] { border-color: var(--red); }
.hint { font-size: 14px; color: var(--muted); }
.error { display: flex; gap: 8px; align-items: flex-start; color: var(--red); font-size: 14px; font-weight: 600; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--touch); padding: 0 18px; border-radius: var(--radius-s);
  font-weight: 700; font-size: 16px; transition: background var(--quick), color var(--quick), border-color var(--quick); position: relative; }
.btn.block { width: 100%; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:active:not(:disabled) { background: var(--blue-press); }
.btn.secondary { background: var(--paper); color: var(--ink); border: 1.5px solid var(--line-strong); }
.btn.secondary:active:not(:disabled) { background: var(--surface); }
.btn.soft { background: var(--blue-soft); color: var(--blue-ink); }
.btn.danger { background: var(--paper); color: var(--red); border: 1.5px solid #efc9c9; }
.btn.small { min-height: 40px; padding: 0 12px; font-size: 14px; }
.btn.link { min-height: 40px; padding: 0 4px; color: var(--blue-ink); font-weight: 700; font-size: 15px; }
.btn .spinner { display: none; }
.btn.busy { color: transparent !important; pointer-events: none; }
.btn.busy .spinner { display: block; position: absolute; inset: 0; margin: auto; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid rgba(255,255,255,.45); border-top-color: #fff; animation: spin .8s linear infinite; }
.spinner.dark { border-color: var(--blue-soft); border-top-color: var(--blue); }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { width: var(--touch); height: var(--touch); display: inline-grid; place-items: center; border-radius: var(--radius-s); color: var(--muted); flex: none; }
.icon-btn:active { background: var(--surface); }

/* Shell */
.app { min-height: 100dvh; }
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: rgba(255,255,255,.94);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  padding: max(10px, env(safe-area-inset-top)) var(--gutter) 10px; border-bottom: 1px solid var(--line); }
.who { font-size: 14px; color: var(--muted); font-weight: 600; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#main { outline: none; width: 100%; max-width: 600px; margin: 0 auto; padding: 18px var(--gutter) calc(var(--tabs) + 32px); display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
body.with-cart #main { padding-bottom: calc(var(--tabs) + 150px); }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--paper); border-top: 1px solid var(--line);
  padding: 4px max(4px, env(safe-area-inset-left)) env(safe-area-inset-bottom); }
.tabs button { position: relative; display: grid; justify-items: center; gap: 2px; min-height: 58px; padding: 8px 2px 6px; color: var(--muted); font-size: 12px; font-weight: 600; border-radius: 12px; }
.tabs button svg { width: 24px; height: 24px; }
.tabs button[aria-current="page"] { color: var(--blue); }
.tabs button:active { background: var(--surface); }
.badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--blue); color: #fff; font-size: 11px; line-height: 18px; font-weight: 800; }
@media (min-width: 720px) {
  .tabs { left: 50%; right: auto; transform: translateX(-50%); width: 600px; bottom: 12px; border: 1px solid var(--line); border-radius: 20px; padding-bottom: 4px; box-shadow: 0 8px 30px rgba(20,21,28,.08); }
  :root { --tabs: 90px; }
}

/* Page heads */
.head { display: grid; gap: 4px; }
.head p { color: var(--muted); font-size: 15px; }
.back { display: inline-flex; align-items: center; gap: 2px; min-height: 40px; color: var(--blue-ink); font-weight: 700; margin-left: -6px; }

/* Cards */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; min-width: 0; }
.card.soft { background: var(--surface); border-color: transparent; }
.card.accent { border-color: #c8d2ff; background: #fafbff; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.divider { height: 1px; background: var(--line); margin: 0 -16px; }

/* Search */
.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 44px; background: var(--surface); border-color: transparent; }
.search input:focus { background: var(--paper); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter); }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--line); font-size: 14px; font-weight: 700; color: var(--muted); background: var(--paper); }
.chip[aria-pressed="true"] { border-color: var(--blue); color: var(--blue-ink); background: var(--blue-soft); }

/* App list */
.apps { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.apps li + li { border-top: 1px solid var(--line); }
.app-row { position: relative; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 14px; cursor: pointer; transition: background var(--quick); }
.app-row:active { background: var(--surface); }
.app-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.app-row .name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.app-row .name small { display: block; font-size: 13px; font-weight: 600; }
.box { width: 26px; height: 26px; flex: none; border-radius: 8px; border: 2px solid var(--line-strong); display: grid; place-items: center; color: #fff; transition: background var(--quick), border-color var(--quick); }
.box svg { width: 18px; height: 18px; stroke-width: 2.6; opacity: 0; }
.app-row input:checked + .box { background: var(--blue); border-color: var(--blue); }
.app-row input:checked + .box svg { opacity: 1; }
.app-row input:focus-visible + .box { outline: 3px solid #92a5ff; outline-offset: 2px; }
.app-row.on { background: #fafbff; }
.tile { width: 44px; height: 44px; border-radius: 11px; flex: none; object-fit: cover; background: var(--blue-soft); color: var(--blue-ink); display: grid; place-items: center; font-weight: 800; font-size: 18px; border: 1px solid var(--line); }
.tile.sm { width: 32px; height: 32px; border-radius: 8px; font-size: 14px; }
.state { font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.state.now { color: var(--green); }
.state.busy, .state.soon { color: var(--orange); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

/* Cart bar above the tabs: compact, the floor of the sum sits inside the field */
.cartbar { position: fixed; z-index: 19; left: 0; right: 0; bottom: var(--tabs); background: var(--paper); border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgba(20,21,28,.06);
  padding: 6px var(--gutter) 10px; display: grid; gap: 8px; }
@media (min-width: 720px) { .cartbar { left: 50%; right: auto; width: 600px; transform: translateX(-50%); border: 1px solid var(--line); border-radius: 20px; bottom: calc(var(--tabs) + 4px); } }
.cart-note { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: -6px; }
.cart-note .btn.link { min-height: 36px; font-size: 14px; }
.cart-sum { display: flex; align-items: center; gap: 12px; }
.money-input { position: relative; display: block; }
.money-input input { font-size: 22px; font-weight: 800; padding-right: 36px; min-height: 52px; letter-spacing: -0.01em; }
.money-input::after { content: "₽"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 20px; font-weight: 800; color: var(--muted); pointer-events: none; }
.money-input.with-min { flex: 1; min-width: 0; }
.money-input.with-min::after { content: none; }
.money-input.with-min input { font-size: 20px; min-height: 48px; padding: 8px 112px 8px 14px; }
.money-input .min { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 13px; font-weight: 700; color: var(--muted); pointer-events: none; white-space: nowrap; }
.money-input input[aria-invalid="true"] + .min { color: var(--red); }
.earn { text-align: right; flex: none; line-height: 1.2; }
.earn span { display: block; font-size: 12px; font-weight: 700; color: var(--muted); }
.earn b { font-size: 18px; color: var(--green); }

/* Prices */
.price-row { display: grid; grid-template-columns: 1fr 140px; gap: 12px; align-items: center; }
.price-row + .price-row { border-top: 1px solid var(--line); padding-top: 12px; }
.price-row .label b { display: block; font-weight: 700; }
.price-row .label span { font-size: 14px; color: var(--muted); }
.money-input.compact input { font-size: 18px; min-height: var(--touch); }
.money-input.compact::after { font-size: 17px; }
table.preview { width: 100%; border-collapse: collapse; font-size: 15px; }
table.preview th { text-align: left; font-size: 13px; font-weight: 700; color: var(--muted); padding: 0 0 8px; }
table.preview td { padding: 8px 0; border-top: 1px solid var(--line); }
table.preview th:not(:first-child), table.preview td:not(:first-child) { text-align: right; }
table.preview td.earn-cell { color: var(--green); font-weight: 700; }

/* Orders */
.order-card { display: grid; gap: 8px; width: 100%; text-align: left; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; transition: background var(--quick); }
.order-card:active { background: var(--surface); }
.order-card .apps-line { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-card .sum { font-weight: 800; font-size: 17px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; padding: 4px 10px 4px 8px; border-radius: 999px; white-space: nowrap; }
.status svg { width: 16px; height: 16px; }
.status.wait { color: var(--orange); background: var(--orange-soft); }
.status.paid { color: var(--blue-ink); background: var(--blue-soft); }
.status.done { color: var(--green); background: var(--green-soft); }
.status.off { color: var(--muted); background: var(--surface); }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); display: grid; gap: 8px; justify-items: center; }
.empty svg { width: 40px; height: 40px; color: var(--line-strong); }

/* Order detail */
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; }
.kv b { font-weight: 800; }
.kv .earn-v { color: var(--green); }
.app-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.app-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 10px; background: var(--surface); font-size: 14px; font-weight: 600; max-width: 100%; }
.app-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linkbox { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; border-radius: var(--radius-s); background: var(--surface); }
.linkbox code { flex: 1; min-width: 0; font: 600 14px/1.4 ui-monospace, "SF Mono", Menlo, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 140px; }
.step { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.step-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.step-head h3 { font-size: 17px; }
.secret { display: flex; align-items: center; gap: 10px; padding: 10px 6px 10px 14px; border-radius: var(--radius-s); background: var(--surface); }
.secret .k { font-size: 13px; font-weight: 700; color: var(--muted); }
.secret .v { font: 700 17px/1.35 ui-monospace, "SF Mono", Menlo, monospace; word-break: break-all; user-select: all; -webkit-user-select: all; }
.timer { display: grid; gap: 6px; }
.timer .row { font-weight: 700; }
.timer .row.warn { color: var(--orange); }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--blue); border-radius: 3px; transition: width 1s linear; }
.bar.warn i { background: var(--orange); }
.code { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 8px 14px 16px; border-radius: var(--radius-s); background: var(--green-soft); }
.code b { font: 800 32px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .12em; color: var(--ink); }
.code small { display: block; font-size: 13px; font-weight: 700; color: var(--green); margin-top: 4px; }
.waiting { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius-s); background: var(--blue-soft); color: var(--blue-ink); font-weight: 700; font-size: 15px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-s); font-size: 15px; font-weight: 600; }
.notice svg { margin-top: 1px; }
.notice.warn { background: var(--orange-soft); color: var(--orange); }
.notice.bad { background: var(--red-soft); color: var(--red); }
.notice.info { background: var(--blue-soft); color: var(--blue-ink); }
.notice.ok { background: var(--green-soft); color: var(--green); }
.done-line { display: flex; align-items: center; gap: 8px; color: var(--green); font-weight: 700; }
.locked { color: var(--muted); font-size: 15px; }

/* Profile */
.money3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.money3 div { background: var(--surface); border-radius: var(--radius-s); padding: 12px; display: grid; gap: 2px; }
.money3 span { font-size: 12px; font-weight: 700; color: var(--muted); }
.money3 b { font-size: 18px; font-weight: 800; }
.money3 .owed b { color: var(--green); }

/* Dialog and toast */
dialog { border: 0; padding: 0; overflow: auto; border-radius: 22px; width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); background: var(--paper); color: var(--ink);
  box-shadow: 0 24px 60px rgba(20,21,28,.22); }
dialog::backdrop { background: rgba(20,21,28,.45); }
.dlg { padding: 22px 20px 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.dlg > *, .dlg .lead > div { min-width: 0; }
.dlg .lead { display: flex; gap: 12px; align-items: flex-start; }
.dlg .lead .big-i { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.dlg .lead .big-i.warn { background: var(--orange-soft); color: var(--orange); }
.dlg .lead .big-i.ok { background: var(--green-soft); color: var(--green); }
.dlg .lead .big-i.info { background: var(--blue-soft); color: var(--blue-ink); }
.dlg .lead .big-i svg { width: 24px; height: 24px; }
.dlg p { color: var(--muted); }
.dlg .btn-row .btn { flex: 1 1 130px; padding: 0 12px; white-space: nowrap; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs) + 16px); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 60;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 15px; font-weight: 600; max-width: calc(100vw - 32px);
  transition: opacity 180ms, transform 180ms; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
body.with-cart .toast { bottom: calc(var(--tabs) + 140px); }

/* Skeleton */
.skeleton { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius); }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
