:root {
  color-scheme: dark;
  font-family: "SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
  --bg: #07101c;
  --bg-raised: #0b1625;
  --surface: rgba(16, 29, 47, .78);
  --surface-solid: #111e30;
  --surface-raised: rgba(24, 40, 62, .88);
  --surface-muted: rgba(255, 255, 255, .035);
  --surface-hover: rgba(255, 255, 255, .055);
  --text: #f4f7fb;
  --text-strong: #ffffff;
  --muted: #9aa9bd;
  --faint: #718198;
  --line: rgba(194, 214, 239, .12);
  --line-strong: rgba(194, 214, 239, .21);
  --primary: #3b82f6;
  --primary-hover: #5595fa;
  --primary-soft: rgba(59, 130, 246, .14);
  --primary-line: rgba(96, 165, 250, .36);
  --success: #5bd79a;
  --success-bg: rgba(32, 176, 107, .13);
  --warning: #e6b35a;
  --warning-bg: rgba(216, 148, 38, .13);
  --danger: #ff7b74;
  --danger-bg: rgba(229, 72, 67, .12);
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 16px;
  --shadow-sm: 0 8px 24px rgba(0, 0, 0, .16);
  --shadow: 0 24px 64px rgba(0, 0, 0, .28);
  --glass-blur: blur(24px) saturate(130%);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #edf3fa;
  --bg-raised: #e6edf7;
  --surface: rgba(255, 255, 255, .76);
  --surface-solid: #ffffff;
  --surface-raised: rgba(255, 255, 255, .9);
  --surface-muted: rgba(23, 51, 88, .035);
  --surface-hover: rgba(32, 76, 132, .055);
  --text: #203047;
  --text-strong: #0c1728;
  --muted: #61718a;
  --faint: #8490a2;
  --line: rgba(40, 68, 105, .12);
  --line-strong: rgba(40, 68, 105, .21);
  --primary: #1769e0;
  --primary-hover: #0d5bc7;
  --primary-soft: rgba(23, 105, 224, .09);
  --primary-line: rgba(23, 105, 224, .28);
  --success: #0a7b4d;
  --success-bg: rgba(12, 146, 89, .09);
  --warning: #9a6516;
  --warning-bg: rgba(187, 119, 17, .1);
  --danger: #c93832;
  --danger-bg: rgba(201, 56, 50, .08);
  --shadow-sm: 0 8px 24px rgba(49, 74, 111, .08);
  --shadow: 0 24px 64px rgba(49, 74, 111, .14);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% -10%, rgba(42, 111, 219, .16), transparent 34rem),
    radial-gradient(circle at 88% 0%, rgba(78, 101, 173, .11), transparent 31rem),
    var(--bg);
  color: var(--text);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; }
