:root {
  /* Brand: Black · Silver */
  --bg: #0a0a0b;
  --surface: #141416;
  --ink: #f2f3f5;
  --ink-2: #c4c7ce;
  --muted: #8a8e97;
  --line: #26272b;
  --accent: #b9bec7;
  --accent-2: #dde0e5;
  --base: #0a0a0b;
  --base-2: #1c1d20;
  --ok: #6cc28f;
  --ok-bg: #12291c;
  --bad: #e58378;
  --bad-bg: #331816;
  --warn: #d8c08a;
  --warn-bg: #2a2416;
  --radius: 14px;
  --sans: 'Manrope', system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--sans); font-weight: 600; line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 .4em; }
h1 { font-size: clamp(1.8rem, 3.6vw, 2.4rem); }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; margin-top: 1.4em; }

.container { width: 100%; max-width: 980px; margin: 0 auto; padding: 0 16px; }
main.container { flex: 1; padding-top: 40px; padding-bottom: 64px; }
main.wide { max-width: 1120px; }

/* Header */
.topbar { background: var(--base); color: var(--ink); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; }
.brand:hover { text-decoration: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { display: block; line-height: 0; margin-bottom: 5px; color: var(--ink); }
.brand-text small { font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-2); }
.nav { display: flex; align-items: center; gap: 18px; font-size: .92rem; }
.nav a, .nav .link { color: var(--ink-2); }
.nav form { margin: 0; }
.link { background: none; border: 0; font: inherit; cursor: pointer; padding: 0; }
@media (max-width: 600px) {
  .brand-text small { display: none; }
  .nav { gap: 12px; font-size: .85rem; }
}

