/* GramPay UI — токены и базовые компоненты */
@import url("/static/css/fonts.css");

:root {
  --gp-blue: #3D5A80;
  --gp-sky: #98C1D9;
  --gp-white: #FFFFFF;
  --gp-coral: #EE6C4D;
  --gp-ink: #293241;

  --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", monospace;

  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --ease: cubic-bezier(.2, .7, .2, 1);
  --t-fast: .15s var(--ease);
  --t: .25s var(--ease);
}

:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: #F3F6FA;
  --bg-elevated: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F6F8FB;
  --surface-3: #EDF2F7;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --text: #293241;
  --text-2: #50607A;
  --muted: #8593A7;
  --primary: #3D5A80;
  --primary-hover: #34506F;
  --primary-soft: rgba(61, 90, 128, .09);
  --primary-contrast: #FFFFFF;
  --accent: #98C1D9;
  --accent-soft: rgba(152, 193, 217, .22);
  --accent-text: #3D5A80;
  --cta: #EE6C4D;
  --cta-hover: #E25A3A;
  --cta-soft: rgba(238, 108, 77, .12);
  --success: #1F9D69;
  --success-soft: rgba(31, 157, 105, .11);
  --danger: #E0533A;
  --danger-soft: rgba(224, 83, 58, .1);
  --warning: #D98E1C;
  --warning-soft: rgba(217, 142, 28, .12);
  --info: #3D7FBF;
  --info-soft: rgba(61, 127, 191, .1);
  --shadow-sm: 0 1px 2px rgba(41, 50, 65, .06);
  --shadow: 0 1px 2px rgba(41, 50, 65, .05), 0 8px 24px -8px rgba(41, 50, 65, .12);
  --shadow-lg: 0 24px 60px -18px rgba(41, 50, 65, .28);
  --ring: 0 0 0 4px rgba(61, 90, 128, .16);
  --chart-line: #3D5A80;
  --chart-fill: rgba(61, 90, 128, .14);
  --chart-grid: rgba(41, 50, 65, .07);
  --scrim: rgba(24, 30, 40, .45);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1B212C;
  --bg-elevated: #232B38;
  --surface: #232B38;
  --surface-2: #293241;
  --surface-3: #313C4E;
  --border: #334052;
  --border-strong: #435168;
  --text: #EEF3F8;
  --text-2: #B2C0D0;
  --muted: #7F8FA5;
  --primary: #98C1D9;
  --primary-hover: #B2D2E4;
  --primary-soft: rgba(152, 193, 217, .12);
  --primary-contrast: #1B212C;
  --accent: #98C1D9;
  --accent-soft: rgba(152, 193, 217, .14);
  --accent-text: #98C1D9;
  --cta: #EE6C4D;
  --cta-hover: #F3805F;
  --cta-soft: rgba(238, 108, 77, .16);
  --success: #3CCB8E;
  --success-soft: rgba(60, 203, 142, .14);
  --danger: #F07A5E;
  --danger-soft: rgba(240, 122, 94, .15);
  --warning: #F0B24C;
  --warning-soft: rgba(240, 178, 76, .15);
  --info: #7DB5E0;
  --info-soft: rgba(125, 181, 224, .14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 10px 30px -10px rgba(0, 0, 0, .45);
  --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, .6);
  --ring: 0 0 0 4px rgba(152, 193, 217, .2);
  --chart-line: #98C1D9;
  --chart-fill: rgba(152, 193, 217, .16);
  --chart-grid: rgba(255, 255, 255, .06);
  --scrim: rgba(8, 11, 16, .6);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "tnum" 0;
  transition: background-color var(--t), color var(--t);
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.02em; font-weight: 800; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.success { color: var(--success); }
.danger { color: var(--danger); }
.warning { color: var(--warning); }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
::selection { background: var(--accent-soft); }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-xs); }

/* ── логотип ─────────────────────────────────────────────────── */
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; }
.logo img, .logo svg { height: 30px; width: auto; }
.logo-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--gp-blue); color: #fff; flex: none; }
.logo-mark svg { width: 20px; height: auto; }
[data-theme="dark"] .logo-mark { background: var(--gp-blue); }
.logo-word { height: 22px; width: auto; color: currentColor; }