button, input, select, summary, a { -webkit-tap-highlight-color: transparent; }
.icon {
  display: block;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

button, .button {
  position: relative;
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  overflow: hidden;
  padding: 9px 15px;
  border: 1px solid rgba(118, 173, 255, .44);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #438bfa, #246ce0);
  color: #fff;
  box-shadow: 0 7px 18px rgba(21, 91, 205, .22);
  font-weight: 680;
  letter-spacing: -.01em;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: transform 180ms var(--ease-out), border-color 180ms ease, background-color 180ms ease, box-shadow 180ms ease, color 180ms ease;
}
button::after, .button::after {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255, 255, 255, .2), transparent 58%);
  content: "";
  opacity: 0;
  transform: scale(.72);
  transition: opacity 160ms ease, transform 220ms var(--ease-out);
  pointer-events: none;
}
button:hover, .button:hover {
  border-color: rgba(145, 190, 255, .62);
  background: linear-gradient(180deg, #5598fa, #2c73e5);
  box-shadow: 0 10px 24px rgba(21, 91, 205, .28);
  transform: translateY(-1px);
}
button:active, .button:active { transform: translateY(0) scale(.985); }
button:active::after, .button:active::after { opacity: 1; transform: scale(1.1); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
button:focus-visible, .button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 34%, transparent);
  outline-offset: 2px;
}
.secondary {
  border-color: var(--line-strong);
  background: var(--surface-muted);
  color: var(--text);
  box-shadow: none;
}
.secondary:hover {
  border-color: var(--primary-line);
  background: var(--surface-hover);
  color: var(--text-strong);
  box-shadow: var(--shadow-sm);
}
.danger {
  border-color: color-mix(in srgb, var(--danger) 36%, transparent);
  background: var(--danger-bg);
  color: var(--danger);
  box-shadow: none;
}
.danger:hover {
  border-color: color-mix(in srgb, var(--danger) 58%, transparent);
  background: color-mix(in srgb, var(--danger-bg) 80%, var(--surface-hover));
  color: var(--danger);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--danger) 13%, transparent);
}
.icon-button { width: 42px; padding: 0; }
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--text-strong);
  color: var(--bg);
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.shell { min-height: 100vh; }
.auth-scene {
  position: relative;
  isolation: isolate;
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: space-between;
  gap: clamp(48px, 8vw, 144px);
  overflow: hidden;
  padding: clamp(32px, 6vw, 88px);
}
.auth-atmosphere {
  position: absolute;
  z-index: -1;
  inset: -18%;
  background:
    radial-gradient(circle at 75% 42%, rgba(57, 132, 247, .21), transparent 22%),
    radial-gradient(circle at 25% 65%, rgba(80, 102, 196, .14), transparent 27%);
  filter: blur(18px);
  animation: atmosphere-drift 14s ease-in-out infinite alternate;
}
.auth-context { max-width: 620px; flex: 1 1 620px; padding-left: clamp(0px, 3vw, 44px); }
.context-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 28px;
  color: color-mix(in srgb, var(--primary) 70%, var(--text));
  font-size: .82rem;
  font-weight: 700;
}
.context-chip span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--success) 12%, transparent);
}
.auth-context h2 {
  max-width: none;
  margin: 0 0 22px;
  color: var(--text-strong);
  font-size: clamp(3rem, 6vw, 5.2rem);
  font-weight: 660;
  letter-spacing: -.04em;
  line-height: .98;
  white-space: nowrap;
}
.auth-context > p { max-width: 40rem; margin: 0; color: var(--muted); font-size: clamp(1rem, 1.5vw, 1.18rem); line-height: 1.8; }
.context-ledger { display: flex; gap: 24px; margin-top: 44px; color: var(--faint); font-size: .82rem; }
.context-ledger span { position: relative; padding-left: 13px; }
.context-ledger span::before { position: absolute; top: .65em; left: 0; width: 4px; height: 4px; border-radius: 50%; background: currentColor; content: ""; }
.auth-card {
  position: absolute;
  top: 50%;
  right: clamp(32px, 7vw, 112px);
  width: min(40vw, 500px);
  padding: clamp(28px, 4vw, 42px);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  transform: translateY(-50%);
  animation: auth-arrive 620ms var(--ease-out) both;
}
.auth-card::before {
  position: absolute;
  inset: 0 14% auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .4), transparent);
  content: "";
}
.brand-lockup { display: flex; align-items: center; gap: 13px; margin-bottom: 38px; }
.brand-lockup h1 { margin: 0 0 2px; color: var(--text-strong); font-size: 1.08rem; letter-spacing: -.02em; }
.brand-lockup p { margin: 0; color: var(--muted); font-size: .8rem; }
.brand-mark, .topbar-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(144, 190, 255, .38);
  border-radius: 12px;
  background: linear-gradient(145deg, #4796ff, #1762d9);
  color: #fff;
  box-shadow: 0 10px 24px rgba(25, 94, 205, .26);
}
.brand-mark .icon { width: 20px; height: 20px; }
.auth-heading { margin-bottom: 24px; }
.auth-heading h2 { margin: 0 0 6px; color: var(--text-strong); font-size: 1.75rem; letter-spacing: -.03em; }
.auth-heading p { margin: 0; color: var(--muted); }
.auth-card form { display: grid; gap: 16px; }
.auth-card button { width: 100%; margin-top: 4px; }
.auth-note {
  margin: 24px 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: .76rem;
  text-align: center;
}
#totp-qr {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 18px auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
#totp-secret { display: inline-block; max-width: 100%; overflow-wrap: anywhere; user-select: all; }

