/* TokenLab Pool — styles. Tokens follow plans/…/design-spec.md: dark by default, light via [data-theme="light"]. */

:root, [data-theme="dark"] {
  color-scheme: dark;
  --bg:#0F1217; --surface:#161A21; --surface-2:#1D222B; --surface-3:#262C36;
  --border:#2A303A; --border-strong:#3A424F; --input-border:#626B78;
  --text:#E7EBF0; --text-muted:#9AA3AF; --text-disabled:#6B7480;
  --accent:#3CC9B5; --accent-hover:#5AD6C4; --accent-active:#2FB3A1; --on-accent:#07201C;
  --pool:#3CC9B5; --debt:#E8AE4A; --niko:#9AA0FA; --fil:#D98AD0; --loss:#F07A7A; --ok:#58C98E;
  --danger-bg:#E5605F; --on-danger:#1A0606;
  --tint:14%;
  --focus:#7CB7FF; --scrim:rgba(0,0,0,.60);
  --elev-1:0 2px 8px rgba(0,0,0,.40);
  --elev-2:0 16px 40px rgba(0,0,0,.55);
}
[data-theme="light"] {
  color-scheme: light;
  --bg:#F5F6F8; --surface:#FFFFFF; --surface-2:#EEF0F3; --surface-3:#E3E7EC;
  --border:#D9DDE3; --border-strong:#B9C0CA; --input-border:#848D9A;
  --text:#14181F; --text-muted:#576170; --text-disabled:#9AA2AD;
  --accent:#0E7468; --accent-hover:#0B5F55; --accent-active:#0A5048; --on-accent:#FFFFFF;
  --pool:#0E7468; --debt:#9A5B00; --niko:#4C4FD8; --fil:#A13C98; --loss:#C0352F; --ok:#1E7B45;
  --danger-bg:#C0352F; --on-danger:#FFFFFF;
  --tint:10%;
  --focus:#1F5FD6; --scrim:rgba(20,24,31,.40);
  --elev-1:0 1px 2px rgba(20,24,31,.06), 0 4px 12px rgba(20,24,31,.08);
  --elev-2:0 16px 40px rgba(20,24,31,.16);
}
:root {
  --sans:'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono:'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --s-1:4px; --s-2:8px; --s-3:12px; --s-4:16px; --s-5:20px; --s-6:24px; --s-8:32px; --s-10:40px; --s-12:48px;
  --r-sm:6px; --r-md:8px; --r-lg:12px; --r-xl:16px; --r-full:999px;
  --z-sticky:10; --z-nav:20; --z-fab:30; --z-toast:70;
  --dur-1:120ms; --dur-2:200ms; --dur-3:280ms;
  --ease-out:cubic-bezier(.2,.8,.2,1); --ease-in:cubic-bezier(.4,0,1,1);
  --tap:44px; --sidebar:232px; --tabbar:64px;
}
@media (prefers-reduced-motion: reduce) { :root { --dur-1:0ms; --dur-2:0ms; --dur-3:0ms; } }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 15px/22px var(--sans); min-height: 100dvh; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a, button, summary, label { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--surface); padding: 10px 14px; border-radius: var(--r-md); border: 1px solid var(--border-strong); }
.skip-link:focus { top: 8px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.small { font-size: 13px; line-height: 18px; }
.warn { color: var(--debt); }
.pos { color: var(--ok); }
.neg { color: var(--loss); }
.h2 { font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -.01em; }
.h3 { font-size: 17px; line-height: 24px; font-weight: 600; letter-spacing: -.01em; }
.link { color: var(--accent); text-decoration: none; font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; min-height: var(--tap); padding: 0; border: 0; background: none; }
.link:hover { text-decoration: underline; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- shell ---------- */
.app { min-height: 100dvh; }
.sidebar { display: none; }
.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky); background: var(--bg); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--s-2); min-height: 56px;
  padding: env(safe-area-inset-top) calc(16px + env(safe-area-inset-right)) 0 calc(16px + env(safe-area-inset-left));
}
.page-title { font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -.01em; margin-right: auto; }
.rates { display: none; align-items: baseline; gap: 6px; font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.rates .num { color: var(--text); }
.rates-meta.warn { color: var(--debt); }
.sync { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; color: var(--text-muted); min-width: var(--tap); min-height: var(--tap); }
.sync-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.sync[data-state="connecting"] .sync-dot { background: transparent; box-shadow: inset 0 0 0 2px var(--debt); }
.sync[data-state="offline"] .sync-dot { background: var(--loss); border-radius: 2px; }
.sync[data-state="offline"] .sync-text { position: static; width: auto; height: auto; clip: auto; color: var(--loss); }
.theme-btn, .add-btn { display: none !important; }
.view { padding: var(--s-4) calc(16px + env(safe-area-inset-right)) calc(var(--tabbar) + env(safe-area-inset-bottom) + 24px) calc(16px + env(safe-area-inset-left)); display: grid; gap: var(--s-4); outline: none; }
body.is-admin .view { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 96px); }

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: var(--z-nav); display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.tab { flex: 1; display: grid; justify-items: center; align-content: center; gap: 2px; min-height: var(--tabbar); text-decoration: none; color: var(--text-muted); font-size: 12px; line-height: 16px; font-weight: 500; }
.tab .icon { width: 24px; height: 24px; padding: 2px 16px; box-sizing: content-box; border-radius: var(--r-full); }
.tab.is-active { color: var(--text); font-weight: 600; }
.tab.is-active .icon { background: var(--surface-3); color: var(--accent); }
.fab {
  position: fixed; right: calc(16px + env(safe-area-inset-right)); bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 16px); z-index: var(--z-fab);
  width: 56px; height: 56px; border-radius: var(--r-xl); border: 0; background: var(--accent); color: var(--on-accent); box-shadow: var(--elev-1);
  display: grid; place-items: center;
}
.fab .icon { width: 24px; height: 24px; stroke-width: 2; }
.fab:hover { background: var(--accent-hover); }

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; font-size: 16px; }
.brand-mark { width: 24px; height: 24px; color: var(--accent); }
.brand-text span { color: var(--text-muted); font-weight: 500; }

