/* ============================================================
   Foundry — design system
   Raw BFBB, no build. Apple-esque credit-ledger aesthetic.
   Type duality: human sans (system) + machine mono (tnum, numbers only).
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  /* type */
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro", "Segoe UI",
    Roboto, Helvetica, Arial, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Roboto Mono", "Cascadia Code",
    Menlo, Consolas, monospace;

  /* scale */
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-base: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --fs-2xl: 24px;
  --fs-3xl: 32px;
  --fs-4xl: 44px;
  --fs-hero: 60px;

  --lh-tight: 1.15;
  --lh-snug: 1.3;
  --lh-normal: 1.5;

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semi: 590;
  --fw-bold: 700;

  /* spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* radius */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-2xl: 22px;
  --r-pill: 999px;

  /* z */
  --z-base: 0;
  --z-sticky: 20;
  --z-overlay: 60;
  --z-sheet: 80;
  --z-modal: 90;
  --z-toast: 100;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 120ms;
  --dur: 200ms;
  --dur-slow: 360ms;
}

/* light theme */
:root,
[data-theme="light"] {
  --bg: #fbfbfd;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --surface-3: #ececef;
  --fill-hover: #f0f0f3;

  --ink: #1d1d1f;
  --ink-2: #515154;
  --ink-3: #6e6e73;
  --ink-4: #86868b;
  --ink-5: #a1a1a6;

  --line: #d8d8de;
  --line-soft: #e6e6eb;
  --line-strong: #c7c7cc;

  --accent: #0071e3;
  --accent-hover: #0066cc;
  --accent-press: #0058b0;
  --accent-soft: rgba(0, 113, 227, 0.1);
  --accent-ink: #ffffff;

  --green: #1d8e4f;
  --green-soft: rgba(29, 142, 79, 0.12);
  --amber: #b26a00;
  --amber-soft: rgba(179, 106, 0, 0.14);
  --red: #d23b3b;
  --red-soft: rgba(210, 59, 59, 0.12);
  --violet: #6b4fbb;
  --violet-soft: rgba(107, 79, 187, 0.12);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 1px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-sheet: -18px 0 48px rgba(0, 0, 0, 0.14);

  --frost: rgba(255, 255, 255, 0.72);
  --boot-bg: #000000;

  --track: rgba(0, 0, 0, 0.18);
}

/* dark theme — true black, OLED */
[data-theme="dark"] {
  --bg: #000000;
  --bg-elev: #0a0a0c;
  --surface: #161618;
  --surface-2: #1c1c1e;
  --surface-3: #2a2a2e;
  --fill-hover: #232326;

  --ink: #f5f5f7;
  --ink-2: #d6d6db;
  --ink-3: #a1a1a6;
  --ink-4: #86868b;
  --ink-5: #6e6e73;

  --line: #2a2a2e;
  --line-soft: #232326;
  --line-strong: #3a3a3e;

  --accent: #0a84ff;
  --accent-hover: #1f8eff;
  --accent-press: #3f9fff;
  --accent-soft: rgba(10, 132, 255, 0.18);
  --accent-ink: #ffffff;

  --green: #30d158;
  --green-soft: rgba(48, 209, 88, 0.16);
  --amber: #ffa00a;
  --amber-soft: rgba(255, 160, 10, 0.16);
  --red: #ff5a4d;
  --red-soft: rgba(255, 90, 77, 0.16);
  --violet: #bfa6ff;
  --violet-soft: rgba(191, 166, 255, 0.16);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.6);
  --shadow-sheet: -18px 0 50px rgba(0, 0, 0, 0.6);

  --frost: rgba(10, 10, 12, 0.72);
  --boot-bg: #000000;

  --track: rgba(255, 255, 255, 0.2);
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
  overflow: hidden; /* the app shell scrolls internally */
}
h1,
h2,
h3,
h4,
h5,
p,
figure,
blockquote {
  margin: 0;
}
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
ul,
ol {
  margin: 0;
  padding: 0;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
::selection {
  background: var(--accent-soft);
}
img,
svg {
  display: block;
}

/* numbers — the machine mono treatment */
.num,
.mono {
  font-family: var(--mono);
  font-feature-settings: "tnum" 1, "cv01" 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* scrollbars — quiet */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--r-pill);
  border: 3px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--ink-4);
  background-clip: padding-box;
  border: 3px solid transparent;
}

/* ---------- Boot loader ---------- */
.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--boot-bg);
  z-index: var(--z-toast);
  transition: opacity var(--dur-slow) var(--ease);
}
.boot.gone {
  opacity: 0;
  pointer-events: none;
}
.boot__mark {
  width: 56px;
  height: 56px;
  border-radius: var(--r-lg);
  background: #ffffff;
  color: #000;
  display: grid;
  place-items: center;
  font-weight: var(--fw-bold);
  font-size: 30px;
  letter-spacing: -0.04em;
  animation: bootpulse 1.4s var(--ease) infinite;
}
@keyframes bootpulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.9;
  }
  50% {
    transform: scale(0.94);
    opacity: 0.6;
  }
}