.app-atmosphere {
  position: fixed;
  z-index: -1;
  inset: 0;
  background:
    radial-gradient(circle at 82% -8%, rgba(49, 120, 226, .13), transparent 31rem),
    radial-gradient(circle at 8% 72%, rgba(63, 83, 158, .08), transparent 26rem);
  pointer-events: none;
}
.topbar {
  position: sticky;
  z-index: 50;
  top: 0;
  display: grid;
  min-height: 68px;
  grid-template-columns: max-content minmax(320px, auto) minmax(190px, 1fr) max-content;
  align-items: center;
  gap: 16px;
  margin: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  box-shadow: 0 12px 36px rgba(0, 0, 0, .12);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; min-width: max-content; padding-right: 3px; }
.topbar-mark { width: 36px; height: 36px; border-radius: 11px; box-shadow: 0 8px 18px rgba(25, 94, 205, .2); }
.topbar-mark .icon { width: 17px; height: 17px; }
.topbar-brand > span:last-child { display: grid; }
.topbar-brand strong { color: var(--text-strong); font-size: .88rem; letter-spacing: -.01em; }
.topbar-brand small { color: var(--faint); font-size: .68rem; }
.topbar nav { display: flex; min-width: 0; gap: 3px; overflow-x: auto; scrollbar-width: none; }
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav button {
  min-height: 40px;
  flex: 0 0 auto;
  padding: 8px 11px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  white-space: nowrap;
}
.topbar nav button .icon { width: 16px; height: 16px; }
.topbar nav button:hover { border-color: var(--line); background: var(--surface-hover); color: var(--text-strong); box-shadow: none; transform: none; }
.topbar nav button.active { border-color: var(--primary-line); background: var(--primary-soft); color: color-mix(in srgb, var(--primary) 72%, var(--text)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04); }
.command-search, .ledger-search {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--faint);
}
.command-search { max-width: 460px; justify-self: end; }
.command-search input, .ledger-search input {
  min-width: 0;
  min-height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.command-search input:focus, .ledger-search input:focus { box-shadow: none; }
.command-search:focus-within, .ledger-search:focus-within { border-color: var(--primary-line); background: var(--primary-soft); }
.command-search kbd {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--faint);
  font: inherit;
  font-size: .68rem;
}
.topbar-tools { display: flex; align-items: center; gap: 7px; }
.theme-icon-sun { display: none; }
:root[data-theme="light"] .theme-icon-moon { display: none; }
:root[data-theme="light"] .theme-icon-sun { display: block; }
.user-menu { position: relative; }
.user-menu summary {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  list-style: none;
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--surface-hover); }
.user-menu summary > .icon { width: 14px; height: 14px; color: var(--faint); }
.user-avatar {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border: 1px solid var(--primary-line);
  border-radius: 50%;
  background: var(--primary-soft);
  color: color-mix(in srgb, var(--primary) 68%, var(--text));
  font-size: .76rem;
  font-weight: 780;
}
#current-user { max-width: 150px; overflow: hidden; color: var(--muted); font-size: .74rem; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-body {
  position: absolute;
  z-index: 60;
  top: calc(100% + 9px);
  right: 0;
  width: 180px;
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-raised);
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass-blur);
  animation: menu-arrive 180ms var(--ease-out);
}
.user-menu-body button { width: 100%; justify-content: flex-start; }
.network-progress {
  position: fixed;
  z-index: 80;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--primary);
  box-shadow: 0 0 12px color-mix(in srgb, var(--primary) 58%, transparent);
  opacity: 0;
  transform: scaleX(0);
  transform-origin: left;
}
.network-busy .network-progress { opacity: 1; transform: scaleX(.72); transition: transform 8s cubic-bezier(.1, .7, .2, 1), opacity 120ms ease; }