.me { position: relative; }
.me-button { display: flex; align-items: center; gap: 10px; min-height: var(--tap); min-width: var(--tap); padding: 0 4px; border: 0; background: none; border-radius: var(--r-md); }
.me-button:hover { background: var(--surface-2); }
.me-label { display: none; text-align: left; line-height: 18px; }
.me-label > span { display: block; }
.me-role { font-size: 12px; color: var(--text-muted); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 600; font-size: 14px;
  background: color-mix(in srgb, var(--accent) var(--tint), var(--surface)); color: var(--accent); flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.avatar-niko { background: color-mix(in srgb, var(--niko) var(--tint), var(--surface)); color: var(--niko); }
.avatar-fil { background: color-mix(in srgb, var(--fil) var(--tint), var(--surface)); color: var(--fil); }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--elev-1); padding: 6px; z-index: var(--z-nav); }
.menu-who { padding: 8px 10px 2px; font-weight: 600; }
.menu-rates { padding: 2px 10px 10px; font-size: 13px; color: var(--text-muted); display: grid; gap: 2px; }
.rates-pair { display: inline-flex; gap: 6px; }
.menu [role="menu"] { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; display: grid; }
.menu-item { width: 100%; display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 0 10px; border: 0; background: none; border-radius: var(--r-md); text-align: left; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); }

@media (min-width: 768px) {
  .tabbar, .fab { display: none !important; }
  .app { display: grid; grid-template-columns: 80px minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { display: flex; flex-direction: column; gap: var(--s-4); grid-row: 1 / span 2; position: sticky; top: 0; height: 100dvh; border-right: 1px solid var(--border); padding: var(--s-4) var(--s-2); background: var(--bg); }
  .sidebar .brand { justify-content: center; min-height: 40px; }
  .sidebar .brand-text { display: none; }
  .nav-list { display: grid; gap: 4px; }
  .nav-item { display: grid; justify-items: center; gap: 4px; padding: 10px 4px; border-radius: var(--r-md); text-decoration: none; color: var(--text-muted); font-size: 12px; line-height: 16px; font-weight: 500; }
  .nav-item .icon { width: 24px; height: 24px; }
  .nav-item:hover { background: var(--surface-2); color: var(--text); }
  .nav-item.is-active { background: var(--surface-3); color: var(--text); font-weight: 600; }
  .nav-item.is-active .icon { color: var(--accent); }
  .topbar { min-height: 64px; padding: 0 24px; gap: var(--s-3); }
  .page-title { font-size: 24px; line-height: 32px; }
  .sync-text { position: static; width: auto; height: auto; clip: auto; }
  .theme-btn { display: inline-grid !important; }
  body.is-admin .add-btn { display: inline-flex !important; }
  .view { padding: 24px; gap: var(--s-6); }
  body.is-admin .view { padding-bottom: 48px; }
  #act-theme { display: none; }
}
@media (min-width: 1024px) {
  .app { grid-template-columns: var(--sidebar) minmax(0, 1fr); }
  .sidebar { padding: var(--s-5) var(--s-3); }
  .sidebar .brand { justify-content: flex-start; padding: 0 10px; }
  .sidebar .brand-text { display: inline; }
  .nav-item { display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 0 12px; font-size: 15px; }
  .nav-item .icon { width: 20px; height: 20px; }
  .topbar { padding: 0 32px; }
  .view { padding: 32px; }
  .rates { display: inline-flex; }
  .me-label { display: block; }
  .menu-rates { display: none; }
}
@media (min-width: 1280px) {
  .view > * { width: 100%; max-width: 1200px; margin-inline: auto; }
}

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 16px; border-radius: var(--r-md);
  border: 1px solid transparent; font-weight: 500; text-decoration: none; white-space: nowrap; transition: background var(--dur-1), border-color var(--dur-1); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:active:not(:disabled) { background: var(--accent-active); }
.btn-ghost, .btn-secondary { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover:not(:disabled), .btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--danger-bg); color: var(--on-danger); }
.btn-danger:hover:not(:disabled) { filter: brightness(1.08); }
.btn-danger-ghost { background: transparent; color: var(--loss); }
.btn-danger-ghost:hover:not(:disabled) { background: color-mix(in srgb, var(--loss) var(--tint), var(--surface)); }
.btn-sm { font-size: 14px; padding: 0 12px; }
.btn-block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); border: 0; border-radius: var(--r-md); background: transparent; color: var(--text-muted); flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn-danger:hover { color: var(--loss); }
.btn-ghost:active:not(:disabled), .btn-secondary:active:not(:disabled), .icon-btn:active, .seg-btn:active { background: var(--surface-3); }