/* ---------- App shell ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
}
.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.app-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-8) var(--sp-16);
}
@media (max-width: 720px) {
  .page {
    padding: var(--sp-5) var(--sp-4) calc(var(--sp-12) + env(safe-area-inset-bottom));
  }
}

/* page header (per-view sticky title + actions) */
.page-head {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-2) 0 var(--sp-4);
  margin-bottom: var(--sp-2);
  background: linear-gradient(var(--bg) 70%, transparent);
}
.page-head__left {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
}
.page-head__icon {
  width: 38px;
  height: 38px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.page-head__titles {
  min-width: 0;
}
.page-head__title {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semi);
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.page-head__sub {
  font-size: var(--fs-sm);
  color: var(--ink-3);
  margin-top: 2px;
}
.page-head__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-shrink: 0;
}
@media (max-width: 720px) {
  .page-head__title {
    font-size: var(--fs-xl);
  }
  .page-head__icon {
    display: none;
  }
}

/* ---------- Sidebar ---------- */
.sidebar {
  display: flex;
  flex-direction: column;
  padding: var(--sp-5) var(--sp-3);
  border-right: 1px solid var(--line-soft);
  background: var(--bg);
  min-height: 0;
}
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3) var(--sp-5);
}
.sidebar__mark {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: var(--bg);
  display: grid;
  place-items: center;
  font-weight: var(--fw-bold);
  font-size: 16px;
  letter-spacing: -0.04em;
  flex-shrink: 0;
}
.sidebar__name {
  font-size: var(--fs-md);
  font-weight: var(--fw-semi);
  letter-spacing: -0.01em;
}
.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: var(--sp-2);
}
.sidebar__section-label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: var(--sp-4) var(--sp-3) var(--sp-1);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  width: 100%;
  text-align: left;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  position: relative;
}
.nav-item:hover {
  background: var(--fill-hover);
  color: var(--ink);
}
.nav-item.is-active {
  background: var(--surface-2);
  color: var(--ink);
}
.nav-item.is-active .nav-item__icon {
  color: var(--accent);
}
.nav-item__icon {
  display: grid;
  place-items: center;
  color: var(--ink-3);
  flex-shrink: 0;
  transition: color var(--dur-fast) var(--ease);
}
.nav-item:hover .nav-item__icon {
  color: var(--ink);
}
.nav-item__label {
  flex: 1;
}
.nav-item__count {
  font-size: var(--fs-xs);
  color: var(--ink-4);
  font-family: var(--mono);
  font-feature-settings: "tnum";
}

.sidebar__foot {
  margin-top: auto;
  padding-top: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.sidebar__controls {
  display: flex;
  gap: var(--sp-2);
  padding: 0 var(--sp-2);
}
.sidebar__controls .source {
  flex: 1;
  justify-content: center;
}
.mobile-topbar {
  display: none;
}
.mobile-topbar__name {
  font-weight: var(--fw-semi);
  letter-spacing: -0.01em;
}

/* user chip */
.user-chip {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2);
  border-radius: var(--r-md);
  border: 1px solid var(--line-soft);
  background: var(--surface);
  min-width: 0;
}
.user-chip__avatar {
  flex-shrink: 0;
}
.user-chip__meta {
  min-width: 0;
  flex: 1;
}
.user-chip__name {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-chip__sub {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* avatar */
.avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--r-pill);
  display: grid;
  place-items: center;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  color: #fff;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  background: var(--avatar-bg, var(--accent));
  overflow: hidden;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar--lg {
  width: 44px;
  height: 44px;
  font-size: var(--fs-md);
}
.avatar--sm {
  width: 22px;
  height: 22px;
  font-size: 10px;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-6);
  background: var(--frost);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line-soft);
  min-height: 60px;
}
.topbar__title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar__h {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semi);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.topbar__sub {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  margin-top: 1px;
}
.topbar__spacer {
  flex: 1;
}
.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* mobile brand shown when sidebar hidden */
.topbar__brand-mobile {
  display: none;
  align-items: center;
  gap: var(--sp-2);
  font-weight: var(--fw-semi);
  letter-spacing: -0.01em;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 34px;
  padding: 0 var(--sp-4);
  border-radius: var(--r-pill);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  letter-spacing: -0.01em;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
  border: 1px solid transparent;
  user-select: none;
}
.btn:active {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}
.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
}
.btn--secondary {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--line-soft);
}
.btn--secondary:hover:not(:disabled) {
  background: var(--fill-hover);
}
[data-theme="dark"] .btn--secondary {
  background: var(--surface-2);
  border-color: var(--line);
}
.btn--ghost {
  background: transparent;
  color: var(--ink-2);
}
.btn--ghost:hover:not(:disabled) {
  background: var(--fill-hover);
  color: var(--ink);
}
.btn--danger {
  background: var(--red-soft);
  color: var(--red);
}
.btn--danger:hover:not(:disabled) {
  background: var(--red);
  color: #fff;
}
.btn--sm {
  height: 28px;
  padding: 0 var(--sp-3);
  font-size: var(--fs-sm);
}
.btn--lg {
  height: 42px;
  padding: 0 var(--sp-6);
  font-size: var(--fs-base);
}
.btn--block {
  width: 100%;
}
.btn__icon {
  display: grid;
  place-items: center;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--r-pill);
  color: var(--ink-2);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
  flex-shrink: 0;
}
.icon-btn:hover {
  background: var(--fill-hover);
  color: var(--ink);
}
.icon-btn:active {
  transform: scale(0.94);
}
.icon-btn--sm {
  width: 28px;
  height: 28px;
}

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 var(--sp-2);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  letter-spacing: 0;
  background: var(--surface-2);
  color: var(--ink-2);
  white-space: nowrap;
}
.badge__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.badge--green {
  background: var(--green-soft);
  color: var(--green);
}
.badge--amber {
  background: var(--amber-soft);
  color: var(--amber);
}
.badge--red {
  background: var(--red-soft);
  color: var(--red);
}
.badge--violet {
  background: var(--violet-soft);
  color: var(--violet);
}
.badge--blue {
  background: var(--accent-soft);
  color: var(--accent);
}
.badge--ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-3);
}
.badge--lg {
  height: 24px;
  font-size: var(--fs-sm);
  padding: 0 var(--sp-3);
}