.footer { color: var(--muted); font-size: .82rem; padding: 24px 0; border-top: 1px solid var(--line); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--base); border: 1px solid var(--accent);
  border-radius: 10px; padding: 12px 22px; font: 600 .95rem var(--sans);
  cursor: pointer; transition: transform .15s, background .15s;
}
.btn:hover { text-decoration: none; background: var(--accent-2); }
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 7px 14px; font-size: .85rem; background: var(--accent); border-color: var(--accent); color: var(--base); }
.btn-sm:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #1a0d0b; }
.btn-danger.btn-ghost { background: transparent; color: var(--bad); border-color: var(--bad); margin-top: 20px; }
.btn-wallet { background: #fff; border-color: #fff; color: #000; padding: 14px 22px; font-size: 1rem; }
.btn-wallet:hover { background: #e6e6e6; }
.full { width: 100%; }
.gwallet { margin-top: 10px; }


/* Shared blocks */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.panel.flush { padding: 0; overflow: hidden; }
.narrow { max-width: 440px; margin: 0 auto; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.prewrap { white-space: pre-wrap; }
.eyebrow { text-transform: uppercase; letter-spacing: .16em; font-size: .75rem; font-weight: 700; color: var(--accent); margin: 0 0 6px; }
.page-head { margin-bottom: 24px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.actions.center { justify-content: center; }
.empty { text-align: center; padding: 48px 28px; }
.empty-row { padding: 28px; margin: 0; }
.note { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 10px 14px; font-size: .85rem; }

.flash { border-radius: 10px; padding: 12px 16px; margin-bottom: 20px; font-size: .92rem; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--bad-bg); color: var(--bad); }

.badge { display: inline-block; border-radius: 999px; padding: 4px 12px; font-size: .8rem; font-weight: 700; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-pending { background: var(--warn-bg); color: var(--warn); }

/* Home */
.hero { text-align: center; padding: 24px 0 48px; }
.hero h1.hero-word { margin: 6px auto 22px; width: min(440px, 82%); line-height: 0; }
.hero-word svg { width: 100%; height: auto; display: block; }
.hero-emblem { margin-bottom: 18px; line-height: 0; }
.lead { font-size: 1.15rem; color: var(--ink-2); max-width: 560px; margin: 0 auto; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.step span { color: var(--accent); font-size: .8rem; font-weight: 700; letter-spacing: .14em; }
.step h3 { margin: 6px 0 4px; }
.step p { margin: 0; color: var(--muted); font-size: .9rem; }
@media (max-width: 800px) { .steps { grid-template-columns: 1fr 1fr; } }
@media (max-width: 460px) { .steps { grid-template-columns: 1fr; } }

/* Forms */
.form { display: grid; gap: 16px; margin-top: 16px; }
.form.grid-2 { grid-template-columns: 1fr 1fr; }
.span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form.grid-2 { grid-template-columns: 1fr; } }
label { display: flex; flex-direction: column; gap: 6px; font-size: .88rem; font-weight: 600; color: var(--ink-2); }
input, select, textarea {
  font: 400 1rem var(--sans); color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
input[type=file] { padding: 9px; }
label.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 500; }
label.check input { width: auto; margin-top: 3px; accent-color: var(--accent); }

/* Application timeline */
.timeline { list-style: none; padding: 0; margin: 24px 0; }
.timeline li { position: relative; padding: 0 0 22px 32px; display: flex; flex-direction: column; color: var(--muted); }
.timeline li::before { content: ''; position: absolute; left: 0; top: 4px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); }
.timeline li::after { content: ''; position: absolute; left: 7px; top: 22px; bottom: 2px; width: 2px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li b { color: var(--ink); font-weight: 600; }
.timeline li span { font-size: .88rem; }
.timeline li.done::before { background: var(--ok); border-color: var(--ok); }
.timeline li.current::before { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px rgba(185, 190, 199, .18); }
.timeline li.failed::before { background: var(--bad); border-color: var(--bad); }

/* ID card (Wallet-style preview) */
.card-layout { display: grid; grid-template-columns: minmax(0, 360px) 1fr; gap: 28px; align-items: start; }
@media (max-width: 780px) { .card-layout { grid-template-columns: 1fr; } }
.idcard {
  position: relative; color: var(--ink); border-radius: 18px; padding: 18px 20px 20px; overflow: hidden;
  background:
    repeating-radial-gradient(circle at 110% -10%, rgba(185, 190, 199, .05) 0 1px, transparent 1px 9px),
    linear-gradient(160deg, #1f2023 0%, #0d0d0f 60%, #050506 100%);
  box-shadow: 0 24px 48px -16px rgba(0, 0, 0, .7), inset 0 0 0 1px rgba(185, 190, 199, .22);
  max-width: 360px;
}
.idcard.revoked { filter: grayscale(.9); opacity: .75; }
.idcard small { display: block; color: var(--accent); font-size: .62rem; letter-spacing: .08em; font-weight: 700; }
.idcard-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.idcard-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.idcard-status { text-align: right; font-size: .82rem; font-weight: 600; }
.idcard-body { display: flex; justify-content: space-between; gap: 12px; }
.idcard-name { font-size: 1.3rem; font-weight: 500; line-height: 1.2; margin: 2px 0 16px; word-break: break-word; }
.idcard-row { display: flex; gap: 16px; font-size: .9rem; }
.idcard-row > div { white-space: nowrap; }
.idcard-fields { min-width: 0; }
.idcard-photo { width: 76px; height: 101px; object-fit: cover; border-radius: 6px; box-shadow: 0 0 0 1px rgba(185, 190, 199, .35); flex-shrink: 0; }
.idcard-aux { margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(185, 190, 199, .18); justify-content: space-between; }

.mail-panel { margin-top: 24px; }
.mail-panel .mailbox + .mailbox { margin-top: 12px; }
.inline-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 10px; }
@media (max-width: 640px) { .inline-form { grid-template-columns: 1fr; } }
.mail-help { margin-top: 18px; }
.mail-help summary { cursor: pointer; font-weight: 600; }
.mail-help p { margin: 10px 0; }
.admin-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.admin-actions form { margin: 0; }
.mailbox { margin-top: 20px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.mailbox small { display: block; color: var(--accent); font-size: .68rem; letter-spacing: .1em; font-weight: 700; }
.mailbox b { display: block; font-size: 1.05rem; margin: 4px 0 2px; word-break: break-all; }
.mailbox p { margin: 0; }
.qr { display: flex; gap: 18px; align-items: center; margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line); }
.qr img { border-radius: 10px; background: #fff; padding: 6px; flex-shrink: 0; }
.qr p { margin: 4px 0 6px; }
@media (max-width: 460px) { .qr { flex-direction: column; text-align: center; } }

/* Admin */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; border-radius: 999px; color: var(--ink-2); border: 1px solid var(--line); font-size: .9rem; }
.tabs a:hover { text-decoration: none; background: var(--surface); }
.tabs a.active { background: var(--accent); color: var(--base); border-color: var(--accent); }
.tabs a span { opacity: .65; margin-left: 4px; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 18px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 18px; border-bottom: 1px solid var(--line); }
.table tr:last-child td { border-bottom: 0; }
.person { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.person img { width: 34px; height: 45px; object-fit: cover; border-radius: 4px; }
@media (max-width: 640px) { .table th:nth-child(3), .table td:nth-child(3), .table th:nth-child(4), .table td:nth-child(4) { display: none; } }

.detail { display: grid; grid-template-columns: 240px 1fr; gap: 24px; align-items: start; }
.detail-photo { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); }
@media (max-width: 700px) { .detail { grid-template-columns: 1fr; } .detail-photo { max-width: 240px; } }
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; margin: 0; }
.dl dt { color: var(--muted); font-size: .88rem; }
.dl dd { margin: 0; font-weight: 500; }
.dl.left { text-align: left; margin-top: 20px; }
@media (max-width: 460px) { .dl { grid-template-columns: 105px 1fr; } }
.review { display: grid; gap: 14px; margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line); }
.review form { margin: 0; }
.reject { display: flex; gap: 10px; align-items: stretch; }
@media (max-width: 640px) { .reject { flex-direction: column; } }

/* Card verification */
.verify-badge { width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 16px; display: grid; place-items: center; font-size: 2rem; font-weight: 700; }
.verify-badge.ok { background: var(--ok-bg); color: var(--ok); }
.verify-badge.bad { background: var(--bad-bg); color: var(--bad); }
.verify-photo { width: 120px; height: 160px; object-fit: cover; border-radius: 10px; margin-top: 12px; border: 1px solid var(--line); }

/* Messages */
.mail-layout { display: grid; grid-template-columns: 170px 1fr; gap: 20px; align-items: start; }
.mail-folders { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 16px; }
.mail-folders a { padding: 9px 12px; border-radius: 10px; color: var(--ink-2); display: flex; justify-content: space-between; }
.mail-folders a:hover { background: var(--surface); text-decoration: none; }
.mail-folders a.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.mail-folders span { background: var(--accent); color: var(--base); border-radius: 999px; font-size: .75rem; font-weight: 700; padding: 1px 8px; }
.mail-list { list-style: none; margin: 0; padding: 0; }
.mail-list li + li { border-top: 1px solid var(--line); }
.mail-list a { display: grid; grid-template-columns: minmax(120px, 220px) 1fr auto; gap: 16px; padding: 14px 18px; color: var(--ink-2); }
.mail-list a:hover { background: rgba(255, 255, 255, .03); text-decoration: none; }
.mail-list li.unread a { color: var(--ink); font-weight: 600; }
.mail-list li.unread .who::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 8px; vertical-align: middle; }
.mail-list .who, .mail-list .subj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-list .when { color: var(--muted); font-size: .85rem; font-weight: 400; }
.mail-read { padding: 24px; }
.mail-read h2 { font-size: 1.4rem; }
.mail-meta { margin: 12px 0 16px; grid-template-columns: 70px 1fr; }
.mail-frame { width: 100%; height: 72vh; min-height: 480px; border: 0; border-radius: 10px; background: #fff; margin-top: 18px; }
.mail-text { white-space: pre-wrap; word-wrap: break-word; font: inherit; margin: 18px 0 0; color: var(--ink); }
.mail-attachments { margin-top: 18px; display: flex; flex-direction: column; gap: 6px; }
.mail-compose { padding: 22px; margin-top: 0; }
.mail-compose input[disabled] { opacity: .7; }
.btn-sm2 { padding: 7px 14px; font-size: .85rem; }
.sync-note { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.sync-note input { width: auto; flex: 1; min-width: 180px; padding: 7px 10px; }
.activate-form { grid-template-columns: 1fr auto; }
@media (max-width: 720px) {
  .mail-layout { grid-template-columns: 1fr; }
  .mail-folders { flex-direction: row; position: static; }
  .mail-list a { grid-template-columns: 1fr auto; }
  .mail-list .subj { grid-column: 1 / -1; grid-row: 2; }
}

/* Form validation (replaces browser bubbles) */
input.invalid, select.invalid, textarea.invalid { border-color: var(--bad); }
input.invalid:focus, select.invalid:focus, textarea.invalid:focus { outline-color: var(--bad); }
label.check input.invalid { outline: 2px solid var(--bad); outline-offset: 2px; }
.field-error { display: flex; align-items: flex-start; gap: 7px; color: var(--bad); font-size: .83rem; font-weight: 500; line-height: 1.4; }
.field-error::before { content: '!'; flex: none; width: 16px; height: 16px; margin-top: 1px; border-radius: 50%; background: var(--bad); color: var(--bg); font-size: .7rem; font-weight: 800; display: grid; place-items: center; }
label.check .field-error { flex-basis: 100%; }
label.check { flex-wrap: wrap; }

/* Password strength meter */
.pw-meter { display: flex; flex-direction: column; gap: 6px; font-size: .8rem; font-weight: 500; color: var(--muted); }
.pw-bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.pw-bars i { height: 4px; border-radius: 2px; background: var(--line); transition: background .2s; }
.pw-meter[data-score=""] .pw-bars { display: none; }
.pw-meter[data-score="0"] .pw-bars i:nth-child(-n+1),
.pw-meter[data-score="1"] .pw-bars i:nth-child(-n+1) { background: var(--bad); }
.pw-meter[data-score="2"] .pw-bars i:nth-child(-n+2) { background: var(--warn); }
.pw-meter[data-score="3"] .pw-bars i:nth-child(-n+3),
.pw-meter[data-score="4"] .pw-bars i { background: var(--ok); }
.pw-meter[data-ok="0"] .pw-text { color: var(--bad); }
.pw-meter[data-ok="1"] .pw-text { color: var(--ok); }

/* App shell (PWA): bottom tab bar on phones, iPhone safe areas */
.tabbar { display: none; }
.ios-install { display: none; }
@media (max-width: 720px) {
  body.signed-in .nav { display: none; }
  body.signed-in { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  body.signed-in .footer { display: none; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: rgba(12, 12, 14, .88); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; color: var(--muted); font-size: .7rem; font-weight: 600; letter-spacing: .02em; border-radius: 12px; -webkit-tap-highlight-color: transparent; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.active { color: var(--ink); }
  .tabbar svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar a.active svg { stroke-width: 1.9; }
  .ios-install:not([hidden]) {
    display: flex; align-items: center; gap: 10px;
    position: fixed; left: 12px; right: 12px; z-index: 60;
    bottom: calc(12px + env(safe-area-inset-bottom));
    padding: 12px 14px; border-radius: 14px; font-size: .85rem; line-height: 1.4; color: var(--ink-2);
    background: var(--surface); border: 1px solid var(--line); box-shadow: 0 16px 40px rgba(0, 0, 0, .6);
  }
  body.signed-in .ios-install:not([hidden]) { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .ios-install svg { width: 16px; height: 16px; vertical-align: -3px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .ios-install b { color: var(--ink); }
  .ios-install button { margin-left: auto; flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 1.1rem; line-height: 1; cursor: pointer; }
  main.container { padding-top: 24px; }
}
/* Installed app: content starts below the status bar / notch */
html.standalone .topbar { padding-top: env(safe-area-inset-top); }
html.standalone .ios-install { display: none !important; }
.topbar, .tabbar { padding-left: max(0px, env(safe-area-inset-left)); padding-right: max(0px, env(safe-area-inset-right)); }

.app-panel { margin-top: 0; }
.profile-links { display: grid; gap: 10px; }
.profile-links form { margin: 0; }

.offline-page { min-height: 100vh; display: grid; place-content: center; text-align: center; gap: 10px; padding: 24px; }
.offline-mark { line-height: 0; margin-bottom: 8px; }

/* Documents tab: Diia-style ID card */
.doc-layout { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 32px; align-items: start; }
@media (max-width: 820px) { .doc-layout { grid-template-columns: 1fr; gap: 20px; } }
.doc { width: 100%; max-width: 440px; container-type: inline-size; }
.doc-flip { all: unset; display: block; width: 100%; cursor: pointer; perspective: 1400px; -webkit-tap-highlight-color: transparent; }
.doc-flip:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; border-radius: 22px; }
.doc-inner { position: relative; width: 100%; aspect-ratio: 0.8; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.2, .7, .2, 1); }
.doc.flipped .doc-inner { transform: rotateY(180deg); }
.doc-face {
  position: absolute; inset: 0; border-radius: 22px; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background:
    repeating-radial-gradient(circle at 120% -20%, rgba(185, 190, 199, .05) 0 1px, transparent 1px 8px),
    repeating-linear-gradient(115deg, rgba(185, 190, 199, .025) 0 1px, transparent 1px 6px),
    linear-gradient(160deg, #222327 0%, #0f0f11 55%, #060607 100%);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .85), inset 0 0 0 1px rgba(185, 190, 199, .2);
  color: var(--ink); display: flex; flex-direction: column; padding: 20px 20px 0;
}
.doc-back { transform: rotateY(180deg); align-items: center; justify-content: center; padding: 22px; gap: 18px; }
.doc-mark { position: absolute; right: -18%; bottom: 8%; width: 78%; opacity: .05; pointer-events: none; }
.doc-mark svg { width: 100%; height: auto; display: block; }
.doc-back .doc-mark { right: auto; left: 50%; top: 50%; bottom: auto; transform: translate(-50%, -50%); width: 90%; }
.doc-head { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.doc-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); line-height: 0; }
.doc-type { white-space: nowrap; font-size: clamp(.52rem, 2.5cqw, .68rem); letter-spacing: .18em; text-transform: uppercase; font-weight: 700; color: var(--accent); }
.doc-body { position: relative; display: grid; grid-template-columns: 38% 1fr; gap: 16px; margin-top: 22px; }
.doc-photo { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 10px; box-shadow: 0 0 0 1px rgba(185, 190, 199, .35); background: #1a1b1e; }
.doc-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 10px; align-content: start; }
.doc-field small { display: block; font-size: clamp(.5rem, 2.3cqw, .62rem); letter-spacing: .12em; text-transform: uppercase; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.doc-field b { display: block; font-size: clamp(.72rem, 3.6cqw, .95rem); font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.doc-field.wide { grid-column: 1 / -1; }
.doc-field.wide b { font-size: clamp(.8rem, 4.4cqw, 1.12rem); }
.doc-number { position: relative; display: flex; justify-content: space-between; gap: 12px; margin-top: auto; padding: 14px 0; border-top: 1px solid rgba(185, 190, 199, .16); }
.doc-number .doc-field:last-child { text-align: right; }
.doc-ticker { position: relative; margin: 0 -20px; overflow: hidden; background: var(--accent); color: var(--base); font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.doc.revoked .doc-ticker { background: var(--bad); }
.doc-ticker-track { display: inline-flex; padding: 9px 0; animation: doc-ticker 18s linear infinite; }
.doc-ticker-track span { padding: 0 14px; }
.doc-ticker-track span::after { content: '•'; margin-left: 28px; opacity: .5; }
@keyframes doc-ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.doc-qr { position: relative; text-align: center; }
.doc-qr img { width: min(240px, 62vw); height: auto; border-radius: 14px; background: #fff; padding: 10px; display: block; margin: 0 auto; }
.doc-qr p { margin: 12px 0 0; font-size: .82rem; color: var(--ink-2); }
.doc-mrz { position: relative; margin: 0; font: 600 clamp(.62rem, 2.6vw, .8rem)/1.45 ui-monospace, 'SFMono-Regular', Menlo, monospace; letter-spacing: .04em; color: var(--ink); background: rgba(255, 255, 255, .05); border-radius: 10px; padding: 10px 12px; white-space: pre; overflow: hidden; }
.doc.revoked .doc-face { filter: grayscale(1); }
.doc-hint { text-align: center; margin: 12px 0 0; }
.doc-actions { display: grid; gap: 10px; }
.doc-explain { margin: 6px 0 0; }
.live-badge { margin: 4px auto 0; padding: 8px 12px; border-radius: 10px; font-size: .85rem; font-weight: 600; max-width: 340px; }
.live-badge.ok { background: var(--ok-bg); color: var(--ok); }
.live-badge.warn { background: var(--warn-bg); color: var(--warn); }
.live-badge.bad { background: var(--bad-bg); color: var(--bad); }
@media (prefers-reduced-motion: reduce) { .doc-ticker-track { animation: none; } .doc-inner { transition: none; } }

/* Tab badges */
.tab-icon { position: relative; line-height: 0; }
.tab-icon em, .nav-badge { font-style: normal; background: var(--accent); color: var(--base); font-size: .62rem; font-weight: 800; border-radius: 999px; padding: 1px 5px; min-width: 16px; text-align: center; }
.tab-icon em { position: absolute; top: -4px; right: -10px; line-height: 1.4; }
.nav-badge { margin-left: 4px; font-size: .7rem; vertical-align: 1px; }
@media (max-width: 720px) { .tabbar a { font-size: .64rem; } .tabbar svg { width: 24px; height: 24px; } }

/* People and avatars */
.avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: .82rem; font-weight: 700; letter-spacing: .04em; color: var(--ink); background: linear-gradient(150deg, #2a2b30, #141416); box-shadow: inset 0 0 0 1px var(--line); }
.people { list-style: none; margin: 0; padding: 0; }
.people li { display: flex; align-items: center; gap: 14px; padding: 14px 18px; }
.people li + li { border-top: 1px solid var(--line); }
.people-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.people-name small { color: var(--muted); }

/* Referendums */
.vote-card { display: block; color: inherit; margin-bottom: 14px; transition: border-color .15s; }
.vote-card:hover { text-decoration: none; border-color: var(--accent); }
.vote-card h2 { margin: 12px 0 6px; font-size: 1.25rem; }
.vote-card p { margin: 0; }
.lead-left { color: var(--ink-2); max-width: 680px; }
.ballot { gap: 10px; }
.ballot-option { flex-direction: row; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; font-size: 1rem; font-weight: 500; color: var(--ink); cursor: pointer; }
.ballot-option:has(input:checked) { border-color: var(--accent); background: rgba(185, 190, 199, .06); }
.ballot-option input { width: auto; accent-color: var(--accent); }
.results { list-style: none; padding: 0; margin: 12px 0 18px; display: grid; gap: 14px; }
.results .bar { height: 8px; border-radius: 4px; background: var(--line); margin-top: 6px; overflow: hidden; }
.results .bar i { display: block; height: 100%; background: var(--muted); border-radius: 4px; }
.results li.top .bar i { background: var(--accent); }

/* Chats */
.chat-start { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; margin-bottom: 16px; }
.chat-start .flash { grid-column: 1 / -1; margin: 0; }
.chat-list { list-style: none; margin: 0; padding: 0; }
.chat-list li + li { border-top: 1px solid var(--line); }
.chat-list a { display: flex; align-items: center; gap: 14px; padding: 14px 18px; color: inherit; }
.chat-list a:hover { text-decoration: none; background: rgba(255, 255, 255, .03); }
.chat-preview { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-preview small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-list li.unread .chat-preview small { color: var(--ink); }
.chat-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; color: var(--muted); }
.chat-meta .count { background: var(--accent); color: var(--base); border-radius: 999px; font-size: .7rem; font-weight: 800; padding: 1px 7px; }
.chat { display: flex; flex-direction: column; height: calc(100vh - 170px); height: calc(100dvh - 170px); min-height: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.chat-back { font-size: 1.3rem; color: var(--ink-2); padding-right: 4px; }
.chat-back:hover { text-decoration: none; }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; }
.chat-empty { margin: auto; }
.bubble { max-width: 78%; align-self: flex-start; background: #202125; border-radius: 16px 16px 16px 4px; padding: 8px 12px 6px; }
.bubble.mine { align-self: flex-end; background: var(--accent); color: var(--base); border-radius: 16px 16px 4px 16px; }
.bubble p { margin: 0; white-space: pre-wrap; word-wrap: break-word; line-height: 1.4; }
.bubble time { display: block; text-align: right; font-size: .66rem; opacity: .6; margin-top: 2px; }
.chat-send { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: var(--bg); }
.chat-send textarea { resize: none; max-height: 140px; border-radius: 20px; padding: 10px 16px; }
.chat-send .btn { border-radius: 20px; }
@media (max-width: 720px) {
  body.chat-page main.container { padding-top: 12px; padding-bottom: 0; }
  body.chat-page .chat { height: calc(100dvh - 64px - 64px - 24px - env(safe-area-inset-bottom)); }
}

/* Segmented control (News | Decrees | Laws, Chats | Mail) */
.segments { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 18px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.segments a { padding: 7px 16px; border-radius: 9px; color: var(--ink-2); font-size: .9rem; font-weight: 600; }
.segments a:hover { text-decoration: none; color: var(--ink); }
.segments a.active { background: var(--accent); color: var(--base); }

/* News, decrees, laws */
.post-card { display: block; color: inherit; margin-bottom: 14px; transition: border-color .15s; }
.post-card:hover { text-decoration: none; border-color: var(--accent); }
.post-card h2 { margin: 10px 0 6px; font-size: 1.25rem; }
.post-card p { margin: 0; }
.post-meta { display: flex; justify-content: space-between; gap: 10px; align-items: center; font-size: .8rem; color: var(--muted); }
.post-kind { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; color: var(--accent); }
.post-card.decree, .doc-text.decree { border-left: 3px solid var(--accent); }
.post-card.constitution { background: linear-gradient(160deg, #1d1e22, var(--surface)); border-color: #3a3c43; }
.doc-text { max-width: 760px; }
.doc-text h1 { margin: 12px 0 18px; font-size: clamp(1.6rem, 3.4vw, 2.1rem); }
.rich { color: var(--ink-2); line-height: 1.7; }
.rich h2 { font-size: 1.15rem; margin: 30px 0 8px; color: var(--ink); text-transform: uppercase; letter-spacing: .06em; }
.rich h3 { font-size: 1rem; margin: 20px 0 4px; color: var(--ink); }
.rich p { margin: 0 0 12px; }
.rich ul { margin: 0 0 12px; padding-left: 20px; }
.rich strong { color: var(--ink); }
.signature { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-style: italic; }
.law-version { margin-bottom: 12px; }
.law-version summary { cursor: pointer; font-weight: 600; }
code { font: .85em ui-monospace, Menlo, monospace; background: var(--bg); padding: 1px 5px; border-radius: 5px; border: 1px solid var(--line); }

/* Notifications panel */
.push-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Registry */
.registry-nav span { background: var(--base); color: var(--ink); border-radius: 999px; padding: 0 7px; font-size: .75rem; margin-left: 4px; }
.search-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.search-bar input, .search-bar select { flex: 1; }
.registry-list { list-style: none; margin: 0; padding: 0; }
.registry-list li { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; align-items: center; padding: 12px 18px; }
.registry-list li + li { border-top: 1px solid var(--line); }
.registry-list .person { min-width: 0; }
.registry-list .people-name a { color: var(--ink); }
.role-tags { display: flex; gap: 6px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.row-actions form { margin: 0; }
@media (max-width: 760px) { .registry-list li { grid-template-columns: 1fr; } .row-actions { justify-content: flex-start; } }
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: grid; grid-template-columns: 150px 1fr; gap: 14px; padding: 12px 18px; }
.activity li + li { border-top: 1px solid var(--line); }
.activity time { color: var(--muted); font-size: .85rem; }
.activity p { margin: 0; color: var(--ink-2); }
.activity b { color: var(--ink); }
@media (max-width: 640px) { .activity li { grid-template-columns: 1fr; gap: 2px; } }

/* Invites */
.invite-link { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin-top: 12px; }
.invite-link input { font-size: .9rem; }
@media (max-width: 560px) { .invite-link { grid-template-columns: 1fr 1fr; } .invite-link input { grid-column: 1 / -1; } }
.invite-stats { display: flex; gap: 28px; margin-top: 16px; }
.invite-stats b { display: block; font-size: 1.6rem; font-weight: 600; }
.invite-stats small { color: var(--muted); }
.invited-by { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; color: var(--ink-2); }

/* Two-step sign-in */
.twofa-steps { margin: 0; padding-left: 20px; display: grid; gap: 22px; }
.twofa-steps li { color: var(--ink-2); }
.twofa-steps b { color: var(--ink); }
.twofa-qr { display: block; margin: 14px 0 10px; background: #fff; border-radius: 12px; padding: 10px; width: 200px; height: 200px; }
.twofa-key { display: inline-block; margin-top: 8px; font-size: 1rem; letter-spacing: .08em; padding: 8px 12px; }
.twofa-form { grid-template-columns: 1fr auto; max-width: 360px; margin-top: 10px; }
.twofa-input { font-size: 1.4rem; letter-spacing: .2em; text-align: center; }
.recovery-codes { list-style: none; padding: 0; margin: 16px 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; max-width: 360px; }
.recovery-codes code { display: block; text-align: center; font-size: 1rem; padding: 8px; letter-spacing: .06em; }
.twofa-status p { margin: 0 0 10px; }
.inline-2fa { grid-template-columns: 1fr auto; max-width: 460px; margin-top: 8px; }
.inline-2fa:has(input[type=password]) { grid-template-columns: 1fr 1fr auto; }
@media (max-width: 560px) { .inline-2fa, .inline-2fa:has(input[type=password]) { grid-template-columns: 1fr; } }

/* Telegram Mini App */
body.tg-app { min-height: 100vh; }
.tg-main { width: 100%; box-sizing: border-box; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); max-width: 460px; margin: 0 auto; }
.tg-main .doc { margin: 0 auto; }
.tg-more { margin-top: 18px; }
