/* ===== Tokens ===== */
:root {
  --canvas: #EDEFF3;
  --surface: #FFFFFF;
  --ink: #151A2D;
  --ink-2: #50576D;
  --ink-3: #8A90A2;
  --line: #DCE0E7;
  --line-2: #EBEEF2;
  --go: #0C8A62;
  --go-dark: #086B4B;
  --go-tint: #E2F3EB;
  --run: #2550C4;   --run-tint: #E5ECFB;
  --wait: #5F667A;  --wait-tint: #ECEEF2;
  --warn: #A35F00; --warn-tint: #FFF1D9;
  --bad: #BF3624;  --bad-tint: #FCE6E2;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --nav-h: 64px;
  --tray-h: 76px;
  --font: 'Rubik', 'Segoe UI', 'Arial Hebrew', Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--run); }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; unicode-bidi: isolate; direction: ltr; display: inline-block; }
.muted { color: var(--ink-2); }
.ic { width: 20px; height: 20px; flex: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--run) 55%, transparent); outline-offset: 2px; }

/* ===== Buttons & fields ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--r);
  border: 1px solid transparent; background: var(--surface); color: var(--ink);
  font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:disabled { cursor: not-allowed; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #23294A; }
.btn-go { background: var(--go); color: #fff; }
.btn-go:hover { background: var(--go-dark); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: var(--surface); }
.btn-danger { background: var(--bad-tint); color: var(--bad); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: var(--r-sm); }
.btn-lg { min-height: 54px; font-size: 18px; }
.btn-block { display: flex; width: 100%; }
.linkish { background: none; border: 0; padding: 4px 0; color: var(--run); cursor: pointer; font-size: 14px; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: inherit; cursor: pointer; }
.icon-btn:hover { background: rgba(255,255,255,.12); }

.field { display: grid; gap: 6px; }
.field > span { font-size: 14px; font-weight: 500; color: var(--ink-2); }
.field input, .field select, .field textarea, .input {
  width: 100%; min-height: 46px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface);
}
.field input, .field select { height: 46px; }
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(21,26,45,.12); }
.field small { color: var(--ink-3); font-size: 13px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--ink); }
.stack { display: grid; gap: 16px; }

.alert { padding: 12px 14px; border-radius: var(--r-sm); font-size: 15px; }
.alert-bad { background: var(--bad-tint); color: var(--bad); }
.alert-ok { background: var(--go-tint); color: var(--go-dark); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 99px; font-size: 13px; font-weight: 500; white-space: nowrap;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-wait { background: var(--wait-tint); color: var(--wait); }
.pill-run  { background: var(--run-tint); color: var(--run); }
.pill-done { background: var(--go-tint); color: var(--go-dark); }
.pill-warn { background: var(--warn-tint); color: var(--warn); }
.pill-bad  { background: var(--bad-tint); color: var(--bad); }

/* ===== Auth ===== */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-box { width: 100%; max-width: 380px; }
.auth-title { font-size: 30px; line-height: 1.15; margin: 0 0 6px; letter-spacing: -.01em; }
.auth .muted { margin: 0 0 24px; }
.auth form { margin-top: 8px; }
.auth .alert { margin-bottom: 16px; }
.blocked { text-align: center; }
.blocked-mark { width: 64px; height: 64px; border-radius: 50%; background: var(--bad-tint); color: var(--bad); display: grid; place-items: center; margin: 0 auto 16px; }
.blocked-mark .ic { width: 30px; height: 30px; stroke-width: 2.6; }
.install-next { padding-inline-start: 20px; margin: 0 0 24px; display: grid; gap: 8px; }