/* ---------- Segmented ---------- */
.segmented {
  display: inline-flex;
  padding: 2px;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  gap: 0;
}
.segmented__btn {
  padding: 5px var(--sp-3);
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--ink-3);
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.segmented__btn:hover {
  color: var(--ink);
}
.segmented__btn.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .segmented__btn.is-active {
  background: var(--surface-3);
}

/* ---------- Toggle (switch) ---------- */
.switch {
  position: relative;
  display: inline-flex;
  width: 36px;
  height: 22px;
  border-radius: var(--r-pill);
  background: var(--line-strong);
  transition: background var(--dur) var(--ease);
  flex-shrink: 0;
  cursor: pointer;
}
.switch.is-on {
  background: var(--green);
}
.switch__knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform var(--dur) var(--ease-out);
}
.switch.is-on .switch__knob {
  transform: translateX(14px);
}

/* ---------- Forms ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field__label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--ink-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.field__hint {
  font-size: var(--fs-xs);
  color: var(--ink-3);
}
.field__error {
  font-size: var(--fs-xs);
  color: var(--red);
}
.input,
.textarea,
.select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 9px var(--sp-3);
  font-size: var(--fs-md);
  color: var(--ink);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease);
  font-family: var(--sans);
}
.textarea {
  resize: vertical;
  min-height: 76px;
  line-height: var(--lh-normal);
}
.input::placeholder,
.textarea::placeholder {
  color: var(--ink-4);
}
.input:hover,
.textarea:hover,
.select:hover {
  border-color: var(--line-strong);
}
.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.input--error {
  border-color: var(--red);
}
.input--error:focus {
  box-shadow: 0 0 0 4px var(--red-soft);
}
.input--mono {
  font-family: var(--mono);
  font-feature-settings: "tnum";
  letter-spacing: -0.01em;
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--sp-3) center;
  padding-right: var(--sp-8);
  cursor: pointer;
}

/* input with affix */
.input-affix {
  position: relative;
  display: flex;
  align-items: center;
}
.input-affix__pre,
.input-affix__post {
  position: absolute;
  font-size: var(--fs-md);
  color: var(--ink-3);
  pointer-events: none;
}
.input-affix__pre {
  left: var(--sp-3);
}
.input-affix__post {
  right: var(--sp-3);
}
.input-affix .input {
  padding-left: calc(var(--sp-3) + var(--pre-w, 0px));
  padding-right: calc(var(--sp-3) + var(--post-w, 0px));
}
.input-affix .input--mono + .input-affix__post,
.input-affix__post.is-mono {
  font-family: var(--mono);
}

/* tag chips input */
.tag-input {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  min-height: 40px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.tag-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.tag-input__input {
  flex: 1;
  min-width: 80px;
  border: none;
  outline: none;
  background: transparent;
  font-size: var(--fs-md);
  padding: 3px 4px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 4px 0 8px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--ink-2);
}
.chip__remove {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: var(--ink-3);
}
.chip__remove:hover {
  background: var(--surface-3);
  color: var(--ink);
}