.field { display: grid; gap: 6px; align-content: start; min-width: 0; border: 0; padding: 0; margin: 0; }
.label { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--text); padding: 0; }
.req { color: var(--loss); }
.help { font-size: 13px; line-height: 18px; color: var(--text-muted); }
.input { width: 100%; min-height: var(--tap); padding: 0 12px; border-radius: var(--r-md); border: 1px solid var(--input-border); background: var(--bg); color: var(--text); font-size: 16px; line-height: 24px; }
.input:hover { border-color: var(--text-muted); }
.input:focus-visible { border-color: var(--accent); }
.input[aria-invalid="true"] { border-color: var(--loss); }
.input.num { font-family: var(--mono); }
select.input { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239AA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
input[type="date"].input { padding-right: 8px; }
.input-wrap { position: relative; display: block; }
.input-wrap .input { padding-right: 48px; }
.input-btn { position: absolute; right: 0; top: 0; }
.input-icon { position: relative; display: block; }
.input-icon .icon { position: absolute; left: 12px; top: 12px; color: var(--text-muted); pointer-events: none; }
.input-icon .input { padding-left: 40px; }
.form-error { display: flex; gap: 8px; align-items: flex-start; color: var(--loss); font-size: 13px; line-height: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.field-full { grid-column: 1 / -1; }
.form-stack { display: grid; gap: var(--s-4); }
@media (max-width: 420px) { .form-grid { grid-template-columns: 1fr; } }

.seg { display: inline-flex; gap: 2px; padding: 2px; background: var(--surface-2); border-radius: 10px; flex-wrap: wrap; }
.seg-btn { min-height: 40px; padding: 0 12px; border: 1px solid transparent; border-radius: var(--r-md); background: transparent; color: var(--text-muted); font-size: 14px; font-weight: 500; }
.seg-btn[aria-pressed="true"] { background: var(--surface-3); border-color: var(--border-strong); color: var(--text); }
.seg-btn:hover:not([aria-pressed="true"]), .filter-chip:hover:not([aria-pressed="true"]) { color: var(--text); background: var(--surface-3); }
[data-theme="light"] .seg-btn[aria-pressed="true"] { background: var(--surface); }

.banner { padding: 10px 12px; border-radius: var(--r-md); font-size: 14px; line-height: 20px; }
.banner-error { background: color-mix(in srgb, var(--loss) var(--tint), var(--surface)); color: var(--loss); }
.banner-info { background: var(--surface-2); color: var(--text); }
.banner-warn { background: color-mix(in srgb, var(--debt) var(--tint), var(--surface)); color: var(--debt); }
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--text-muted); font-size: 12px; font-weight: 500; vertical-align: middle; }
.badge-debt { background: color-mix(in srgb, var(--debt) var(--tint), var(--surface)); color: var(--debt); }
.badge-loss { background: color-mix(in srgb, var(--loss) var(--tint), var(--surface)); color: var(--loss); }
.badge-ok { background: color-mix(in srgb, var(--ok) var(--tint), var(--surface)); color: var(--ok); gap: 4px; }
.badge-accent { background: color-mix(in srgb, var(--accent) var(--tint), var(--surface)); color: var(--accent); }
.badge-niko { background: color-mix(in srgb, var(--niko) var(--tint), var(--surface)); color: var(--niko); }
.badge-fil { background: color-mix(in srgb, var(--fil) var(--tint), var(--surface)); color: var(--fil); }
.badge .icon { width: 14px; height: 14px; }

