:root {
  --bg: #f0f4f9; --surface: #fff; --surface2: #f8fafd; --text: #1f1f1f; --muted: #5f6368; --border: #dadce0;
  --primary: #0b57d0; --primary-hover: #0842a0; --on-primary: #fff; --primary-soft: #d3e3fd; --on-primary-soft: #041e49;
  --danger: #b3261e; --danger-soft: #f9dedc; --ok: #146c2e; --ok-soft: #c4eed0; --warn-soft: #fff0c2; --warn: #5c4200;
  --shadow: 0 1px 2px rgba(60,64,67,.15), 0 1px 3px 1px rgba(60,64,67,.1);
  --font: "Google Sans", "Product Sans", Roboto, "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #131314; --surface: #1e1f20; --surface2: #282a2c; --text: #e3e3e3; --muted: #9aa0a6; --border: #444746;
    --primary: #a8c7fa; --primary-hover: #d3e3fd; --on-primary: #062e6f; --primary-soft: #0842a0; --on-primary-soft: #d3e3fd;
    --danger: #f2b8b5; --danger-soft: #601410; --ok: #6dd58c; --ok-soft: #0f5223; --warn-soft: #4a3c00; --warn: #ffe08a; --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 400; margin: 0; }
button { font: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---- brand ---- */
.brand { font-size: 22px; font-weight: 500; letter-spacing: -.3px; color: var(--text); display: inline-flex; align-items: center; gap: 10px; text-decoration: none !important; }
.brand .logo { width: 30px; height: 30px; border-radius: 9px; background: var(--primary); display: grid; place-items: center; }
.brand .logo svg { width: 20px; height: 20px; fill: var(--on-primary); }
.brand b { font-weight: 500; color: var(--muted); }

/* ---- centered auth card (sign-in style) ---- */
.center { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 12px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 28px; width: 100%; max-width: 450px; padding: 48px 40px 36px; }
.auth-card .brand { margin-bottom: 16px; }
.auth-card h1 { font-size: 24px; margin-bottom: 8px; }
.auth-card .sub { font-size: 16px; margin-bottom: 28px; }
.auth-card.wide { max-width: 520px; }
.auth-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 36px; gap: 12px; flex-wrap: wrap; }
.page-foot { margin-top: 20px; font-size: 12px; color: var(--muted); display: flex; gap: 16px; }
@media (max-width: 520px) { .center { justify-content: flex-start; padding-top: 0; } .auth-card { border: 0; border-radius: 0; background: transparent; padding: 32px 16px; } }

/* ---- fields ---- */
.field { position: relative; margin-bottom: 18px; }
.field input, .field select, .field textarea { width: 100%; padding: 16px 14px; font: inherit; font-size: 16px; color: var(--text); background: transparent; border: 1px solid var(--muted); border-radius: 6px; outline: none; transition: border-color .12s; }
.field textarea { min-height: 90px; resize: vertical; }
.field label { position: absolute; left: 10px; top: 15px; padding: 0 4px; background: var(--surface); color: var(--muted); font-size: 16px; pointer-events: none; transition: all .12s ease; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.field input:focus + label, .field input:not(:placeholder-shown) + label, .field textarea:focus + label, .field textarea:not(:placeholder-shown) + label, .field select + label { top: -9px; font-size: 12px; }
.field input:focus + label, .field textarea:focus + label { color: var(--primary); }
.field.error input { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
.field.error label { color: var(--danger); }
.field .msg { font-size: 12px; color: var(--danger); margin: 4px 14px 0; }
.field .help { font-size: 12px; color: var(--muted); margin: 4px 14px 0; }
.check { display: flex; align-items: center; gap: 10px; margin: -6px 0 18px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.code-input input { font-size: 22px; letter-spacing: 6px; text-align: center; }
.chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 100px; padding: 4px 12px 4px 4px; margin-bottom: 24px; cursor: pointer; background: none; color: var(--text); font-weight: 500; }
.chip .avatar { width: 24px; height: 24px; font-size: 12px; }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 24px; border-radius: 100px; border: 1px solid transparent; cursor: pointer; font-weight: 500; font-size: 14px; background: var(--primary); color: var(--on-primary); text-decoration: none !important; transition: box-shadow .1s, background .1s; }
.btn:hover { box-shadow: var(--shadow); background: var(--primary-hover); }
.btn:disabled { opacity: .5; cursor: default; box-shadow: none; }
.btn.secondary { background: transparent; color: var(--primary); border-color: var(--border); }
.btn.secondary:hover { background: var(--primary-soft); }
.btn.text { background: transparent; color: var(--primary); padding: 0 12px; }
.btn.text:hover { background: var(--primary-soft); box-shadow: none; }
.btn.danger { background: var(--danger); color: var(--surface); }
.btn.danger.secondary { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.small { height: 32px; padding: 0 16px; }
.btn.block { width: 100%; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions.end { justify-content: flex-end; }
.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); } }

/* ---- app shell ---- */
header.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; height: 64px; padding: 0 16px 0 24px; background: var(--bg); }
.menu { position: relative; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--primary-soft); color: var(--on-primary-soft); display: grid; place-items: center; font-weight: 500; font-size: 16px; overflow: hidden; flex: none; text-transform: uppercase; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.big { width: 96px; height: 96px; font-size: 40px; }
.avatar-btn { border: 0; background: none; padding: 4px; border-radius: 50%; cursor: pointer; }
.avatar-btn:hover { background: var(--primary-soft); }
.popover { position: absolute; right: 0; top: 52px; width: 320px; max-width: calc(100vw - 24px); background: var(--surface); border-radius: 28px; box-shadow: 0 4px 12px rgba(0,0,0,.25); padding: 20px; text-align: center; }
.popover .avatar { margin: 0 auto 8px; width: 64px; height: 64px; font-size: 26px; }
.popover .name { font-size: 16px; font-weight: 500; } .popover .actions { justify-content: center; margin-top: 16px; }
.layout { display: flex; max-width: 1180px; margin: 0 auto; padding: 0 16px 48px; gap: 8px; }
nav.side { width: 256px; flex: none; position: sticky; top: 64px; align-self: flex-start; padding-right: 8px; }
nav.side a { display: flex; align-items: center; gap: 14px; height: 48px; padding: 0 24px; border-radius: 100px; color: var(--text); font-weight: 500; text-decoration: none; }
nav.side a:hover { background: var(--primary-soft); }
nav.side a.active { background: var(--primary-soft); color: var(--on-primary-soft); }
nav.side a .badge { margin-left: auto; }
nav.side svg, .ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
main.content { flex: 1; min-width: 0; max-width: 780px; margin: 0 auto; }
main.content h1 { font-size: 28px; text-align: center; margin: 8px 0 4px; }
main.content .lead { text-align: center; color: var(--muted); margin-bottom: 28px; font-size: 15px; }
@media (max-width: 900px) {
  .layout { flex-direction: column; padding: 0 12px 40px; }
  nav.side { width: auto; max-width: 100%; align-self: stretch; position: static; display: flex; overflow-x: auto; gap: 4px; padding: 0 0 12px; }
  nav.side a { padding: 0 16px; flex: none; height: 40px; }
  main.content h1 { font-size: 24px; }
}