#main-content { min-height: calc(100vh - 88px); }
.view {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 64px;
}
.view-enter { animation: view-arrive 260ms var(--ease-out) both; }
.narrow-view { width: min(800px, calc(100% - 40px)); }
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}
.page-kicker { margin: 0 0 6px; color: var(--primary); font-size: .75rem; font-weight: 740; }
h1, h2, h3 { color: var(--text-strong); }
h2 { margin: 0 0 5px; font-size: clamp(1.65rem, 2.4vw, 2.1rem); font-weight: 670; letter-spacing: -.03em; line-height: 1.15; }
h3 { margin: 0; font-size: 1rem; font-weight: 680; letter-spacing: -.015em; }
.muted { margin: 3px 0 0; color: var(--muted); }
.content-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin: 30px 2px 12px;
}
.content-head .muted { font-size: .84rem; }
.settings-block-head { margin-top: 38px; }

.panel {
  width: 100%;
  margin: 0 0 20px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
form { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); align-items: end; }
.compact { max-width: 720px; }
label { display: grid; gap: 7px; color: color-mix(in srgb, var(--text) 90%, var(--muted)); font-size: .82rem; font-weight: 650; }
input, select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface-solid) 72%, transparent);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025);
  outline: none;
  transition: border-color 170ms ease, background-color 170ms ease, box-shadow 170ms ease;
}
input::placeholder { color: var(--faint); }
input:hover, select:hover { border-color: color-mix(in srgb, var(--line-strong) 65%, var(--primary)); }
input:focus, select:focus {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--surface-solid) 88%, transparent);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
select { color-scheme: inherit; }

.info-strip, .alert {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin: 0 0 20px;
  padding: 14px 16px;
  border: 1px solid var(--primary-line);
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--text);
}
.info-strip strong, .alert strong { flex: 0 0 auto; color: color-mix(in srgb, var(--primary) 58%, var(--text-strong)); }
.alert-danger { border-color: color-mix(in srgb, var(--danger) 32%, transparent); background: var(--danger-bg); color: color-mix(in srgb, var(--danger) 60%, var(--text)); }
.alert-danger strong { color: var(--danger); }
.error { color: var(--danger); }
#login-error { margin: 12px 0 0; animation: error-nudge 260ms var(--ease-out); }
#login-error:empty { display: none; }

.segmented {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-muted);
}
.segmented button {
  min-height: 38px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}
.segmented button:hover { border-color: transparent; background: var(--surface-hover); color: var(--text); box-shadow: none; transform: none; }
.segmented button.active { border-color: var(--primary-line); background: var(--primary-soft); color: color-mix(in srgb, var(--primary) 62%, var(--text)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04); }

.status-overview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px);
}
.overview-item {
  position: relative;
  display: grid;
  min-height: 94px;
  align-content: center;
  gap: 6px;
  padding: 18px 22px;
  border-right: 1px solid var(--line);
}
.overview-item:last-child { border-right: 0; }
.overview-item::before { position: absolute; top: 22px; left: 10px; width: 3px; height: 28px; border-radius: 3px; background: var(--muted); content: ""; opacity: .55; }
.overview-item.success::before { background: var(--success); }
.overview-item.warning::before { background: var(--warning); }
.overview-item.accent::before { background: var(--primary); }
.overview-item span { color: var(--muted); font-size: .76rem; }
.overview-item strong { color: var(--text-strong); font-size: 1.55rem; font-weight: 680; letter-spacing: -.03em; line-height: 1; }