/* ---------- panels & tiles ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-4); min-width: 0; display: grid; gap: var(--s-4); align-content: start; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); flex-wrap: wrap; min-height: 32px; }
.panel-foot { font-size: 14px; border-top: 1px solid var(--border); padding-top: var(--s-3); }
@media (min-width: 768px) { .panel { padding: var(--s-5); } }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
.tile { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-4); display: grid; gap: 2px; align-content: start; min-height: 96px; min-width: 0; text-decoration: none; }
a.tile:hover { border-color: var(--border-strong); }
.tile-hero { grid-column: 1 / -1; }
.tile-label { display: flex; align-items: center; gap: 8px; font-size: 13px; line-height: 18px; font-weight: 500; color: var(--text-muted); }
.tile-label::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--c, var(--text-muted)); flex: none; }
.tile-value { font: 500 clamp(18px, 5.4vw, 22px)/30px var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile-value .unit { font: 400 15px/22px var(--sans); color: var(--text-muted); }
.forecast { margin-top: calc(-1 * var(--s-2)); }
.tile-hero .tile-value { font-size: 28px; line-height: 36px; }
.tile-sub { font-size: 13px; line-height: 18px; color: var(--text-muted); }
.tile-sol { --c: var(--pool); } .tile-debt { --c: var(--debt); } .tile-loss { --c: var(--loss); } .tile-niko { --c: var(--niko); } .tile-fil { --c: var(--fil); }
.tile.is-me { border-color: color-mix(in srgb, var(--c) 45%, var(--border)); }
@media (min-width: 768px) {
  .tiles { gap: var(--s-4); }
  .tile-value { font-size: 24px; line-height: 32px; }
  .tile-hero .tile-value { font-size: 32px; line-height: 40px; }
}
@media (min-width: 1024px) {
  .tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .tiles > .tile { grid-column: span 2; }
  .tiles > .tile-hero { grid-column: span 2; }
  .tiles-5 > .tile:nth-child(n+4) { grid-column: span 3; }
  .tiles-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tiles-4 > .tile { grid-column: auto; }
  .tiles-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tiles-3 > .tile { grid-column: auto; }
}
.tiles-3 > .tile:first-child { grid-column: 1 / -1; }
@media (min-width: 1024px) { .tiles-3 > .tile:first-child { grid-column: auto; } }

.grid-main { display: grid; gap: var(--s-4); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1024px) {
  .grid-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--s-6); }
  .grid-main-rev { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); }
}
.cards-grid { display: grid; gap: var(--s-4); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1024px) { .cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-6); } }
@media (min-width: 1280px) { .cards-grid:not(.cards-2) { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.empty { display: grid; justify-items: center; text-align: center; gap: var(--s-2); padding: var(--s-8) var(--s-4); }
.empty-sm { padding: var(--s-4); }
.empty-title { font-weight: 600; font-size: 16px; }
.empty .btn { margin-top: var(--s-2); }

.skeleton-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-3); }
.skeleton-grid i { display: block; height: 96px; border-radius: var(--r-lg); background: var(--surface-2); animation: pulse 1.2s ease-in-out infinite alternate; }
.skeleton-grid i.wide { grid-column: 1 / -1; height: 240px; }
@keyframes pulse { from { opacity: .55; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .skeleton-grid i { animation: none; } }

/* ---------- chips, kinds ---------- */
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; border-radius: var(--r-full); border: 1px solid var(--border-strong); font: 500 13px/18px var(--mono); color: var(--text-muted); }
.chip-next { border-color: var(--debt); color: var(--debt); background: color-mix(in srgb, var(--debt) var(--tint), var(--surface)); }
.chip-overdue { border-color: var(--loss); color: var(--loss); background: color-mix(in srgb, var(--loss) var(--tint), var(--surface)); }
.chip .icon { width: 14px; height: 14px; }
.kind-income { --k: var(--ok); } .kind-expense { --k: var(--loss); } .kind-topup { --k: var(--pool); } .kind-debt_payment { --k: var(--debt); }
.kind-payout, .kind-share_spend { --k: var(--text-muted); }
.kind-tag { display: inline-flex; align-items: center; height: 22px; padding: 0 7px; border-radius: var(--r-sm); font-size: 12px; font-weight: 500; color: var(--k); background: color-mix(in srgb, var(--k) var(--tint), var(--surface)); }
.kind-payout.kind-tag, .kind-share_spend.kind-tag { background: var(--surface-2); }