/* ===== Client shell ===== */
.topbar { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-in { max-width: 760px; margin: 0 auto; height: 56px; padding: 0 16px; display: flex; align-items: center; gap: 16px; }
.brand { color: #fff; text-decoration: none; font-weight: 600; font-size: 17px; white-space: nowrap; }
.nav { display: flex; gap: 4px; margin-inline-start: auto; }
.nav-link {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--r-sm);
  color: rgba(255,255,255,.72); text-decoration: none; font-size: 15px; white-space: nowrap;
}
.nav-link:hover { color: #fff; }
.nav-link.is-active { color: #fff; background: rgba(255,255,255,.12); }
.logout { display: flex; align-items: center; gap: 4px; margin: 0; }
.who { font-size: 14px; color: rgba(255,255,255,.65); max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.page { max-width: 760px; margin: 0 auto; padding: 20px 16px 40px; }
.page-order { padding-bottom: calc(var(--tray-h) + 40px); }
.page-title { font-size: 22px; margin: 4px 0 16px; }
.empty { text-align: center; padding: 48px 16px; color: var(--ink-2); }
.empty .btn { margin-top: 8px; }
.more { margin-top: 16px; }

/* ===== Balance ===== */
.balance {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 4px 2px 18px; margin-bottom: 18px; border-bottom: 1px solid var(--line);
}
.bal-main { display: grid; }
.bal-label { font-size: 14px; color: var(--ink-2); }
.bal-value { font-size: 40px; line-height: 1.1; font-weight: 600; letter-spacing: -.02em; }
.bal-note { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.bal-side { display: flex; gap: 24px; margin: 0; }
.bal-side div { display: grid; }
.bal-side dt { font-size: 13px; color: var(--ink-2); }
.bal-side dd { margin: 0; font-size: 18px; font-weight: 500; }
.bal-debt.has-debt dd { color: var(--bad); }

/* ===== Order form ===== */
.order { display: grid; gap: 22px; }
.block { border: 0; margin: 0; padding: 0; min-width: 0; }
.block-title { display: block; font-size: 15px; font-weight: 600; margin: 0 0 10px; padding: 0; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }

.platforms { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
.platforms::-webkit-scrollbar { display: none; }
.plat { position: relative; flex: none; }
.plat input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.plat > span:last-child { display: inline-block; }
.plat {
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 16px;
  border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font-weight: 500; cursor: pointer;
}
.plat-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pc); }
.plat:has(input:checked) { background: var(--ink); color: #fff; border-color: var(--ink); }
.plat:has(input:checked) .plat-dot { box-shadow: 0 0 0 2px rgba(255,255,255,.9); }
.plat:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--run) 55%, transparent); outline-offset: 2px; }

.linkbox {
  display: flex; align-items: center; gap: 8px; background: var(--surface);
  border: 1.5px solid var(--line); border-radius: var(--r); padding: 0 6px 0 12px; min-height: 56px;
}
.linkbox:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(21,26,45,.1); }
.linkbox-ic { color: var(--ink-3); display: grid; padding-inline-start: 6px; }
.linkbox input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 16px; padding: 12px 0; text-align: left; }
.linkbox input::placeholder { text-align: right; direction: rtl; color: var(--ink-3); }
.paste {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px;
  border-radius: var(--r-sm); border: 0; background: var(--canvas); cursor: pointer; font-size: 14px; font-weight: 500;
}
.paste .ic { width: 18px; height: 18px; }
.hint { min-height: 22px; margin: 6px 2px 0; font-size: 14px; color: var(--ink-2); }
.hint.is-ok { color: var(--go-dark); }
.hint.is-bad { color: var(--bad); }

.services { background: var(--surface); border-radius: var(--r-lg); border: 1px solid var(--line); overflow: hidden; }
.services > .muted { padding: 20px; margin: 0; }
.svc { padding: 14px 16px 12px; border-top: 1px solid var(--line-2); position: relative; transition: background-color .15s; }
.svc:first-child { border-top: 0; }
.svc.is-on { background: #F6FBF8; }
.svc.is-on::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 0; width: 4px; background: var(--go); }
.svc.is-bad::before { background: var(--bad); }
.svc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.svc-title { display: grid; }
.svc-name { font-weight: 600; font-size: 17px; }
.svc-rate { font-size: 13px; color: var(--ink-3); }
.svc-price { font-size: 18px; font-weight: 600; color: var(--ink-3); min-width: 64px; text-align: left; }
.svc.is-on .svc-price { color: var(--ink); }
.svc-desc { margin: 2px 0 0; font-size: 13px; color: var(--ink-2); }
.svc-qty { display: flex; gap: 8px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  height: 38px; min-width: 58px; padding: 0 12px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 500;
}
.chip:hover { border-color: var(--ink-3); }
.chip.is-on { background: var(--ink); color: #fff; border-color: var(--ink); }
.qty {
  width: 120px; height: 38px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--surface); font-variant-numeric: tabular-nums; text-align: center;
  -moz-appearance: textfield;
}
.qty::-webkit-outer-spin-button, .qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty::placeholder { color: var(--ink-3); font-size: 14px; }
.qty:focus { outline: none; border-color: var(--ink); }
.svc-err { margin: 6px 0 0; font-size: 13px; color: var(--bad); min-height: 0; }
.svc-err:empty { display: none; }