/* ---------- Cards / surfaces ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-xl);
  padding: var(--sp-5);
}
.card--flush {
  padding: 0;
  overflow: hidden;
}
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--line-soft);
}
.card__title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semi);
  letter-spacing: -0.01em;
}
.card__sub {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  margin-top: 2px;
}

/* metric tile */
.metric {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-xl);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
}
.metric__label {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.metric__value {
  font-family: var(--mono);
  font-feature-settings: "tnum";
  font-size: var(--fs-2xl);
  font-weight: var(--fw-medium);
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.1;
}
.metric__value--hero {
  font-size: var(--fs-hero);
  font-weight: var(--fw-regular);
  letter-spacing: -0.045em;
}
.metric__value--sm {
  font-size: var(--fs-lg);
}
.metric__delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
}
.metric__delta--up {
  color: var(--green);
}
.metric__delta--down {
  color: var(--red);
}
.metric__delta--flat {
  color: var(--ink-3);
}
.metric__foot {
  font-size: var(--fs-xs);
  color: var(--ink-3);
}

/* ---------- Keys view ---------- */
.filters {
  display: flex;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}
.filters__search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 220px;
  color: var(--ink-3);
}
.filters__search > svg {
  position: absolute;
  left: var(--sp-3);
  pointer-events: none;
}
.filters__search .filters__input {
  padding-left: calc(var(--sp-3) + 22px);
}
.filters__input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 9px var(--sp-3);
  font-size: var(--fs-md);
  color: var(--ink);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.filters__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.filters .select {
  width: auto;
  min-width: 140px;
}

/* detail */
.detail-id {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}
.detail-id__main {
  flex: 1;
  min-width: 0;
}
.detail-id__label {
  font-size: var(--fs-xl);
  font-weight: var(--fw-semi);
  letter-spacing: -0.02em;
}
.detail-id__sub {
  font-size: var(--fs-sm);
  color: var(--ink-3);
  margin-top: 2px;
}
.detail-actions {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.detail-actions .btn {
  flex: 1;
  min-width: 120px;
}

/* model chip multi-select */
.model-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.model-chip {
  padding: 6px var(--sp-3);
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-3);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  font-family: var(--mono);
  font-feature-settings: "tnum";
  transition: all var(--dur-fast) var(--ease);
}
.model-chip:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}
.model-chip.is-active {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}

/* responsive table column hiding */
@media (max-width: 920px) {
  .hide-md {
    display: none !important;
  }
}
@media (max-width: 720px) {
  .hide-sm {
    display: none !important;
  }
}

/* ---------- Grants view ---------- */
.unit-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--line-soft);
}
.unit-row:last-child {
  border-bottom: none;
}
.unit-row__amt {
  font-size: var(--fs-md);
  min-width: 90px;
}
.unit-row__period {
  font-size: var(--fs-sm);
  flex: 1;
  min-width: 0;
}
.unit-row__when {
  font-size: var(--fs-xs);
  width: 130px;
  text-align: right;
}

/* sent confirmation (grant create) */
.sent-confirm {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4) 0 var(--sp-2);
}
.sent-confirm__icon {
  width: 52px;
  height: 52px;
  border-radius: var(--r-lg);
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
}
.sent-confirm__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semi);
  letter-spacing: -0.02em;
  margin-top: var(--sp-1);
}
.sent-confirm__body {
  font-size: var(--fs-sm);
  color: var(--ink-3);
  line-height: var(--lh-normal);
  max-width: 340px;
}

/* ---------- Models view ---------- */
.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-4);
}
.model-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-xl);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.model-card:hover {
  border-color: var(--line-strong);
}
.model-card.is-disabled {
  opacity: 0.6;
}
.model-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}
.model-card__name {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semi);
  letter-spacing: -0.02em;
}
.model-card__pricing {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
}
.price-cell {
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-3);
}
.price-cell__label {
  font-size: 11px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.price-cell__value {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  margin-top: 2px;
  white-space: nowrap;
}
.model-card__meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  flex-wrap: wrap;
}
.dot-sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--ink-4);
  flex-shrink: 0;
}

/* ---------- Tables ---------- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-xl);
  overflow: hidden;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-md);
}
.table thead th {
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
  position: sticky;
  top: 0;
  white-space: nowrap;
}
.table tbody td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  color: var(--ink);
}
.table tbody tr:last-child td {
  border-bottom: none;
}
.table tbody tr {
  transition: background var(--dur-fast) var(--ease);
  cursor: pointer;
}
.table tbody tr:hover {
  background: var(--fill-hover);
}
.table .col-num,
.table .num {
  text-align: right;
}
.table th.num {
  text-align: right;
}
.table--loose tbody td {
  padding: var(--sp-4);
}

/* key cell — redacted token + label */
.keycell {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
}
.keycell__main {
  min-width: 0;
}
.keycell__label {
  font-weight: var(--fw-semi);
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.keycell__sub {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tok {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-feature-settings: "tnum";
  font-size: var(--fs-xs);
  color: var(--ink-3);
  background: var(--surface-2);
  padding: 3px 7px;
  border-radius: var(--r-xs);
  letter-spacing: -0.01em;
}

/* ---------- Sheet (right-side drawer) ---------- */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: var(--z-overlay);
  opacity: 0;
  animation: scrim-in var(--dur) var(--ease) forwards;
}
.scrim.closing {
  animation: scrim-out var(--dur) var(--ease) forwards;
}
@keyframes scrim-in {
  to {
    opacity: 1;
  }
}
@keyframes scrim-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}
[data-theme="dark"] .scrim {
  background: rgba(0, 0, 0, 0.6);
}
.sheet {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: 100%;
  background: var(--bg);
  border-left: 1px solid var(--line-soft);
  box-shadow: var(--shadow-sheet);
  z-index: var(--z-sheet);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  animation: sheet-in var(--dur-slow) var(--ease-out) forwards;
}
.sheet.closing {
  animation: sheet-out var(--dur) var(--ease) forwards;
}
@keyframes sheet-in {
  to {
    transform: translateX(0);
  }
}
@keyframes sheet-out {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(100%);
  }
}
.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--line-soft);
  flex-shrink: 0;
}
.sheet__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semi);
  letter-spacing: -0.02em;
}
.sheet__sub {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  margin-top: 2px;
}
.sheet__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}
.sheet__foot {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--line-soft);
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
  flex-shrink: 0;
  background: var(--bg);
}