/* ---------- entries ---------- */
.entry-list { display: grid; }
.entry { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 4px 12px; align-items: start; padding: 12px 0; border-top: 1px solid var(--border); }
.entry:first-child { border-top: 0; }
.entry-icon { width: 36px; height: 36px; border-radius: var(--r-md); display: grid; place-items: center; color: var(--k); background: color-mix(in srgb, var(--k) var(--tint), var(--surface)); }
.entry-icon.kind-payout, .entry-icon.kind-share_spend { background: var(--surface-2); }
.entry-main { min-width: 0; display: grid; gap: 4px; }
.entry-title { font-weight: 500; overflow-wrap: anywhere; }
.entry-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 13px; line-height: 18px; color: var(--text-muted); }
.meta-edit { font-style: italic; }
.entry-note { font-size: 14px; line-height: 20px; color: var(--text-muted); overflow-wrap: anywhere; }
.entry-amount { text-align: right; display: grid; gap: 2px; justify-items: end; }
.amount { font-weight: 500; white-space: nowrap; }
.amount.neg { color: var(--text); }
.amount .unit { font-family: var(--sans); font-size: 13px; color: var(--text-muted); font-weight: 400; }
.entry-actions { grid-column: 2 / -1; display: flex; justify-content: flex-end; gap: 4px; margin-top: -4px; }
.entry-compact { grid-template-columns: 32px minmax(0, 1fr) auto; padding: 10px 0; }
/* On narrow phones the amount column keeps only the number and $; the «из пула» hint is redundant with the kind tag. */
@media (max-width: 479px) { .entry-hint, .entry-meta .year { display: none; } .entry { grid-template-columns: 32px minmax(0, 1fr) auto; gap: 4px 10px; } .entry-icon { width: 32px; height: 32px; } }
.entry-compact .entry-icon { width: 32px; height: 32px; }
.entry-compact .entry-note { display: none; }
@media (min-width: 768px) {
  .entry-list-full .entry { grid-template-columns: 36px minmax(0, 1fr) minmax(140px, auto) auto; align-items: center; }
  .entry-list-full.has-actions .entry { grid-template-columns: 36px minmax(0, 1fr) minmax(140px, auto) 92px; }
  .entry-list-full .entry-actions { grid-column: auto; margin: 0; }
}
/* Phones: actions sit under the amount instead of taking their own row. */
@media (max-width: 767px) {
  .entry-list-full .entry-icon { grid-column: 1; grid-row: 1; }
  .entry-list-full .entry-main { grid-column: 2; grid-row: 1 / span 2; }
  .entry-list-full .entry-amount { grid-column: 3; grid-row: 1; }
  .entry-list-full .entry-actions { grid-column: 3; grid-row: 2; margin: 0; align-self: end; gap: 0; }
}
.group-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-muted); padding: 10px 0 6px; border-bottom: 1px solid var(--border-strong); position: sticky; top: calc(56px + env(safe-area-inset-top)); background: var(--surface); z-index: 1; text-transform: none; }
@media (min-width: 768px) { .group-head { top: 64px; } }
.group-head span:first-child::first-letter { text-transform: uppercase; }

.toolbar { display: grid; gap: var(--s-3); }
.toolbar-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-3); }
@media (min-width: 640px) { .toolbar-row { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); } .toolbar-row > :first-child { grid-column: 1 / -1; } }
@media (min-width: 900px) { .toolbar-row > :first-child { grid-column: auto; } }
.chip-filters { display: flex; gap: var(--s-2); overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
@media (min-width: 768px) { .chip-filters { flex-wrap: wrap; overflow: visible; } }
.filter-chip { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: var(--r-full); border: 1px solid var(--border-strong); background: transparent; font-size: 14px; color: var(--text); }
.filter-chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.filter-chip[aria-pressed="true"] .muted { color: inherit; opacity: .75; }
@media (pointer: coarse) { .filter-chip { min-height: var(--tap); } }

/* ---------- chart & bars ---------- */
.chart-wrap { position: relative; }
/* The curve takes the trend colour of the range (up/down); flat or single-point ranges keep the pool colour. */
.chart { --chart-c: var(--pool); display: block; width: 100%; height: auto; touch-action: pan-y; border-radius: var(--r-sm); }
.chart.is-up { --chart-c: var(--ok); }
.chart.is-down { --chart-c: var(--loss); }
.chart .grid { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 1 5; stroke-linecap: round; opacity: .9; }
.chart .axis { fill: var(--text-muted); font: 12px var(--mono); }
.chart .g-top { stop-color: var(--chart-c); stop-opacity: .28; }
.chart .g-bot { stop-color: var(--chart-c); stop-opacity: 0; }
[data-theme="light"] .chart .g-top { stop-opacity: .18; }
.chart .line { fill: none; stroke: var(--chart-c); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart .dot { fill: var(--chart-c); stroke: var(--surface); stroke-width: 2; }
.chart .halo { fill: var(--chart-c); opacity: .18; }
.chart .cursor { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .pt { fill: var(--chart-c); stroke: var(--surface); stroke-width: 2; }
.chart-tip { position: absolute; transform: translate(-50%, calc(-100% - 12px)); background: var(--surface-3); border-radius: var(--r-sm); box-shadow: var(--elev-1); padding: 6px 10px; font-size: 13px; line-height: 18px; display: grid; gap: 1px; pointer-events: none; white-space: nowrap; }
.chart-tip.is-below { transform: translate(-50%, 14px); }
.chart-range { margin-left: auto; }

/* ---------- pool panel: stats column + curve ---------- */
.pool-body { display: grid; gap: var(--s-5); min-width: 0; }
.pool-stats { display: grid; gap: var(--s-3); align-content: start; min-width: 0; }
.pool-label { display: flex; align-items: center; gap: 8px; font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.pool-label::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--pool); flex: none; }
.pool-value { font: 500 clamp(30px, 8.5vw, 40px)/1.15 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; white-space: nowrap; margin-top: -4px; }
.pool-value .unit { font: 400 16px/22px var(--sans); color: var(--text-muted); letter-spacing: 0; }
.pool-sub { font-size: 14px; line-height: 20px; color: var(--text-muted); margin-top: -8px; }
.pool-caption { font-family: var(--sans); }
.pool-delta { display: inline-flex; align-items: center; gap: 6px; width: max-content; max-width: 100%; min-height: 28px; padding: 2px 10px 2px 8px; border-radius: var(--r-full); font-size: 14px; line-height: 20px; font-weight: 500; background: color-mix(in srgb, currentColor 12%, transparent); }
.pool-delta .icon { width: 16px; height: 16px; stroke-width: 2.25; }
.pool-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3) var(--s-4); border-top: 1px solid var(--border); padding-top: var(--s-3); }
.pool-grid dt, .pool-days dt { font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.pool-grid dd { font-size: 15px; line-height: 20px; font-weight: 500; white-space: nowrap; }
.pool-grid dd .unit { font: 400 12px/16px var(--sans); color: var(--text-muted); }
.pool-cnt { display: block; font: 400 12px/16px var(--sans); color: var(--text-muted); }
.pool-days { display: grid; gap: 6px; border-top: 1px solid var(--border); padding-top: var(--s-3); }
.pool-days > div { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-2); }
.pool-days dd { font-size: 13px; line-height: 18px; white-space: nowrap; }
.pool-chart { min-width: 0; }
@media (min-width: 640px) {
  .pool-body { grid-template-columns: minmax(220px, 1fr) minmax(0, 2fr); gap: var(--s-6); align-items: start; }
  .pool-stats { padding-right: var(--s-5); border-right: 1px solid var(--border); }
}
@media (min-width: 1024px) { .pool-body { grid-template-columns: minmax(260px, 7fr) minmax(0, 13fr); gap: var(--s-8); } }
.seg-tint .seg-btn[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) var(--tint), var(--surface)); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); color: var(--accent); }
.chart-table summary { cursor: pointer; font-size: 13px; color: var(--text-muted); min-height: var(--tap); display: flex; align-items: center; width: max-content; }
.chart-table summary::before, .tranches summary::before { content: '›'; display: inline-block; width: 16px; margin-right: 6px; font-size: 18px; text-align: center; transition: transform var(--dur-1); }
details[open] > summary::before { transform: rotate(90deg); }
.chart-table summary:hover, .tranches summary:hover { color: var(--text); }
summary::-webkit-details-marker { display: none; }
.table-scroll { overflow-x: auto; max-height: 320px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 500; font-size: 13px; color: var(--text-muted); padding: 8px; border-bottom: 1px solid var(--border-strong); position: sticky; top: 0; background: var(--surface); }
.table td { padding: 8px; border-bottom: 1px solid var(--border); }
.table .num { text-align: right; }