.onboard-shell {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px);
}
.onboard-shell > summary {
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 16px;
  color: var(--text);
  cursor: pointer;
  list-style: none;
}
.onboard-shell > summary::-webkit-details-marker { display: none; }
.onboard-shell > summary > span { display: inline-flex; align-items: center; gap: 9px; color: color-mix(in srgb, var(--primary) 68%, var(--text)); font-weight: 700; }
.onboard-shell > summary > span .icon { width: 17px; height: 17px; }
.onboard-shell > summary small { color: var(--muted); font-size: .78rem; }
.onboard-shell[open] > summary { border-bottom: 1px solid var(--line); background: var(--primary-soft); }
.onboard-shell-body { padding: 18px; animation: sheet-arrive 240ms var(--ease-out); }
.onboard-shell .panel { margin-bottom: 0; padding: 0; border: 0; background: transparent; box-shadow: none; backdrop-filter: none; }
.onboard-shell .onboarding-step { margin-top: 18px; padding: 18px; border: 1px solid var(--primary-line); background: var(--primary-soft); }
.ledger-toolbar {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(260px, 380px) max-content;
  align-items: center;
  gap: 12px;
  margin: 22px 2px 12px;
}
.ledger-toolbar .muted { font-size: .82rem; }
.ledger-search { min-width: 0; }
.ledger-table { max-height: min(66vh, 760px); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card {
  position: relative;
  overflow: hidden;
  padding: 21px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px);
  transition: transform 200ms var(--ease-out), border-color 180ms ease, background-color 180ms ease;
}
.card:hover { border-color: var(--primary-line); background: var(--surface-raised); transform: translateY(-2px); }
.card-head { display: flex; justify-content: space-between; gap: 14px; }
.card-title { margin: 0; font-size: 1.05rem; }
.account-phone { margin-top: 4px; color: var(--muted); font-size: .88rem; }
.account-note { min-height: 1.5em; margin: 22px 0; color: var(--text); }
.card > button { width: 100%; }
.badge, .status {
  display: inline-flex;
  min-height: 25px;
  width: max-content;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border: 1px solid color-mix(in srgb, var(--success) 22%, transparent);
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--success);
  font-size: .72rem;
  font-weight: 720;
  white-space: nowrap;
}
.badge::before, .status::before { width: 5px; height: 5px; border-radius: 50%; background: currentColor; content: ""; }
.badge.degraded, .badge.onboarding, .status.warning { border-color: color-mix(in srgb, var(--warning) 22%, transparent); background: var(--warning-bg); color: var(--warning); }
.badge.disabled, .badge.deleted, .status.failed { border-color: color-mix(in srgb, var(--danger) 22%, transparent); background: var(--danger-bg); color: var(--danger); }
.status.neutral { border-color: var(--line); background: var(--surface-muted); color: var(--muted); }
.code-box {
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--primary-line);
  border-radius: 12px;
  background: rgba(3, 9, 18, .68);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
  font: 720 2rem ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .18em;
  text-align: center;
}
.empty-state {
  grid-column: 1 / -1;
  padding: 48px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-muted);
  color: var(--muted);
  text-align: center;
}
.empty-state strong { display: block; margin-bottom: 5px; color: var(--text); }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}
table { width: 100%; min-width: 820px; border-collapse: separate; border-spacing: 0; }
th, td {
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: .82rem;
  text-align: left;
  vertical-align: middle;
}
th {
  position: sticky;
  z-index: 2;
  top: 0;
  background: color-mix(in srgb, var(--surface-solid) 90%, transparent);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 720;
  backdrop-filter: blur(16px);
}
tbody tr { transition: background-color 150ms ease; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-hover); }
.account-cell strong { display: block; color: var(--text-strong); }
.account-cell span { display: block; margin-top: 2px; color: var(--muted); }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.actions > * { flex: 0 0 auto; }
td button, td .button, .action-menu summary { min-height: 34px; padding: 6px 9px; font-size: .74rem; }
td button, td .button { white-space: nowrap; }
td button .icon, .action-menu .icon { width: 14px; height: 14px; }
.ledger-table td:last-child { min-width: 430px; }
.action-menu { position: relative; width: max-content; }
.action-menu summary {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface-muted);
  color: var(--muted);
  font-weight: 680;
  cursor: pointer;
  list-style: none;
}
.action-menu summary::-webkit-details-marker { display: none; }
.action-menu[open] summary { border-color: var(--primary-line); background: var(--primary-soft); color: color-mix(in srgb, var(--primary) 62%, var(--text)); }
.action-menu-body {
  display: grid;
  gap: 7px;
  width: 220px;
  margin-top: 8px;
  padding: 9px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
  animation: menu-arrive 180ms var(--ease-out);
}
.action-menu-body button { width: 100%; white-space: normal; }
.advanced-settings { grid-column: 1 / -1; margin-top: 4px; border-top: 1px solid var(--line); }
.advanced-settings summary { width: max-content; max-width: 100%; padding: 15px 0 4px; color: color-mix(in srgb, var(--primary) 65%, var(--text)); font-size: .82rem; font-weight: 690; cursor: pointer; }
.advanced-settings-body { display: grid; gap: 16px; padding-top: 14px; }
.checkbox-label { display: flex; width: max-content; max-width: 100%; min-height: 40px; align-items: center; gap: 9px; cursor: pointer; }
.checkbox-label input { width: 18px; min-height: 18px; height: 18px; margin: 0; accent-color: var(--primary); }
.form-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.connection-status { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 14px; padding: 13px 15px; border: 1px solid var(--primary-line); border-radius: 10px; background: var(--primary-soft); color: var(--muted); }
.connection-status strong { color: color-mix(in srgb, var(--primary) 58%, var(--text)); }
.step-list { display: flex; gap: 8px; margin: 0 0 20px; padding: 0; list-style: none; }
.step-list li { flex: 1; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-muted); color: var(--muted); font-size: .76rem; font-weight: 680; text-align: center; transition: all 200ms ease; }
.step-list li.active { border-color: var(--primary-line); background: var(--primary-soft); color: color-mix(in srgb, var(--primary) 64%, var(--text)); }
.step-list li.done { border-color: color-mix(in srgb, var(--success) 24%, transparent); background: var(--success-bg); color: var(--success); }
.completion { display: flex; align-items: center; gap: 13px; }
.completion-mark { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid color-mix(in srgb, var(--success) 30%, transparent); border-radius: 50%; background: var(--success-bg); color: var(--success); }
.completion-mark .icon { width: 20px; height: 20px; }
#devices-panel, #connection-panel { margin-top: 24px; animation: sheet-arrive 260ms var(--ease-out); }