/* ---------- Modal (centered) ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: var(--sp-5);
}
.modal__panel {
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  padding: var(--sp-6);
  animation: modal-in var(--dur-slow) var(--ease-out);
}
@keyframes modal-in {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
}
.modal__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semi);
  letter-spacing: -0.02em;
  margin-bottom: var(--sp-2);
}
.modal__body {
  color: var(--ink-2);
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
}
.modal__foot {
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
  margin-top: var(--sp-6);
}

/* ---------- Toast ---------- */
.toast-rail {
  position: fixed;
  bottom: var(--sp-5);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: calc(100% - var(--sp-8));
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  background: var(--ink);
  color: var(--bg);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  pointer-events: auto;
  animation: toast-in var(--dur-slow) var(--ease-out);
  max-width: 100%;
}
.toast.is-leaving {
  animation: toast-out var(--dur) var(--ease) forwards;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
}
@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
}
.toast__icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.toast--success .toast__icon {
  color: var(--green);
}
.toast--error .toast__icon {
  color: var(--red);
}
[data-theme="dark"] .toast {
  background: var(--surface-3);
  color: var(--ink);
  border: 1px solid var(--line);
}

/* ---------- Empty state ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-12) var(--sp-6);
  gap: var(--sp-3);
}
.empty__icon {
  width: 48px;
  height: 48px;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  color: var(--ink-3);
  display: grid;
  place-items: center;
  margin-bottom: var(--sp-1);
}
.empty__title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semi);
}
.empty__body {
  font-size: var(--fs-sm);
  color: var(--ink-3);
  max-width: 360px;
}

/* skeleton */
.skel {
  background: linear-gradient(
    90deg,
    var(--surface-2) 0%,
    var(--surface-3) 50%,
    var(--surface-2) 100%
  );
  background-size: 200% 100%;
  animation: skel 1.3s var(--ease) infinite;
  border-radius: var(--r-xs);
}
@keyframes skel {
  to {
    background-position: -200% 0;
  }
}

/* ---------- Charts ---------- */
.chart {
  width: 100%;
  display: block;
}
.chart--area {
  height: 200px;
}
.barlist {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.barlist__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-3);
  padding: 8px var(--sp-2);
  border-radius: var(--r-sm);
  position: relative;
  cursor: default;
  transition: background var(--dur-fast) var(--ease);
}
.barlist__row:hover {
  background: var(--fill-hover);
}
.barlist__label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  z-index: 1;
}
.barlist__label .tok {
  background: rgba(255, 255, 255, 0.6);
}
[data-theme="dark"] .barlist__label .tok {
  background: var(--surface-3);
}
.barlist__vals {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  z-index: 1;
}
.barlist__fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--accent-soft);
  border-radius: var(--r-sm);
  transition: width var(--dur-slow) var(--ease-out);
}
.barlist__val {
  font-family: var(--mono);
  font-feature-settings: "tnum";
  font-size: var(--fs-sm);
  color: var(--ink-2);
  min-width: 64px;
  text-align: right;
}
.barlist__count {
  font-size: var(--fs-xs);
  color: var(--ink-4);
  font-family: var(--mono);
  font-feature-settings: "tnum";
}

/* ---------- Token reveal card ---------- */
.reveal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.reveal__token {
  font-family: var(--mono);
  font-feature-settings: "tnum";
  font-size: var(--fs-md);
  letter-spacing: -0.01em;
  word-break: break-all;
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  user-select: all;
  color: var(--ink);
}
.reveal__warn {
  display: flex;
  gap: var(--sp-2);
  align-items: flex-start;
  font-size: var(--fs-sm);
  color: var(--amber);
}