/* ── кнопки ──────────────────────────────────────────────────── */
.btn {
  --h: 42px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--h); padding: 0 18px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--surface-3); color: var(--text);
  font-weight: 700; font-size: 14px; letter-spacing: -.005em;
  cursor: pointer; user-select: none; white-space: nowrap;
  transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.btn:hover { background: var(--border); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-loading { opacity: .6; cursor: not-allowed; pointer-events: none; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--gp-blue); color: #fff; box-shadow: 0 6px 16px -8px rgba(61, 90, 128, .8); }
.btn-primary:hover { background: #34506F; color: #fff; }
[data-theme="dark"] .btn-primary { background: #4A6B96; box-shadow: 0 8px 20px -10px rgba(0, 0, 0, .7); }
[data-theme="dark"] .btn-primary:hover { background: #56799f; }
.btn-cta { background: var(--cta); color: #fff; box-shadow: 0 8px 20px -10px rgba(238, 108, 77, .9); }
.btn-cta:hover { background: var(--cta-hover); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border-strong); }
.btn-outline:hover { background: var(--surface-2); border-color: var(--muted); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-soft { background: var(--primary-soft); color: var(--accent-text); }
.btn-soft:hover { background: var(--accent-soft); }
.btn-sm { --h: 34px; padding: 0 12px; font-size: 13px; border-radius: var(--radius-xs); }
.btn-lg { --h: 52px; padding: 0 26px; font-size: 16px; border-radius: var(--radius); }
.btn-icon { width: var(--h); padding: 0; }
.btn-block { width: 100%; }
.btn .spinner { width: 16px; height: 16px; }

.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite; opacity: .8;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── формы ───────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 7px; }
.field + .field { margin-top: 16px; }
.label { font-size: 13px; font-weight: 700; color: var(--text-2); display: flex; justify-content: space-between; gap: 8px; }
.hint { font-size: 12.5px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; height: 44px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.textarea { height: auto; min-height: 90px; padding: 12px 14px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.input.mono { font-family: var(--mono); font-size: 13.5px; }
.select { appearance: none; padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%238593A7' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-right: 88px; }
.input-group .addon { position: absolute; right: 6px; display: flex; gap: 4px; align-items: center; }
.input-prefix { position: absolute; left: 14px; color: var(--muted); font-weight: 700; pointer-events: none; }
.input-group .input.has-prefix { padding-left: 30px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .field + .field { margin-top: 0; }
.form-grid .span-2 { grid-column: span 2; }
.form-error { color: var(--danger); font-size: 13px; font-weight: 600; min-height: 1em; }

.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: 14px; }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; z-index: 1; }
.switch .track { position: absolute; inset: 0; border-radius: 99px; background: var(--border-strong); transition: background var(--t-fast); }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform var(--t-fast); }
.switch input:checked + .track { background: var(--success); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: var(--ring); }

/* ── карточки ────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 0; }
.card-head h3 { font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.card-head .sub { font-size: 13px; color: var(--muted); font-weight: 600; }
.card-body { padding: 18px 22px 22px; }
.card-foot { border-top: 1px solid var(--border); padding: 14px 22px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* ── бейджи ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px;
  border-radius: 99px; font-size: 12px; font-weight: 700; letter-spacing: .01em;
  background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-primary { background: var(--primary-soft); color: var(--accent-text); }
.badge-cta { background: var(--cta-soft); color: var(--cta); }
.badge-outline { background: transparent; border: 1px solid var(--border-strong); }
.pulse { position: relative; }
.pulse::after { content: ""; position: absolute; inset: -3px; border-radius: 50%; background: currentColor; opacity: .35; animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { 0% { transform: scale(.6); opacity: .5; } 100% { transform: scale(2.2); opacity: 0; } }

/* ── таблицы ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th {
  text-align: left; font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; padding: 12px 16px;
  border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface);
}
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--surface-2); }
.table .right { text-align: right; }
.table-empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.table-empty svg { width: 40px; height: 40px; margin: 0 auto 10px; opacity: .5; }

/* ── вкладки и чипы ──────────────────────────────────────────── */
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface-3); border-radius: 12px; }
.tab { height: 34px; padding: 0 14px; border-radius: 9px; border: 0; background: transparent; font-weight: 700; font-size: 13.5px; color: var(--text-2); cursor: pointer; transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast); }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tab .count { margin-left: 6px; font-size: 11.5px; padding: 1px 7px; border-radius: 99px; background: var(--surface-3); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 32px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); font-weight: 700; font-size: 13px; color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: all var(--t-fast); }
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--gp-blue); border-color: var(--gp-blue); color: #fff; }
[data-theme="dark"] .chip.active { background: var(--accent); border-color: var(--accent); color: #1B212C; }

/* ── модальные окна и шторки ─────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 100; background: var(--scrim);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; transition: opacity var(--t); backdrop-filter: blur(3px);
}
.overlay.open { opacity: 1; }
.modal {
  width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg); transform: translateY(14px) scale(.98); transition: transform var(--t);
}
.overlay.open .modal { transform: none; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 24px 26px 6px; }
.modal-head h3 { font-size: 20px; }
.modal-head p { color: var(--muted); font-size: 14px; margin-top: 4px; }
.modal-body { padding: 18px 26px; }
.modal-foot { padding: 6px 26px 24px; display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.modal-lg { width: min(760px, 100%); }

.drawer-overlay { justify-content: flex-end; padding: 0; }
.drawer {
  width: min(560px, 100%); height: 100%; overflow: auto; background: var(--bg-elevated);
  border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  transform: translateX(40px); transition: transform var(--t);
}
.overlay.open .drawer { transform: none; }
.drawer-head { position: sticky; top: 0; z-index: 2; background: var(--bg-elevated); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.drawer-body { padding: 22px 24px 40px; }

/* ── уведомления ─────────────────────────────────────────────── */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  pointer-events: auto; min-width: 260px; max-width: 380px; display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--radius); background: var(--gp-ink); color: #fff;
  box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 600;
  animation: toast-in .3s var(--ease);
}
.toast svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.toast.success svg { color: #3CCB8E; }
.toast.error svg { color: #F07A5E; }
.toast.leaving { animation: toast-out .25s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px) scale(.97); } }