#flash {
  position: fixed;
  z-index: 90;
  top: 90px;
  right: 20px;
  max-width: min(430px, calc(100% - 40px));
  padding: 13px 17px 13px 42px;
  border: 1px solid color-mix(in srgb, var(--success) 26%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-raised) 92%, transparent);
  color: var(--text-strong);
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass-blur);
  animation: toast-in 260ms var(--ease-out);
}
#flash::before { position: absolute; top: 50%; left: 18px; width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 5px var(--success-bg); content: ""; transform: translateY(-50%); }
#flash.error-flash { border-color: color-mix(in srgb, var(--danger) 32%, var(--line)); }
#flash.error-flash::before { background: var(--danger); box-shadow: 0 0 0 5px var(--danger-bg); }

@keyframes atmosphere-drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to { transform: translate3d(2%, 2%, 0) scale(1.06); }
}
@keyframes auth-arrive {
  from { opacity: .45; }
}
@keyframes view-arrive {
  from { opacity: .6; transform: translateY(10px); }
}
@keyframes sheet-arrive {
  from { opacity: .65; clip-path: inset(0 0 20% 0 round 14px); transform: translateY(-8px); }
}
@keyframes menu-arrive {
  from { opacity: .6; filter: blur(4px); transform: translateY(-7px) scale(.98); }
}
@keyframes toast-in {
  from { opacity: .55; filter: blur(6px); transform: translateY(-10px) scale(.98); }
}
@keyframes error-nudge {
  35% { transform: translateX(4px); }
  70% { transform: translateX(-3px); }
}