/* ---------- Copy button inline ---------- */
.copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  color: var(--ink-3);
  padding: 4px 8px;
  border-radius: var(--r-xs);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.copy:hover {
  background: var(--surface-2);
  color: var(--ink);
}

/* ---------- Data-source pill (Demo/Live) ---------- */
.source {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 30px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.source:hover {
  background: var(--fill-hover);
}
.source__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  flex-shrink: 0;
}
.source.is-live .source__dot {
  background: var(--green);
}
.source.is-demo {
  color: var(--amber);
}
.source.is-live {
  color: var(--green);
}

/* ---------- Misc layout helpers ---------- */
.row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.row--between {
  justify-content: space-between;
}
.row--wrap {
  flex-wrap: wrap;
}
.col {
  display: flex;
  flex-direction: column;
}
.col--gap {
  gap: var(--sp-3);
}
.col--gap-lg {
  gap: var(--sp-5);
}
.grid {
  display: grid;
  gap: var(--sp-4);
}
.grid--metrics {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.grid--2 {
  grid-template-columns: repeat(2, 1fr);
}
@media (max-width: 640px) {
  .grid--2 {
    grid-template-columns: 1fr;
  }
}
.muted {
  color: var(--ink-3);
}
.tnum {
  font-family: var(--mono);
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}
.nowrap {
  white-space: nowrap;
}
.truncate {
  min-width: 0;
}
.divider {
  height: 1px;
  background: var(--line-soft);
  border: none;
  margin: 0;
}
.section-label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stack-list {
  list-style: none;
  display: flex;
  flex-direction: column;
}
.kv {
  display: grid;
  grid-template-columns: minmax(120px, auto) 1fr;
  gap: var(--sp-2) var(--sp-4);
  align-items: baseline;
}
.kv__k {
  font-size: var(--fs-sm);
  color: var(--ink-3);
}
.kv__v {
  font-size: var(--fs-sm);
  color: var(--ink);
  min-width: 0;
  word-break: break-word;
}
.kv__v.num {
  text-align: left;
}

/* timeline */
.timeline {
  display: flex;
  flex-direction: column;
  position: relative;
  padding-left: var(--sp-5);
}
.timeline__item {
  position: relative;
  padding-bottom: var(--sp-4);
}
.timeline__item:last-child {
  padding-bottom: 0;
}
.timeline__item::before {
  content: "";
  position: absolute;
  left: -15px;
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--ink-4);
}
.timeline__item::after {
  content: "";
  position: absolute;
  left: -12px;
  top: 12px;
  bottom: -4px;
  width: 2px;
  background: var(--line-soft);
}
.timeline__item:last-child::after {
  display: none;
}
.timeline__title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}
.timeline__meta {
  font-size: var(--fs-xs);
  color: var(--ink-3);
}

/* ---------- Responsive: sidebar → bottom tab bar ---------- */
.mobile-tabs {
  display: none;
}
@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
  }
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    padding-top: calc(var(--sp-2) + env(safe-area-inset-top));
    background: var(--frost);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--line-soft);
    min-height: 52px;
  }
  .topbar__brand-mobile {
    display: flex;
  }
  .topbar {
    padding-left: var(--sp-4);
    padding-right: var(--sp-4);
  }
  .mobile-tabs {
    display: flex;
    position: sticky;
    bottom: 0;
    z-index: var(--z-sticky);
    background: var(--frost);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--line-soft);
    padding: 6px env(safe-area-inset-left) calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .mobile-tabs .nav-item {
    flex-direction: column;
    gap: 2px;
    padding: 4px 10px;
    font-size: var(--fs-xs);
    border-radius: var(--r-md);
    flex: 1;
    justify-content: center;
  }
  .mobile-tabs .nav-item__label {
    font-size: 10px;
  }
  .mobile-tabs .nav-item__count {
    display: none;
  }
}

/* very small: condense hero */
@media (max-width: 480px) {
  .metric__value--hero {
    font-size: 40px;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .boot__mark {
    animation: none;
  }
}

/* utility: fade content in on view mount */
.fade-in {
  animation: fade-in var(--dur) var(--ease) both;
}
@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Notice / copy blocks ---------- */
.notice {
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
}
.copy-line {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-3);
  min-width: 0;
}
.copy-line code,
.copy-line pre {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: auto;
  color: var(--ink);
  font-size: var(--fs-xs);
  white-space: nowrap;
}
.copy-line--block {
  align-items: stretch;
  flex-direction: column;
  padding: var(--sp-3);
}
.copy-line--block pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-elev);
  border-radius: var(--r-sm);
  padding: var(--sp-3);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.load-more {
  display: flex;
  justify-content: center;
  padding: var(--sp-4);
  border-top: 1px solid var(--line-soft);
}