.bars { display: grid; gap: var(--s-3); }
.bar-top { display: flex; justify-content: space-between; gap: var(--s-3); font-size: 14px; }
.bar-label { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.swatch { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.bar-track { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.bar-track i { display: block; height: 100%; border-radius: 4px; }

/* ---------- debts & partners ---------- */
.debt-remaining { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.big { font-size: 24px; line-height: 32px; font-weight: 500; }
.progress { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--debt); border-radius: 4px; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--s-3) var(--s-4); }
.kv div { display: grid; gap: 2px; }
.kv dt { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.kv dd { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 500; }
.kv-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tranches summary { cursor: pointer; font-size: 14px; color: var(--text-muted); min-height: var(--tap); display: flex; align-items: center; }
.mini-list { display: grid; }
.mini-list li { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 14px; }
.card-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }

.partner-card .h3 { display: flex; align-items: center; gap: 10px; }
.partner-niko { --c: var(--niko); } .partner-fil { --c: var(--fil); }
.partner-card.is-selected { border-color: color-mix(in srgb, var(--c) 55%, var(--border)); }
.partner-left { display: grid; gap: 2px; }
.partner-left .tile-label::before { background: var(--c); }
.stack-bar { display: flex; gap: 2px; height: 10px; border-radius: 5px; overflow: hidden; background: var(--surface-2); }
.stack-bar i { display: block; height: 100%; }
.sb-left { background: var(--c); }
.sb-withdrawn { background: color-mix(in srgb, var(--c) 45%, var(--surface)); }
.sb-spent { background: repeating-linear-gradient(135deg, var(--c) 0 3px, color-mix(in srgb, var(--c) 30%, var(--surface)) 3px 6px); }
.kv .dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* ---------- sheet (entry form) & dialogs ---------- */
dialog { color: var(--text); }
dialog::backdrop { background: var(--scrim); }
.sheet { margin: auto 0 0; width: 100%; max-width: 100%; max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: var(--r-xl) var(--r-xl) 0 0; background: var(--surface); box-shadow: var(--elev-2); }
.sheet[open] { animation: sheet-up var(--dur-3) var(--ease-out); }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } }
.sheet-form { display: flex; flex-direction: column; max-height: calc(100dvh - 24px); }
.sheet-head { display: flex; align-items: center; gap: var(--s-2); padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--border); position: relative; }
.sheet-head .h3 { flex: 1; font-size: 20px; line-height: 28px; }
.sheet-grip { position: absolute; left: 50%; top: 6px; width: 32px; height: 4px; border-radius: 2px; background: var(--border-strong); transform: translateX(-50%); }
.sheet-body { overflow-y: auto; padding: var(--s-4); display: grid; gap: var(--s-4); overscroll-behavior: contain; }
.sheet-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-2); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--surface); }
.sheet-foot .form-error { flex-basis: 100%; }
.field-error::before { content: '!'; display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--loss); color: var(--surface); font-size: 11px; font-weight: 700; flex: none; margin-top: 1px; }
.sheet-foot .btn-primary { flex: 1; }
@media (min-width: 768px) {
  .sheet { margin: 0 0 0 auto; width: 440px; height: 100dvh; max-height: 100dvh; border-radius: var(--r-xl) 0 0 var(--r-xl); }
  .sheet[open] { animation-name: drawer-in; }
  .sheet-form { height: 100%; max-height: none; }
  .sheet-body { flex: 1; align-content: start; }
  .sheet-grip { display: none; }
  .sheet-foot .btn-primary { flex: none; }
}
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet[open] { animation: none; } }