@media (max-width: 1180px) {
  .topbar { grid-template-columns: max-content minmax(260px, 1fr) max-content; }
  .command-search { display: none; }
  .status-overview { grid-template-columns: repeat(2, 1fr); }
  .overview-item:nth-child(2) { border-right: 0; }
  .overview-item:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 900px) {
  .auth-scene { gap: 32px; padding: 32px; }
  .auth-card { right: 32px; width: min(46vw, 460px); }
  .auth-context h2 { font-size: clamp(2.5rem, 6vw, 4rem); }
  .topbar { grid-template-columns: 1fr max-content; gap: 8px 12px; }
  .topbar nav { grid-column: 1 / -1; grid-row: 2; }
  .topbar-tools { justify-self: end; }
  .view, .narrow-view { width: calc(100% - 24px); padding: 26px 0 48px; }
  .ledger-toolbar { grid-template-columns: 1fr max-content; }
  .ledger-toolbar > div:first-child { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .auth-scene { display: flex; justify-content: center; padding: 18px; }
  .auth-context { display: none; }
  .auth-card { position: relative; top: auto; right: auto; width: min(100%, 480px); max-width: 480px; padding: 26px; transform: none; }
  .brand-lockup { margin-bottom: 30px; }
  .topbar { display: flex; flex-wrap: wrap; margin: 7px; }
  .topbar-brand { flex: 1 0 100%; padding-right: 96px; }
  .topbar-tools { position: absolute; top: 8px; right: 8px; }
  .topbar nav { order: 3; flex: 1 0 100%; width: 100%; }
  .topbar-brand strong { font-size: .82rem; }
  .topbar-brand small { display: none; }
  #current-user { display: none; }
  .user-menu { order: 1; }
  #theme-toggle { order: 2; }
  .user-menu summary > .icon { display: none; }
  .section-head { align-items: stretch; flex-direction: column; margin-bottom: 18px; }
  .section-head > .segmented { align-self: stretch; }
  .segmented button { flex: 1; }
  .content-head { align-items: flex-start; flex-direction: column; gap: 3px; }
  .info-strip, .alert { flex-direction: column; gap: 4px; }
  .onboard-shell > summary { align-items: flex-start; flex-direction: column; gap: 3px; }
  .ledger-toolbar { grid-template-columns: 1fr max-content; }
  .ledger-search { min-width: 0; }
}

@media (max-width: 560px) {
  .context-ledger { flex-wrap: wrap; }
  .topbar nav button { padding-inline: 10px; }
  .topbar nav button .icon { display: none; }
  .cards { grid-template-columns: 1fr; }
  .card, .panel { padding: 17px; }
  .form-grid { grid-template-columns: 1fr; }
  .status-overview { grid-template-columns: 1fr 1fr; }
  .overview-item { min-height: 82px; padding: 15px 17px; }
  .overview-item strong { font-size: 1.35rem; }
  .overview-item::before { top: 19px; left: 7px; height: 24px; }
  .onboard-shell-body { padding: 16px; }
  .ledger-toolbar { grid-template-columns: minmax(0, 1fr) max-content; }
  .step-list { flex-direction: column; }
  .step-list li { text-align: left; }
  #flash { top: 84px; right: 12px; max-width: calc(100% - 24px); }
}

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