/* ---------- Unified recipient workspace ---------- */
.user-hero {
  position: relative;
  overflow: hidden;
  padding: var(--sp-6);
  border-color: color-mix(in srgb, var(--accent) 24%, var(--line-soft));
  box-shadow: var(--shadow-md);
}
.user-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(80% 130% at 0% 0%, var(--accent-soft), transparent 58%);
  pointer-events: none;
}
.user-hero > * { position: relative; }
.user-hero__label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-3);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.user-hero__amount {
  margin-top: var(--sp-3);
  font-size: clamp(38px, 8vw, var(--fs-hero));
  font-weight: var(--fw-regular);
  letter-spacing: -0.055em;
  line-height: 1;
}
.user-hero__sub {
  margin-top: var(--sp-2);
  color: var(--ink-3);
  font-size: var(--fs-sm);
}
.user-hero__actions {
  margin-top: var(--sp-5);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  align-items: center;
}
.user-hero__ok {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--green);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}
.connect-stack,
.user-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-2);
}
.user-list { gap: 1px; }
.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  transition: background var(--dur-fast) var(--ease);
}
.user-row:hover { background: var(--surface-2); }
.user-row.is-muted { opacity: 0.62; }
.user-row__main,
.user-row__aside,
.user-row__actions {
  min-width: 0;
  display: flex;
}
.user-row__main {
  flex: 1;
  flex-direction: column;
  gap: 3px;
}
.user-row__title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  font-weight: var(--fw-semi);
}
.user-row__sub,
.user-row__meta {
  color: var(--ink-3);
  font-size: var(--fs-xs);
}
.user-row__aside {
  align-items: flex-end;
  flex-direction: column;
  gap: var(--sp-2);
}
.user-row__balance {
  font-weight: var(--fw-semi);
}
.user-row__actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--sp-2);
}
@media (max-width: 640px) {
  .user-row,
  .user-row__aside {
    align-items: stretch;
  }
  .user-row {
    flex-direction: column;
  }
  .user-row__actions {
    justify-content: flex-start;
  }
}

/* ---------- Locked / auth stage ---------- */
.locked-stage {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--sp-6);
  background: radial-gradient(120% 80% at 50% -10%, var(--surface-2) 0%, var(--bg) 60%);
}
.locked-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-8);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  animation: modal-in var(--dur-slow) var(--ease-out);
}
.locked-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.locked-brand__name {
  font-weight: var(--fw-semi);
  font-size: var(--fs-lg);
  letter-spacing: -0.02em;
}
.locked-hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) 0 var(--sp-2);
}
.locked-hero__icon {
  width: 56px;
  height: 56px;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  color: var(--ink-2);
  display: grid;
  place-items: center;
}
.locked-hero__title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-semi);
  letter-spacing: -0.02em;
}
.locked-hero__body {
  color: var(--ink-3);
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  max-width: 300px;
}
.locked-demo {
  text-align: center;
  padding-top: var(--sp-3);
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.locked-demo__line {
  font-size: var(--fs-xs);
  color: var(--ink-3);
}
.link-btn {
  font-size: var(--fs-sm);
  color: var(--accent);
  font-weight: var(--fw-medium);
  padding: 4px;
}
.link-btn:hover {
  text-decoration: underline;
}

/* ---------- Hero figure (credit ledger signature) ---------- */
.hero {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-2xl);
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  position: relative;
  overflow: hidden;
}
.hero__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.hero__label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.hero__range {
  font-size: var(--fs-xs);
  color: var(--ink-4);
}
.hero__figure {
  font-size: var(--fs-hero);
  font-weight: var(--fw-regular);
  letter-spacing: -0.045em;
  line-height: 1;
  color: var(--ink);
}
@media (max-width: 480px) {
  .hero {
    padding: var(--sp-5);
  }
  .hero__figure {
    font-size: 42px;
  }
}
.hero__spark {
  margin: 0 calc(-1 * var(--sp-6));
  margin-top: var(--sp-1);
  margin-bottom: calc(-1 * var(--sp-6));
  padding: 0 var(--sp-6) var(--sp-6);
}
.hero__spark svg {
  display: block;
}

/* partial rollup banner */
.partial {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--amber-soft);
  border-radius: var(--r-lg);
  color: var(--amber);
  font-size: var(--fs-sm);
}
.partial__icon {
  display: grid;
  place-items: center;
  animation: spin 1.4s linear infinite;
}
.partial__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.partial__sub {
  font-size: var(--fs-xs);
  color: var(--ink-3);
}

/* ============================================================
   Floating layers — popovers, dropdowns, menus
   position: fixed; viewport-aware; glued to the trigger.
   ============================================================ */
.float {
  position: fixed;
  top: 0;
  left: 0;
  z-index: var(--z-overlay);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(4px) scale(0.985);
  transform-origin: top center;
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  pointer-events: none;
}
.float.is-open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.float.is-closing {
  opacity: 0;
  transform: translateY(2px) scale(0.99);
}
.float[data-side="top"] {
  transform-origin: bottom center;
}

