:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f0f2f5; --text: #1b2330; --muted: #5b6676;
  --border: #dde1e8; --brand: #4338ca; --brand-hover: #3730a3; --brand-soft: #eef0ff; --on-brand: #ffffff;
  --ok: #0f7b4a; --ok-soft: #e4f6ec; --warn: #8a5300; --warn-soft: #fff3dc; --bad: #b3261e; --bad-soft: #fdeceb;
  --code-bg: #101828; --code-text: #e6edf7; --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117; --surface: #161b22; --surface-2: #1d242d; --text: #e6edf3; --muted: #9aa7b6;
    --border: #2b3441; --brand: #8b93ff; --brand-hover: #a5abff; --brand-soft: #1c2140; --on-brand: #0d1117;
    --ok: #4cc38a; --ok-soft: #12291f; --warn: #f0b24a; --warn-soft: #2d2410; --bad: #ff7b72; --bad-soft: #321616;
    --code-bg: #0a0e14; --code-text: #e6edf7; --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { color: var(--brand-hover); }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
p { margin: 0 0 .85rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: .6rem 16px; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.brand svg { width: 28px; height: 28px; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; margin-left: .5rem; }
.nav a { padding: .45rem .75rem; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a:hover, .nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); }
.userbox { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.userbox form { margin: 0; }
.container { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.grid .card { margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.card-title a { font-weight: 650; font-size: 1.1rem; text-decoration: none; color: var(--text); }
.card-title a:hover { color: var(--brand); }
.meta { display: flex; flex-wrap: wrap; gap: .35rem .9rem; color: var(--muted); font-size: .9rem; }
.empty { text-align: center; padding: 2.5rem 1rem; }
.empty svg { width: 56px; height: 56px; color: var(--brand); margin-bottom: .75rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .55rem 1rem; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; background: var(--brand); color: var(--on-brand); }
.btn:hover { background: var(--brand-hover); color: var(--on-brand); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { background: var(--bad); filter: brightness(.9); color: #fff; }
.btn-small { min-height: 36px; padding: .3rem .7rem; font-size: .9rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

label { display: block; font-weight: 600; margin-bottom: .3rem; }
input[type=text], input[type=password], input[type=email], select, textarea {
  width: 100%; min-height: 44px; padding: .55rem .75rem; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; min-height: 9rem; }
.field { margin-bottom: 1rem; }
.hint { color: var(--muted); font-size: .875rem; margin-top: .25rem; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 200px; margin-bottom: 0; }
fieldset { border: 0; padding: 0; margin: 0 0 1rem; }
legend { font-weight: 600; margin-bottom: .4rem; padding: 0; }
.choices { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.choice span { display: block; border: 2px solid var(--border); border-radius: 10px; padding: .75rem .9rem; background: var(--surface); }
.choice input:checked + span { border-color: var(--brand); background: var(--brand-soft); }
.choice input:focus-visible + span { outline: 3px solid var(--brand); outline-offset: 2px; }
.choice b { display: block; }
details { border: 1px solid var(--border); border-radius: 10px; padding: .6rem .9rem; margin-bottom: 1rem; }
summary { cursor: pointer; font-weight: 600; }

.alert { border-radius: 10px; padding: .75rem 1rem; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.alert-bad { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
.pill { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 650; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table-wrap { overflow-x: auto; }
pre, .code { background: var(--code-bg); color: var(--code-text); border-radius: 10px; padding: .85rem 1rem; overflow-x: auto; font: .85rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; margin: 0 0 .75rem; white-space: pre-wrap; word-break: break-word; }
.secret { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.secret code { flex: 1 1 260px; background: var(--code-bg); color: var(--code-text); padding: .7rem .9rem; border-radius: 10px; word-break: break-all; font-size: .9rem; }

.steps { list-style: none; padding: 0; margin: 0; counter-reset: step; }
.steps > li { counter-increment: step; position: relative; padding: 0 0 1.25rem 3rem; }
.steps > li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 2.1rem; height: 2.1rem; border-radius: 50%; background: var(--brand); color: var(--on-brand); font-weight: 700; display: grid; place-items: center; }
.steps > li:not(:last-child)::after { content: ""; position: absolute; left: 1.02rem; top: 2.3rem; bottom: .2rem; width: 2px; background: var(--border); }
.steps h3 { margin-top: .15rem; }

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .brand { justify-content: center; margin-bottom: 1.25rem; font-size: 1.4rem; }
.auth-card h1 { text-align: center; font-size: 1.35rem; }
.auth-card .lead { text-align: center; color: var(--muted); margin-bottom: 1.25rem; }
.footer-note { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 1rem; }
@media (max-width: 640px) { .topbar-inner { gap: .5rem; } .userbox { margin-left: 0; width: 100%; justify-content: space-between; } h1 { font-size: 1.35rem; } }
@media (prefers-reduced-motion: no-preference) { .btn, .nav a, .choice span { transition: background .15s, border-color .15s; } }

.btn-block { width: 100%; }
.mt-xs { margin-top: .5rem; } .mt-sm { margin-top: .75rem; } .mt-md { margin-top: .9rem; } .mb-lg { margin-bottom: 1.25rem; }
.inline { display: inline; margin: 0; }
.maxw-520 { max-width: 520px; } .maxw-560 { max-width: 560px; }
.steps ol { margin: .25rem 0 .75rem; padding-left: 1.2rem; }

.qr { width: 100%; max-width: 240px; margin: .5rem 0 1rem; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; }
.qr svg { display: block; width: 100%; height: auto; }
.final-address { background: var(--brand-soft); border: 2px solid var(--brand); border-radius: 12px; padding: .85rem 1rem; margin: 0 0 1rem; }
.final-address strong { display: block; font-size: 1.25rem; word-break: break-all; }
label.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 500; }
label.check input { width: 1.25rem; height: 1.25rem; min-height: 0; margin-top: .2rem; flex: none; }