.kind-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
.kind-opt { position: relative; display: block; }
.kind-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.kind-chip { display: grid; justify-items: center; align-content: center; gap: 4px; min-height: 64px; padding: 6px 4px; border-radius: var(--r-md); border: 1px solid var(--border-strong); text-align: center; font-size: 13px; line-height: 16px; font-weight: 500; color: var(--text-muted); }
.kind-chip .icon { color: var(--k); }
.kind-opt input:checked + .kind-chip { border: 2px solid var(--accent); background: var(--surface-2); color: var(--text); padding: 5px 3px; }
.kind-opt input:focus-visible + .kind-chip { outline: 2px solid var(--focus); outline-offset: 2px; }
.split-preview { background: var(--surface-2); border-radius: var(--r-md); padding: var(--s-3); display: grid; gap: var(--s-2); font-size: 14px; }
.split-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2) var(--s-4); }
.split-cell { display: grid; gap: 2px; }
.split-cell dt { font-size: 13px; color: var(--text-muted); display: flex; gap: 6px; align-items: center; }
.split-cell dt::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--c); }
.split-cell dd { font-family: var(--mono); font-weight: 500; }
.c-debt { --c: var(--debt); } .c-sol { --c: var(--pool); } .c-niko { --c: var(--niko); } .c-fil { --c: var(--fil); }