/* ---------- Custom dropdown (select replacement) ---------- */
.dropdown {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 38px;
  padding: 0 var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-size: var(--fs-md);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease);
}
.dropdown:hover {
  border-color: var(--line-strong);
}
.dropdown:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.dropdown[aria-expanded="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.dropdown__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dropdown__caret {
  display: grid;
  place-items: center;
  color: var(--ink-3);
  transition: transform var(--dur-fast) var(--ease);
}
.dropdown[aria-expanded="true"] .dropdown__caret {
  transform: rotate(180deg);
}
.filters .dropdown {
  min-width: 150px;
}

.dropdown__panel {
  min-width: 188px;
  max-width: 320px;
  padding: 5px;
}
.dropdown__list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: min(52vh, 380px);
  overflow-y: auto;
}
.dropdown__item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: var(--fs-md);
  color: var(--ink-2);
  cursor: pointer;
  position: relative;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.dropdown__item:hover,
.dropdown__item:focus-visible {
  background: var(--fill-hover);
  color: var(--ink);
  outline: none;
}
.dropdown__item.is-selected {
  color: var(--ink);
}
.dropdown__item-icon {
  display: grid;
  place-items: center;
  color: var(--ink-3);
  flex-shrink: 0;
}
.dropdown__item-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.dropdown__item-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dropdown__item-hint {
  font-size: var(--fs-xs);
  color: var(--ink-4);
}
.dropdown__item-check {
  display: grid;
  place-items: center;
  color: var(--accent);
  flex-shrink: 0;
}

/* ---------- Account menu ---------- */
.menu {
  width: 272px;
  padding: 6px;
}
.menu__inner {
  display: flex;
  flex-direction: column;
}
.menu__header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 8px 8px 4px;
  min-width: 0;
}
.menu__header-meta {
  min-width: 0;
}
.menu__header-name {
  font-size: var(--fs-md);
  font-weight: var(--fw-semi);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.menu__header-email {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.menu__role {
  padding: 2px 8px 4px;
}
.menu__sep {
  border: none;
  border-top: 1px solid var(--line-soft);
  margin: 5px 4px;
  height: 0;
}

.menu__appearance {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 6px 8px;
}
.menu__appearance-label {
  font-size: var(--fs-sm);
  color: var(--ink-3);
}
.menu__theme {
  display: inline-flex;
  padding: 2px;
  background: var(--surface-2);
  border-radius: var(--r-pill);
}
.menu__theme-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 28px;
  border-radius: var(--r-pill);
  color: var(--ink-3);
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.menu__theme-btn:hover {
  color: var(--ink);
}
.menu__theme-btn.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .menu__theme-btn.is-active {
  background: var(--surface-3);
}

.menu-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  font-size: var(--fs-md);
  color: var(--ink-2);
  text-align: left;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.menu-row:hover {
  background: var(--fill-hover);
  color: var(--ink);
  text-decoration: none;
}
.menu-row__icon {
  display: grid;
  place-items: center;
  color: var(--ink-3);
  flex-shrink: 0;
  transition: color var(--dur-fast) var(--ease);
}
.menu-row:hover .menu-row__icon {
  color: var(--ink);
}
.menu-row__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.menu-row__label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.menu-row__sub {
  font-size: var(--fs-xs);
  color: var(--ink-4);
}
.menu-row__trailing {
  display: grid;
  place-items: center;
  color: var(--ink-4);
  flex-shrink: 0;
}
.menu-row.is-danger,
.menu-row.is-danger .menu-row__icon {
  color: var(--red);
}
.menu-row.is-danger:hover,
.menu-row.is-danger:hover .menu-row__icon {
  background: var(--red-soft);
  color: var(--red);
}

/* ---------- Identity affordances ---------- */
button.user-chip {
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
button.user-chip:hover {
  background: var(--fill-hover);
}
.user-chip__chev {
  display: grid;
  place-items: center;
  color: var(--ink-4);
  transition: transform var(--dur-fast) var(--ease);
  flex-shrink: 0;
}
.user-chip[aria-expanded="true"] .user-chip__chev {
  transform: rotate(180deg);
}
.avatar-btn {
  display: inline-grid;
  place-items: center;
  padding: 2px;
  border-radius: var(--r-pill);
  flex-shrink: 0;
  transition: box-shadow var(--dur-fast) var(--ease);
}
.avatar-btn[aria-expanded="true"] {
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* ---------- Grant sent: what happens next ---------- */
.next-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.next-step {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: 8px 4px;
}
.next-step__icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink-3);
  flex-shrink: 0;
}
.next-step__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  padding-top: 4px;
}
.next-step__title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}
.next-step__body {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  line-height: var(--lh-normal);
}

/* ---------- Loading states ---------- */
/* dim a results region while its data refreshes, instead of a hard skeleton flash */
.is-loading {
  opacity: 0.45;
  transition: opacity var(--dur-fast) var(--ease);
  pointer-events: none;
}
/* gentle spin utility for inline loaders */
.icon.spin {
  animation: spin 1s linear infinite;
  transform-origin: 50% 50%;
}