/* ── мелочи ──────────────────────────────────────────────────── */
.copyable { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; border-radius: 6px; transition: color var(--t-fast); }
.copyable:hover { color: var(--primary); }
.copyable svg { width: 14px; height: 14px; opacity: .6; flex: none; }
.divider { height: 1px; background: var(--border); margin: 18px 0; border: 0; }
.kv { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 10px 16px; font-size: 14px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); font-size: 14px; }
.empty .icon { width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.empty .icon svg { width: 24px; height: 24px; }
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--info-soft); color: var(--text); font-size: 13.5px; line-height: 1.5; }
.callout svg { width: 20px; height: 20px; flex: none; color: var(--info); margin-top: 1px; }
.callout.warning { background: var(--warning-soft); }
.callout.warning svg { color: var(--warning); }
.callout.danger { background: var(--danger-soft); }
.callout.danger svg { color: var(--danger); }
.callout.success { background: var(--success-soft); }
.callout.success svg { color: var(--success); }

.theme-toggle { position: relative; overflow: hidden; }
.theme-toggle .sun, .theme-toggle .moon { transition: transform var(--t), opacity var(--t); }
[data-theme="dark"] .theme-toggle .sun { transform: translateY(-120%) rotate(90deg); opacity: 0; position: absolute; }
[data-theme="light"] .theme-toggle .moon, :root:not([data-theme]) .theme-toggle .moon { transform: translateY(120%); opacity: 0; position: absolute; }

/* монеты / сети */
.coin { position: relative; display: inline-block; vertical-align: middle; width: 36px; height: 36px; flex: none; }
.coin-main { width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 13px; }
img.coin-main { display: block; object-fit: contain; }
.coin-net { position: absolute; right: -3px; bottom: -3px; width: 17px; height: 17px; border-radius: 50%; display: block; object-fit: contain; background: var(--surface); box-shadow: 0 0 0 2px var(--surface); }
.coin-sm { width: 26px; height: 26px; }
.coin-sm .coin-main { font-size: 10px; }
.coin-sm .coin-net { width: 13px; height: 13px; right: -3px; bottom: -3px; }
.coin-lg { width: 48px; height: 48px; }
.coin-lg .coin-net { width: 21px; height: 21px; }

.qr-box { background: #fff; border-radius: var(--radius); padding: 12px; display: inline-block; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.qr-box > img { width: 180px; height: 180px; image-rendering: pixelated; }

.tooltip { position: relative; }
.tooltip[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--gp-ink); color: #fff; font-size: 12px; font-weight: 600; padding: 6px 10px; border-radius: 8px;
  white-space: nowrap; z-index: 50; pointer-events: none; box-shadow: var(--shadow);
}

/* график */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5; transform: translate(-50%, -110%);
  background: var(--gp-ink); color: #fff; border-radius: 10px; padding: 8px 11px; font-size: 12px; font-weight: 600;
  box-shadow: var(--shadow); white-space: nowrap; opacity: 0; transition: opacity .12s;
}
.chart-tip b { font-size: 13.5px; display: block; }
.chart:hover .chart-tip.show { opacity: 1; }
.chart-empty { position: absolute; inset: 0 0 26px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 13.5px; font-weight: 600; pointer-events: none; }
.chart-empty svg { width: 28px; height: 28px; opacity: .6; }

@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .modal-head, .modal-body, .modal-foot { padding-left: 18px; padding-right: 18px; }
  .card-head, .card-body { padding-left: 16px; padding-right: 16px; }
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
