:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eceff3;
  --line: #dde1e7;
  --line-strong: #c7ccd4;
  --text: #121417;
  --muted: #68707c;
  --blue: #2169d4;
  --blue-strong: #1858b8;
  --green: #167c35;
  --red: #c73543;
  --amber: #965f00;
  --shadow: 0 18px 50px rgba(24, 31, 42, .09);
  --radius: 14px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #050505;
  --surface: #151515;
  --surface-2: #1c1c1e;
  --surface-3: #252528;
  --line: #303034;
  --line-strong: #49494f;
  --text: #f7f7f8;
  --muted: #9999a1;
  --blue: #4f8ff2;
  --blue-strong: #3678df;
  --green: #48c868;
  --red: #ff5964;
  --amber: #f3b642;
  --shadow: 0 22px 65px rgba(0, 0, 0, .42);
}

@font-face { font-family: Fredoka; src: url('/static/fonts/Fredoka-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: Fredoka; src: url('/static/fonts/Fredoka-SemiBold.ttf') format('truetype'); font-weight: 600; font-display: swap; }
@font-face { font-family: Fredoka; src: url('/static/fonts/Fredoka-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
html { background: var(--bg); }
body { margin: 0; color: var(--text); background: var(--bg); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; font-size: 15px; line-height: 1.55; letter-spacing: .003em; -webkit-font-smoothing: antialiased; }
h1, h2, h3, .stat-value, .primary, .secondary, .nav-button { font-family: Fredoka, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: 0; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.login-page { min-height: 100dvh; display: grid; grid-template-columns: 1.05fr .95fr; }
.login-visual { position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: clamp(28px, 5vw, 70px); color: #fff; background: #050505; overflow: hidden; }
.login-visual::before { content: ''; position: absolute; width: 580px; height: 580px; right: -210px; bottom: -130px; border-radius: 50%; background: radial-gradient(circle, rgba(61,139,253,.34), transparent 68%); }
.login-visual::after { content: ''; position: absolute; inset: 0; opacity: .2; background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px); background-size: 52px 52px; }
.login-brand, .login-copy, .login-trust { position: relative; z-index: 1; }
.login-brand img { width: 190px; }
.login-copy { max-width: 620px; margin-block: 80px; }
.login-copy p:first-child { color: #7fb3ff; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.login-copy h1 { margin: 16px 0; font-size: clamp(42px, 6vw, 76px); line-height: 1; letter-spacing: -.045em; }
.login-copy h1 span { color: #528ff0; }
.login-copy > p:last-child { max-width: 570px; color: #a6a6ad; font-size: 18px; }
.login-trust { display: flex; flex-wrap: wrap; gap: 18px; color: #aaaab0; font-size: 13px; }
.login-trust span::before { content: '✓'; margin-right: 7px; color: #53d270; }
.login-panel { display: grid; place-items: center; padding: 28px; background: var(--bg); }
.login-card { width: min(100%, 470px); padding: clamp(28px, 5vw, 48px); border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); }
.login-card .mobile-brand { display: none; width: 170px; margin-bottom: 34px; padding: 9px; border-radius: 9px; background: #050505; }
.login-card h2 { margin: 0; font-size: 31px; letter-spacing: -.025em; }
.login-card > p { margin: 10px 0 28px; color: var(--muted); }
.telegram-login { width: 100%; min-height: 52px; display: flex; align-items: center; justify-content: center; gap: 10px; border: 0; border-radius: 11px; color: #fff; background: var(--blue); font-weight: 600; text-decoration: none; cursor: pointer; transition: transform .18s, background .18s; }
.telegram-login:hover { transform: translateY(-2px); background: var(--blue-strong); }
.telegram-login svg { width: 23px; }
.telegram-login.bot-login { border: 1px solid var(--line-strong); color: var(--text); background: var(--surface-2); }
.telegram-login.bot-login:hover { background: var(--surface-3); }
.login-separator { display: flex; align-items: center; gap: 10px; margin: 11px 0; color: var(--muted); font-size: 11px; }
.login-separator::before, .login-separator::after { content: ''; height: 1px; flex: 1; background: var(--line); }
.bot-login-status { margin: 12px 0 0; padding: 10px 12px; border-radius: 8px; color: var(--blue); background: color-mix(in srgb, var(--blue) 9%, var(--surface)); font-size: 12px; text-align: center; }
.login-method-help { margin-top: 15px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.login-method-help p { margin: 0; color: var(--muted); font-size: 12px; }
.login-method-help p + p { margin-top: 7px; }
.login-method-help strong { color: var(--text); }
.security-note { display: flex; gap: 10px; margin-top: 22px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: var(--surface-2); font-size: 12px; }
.security-note svg { width: 19px; flex: 0 0 19px; color: var(--green); }
.login-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 25px; }
.plain-link { color: var(--blue); font-size: 13px; text-decoration: none; }

.app-layout { min-height: 100dvh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; padding: 22px 16px; border-right: 1px solid var(--line); background: var(--surface); }
.side-brand { display: flex; align-items: center; margin-bottom: 16px; padding: 10px 12px; border-radius: 10px; background: #050505; }
.side-brand img { width: 165px; }
.side-nav { display: flex; flex-direction: column; gap: 5px; }
.nav-button { width: 100%; min-height: 46px; display: flex; align-items: center; gap: 12px; padding: 0 13px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; text-align: left; cursor: pointer; }
.nav-button svg { width: 20px; flex: 0 0 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-button:hover { color: var(--text); background: var(--surface-2); }
.nav-button.active { color: #fff; background: var(--blue); }
.side-bottom { margin-top: auto; padding-top: 20px; }
.account-mini { display: flex; align-items: center; gap: 10px; padding: 11px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); }
.avatar { position: relative; width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 38px; border-radius: 50%; color: #fff; background: var(--blue); font-weight: 700; overflow: hidden; }
.avatar img { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.account-mini > div { min-width: 0; }
.account-mini strong, .account-mini span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-mini span { color: var(--muted); font-size: 11px; }

.app-area { min-width: 0; }
.topbar { position: sticky; z-index: 30; top: 0; min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px clamp(18px, 4vw, 42px); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(18px); }
.topbar h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-button { width: 42px; height: 42px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: var(--surface); cursor: pointer; }
.icon-button:hover { background: var(--surface-2); }
.icon-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mobile-menu { display: none; }
.main-content { width: min(1240px, 100%); padding: 34px clamp(18px, 4vw, 42px) 70px; }
.page { display: none; }
.page.active { display: block; animation: pageIn .18s ease both; }
@keyframes pageIn { from { opacity: .3; transform: translateY(5px); } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-head h2 { margin: 0; font-size: clamp(27px, 3.2vw, 38px); letter-spacing: -.03em; }
.page-head p { margin: 5px 0 0; color: var(--muted); }

.stats-grid { display: grid; grid-template-columns: 1.5fr repeat(3, 1fr); gap: 14px; }
.panel, .stat-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 1px 0 rgba(0,0,0,.02); }
.stat-card { min-height: 152px; padding: 22px; }
.stat-card.balance { position: relative; color: #fff; border-color: transparent; background: linear-gradient(135deg, #347ff0, #275ebd); overflow: hidden; }
.stat-card.balance::after { content: ''; position: absolute; width: 190px; height: 190px; top: -80px; right: -45px; border: 35px solid rgba(255,255,255,.09); border-radius: 50%; }
.stat-label { position: relative; z-index: 1; color: var(--muted); font-size: 13px; }
.balance .stat-label { color: rgba(255,255,255,.75); }
.stat-value { position: relative; z-index: 1; display: block; margin-top: 13px; font-size: clamp(25px, 3vw, 34px); line-height: 1; letter-spacing: -.025em; }
.stat-meta { position: relative; z-index: 1; display: block; margin-top: 13px; color: var(--muted); font-size: 12px; }
.balance .stat-meta { color: rgba(255,255,255,.7); }
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.panel { padding: 24px; }
.panel h3 { margin: 0; font-size: 18px; }
.panel-sub { margin: 5px 0 20px; color: var(--muted); font-size: 13px; }
.product-line { display: flex; align-items: center; gap: 14px; }
.product-line img { width: 62px; height: 62px; object-fit: contain; }
.product-line strong, .product-line span { display: block; }
.product-line span { color: var(--muted); font-size: 13px; }
.panel-divider { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.recent { margin-top: 14px; }

.purchase-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 600; }
.input-wrap { display: flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-2); transition: border .15s, box-shadow .15s; }
.input-wrap:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent); }
.input-prefix { padding-left: 14px; color: var(--muted); }
.input-wrap input, .input-wrap select { width: 100%; min-height: 48px; padding: 0 14px; border: 0; outline: 0; color: var(--text); background: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.chip { min-height: 32px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: var(--surface-2); cursor: pointer; font-size: 12px; }
.chip:hover, .chip.active { color: #fff; border-color: var(--blue); background: var(--blue); }
.recipient-card { display: flex; align-items: center; gap: 14px; margin-top: 22px; padding: 15px; border: 1px solid color-mix(in srgb, var(--blue) 34%, var(--line)); border-radius: 12px; background: color-mix(in srgb, var(--blue) 7%, var(--surface-2)); }
.recipient-card.invalid { border-color: color-mix(in srgb, var(--red) 38%, var(--line)); background: color-mix(in srgb, var(--red) 7%, var(--surface-2)); }
.recipient-avatar { position: relative; width: 58px; height: 58px; display: grid; place-items: center; flex: 0 0 58px; border-radius: 50%; color: #fff; background: var(--blue); overflow: hidden; font-size: 21px; font-weight: 700; }
.recipient-avatar img { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.recipient-avatar img:not([src]), .recipient-avatar img[src=""] { display: none; }
.recipient-copy { min-width: 0; }
.recipient-copy strong, .recipient-copy > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recipient-copy strong { font-size: 16px; }
.recipient-copy > span { color: var(--muted); font-size: 12px; }
.recipient-status { width: fit-content; margin-top: 6px; padding: 3px 7px; border-radius: 6px; color: var(--green) !important; background: color-mix(in srgb, var(--green) 12%, transparent); font-weight: 600; }
.recipient-card.invalid .recipient-status { color: var(--red) !important; background: color-mix(in srgb, var(--red) 12%, transparent); }
.summary-card { position: sticky; top: 100px; align-self: start; }
.summary-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.summary-row span { color: var(--muted); }
.summary-row.total { border-bottom: 0; }
.summary-row.total strong { font-size: 24px; color: var(--blue); }
.primary, .secondary, .danger { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 17px; border: 1px solid transparent; border-radius: 9px; font-weight: 600; text-decoration: none; cursor: pointer; }
.primary { color: #fff; background: var(--blue); }
.primary:hover { background: var(--blue-strong); }
.secondary { color: var(--text); border-color: var(--line-strong); background: var(--surface-2); }
.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, var(--line)); background: transparent; }
.wide { width: 100%; }
.summary-card .wide { margin-top: 8px; }
.primary:disabled, .secondary:disabled { opacity: .55; cursor: not-allowed; }

.keys-list { display: flex; flex-direction: column; gap: 9px; }
.key-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 15px; padding: 15px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.key-row strong, .key-row span { display: block; }
.key-row span { color: var(--muted); font-size: 12px; }
.key-prefix { color: var(--blue); font: 600 13px ui-monospace, SFMono-Regular, Menlo, monospace; }
.limit-banner { display: flex; gap: 13px; margin-bottom: 16px; padding: 16px; border: 1px solid color-mix(in srgb, var(--blue) 35%, var(--line)); border-radius: 11px; background: color-mix(in srgb, var(--blue) 8%, var(--surface)); }
.limit-banner strong, .limit-banner span { display: block; }
.limit-banner span { color: var(--muted); font-size: 13px; }
.limit-banner svg { width: 23px; color: var(--blue); fill: none; stroke: currentColor; stroke-width: 1.8; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); background: var(--surface-2); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
td { font-size: 13px; }
tr:last-child td { border-bottom: 0; }
.status { display: inline-flex; padding: 4px 8px; border-radius: 7px; background: var(--surface-3); font-size: 11px; font-weight: 600; }
.status.completed { color: var(--green); background: color-mix(in srgb, var(--green) 12%, var(--surface)); }
.status.processing, .status.pending { color: var(--amber); background: color-mix(in srgb, var(--amber) 12%, var(--surface)); }
.status.failed, .status.cancelled { color: var(--red); background: color-mix(in srgb, var(--red) 11%, var(--surface)); }
.empty { padding: 45px 20px; color: var(--muted); text-align: center; }

.modal-backdrop { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 18px; background: rgba(0,0,0,.68); }
.modal { width: min(100%, 520px); padding: 25px; border: 1px solid var(--line-strong); border-radius: 17px; background: var(--surface); box-shadow: var(--shadow); }
.modal h3 { margin: 0; font-size: 22px; }
.modal p { color: var(--muted); }
.secret-box { padding: 15px; border: 1px dashed var(--line-strong); border-radius: 9px; color: var(--blue); background: var(--surface-2); font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; user-select: all; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.toast-stack { position: fixed; z-index: 150; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; }
.toast { max-width: 360px; padding: 13px 16px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.toast.error { color: var(--red); }
.toast.success { color: var(--green); }
.skeleton { position: relative; overflow: hidden; color: transparent !important; background: var(--surface-3); border-radius: 6px; }
.skeleton::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.12), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

/* Documentation */
.docs-layout { min-height: 100dvh; display: grid; grid-template-columns: 270px minmax(0, 1fr); }
.docs-side { position: sticky; top: 0; height: 100dvh; padding: 24px 18px; border-right: 1px solid var(--line); background: var(--surface); overflow: auto; }
.docs-side .side-brand { padding-inline: 5px; }
.docs-nav-title { margin: 20px 10px 8px; color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.docs-nav a { display: flex; padding: 8px 10px; border-radius: 7px; color: var(--muted); font-size: 13px; text-decoration: none; }
.docs-nav a:hover { color: var(--text); background: var(--surface-2); }
.docs-main { min-width: 0; }
.docs-top { min-height: 70px; display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 30px; border-bottom: 1px solid var(--line); }
.docs-content { width: min(900px, calc(100% - 40px)); margin: 0 auto; padding: 55px 0 100px; }
.docs-content h1 { margin: 0; font-size: clamp(36px, 6vw, 58px); letter-spacing: -.04em; }
.docs-kicker { margin: 0 0 10px; color: var(--blue); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.docs-lead { max-width: 700px; color: var(--muted); font-size: 18px; }
.doc-section { padding-top: 55px; }
.doc-section h2 { margin: 0 0 15px; font-size: 29px; letter-spacing: -.025em; }
.doc-section h3 { margin: 28px 0 10px; }
.doc-section p, .doc-section li { color: var(--muted); }
.endpoint { display: flex; align-items: center; gap: 10px; margin: 18px 0 10px; }
.method { min-width: 54px; padding: 5px 8px; border-radius: 6px; color: #fff; background: var(--blue); text-align: center; font: 700 11px ui-monospace, monospace; }
.method.post { background: var(--green); }
.endpoint code { color: var(--text); font: 14px ui-monospace, monospace; }
.code-block { position: relative; margin: 13px 0; padding: 19px; border: 1px solid var(--line); border-radius: 11px; color: #d8d8dc; background: #0a0a0b; overflow: auto; }
.code-block pre { margin: 0; font: 12px/1.75 ui-monospace, SFMono-Regular, Menlo, monospace; }
.code-block .blue { color: #74aaff; }
.code-block .green { color: #72d68a; }
.doc-note { padding: 15px 17px; border-left: 3px solid var(--blue); border-radius: 7px; color: var(--muted); background: color-mix(in srgb, var(--blue) 7%, var(--surface)); }
.copy-button, .endpoint-copy { min-height: 32px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 7px; color: #fff; background: #222226; font-size: 11px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.copy-button { position: sticky; z-index: 2; left: 100%; top: 0; float: right; margin: -8px -8px 8px 14px; }
.copy-button:hover, .endpoint-copy:hover { border-color: #6f7078; background: #303035; }
.endpoint-copy { margin-left: auto; color: var(--text); background: var(--surface-2); }
.endpoint-copy:hover { border-color: var(--blue); background: var(--surface-3); }
.code-tabs { display: flex; flex-wrap: wrap; gap: 7px; margin: 20px 0 10px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.code-tab { min-height: 34px; padding: 0 13px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; cursor: pointer; }
.code-tab:hover { color: var(--text); }
.code-tab.active { color: #fff; background: var(--blue); }
.ai-prompt-section { margin-top: 35px; padding: 55px 25px 25px; border: 1px solid color-mix(in srgb, var(--blue) 35%, var(--line)); border-radius: 16px; background: color-mix(in srgb, var(--blue) 5%, var(--surface)); }
.ai-prompt { max-height: 680px; border-color: color-mix(in srgb, var(--blue) 50%, #303034); }
.ai-prompt pre { white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 1000px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .purchase-layout { grid-template-columns: 1fr; }
  .summary-card { position: static; }
}

@media (max-width: 780px) {
  .login-page { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-panel { min-height: 100dvh; }
  .login-card .mobile-brand { display: block; }
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; left: 0; top: 0; width: 260px; transform: translateX(-105%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .mobile-menu { display: grid; }
  .topbar { min-height: 68px; }
  .main-content { padding-top: 24px; }
  .stats-grid, .quick-grid { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .key-row { grid-template-columns: minmax(0, 1fr) auto; }
  .key-prefix { grid-column: 1 / -1; }
  .docs-layout { grid-template-columns: 1fr; }
  .docs-side { display: none; }
  .docs-content { width: min(100% - 28px, 900px); padding-top: 34px; }
  .endpoint { flex-wrap: wrap; }
  .endpoint-copy { width: 100%; margin-left: 0; }
  .ai-prompt-section { padding: 38px 14px 14px; }
}

@media (max-width: 480px) {
  .login-panel { padding: 14px; }
  .login-card { padding: 25px 20px; }
  .stat-card, .panel { padding: 19px; }
  .topbar h1 { font-size: 18px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions button { width: 100%; }
}

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