/* ===== Tray (the one bold element) ===== */
.tray {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
  background: var(--ink); color: #fff;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -8px 24px rgba(21,26,45,.18);
}
.tray-in { max-width: 760px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 16px; }
.tray-sum { display: grid; flex: 1; min-width: 0; }
.tray-label { font-size: 13px; color: rgba(255,255,255,.65); }
.tray-total { font-size: 30px; line-height: 1.1; font-weight: 600; letter-spacing: -.02em; }
.btn-order {
  min-height: 56px; min-width: 180px; padding: 0 28px; border-radius: var(--r);
  background: var(--go); color: #fff; font-size: 19px; font-weight: 600;
}
.btn-order:hover:not(:disabled) { background: #0FA071; }
.btn-order:disabled { background: rgba(255,255,255,.12); color: rgba(255,255,255,.55); font-size: 16px; }
.tray-msg { max-width: 760px; margin: 0 auto; padding: 0 16px 10px; color: #FFB4A8; font-size: 14px; }
.tray-msg:empty { display: none; }

/* ===== Sheets (dialogs) ===== */
.sheet { border: 0; padding: 0; border-radius: var(--r-lg); width: min(440px, calc(100% - 24px)); background: var(--surface); color: var(--ink); }
.sheet::backdrop { background: rgba(21,26,45,.55); }
.sheet-in { padding: 24px 20px 20px; }
.sheet-title { margin: 0 0 4px; font-size: 22px; }
.sheet-actions { display: grid; gap: 8px; margin-top: 20px; }
.done-mark { width: 52px; height: 52px; border-radius: 50%; background: var(--go); color: #fff; display: grid; place-items: center; margin-bottom: 12px; }
.done-mark .ic { width: 28px; height: 28px; stroke-width: 2.6; }
.sheet.is-failed .done-mark { background: var(--bad); }
.done-items { list-style: none; margin: 16px 0 0; padding: 0; border-top: 1px solid var(--line-2); }
.done-items li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.done-items li > span:first-child { flex: 1; font-weight: 500; }
.done-bal { display: flex; justify-content: space-between; align-items: baseline; margin-top: 14px; font-size: 15px; color: var(--ink-2); }
.done-bal strong { font-size: 20px; color: var(--ink); }
.sheet[open] { animation: rise .22s ease-out; }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===== Orders list ===== */
.orders { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.ocard { min-width: 0; }
.ocard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; }
.ocard-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.ocard-plat { font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.ocard-plat::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.plat-instagram::before { background: #D62976; } .plat-tiktok::before { background: #111318; }
.plat-facebook::before { background: #1A66E0; } .plat-youtube::before { background: #E52D27; }
.plat-x::before { background: #2A2E37; } .plat-telegram::before { background: #1D93D2; }
.ocard-id { color: var(--ink-3); }
.ocard-time { color: var(--ink-3); }
.ocard-head [data-ostatus] { margin-inline-start: auto; }
.ocard-link { display: block; margin: 8px 0 4px; font-size: 14px; color: var(--ink-2); text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
.ocard-link:hover { text-decoration: underline; }
.ocard-items { list-style: none; margin: 6px 0 0; padding: 0; }
.ocard-items li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line-2); font-size: 15px; }
.oi-name { font-weight: 500; }
.oi-qty { color: var(--ink-2); margin-inline-end: auto; font-size: 14px; }
.ocard-foot { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 15px; }
.ocard-refund { color: var(--go-dark); font-weight: 500; }

/* ===== Ledger ===== */
.ledger { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.ledger-row { display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line-2); }
.ledger-row:first-child { border-top: 0; }
.ledger-main { display: grid; min-width: 0; }
.ledger-type { font-weight: 600; font-size: 15px; }
.ledger-note { font-size: 14px; color: var(--ink-2); overflow-wrap: anywhere; }
.ledger-time { font-size: 13px; color: var(--ink-3); }
.ledger-nums { display: grid; justify-items: end; align-content: start; text-align: left; }
.ledger-nums strong { font-size: 17px; }
.pos { color: var(--go-dark); }
.neg { color: var(--ink); }
.t-debt { color: var(--bad); }
.ledger-after { font-size: 13px; color: var(--ink-3); white-space: nowrap; }

/* ===== Mobile ===== */
@media (max-width: 680px) {
  .nav {
    position: fixed; inset-inline: 0; bottom: 0; z-index: 25; margin: 0; gap: 0;
    background: var(--surface); border-top: 1px solid var(--line);
    height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  }
  .nav-link {
    flex: 1; flex-direction: column; gap: 3px; justify-content: center; border-radius: 0;
    color: var(--ink-3); font-size: 12px; padding: 6px 4px;
  }
  .nav-link .ic { width: 22px; height: 22px; }
  .nav-link.is-active { background: transparent; color: var(--ink); font-weight: 600; }
  .logout { margin-inline-start: auto; }
  .page { padding-bottom: calc(var(--nav-h) + 32px); }
  .page-order { padding-bottom: calc(var(--nav-h) + var(--tray-h) + 32px); }
  .tray { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: 0; }
  .tray-in { padding: 10px 16px; gap: 12px; }
  .tray-total { font-size: 26px; }
  .btn-order { min-width: 0; flex: 1.2; padding: 0 16px; font-size: 18px; }
  .bal-value { font-size: 34px; }
  .balance { gap: 12px; }
  .bal-side { width: 100%; gap: 0; }
  .bal-side div { flex: 1; }
  .sheet { margin-bottom: 0; width: 100%; max-width: none; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .sheet-in { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .svc { padding: 14px 14px 12px; }
  .qty { flex: 1; min-width: 110px; }
}
@media (max-width: 380px) {
  .chip { min-width: 0; padding: 0 10px; }
  .who { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