.dialog { width: min(440px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: var(--r-xl); background: var(--surface); box-shadow: var(--elev-2); }
.dialog-form { display: grid; }
.dialog-head { display: flex; align-items: center; gap: var(--s-2); padding: 12px 8px 4px 20px; }
.dialog-head .h3 { flex: 1; }
.dialog-body { padding: 8px 20px 4px; display: grid; gap: var(--s-4); max-height: 70dvh; overflow-y: auto; }
.dialog-form > .form-error { padding: 4px 20px 0; }
.dialog-foot { display: flex; justify-content: flex-end; gap: var(--s-2); padding: 16px 20px 20px; }
.secret { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: var(--r-md); padding: 4px 4px 4px 12px; font-family: var(--mono); overflow-wrap: anywhere; }
.secret code { flex: 1; }

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: var(--z-toast); left: 16px; right: 16px; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 16px); display: grid; gap: var(--s-2); pointer-events: none; }
body.is-admin .toasts { bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 88px); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 4px; min-height: 48px; padding: 4px 4px 4px 16px; border-radius: var(--r-lg); background: var(--surface-3); box-shadow: var(--elev-1); animation: toast-in var(--dur-2) var(--ease-out); }
.toast-text { flex: 1; font-size: 14px; line-height: 20px; padding: 8px 0; }
.toast-error { box-shadow: var(--elev-1), inset 3px 0 0 var(--loss); }
.toast-action { color: var(--accent); border: 0; font-weight: 600; }
.toast.is-leaving { opacity: 0; transition: opacity var(--dur-2) var(--ease-in); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (min-width: 768px) {
  .toasts, body.is-admin .toasts { left: auto; right: 24px; bottom: 24px; width: 380px; }
}

/* ---------- settings ---------- */
.settings { display: grid; gap: var(--s-4); }
@media (min-width: 1024px) { .settings { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s-6); align-items: start; } .settings .span-2 { grid-column: 1 / -1; } }
.split-inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); align-items: end; }
@media (min-width: 640px) { .split-inputs { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.split-inputs .label::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--c); margin-right: 6px; }
.row-list { display: grid; }
.row-item { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.row-item:first-child { border-top: 0; }
.row-main { flex: 1 1 200px; min-width: 0; display: grid; gap: 2px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.row-item.is-disabled .row-main { opacity: .6; }
.tranche-rows { display: grid; gap: var(--s-2); }
.tranche-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) var(--tap); gap: var(--s-2); align-items: end; }
.radio-row { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.radio-pill { position: relative; }
.radio-pill input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.radio-pill span { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 14px; border-radius: var(--r-md); border: 1px solid var(--border-strong); font-size: 14px; font-weight: 500; color: var(--text-muted); }
.radio-pill input:checked + span { border: 2px solid var(--accent); color: var(--text); background: var(--surface-2); padding: 0 13px; }
.radio-pill input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.sum-ok { color: var(--ok); } .sum-bad { color: var(--loss); }

/* ---------- profit by source (overview) ---------- */
.sources { display: grid; }
.src-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--border); text-decoration: none; border-radius: var(--r-sm); }
.src-row:first-child { border-top: 0; }
.src-row:hover .src-name { color: var(--accent); }
.src-name { font-weight: 500; display: flex; align-items: center; gap: 8px; min-width: 0; }
.src-name::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--ok); flex: none; }
.src-sub { grid-column: 1; font-size: 13px; line-height: 18px; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 2px 8px; }
.src-sol { grid-row: 1; grid-column: 2; font-weight: 500; white-space: nowrap; text-align: right; }
.src-sol .unit { font: 400 13px/18px var(--sans); color: var(--text-muted); }
.src-usd { grid-row: 2; grid-column: 2; font-size: 13px; line-height: 18px; color: var(--text-muted); text-align: right; white-space: nowrap; }
.src-track { grid-column: 1 / -1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.src-track i { display: block; height: 100%; border-radius: 3px; background: var(--ok); }
.src-row .chev { color: var(--text-muted); }

/* ---------- profile ---------- */
.profile { display: grid; gap: var(--s-4); align-content: start; }
@media (min-width: 768px) { .profile { gap: var(--s-6); } }
.profile-hero { display: grid; justify-items: center; text-align: center; gap: var(--s-4); padding: var(--s-6) var(--s-4); }
.profile-avatar-wrap { position: relative; }
.profile-avatar { position: relative; width: 120px; height: 120px; font-size: 48px; border: 0; padding: 0; cursor: pointer; box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px var(--border-strong); }
.profile-avatar:focus-visible { outline: 2px solid var(--focus); outline-offset: 8px; }
.profile-avatar-overlay { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 2px; background: rgba(0,0,0,.55); color: #fff; font: 500 13px/16px var(--sans); opacity: 0; transition: opacity var(--dur-1); border-radius: inherit; }
.profile-avatar-overlay .icon { width: 22px; height: 22px; }
.profile-avatar:hover .profile-avatar-overlay, .profile-avatar:focus-visible .profile-avatar-overlay { opacity: 1; }
@media (hover: none) { .profile-avatar-overlay { opacity: 1; background: linear-gradient(to top, rgba(0,0,0,.6), transparent 55%); align-content: end; padding-bottom: 8px; } .profile-avatar-overlay .icon { display: none; } }
.profile-id { display: grid; gap: var(--s-2); justify-items: center; min-width: 0; }
.profile-name { font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: -.015em; overflow-wrap: anywhere; }
.profile-meta { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 10px; font-size: 14px; }
.profile-id .help { max-width: 48ch; }
.profile-id .card-actions { justify-content: center; margin-top: 4px; }
@media (min-width: 640px) {
  .profile-hero { grid-template-columns: auto minmax(0, 1fr); justify-items: start; text-align: left; align-items: center; gap: var(--s-6); padding: var(--s-6); }
  .profile-id, .profile-id .card-actions { justify-items: start; justify-content: flex-start; }
  .profile-meta { justify-content: flex-start; }
}
.profile-grid { align-items: stretch; align-content: start; }
.status-row { display: flex; gap: 12px; align-items: flex-start; }
.status-icon { width: 40px; height: 40px; border-radius: var(--r-md); display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--text-muted); }
.status-icon.is-on { background: color-mix(in srgb, var(--ok) var(--tint), var(--surface)); color: var(--ok); }
.status-text { display: grid; gap: 2px; min-width: 0; }
.status-title { font-weight: 600; }
.steps { display: grid; gap: var(--s-4); counter-reset: step; }
.steps li { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 10px; font-size: 14px; line-height: 20px; }
.steps li > div { display: grid; gap: var(--s-3); min-width: 0; }
.step-n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font: 600 12px/1 var(--mono); }
.qr { width: 168px; height: 168px; padding: 8px; background: #fff; border-radius: var(--r-md); justify-self: center; }
.qr svg { display: block; width: 100%; height: 100%; }
@media (min-width: 768px) { .qr { width: 192px; height: 192px; } }
.manual-key summary { cursor: pointer; font-size: 13px; color: var(--text-muted); min-height: var(--tap); display: flex; align-items: center; width: max-content; max-width: 100%; }
.manual-key summary:hover { color: var(--text); }
.manual-key[open] summary { margin-bottom: 8px; }
.manual-key .help { margin-top: 8px; }
.code-input { font-size: 22px; letter-spacing: .35em; text-align: center; min-height: 52px; }
.code-input::placeholder { letter-spacing: .35em; color: var(--text-disabled); }

/* ---------- login ---------- */
.login-page { display: grid; }
.login { width: 100%; max-width: 432px; margin: 0 auto; padding: 48px 16px; display: grid; gap: var(--s-6); align-content: start; }
.brand-login { justify-content: center; font-size: 18px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-6); display: grid; gap: var(--s-4); }
@media (min-height: 700px) and (min-width: 768px) { .login { padding-top: 12vh; } }
.login-step-head { display: grid; gap: 4px; }
.login-who { font-size: 14px; color: var(--text-muted); }
.login-back { justify-self: start; }