/* ---- cards ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px 24px; margin-bottom: 16px; }
.card h2 { font-size: 18px; margin-bottom: 4px; }
.card > .muted:first-of-type { margin-bottom: 12px; }
.card.hero { text-align: center; padding: 32px 24px; }
.card.hero .avatar { margin: 0 auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; } .grid2 .card { margin: 0; }
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } }
.row { display: flex; align-items: center; gap: 16px; padding: 14px 0; border-top: 1px solid var(--border); }
.row:first-of-type { border-top: 0; }
.row .grow { flex: 1; min-width: 0; } .row .title { font-weight: 500; } .row .value { word-break: break-word; }
.big-number { font-size: 44px; font-weight: 400; letter-spacing: -1px; line-height: 1.1; margin: 8px 0 4px; }
.badge { display: inline-block; padding: 1px 10px; border-radius: 100px; font-size: 12px; font-weight: 500; background: var(--primary-soft); color: var(--on-primary-soft); }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); } .badge.err { background: var(--danger-soft); color: var(--danger); }
.alert { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; background: var(--danger-soft); color: var(--danger); font-size: 14px; }
.alert.info { background: var(--primary-soft); color: var(--on-primary-soft); } .alert.ok { background: var(--ok-soft); color: var(--ok); } .alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert a { color: inherit; text-decoration: underline; }
.pos { color: var(--ok); } .neg { color: var(--text); }
.tx { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--border); }
.tx:first-child { border-top: 0; } .tx .amt { font-weight: 500; white-space: nowrap; font-variant-numeric: tabular-nums; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 16px; background: var(--surface2); border-radius: 12px; padding: 16px 20px; margin: 16px 0; }
.qr { background: #fff; padding: 8px; border-radius: 12px; display: inline-block; line-height: 0; } .qr svg { width: 200px; height: 200px; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: 2px; word-break: break-all; background: var(--surface2); padding: 10px 14px; border-radius: 8px; display: inline-block; user-select: all; }
.amount-big { font-size: 48px; font-weight: 400; margin: 12px 0; letter-spacing: -1px; }
.scope-list { list-style: none; padding: 0; margin: 16px 0 24px; } .scope-list li { padding: 10px 0; border-top: 1px solid var(--border); display: flex; gap: 12px; align-items: center; } .scope-list li:first-child { border-top: 0; }
.skeleton { height: 120px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); margin-bottom: 16px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 100px); background: #303134; color: #fff; padding: 12px 20px; border-radius: 8px; opacity: 0; transition: all .25s; z-index: 50; max-width: 90vw; pointer-events: none; }
#toast.show { transform: translate(-50%, 0); opacity: 1; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.success-mark { width: 72px; height: 72px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; margin: 0 auto 16px; } .success-mark svg { width: 36px; height: 36px; stroke-width: 2.4; }
.center-text { text-align: center; }
