:root {
  --bg: #f5f3ef;
  --surface: #ffffff;
  --ink: #141414;
  --ink-2: #4a4a48;
  --ink-3: #6f6d69;
  --line: #e4e0d8;
  --line-2: #d4cfc5;
  --accent: #e8590c;
  --accent-ink: #b8460a;
  --ok: #1f7a4d;
  --ok-bg: #e7f3ec;
  --warn: #8a5a00;
  --warn-bg: #fbf1dc;
  --bad: #b42318;
  --bad-bg: #fbe9e7;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  --t-fast: 140ms;
  --t-med: 220ms;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans);
  font-feature-settings: "tnum" 1; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- шапка */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px clamp(16px, 4vw, 40px); }
.brand { font-weight: 700; letter-spacing: .14em; font-size: 14px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.brand b { color: var(--accent); }
.brand span { color: var(--ink-3); font-weight: 500; margin: 0 .35em; }
.langs { display: flex; gap: 2px; background: #ebe7df; border-radius: 999px; padding: 3px; }
.langs button { border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; font-size: 13px; cursor: pointer; color: var(--ink-2); min-height: 32px; }
.langs button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }

/* ---------- кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-weight: 600;
  text-decoration: none; color: var(--ink); transition: background var(--t-fast), border-color var(--t-fast);
}
.btn:hover { border-color: var(--ink-3); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: #2a2a2a; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-ink); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.icon { width: 16px; height: 16px; flex: none; }

/* ---------- страница оплаты */
.pay-wrap { max-width: 880px; margin: 0 auto; padding: 8px clamp(16px, 4vw, 40px) 56px; }
.pay-card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.pay-head { padding: clamp(22px, 4vw, 40px) clamp(20px, 4vw, 40px) 24px; border-bottom: 1px solid var(--line); }
.eyebrow { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 10px; font-weight: 600; }
.pay-desc { margin: 0 0 18px; color: var(--ink-2); font-size: 16px; }
.amount-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.amount { font-size: clamp(40px, 8vw, 64px); line-height: 1; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.amount small { font-size: .38em; font-weight: 600; letter-spacing: .02em; color: var(--ink-3); margin-left: .3em; }
.net { display: inline-flex; align-items: center; gap: 8px; margin-top: 16px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.net i { width: 8px; height: 8px; border-radius: 50%; background: #e50914; display: inline-block; }

.pay-body { display: grid; grid-template-columns: 236px 1fr; gap: clamp(20px, 4vw, 40px); padding: clamp(20px, 4vw, 40px); }
.qr { width: 236px; height: 236px; border: 1px solid var(--line); border-radius: 16px; padding: 14px; background: #fff; display: grid; place-items: center; }
.qr svg, .qr img { width: 100%; height: 100%; image-rendering: pixelated; }
.field-label { font-size: 13px; color: var(--ink-3); margin: 0 0 8px; font-weight: 600; }
.addr {
  font-family: var(--mono); font-size: 15px; word-break: break-all; background: #f8f6f2; border: 1px solid var(--line);
  border-radius: 10px; padding: 14px; margin: 0 0 12px; user-select: all; line-height: 1.55;
}
.addr mark { background: none; color: var(--accent-ink); font-weight: 700; }
.copy-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }

.status { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; background: #f3f1ec; margin-bottom: 18px; }
.status .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink-3); margin-top: 6px; flex: none; }
.status[data-state="open"] .dot { background: var(--accent); animation: pulse 1.6s infinite; }
.status[data-state="partial"] { background: var(--warn-bg); }
.status[data-state="partial"] .dot { background: var(--warn); }
.status[data-state="paid"] { background: var(--ok-bg); }
.status[data-state="paid"] .dot { background: var(--ok); }
.status[data-state="expired"], .status[data-state="cancelled"] { background: var(--bad-bg); }
.status[data-state="expired"] .dot, .status[data-state="cancelled"] .dot { background: var(--bad); }
.status strong { display: block; }
.status p { margin: 2px 0 0; color: var(--ink-2); font-size: 14px; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.warn { border-left: 3px solid var(--accent); padding: 4px 0 4px 14px; margin: 0 0 18px; color: var(--ink-2); font-size: 14px; }
.warn strong { color: var(--ink); }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 8px; font-size: 14px; color: var(--ink-2); }
.steps li { counter-increment: s; display: flex; gap: 10px; }
.steps li::before { content: counter(s); flex: none; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-2); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--ink); }
.pay-foot { padding: 16px clamp(20px, 4vw, 40px); border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-3); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.done { padding: clamp(32px, 6vw, 64px) clamp(20px, 4vw, 40px); text-align: center; }
.done .check { width: 64px; height: 64px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); display: grid; place-items: center; margin: 0 auto 18px; }
.done h2 { margin: 0 0 6px; font-size: 26px; }
.done p { margin: 0; color: var(--ink-2); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity var(--t-med), transform var(--t-med); z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.center-msg { max-width: 520px; margin: 12vh auto; padding: 0 20px; text-align: center; color: var(--ink-2); }
.skeleton { background: linear-gradient(90deg, #eeebe5, #f6f4f0, #eeebe5); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }

@media (max-width: 720px) {
  .pay-body { grid-template-columns: 1fr; }
  .qr { width: min(260px, 100%); height: auto; aspect-ratio: 1; margin: 0 auto; }
  .copy-row .btn { flex: 1 1 140px; }
}

/* ---------- админка */
.admin { max-width: 1240px; margin: 0 auto; padding: 0 clamp(16px, 3vw, 32px) 64px; }
.admin-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 0; border-bottom: 1px solid var(--line); margin-bottom: 24px; flex-wrap: wrap; }
.admin-top .right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #ebe7df; color: var(--ink-2); white-space: nowrap; }
.chip i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.muted { background: #efede8; color: var(--ink-3); }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 20px; }
.metric { padding: 18px 20px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span { display: block; font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.metric strong { display: block; font-size: 26px; margin-top: 4px; letter-spacing: -.01em; }
.alert { border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; font-size: 14px; border: 1px solid; }
.alert.bad { background: var(--bad-bg); border-color: #f1c6c0; color: #7a1a12; }
.alert.warn { background: var(--warn-bg); border-color: #ecd9a8; color: #5c3c00; }
.mainaddr { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; padding: 14px 18px; border: 1px dashed var(--line-2); border-radius: 12px; margin-bottom: 24px; font-size: 14px; color: var(--ink-2); }
.mainaddr code { font-family: var(--mono); color: var(--ink); word-break: break-all; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; font-weight: 600; color: var(--ink-3); border-bottom: 2px solid transparent; margin-bottom: -1px; min-height: 44px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .count { font-weight: 500; color: var(--ink-3); margin-left: 4px; }
.search { min-height: 40px; border: 1px solid var(--line-2); border-radius: 10px; padding: 0 12px; background: var(--surface); width: min(280px, 100%); }

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #faf9f6; }
td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 13px; }
.sub { color: var(--ink-3); font-size: 12px; display: block; margin-top: 2px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.empty { padding: 48px 20px; text-align: center; color: var(--ink-3); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; font-size: 16px; }
.empty .btn { margin-top: 14px; }

.st { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.st-open { background: #fdeee4; color: var(--accent-ink); }
.st-partial { background: var(--warn-bg); color: var(--warn); }
.st-paid { background: var(--ok-bg); color: var(--ok); }
.st-expired, .st-cancelled { background: #efede8; color: var(--ink-3); }

/* выезжающая панель */
.scrim { position: fixed; inset: 0; background: rgb(20 20 20 / .35); opacity: 0; pointer-events: none; transition: opacity var(--t-med); z-index: 30; }
.scrim.open { opacity: 1; pointer-events: auto; }
.panel { position: fixed; top: 0; right: 0; height: 100%; width: min(460px, 100%); background: var(--surface); z-index: 40; transform: translateX(100%); transition: transform var(--t-med) cubic-bezier(.2, .8, .2, 1); display: flex; flex-direction: column; box-shadow: -8px 0 32px rgb(0 0 0 / .08); }
.panel.open { transform: none; }
.panel header { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.panel h2 { margin: 0; font-size: 18px; }
.panel .body { padding: 22px; overflow: auto; flex: 1; }
.panel footer { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }
.f { display: grid; gap: 6px; margin-bottom: 16px; }
.f label { font-size: 13px; font-weight: 600; }
.f input, .f select, .f textarea { min-height: 44px; border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; background: #fff; width: 100%; }
.f textarea { min-height: 72px; resize: vertical; }
.f .hint { font-size: 12px; color: var(--ink-3); }
.f .err { font-size: 13px; color: var(--bad); }
.f [aria-invalid="true"] { border-color: var(--bad); }
.seg { display: flex; gap: 4px; background: #efece6; border-radius: 10px; padding: 3px; margin-bottom: 16px; }
.seg button { flex: 1; border: 0; background: transparent; min-height: 38px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }
.result { border: 1px solid #cfe5d8; background: var(--ok-bg); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.result p { margin: 0 0 8px; font-weight: 600; color: var(--ok); }
.result .mono { word-break: break-all; display: block; margin-bottom: 10px; color: var(--ink); }
.form-error { color: var(--bad); font-size: 14px; margin: 0 0 12px; }

.login { max-width: 380px; margin: 14vh auto; padding: 0 20px; }
.login .card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 28px; }
.login h1 { font-size: 22px; margin: 18px 0 6px; }
.login p { color: var(--ink-2); margin: 0 0 20px; font-size: 14px; }

@media (max-width: 860px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  table.stack thead { display: none; }
  table.stack tr { display: block; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 0; text-align: right; }
  table.stack td::before { content: attr(data-l); color: var(--ink-3); font-size: 12px; text-align: left; flex: none; }
  table.stack td.num { text-align: right; }
  .row-actions { justify-content: flex-end; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0ms !important; }
}
.sk-line { height: 14px; width: 140px; margin-bottom: 18px; } .sk-big { height: 56px; width: min(320px, 80%); }
[hidden] { display: none !important; }
.cell { min-width: 0; }
@media (max-width: 860px) {
  table.stack td { display: grid; grid-template-columns: 88px 1fr; align-items: start; }
  table.stack td::before { padding-top: 2px; }
  table.stack td .cell { text-align: right; overflow-wrap: anywhere; }
  table.stack td[data-l=""] { grid-template-columns: 1fr; }
  table.stack td[data-l=""]::before { display: none; }
  .admin-top .right { width: 100%; }
  .admin-top .right .chip { flex-basis: 100%; justify-content: flex-start; width: max-content; }
  .copy-row .btn { white-space: nowrap; }
}
