/* MoneyShop Partners — каркас по референсу Dub Partner Program (ТЗ, раздел 12) */
:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --muted: #6b7280;
  --faint: #9ca3af;
  --accent: #0b7a62;
  --accent-hover: #09654f;
  --accent-soft: #e7f4f0;
  --primary: #111827;
  --primary-hover: #1f2937;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warn-bg: #fef3c7; --warn-text: #92400e;
  --ok-bg: #dcfce7; --ok-text: #166534;
  --grey-bg: #f3f4f6; --grey-text: #4b5563;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(17, 24, 39, .04);
  --shadow-lg: 0 20px 40px -12px rgba(17, 24, 39, .25);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Каркас ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex: none; padding: 20px 14px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: var(--text); font-weight: 650; font-size: 14px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700; letter-spacing: -.02em; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.nav-group { margin-top: 14px; padding: 0 10px 4px; font-size: 12px; color: var(--faint); }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: #374151; font-weight: 500;
}
.nav a:hover { background: #e9eaee; text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.user-link { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; padding: 6px; border-radius: var(--radius-sm); color: var(--text); }
.user-link:hover { background: #e9eaee; text-decoration: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #d7e9e3; color: var(--accent); display: grid; place-items: center; font-weight: 600; flex: none; }
.user-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.icon-btn { border: 0; background: transparent; color: var(--muted); padding: 8px; border-radius: var(--radius-sm); cursor: pointer; display: inline-grid; place-items: center; }
.icon-btn:hover { background: #e9eaee; color: var(--text); }

.main { flex: 1; min-width: 0; padding: 10px 10px 10px 0; display: flex; }
.panel { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; display: flex; flex-direction: column; }
.page-head { padding: 22px 28px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; }
.crumbs { margin: 4px 0 0; padding: 0; list-style: none; display: flex; gap: 6px; font-size: 13px; color: var(--muted); }
.crumbs li + li::before { content: "/"; margin-right: 6px; color: var(--faint); }
.crumbs a { color: var(--muted); }
.content { padding: 24px 28px; display: flex; flex-direction: column; gap: 20px; flex: 1; }
.footer { padding: 16px 28px; border-top: 1px solid var(--border); color: var(--faint); font-size: 12px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer a { color: var(--muted); }

.topbar { display: none; }
.scrim { display: none; }

@media (max-width: 900px) {
  .shell { display: block; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
  .topbar .brand { padding: 0; }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; height: auto; background: var(--bg); transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(17,24,39,.35); z-index: 40; }
  .main { padding: 0; }
  .panel { border: 0; border-radius: 0; }
  .page-head, .content, .footer { padding-left: 16px; padding-right: 16px; }
  .page-head { padding-top: 16px; padding-bottom: 16px; }
  .content { padding-top: 16px; padding-bottom: 16px; }
}

/* ---------- Карточки ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head h2 { font-size: 15px; }
.card-body { padding: 20px; }
.card-body > * + * { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }

.stat { padding: 18px 20px; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { margin-top: 6px; font-size: 28px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 15px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.stat.accent .stat-value { color: var(--accent); }

details.card > summary { list-style: none; cursor: pointer; padding: 16px 20px; display: flex; align-items: center; gap: 10px; font-weight: 600; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary .chev { margin-left: auto; transition: transform .15s; color: var(--muted); }
details.card[open] > summary { border-bottom: 1px solid var(--border); }
details.card[open] > summary .chev { transform: rotate(180deg); }
.video { position: relative; width: 100%; max-width: 560px; aspect-ratio: 560 / 315; border-radius: var(--radius-sm); overflow: hidden; background: #000; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---------- Формы ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .label { font-size: 13px; font-weight: 500; color: #374151; }
.req { color: var(--danger); margin-left: 2px; }
.input, select.input, textarea.input {
  width: 100%; min-width: 0; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: 8px 12px; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(11, 122, 98, .15); }
.input[readonly] { background: var(--surface-2); }
.input.is-invalid { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 12.5px; }
.hint { color: var(--muted); font-size: 12.5px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 560px) { .form-row { grid-template-columns: minmax(0, 1fr); } }
.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.form-section { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 600; margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-weight: 550; cursor: pointer;
  background: var(--primary); color: #fff; white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-accent { background: var(--accent); }
.btn-accent:hover { background: var(--accent-hover); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-outline:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost-danger { background: transparent; color: var(--danger); border-color: transparent; }
.btn-ghost-danger:hover { background: var(--danger-soft); }
.btn-block { width: 100%; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn .spinner { display: none; }
.btn.is-loading .spinner { display: inline-block; }
.btn.is-loading { pointer-events: none; opacity: .8; }
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px; border: 1px solid; }
.alert-error { background: var(--danger-soft); border-color: #fecaca; color: #991b1b; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-info { background: var(--surface-2); border-color: var(--border); color: #374151; }
.alert ul { margin: 0; padding-left: 18px; }
.secure-note { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; background: var(--accent-soft); color: #0b5d4b; border-radius: var(--radius-sm); font-size: 12.5px; }

/* ---------- Бейджи ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 550; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge-pending { background: var(--warn-bg); color: var(--warn-text); }
.badge-paid { background: var(--ok-bg); color: var(--ok-text); }
.badge-cancelled { background: var(--grey-bg); color: var(--grey-text); }
.badge-plain { background: var(--grey-bg); color: var(--grey-text); }
.badge-plain::before { display: none; }

/* ---------- Таблицы ---------- */
.table-wrap { overflow-x: auto; position: relative; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { padding: 12px 16px; border-top: 1px solid var(--border); font-weight: 600; background: var(--surface-2); }
.table .right { text-align: right; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table tr.changed td { background: #fffbeb; }
.card > .table-wrap .table th:first-child, .card > .table-wrap .table td:first-child { padding-left: 20px; }

@media (max-width: 640px) {
  .table.stack thead { display: none; }
  .table.stack, .table.stack tbody, .table.stack tr, .table.stack td, .table.stack tfoot { display: block; width: 100%; }
  .table.stack tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .table.stack td { border: 0; padding: 3px 0 !important; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table.stack td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex: none; }
  .table.stack td.right { text-align: right; }
  .table.stack td[data-label=""]::before { content: none; }
  .table.stack tfoot td { display: flex; padding: 12px 16px !important; }
}

.empty { padding: 40px 20px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty .icon { width: 28px; height: 28px; color: var(--faint); }

.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { width: 220px; max-width: 100%; }
@media (max-width: 560px) { .filters .field { width: 100%; } }

.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 24px; }
.kv dt { font-size: 12.5px; color: var(--muted); }
.kv dd { margin: 3px 0 0; font-weight: 500; word-break: break-word; }
@media (max-width: 720px) { .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .kv { grid-template-columns: minmax(0, 1fr); } }

.pagination { display: flex; gap: 4px; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--border); }
.pagination a, .pagination span { min-width: 32px; height: 32px; padding: 0 10px; display: inline-grid; place-items: center; border-radius: var(--radius-sm); border: 1px solid var(--border); color: #374151; font-size: 13px; }
.pagination a:hover { background: var(--surface-2); text-decoration: none; }
.pagination .current { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .disabled { color: var(--faint); }

.qr-box { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.qr-frame { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.qr-frame img { display: block; width: 250px; height: 250px; max-width: 100%; }
.code-chip { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-family: var(--mono); font-size: 12.5px; }

.pct-input { width: 120px; }
.pct-hint { color: var(--faint); font-size: 12.5px; margin-left: 8px; white-space: nowrap; }
.iframe-wrap iframe { width: 100%; height: 600px; border: 0; display: block; border-radius: 0 0 var(--radius) var(--radius); }

/* ---------- Модалки и тосты ---------- */
.modal { position: fixed; inset: 0; z-index: 70; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(17, 24, 39, .45); }
.modal.open { display: flex; }
.modal-dialog { width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); }
.modal-dialog.wide { max-width: 560px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 14px 14px; }
.modal-foot .spacer { flex: 1; }
.readonly-sum { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.readonly-sum b { font-size: 22px; display: block; margin-top: 2px; font-variant-numeric: tabular-nums; }

.toasts { position: fixed; top: 16px; right: 16px; z-index: 90; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 10px; min-width: 240px; max-width: 380px; padding: 12px 14px; border-radius: 10px; background: var(--primary); color: #fff; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: toast-in .18s ease; }
.toast.success .icon { color: #4ade80; }
.toast.error .icon { color: #f87171; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- Страницы входа ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; }
.auth .brand { margin-bottom: 18px; padding: 0; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.auth-card.wide { max-width: 520px; }
.auth-card h1 { font-size: 22px; margin-bottom: 6px; }
.auth-card .lead { color: var(--muted); margin: 0 0 20px; }
.auth-foot { margin-top: 18px; text-align: center; color: var(--muted); font-size: 13.5px; }
.auth-copy { margin-top: 24px; color: var(--faint); font-size: 12px; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.label-row a { font-size: 12.5px; }
@media (max-width: 420px) { .auth-card { padding: 22px 18px; } }

/* ---------- Лендинг ---------- */
.landing { min-height: 100vh; display: flex; justify-content: center; padding: 48px 16px 32px; background: linear-gradient(180deg, #e7f4f0 0%, var(--bg) 320px); }
.landing-inner { width: 100%; max-width: 440px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; }
.landing-logo { width: 84px; height: 84px; border-radius: 22px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 28px; font-weight: 750; letter-spacing: -.03em; box-shadow: 0 10px 24px -10px rgba(11,122,98,.6); }
.landing h1 { font-size: 22px; margin-top: 6px; }
.landing p { margin: 0; color: var(--muted); max-width: 340px; }
.landing-links { width: 100%; display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.link-btn { display: flex; align-items: center; justify-content: center; gap: 10px; height: 56px; border-radius: 14px; color: #fff; font-weight: 600; font-size: 16px; box-shadow: 0 6px 16px -8px rgba(0,0,0,.35); transition: transform .12s, filter .12s; }
.link-btn:hover { text-decoration: none; filter: brightness(1.05); transform: translateY(-1px); }
.link-btn .icon { width: 22px; height: 22px; fill: currentColor; stroke: none; }
.link-tg { background: #0088cc; }
.link-wa { background: #25d366; }
.landing-foot { margin-top: 28px; color: var(--faint); font-size: 12px; }
