:root {
  --bg: #ffffff;
  --rail: #f5f7ff;
  --rail-accent: #5b3bf5;
  --text: #101828;
  --muted: #667085;
  --card: #ffffff;
  --border: #e7eaf3;
  --accent: #5b3bf5;
  --accent-2: #23c6ff;
  --fwl-font-family: "Gill Sans", "Trebuchet MS", "Verdana", sans-serif;
  --fwl-text: var(--text);
  --fwl-muted: var(--muted);
  --fwl-text-regular: 15px;
  --fwl-text-title: 18px;
  --fwl-text-subtitle: 17px;
  --fwl-bg: #ffffff;
  --fwl-surface: #f7f8fc;
  --fwl-border: var(--border);
  --fwl-radius: 14px;
  --fwl-shadow: 0 16px 40px rgba(16, 24, 40, 0.1);
  --fwl-primary: var(--accent);
  --fwl-danger: #b42318;
  --fwl-success: #0f766e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Gill Sans", "Trebuchet MS", "Verdana", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.rail {
  background: var(--rail);
  color: #1f2a44;
  padding: 0 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-right: 1px solid var(--border);
}

.rail-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.rail-help {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
}

.rail-help:hover {
  background: rgba(20, 126, 255, 0.06);
  color: var(--ink);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
  margin-top: 0;
}

.brand-mark {
  width: calc(100% + 48px);
  height: 72px;
  border-radius: 0;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  display: grid;
  place-items: center;
  padding: 0;
  margin-left: -24px;
  margin-top: 0;
}

.brand-mark img {
  width: calc(100% + 2px);
  height: auto;
  object-fit: contain;
}

.brand-title {
  font-size: 15px;
  font-weight: 600;
  color: #1f2a44;
  padding-left: 4px;
}

.brand-text {
  width: 100%;
  text-align: center;
}

.brand-sub {
  font-size: 14px;
  color: var(--muted);
}

.profile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--border);
  cursor: pointer;
}

.profile-top {
  display: flex;
  gap: 12px;
  align-items: center;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
}

.profile-name {
  font-size: 15px;
  font-weight: 600;
}

.profile-org {
  font-size: 14px;
  color: var(--muted);
}

.profile-actions {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.profile-actions .link-btn {
  font-size: 13px;
  padding: 0;
  border: none;
  background: transparent;
  color: #2a1b6f;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  opacity: 0.85;
}

.profile-actions .link-btn:hover {
  opacity: 1;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-sep {
  height: 1px;
  background: rgba(30, 48, 84, 0.10);
  margin: 6px 6px;
  border-radius: 999px;
}

.nav-item {
  border: none;
  background: #ffffff;
  color: #1f2a44;
  padding: 10px 12px;
  border-radius: 12px;
  text-align: left;
  font-size: 15px;
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-item.active,
.nav-item:hover {
  border-color: var(--accent);
  background: #f0ecff;
  color: #2a1b6f;
}

.main {
  padding: 28px 32px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100vh;
  overflow: hidden;
}

.mode-page-scroll .main {
  height: auto;
  min-height: 100vh;
  overflow: visible;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

.topbar-left {
  display: flex;
  align-items: flex-end;
  height: 100%;
}

.topbar-right {
  display: flex;
  justify-content: flex-end;
  width: 60%;
}

.page-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  margin-top: 25px;
}

.page-sub {
  margin-top: 4px;
  color: var(--muted);
}

.token-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(80px, 1fr));
  gap: 10px;
}

.token-block {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
}

.token-block span {
  display: block;
  font-size: 14px;
  color: var(--muted);
}

.token-block strong {
  font-size: 18px;
}

.top-bricks {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
}

.brick {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 10px 25px rgba(16, 24, 40, 0.06);
}

.brick.metric {
  text-align: center;
  padding: 20px;
}

.brick-title {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 8px;
}

.brick-value {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.brick-meta {
  font-size: 14px;
  color: var(--muted);
}

.skeleton-text {
  position: relative;
  border-radius: 10px;
  color: transparent !important;
  user-select: none;
  overflow: hidden;
  background: linear-gradient(
    90deg,
    rgba(231, 234, 243, 0.9) 0%,
    rgba(245, 247, 252, 0.95) 45%,
    rgba(231, 234, 243, 0.9) 100%
  );
  background-size: 220% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

.brick-value.skeleton-text {
  height: 22px;
  width: 46px;
  margin: 0 auto 4px;
}

.brick-meta.skeleton-text {
  height: 16px;
  width: 128px;
  margin: 0 auto;
}

.skeleton-block {
  display: inline-block;
  height: 14px;
  border-radius: 10px;
  vertical-align: middle;
  background: linear-gradient(
    90deg,
    rgba(231, 234, 243, 0.9) 0%,
    rgba(245, 247, 252, 0.95) 45%,
    rgba(231, 234, 243, 0.9) 100%
  );
  background-size: 220% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

.sk-w-run { width: 110px; }
.sk-w-status { width: 78px; }
.sk-w-regions { width: 120px; }
.sk-w-tokens { width: 40px; }
.sk-w-action { width: 104px; height: 28px; border-radius: 12px; }

.sk-w-budget { width: 120px; }
.sk-w-balance { width: 52px; }

.sk-l-date { width: 92px; }
.sk-l-type { width: 110px; }
.sk-l-budget { width: 96px; }
.sk-l-delta { width: 54px; }
.sk-l-balance { width: 64px; }

.sk-t-date { width: 92px; }
.sk-t-user { width: 160px; }
.sk-t-type { width: 86px; }
.sk-t-item { width: 180px; }
.sk-t-amt { width: 74px; }
.sk-t-status { width: 66px; }
.sk-t-action { width: 92px; height: 28px; border-radius: 12px; }

.sk-lic-id { width: 160px; }
.sk-lic-user { width: 140px; }
.sk-lic-machine { width: 120px; }
.sk-lic-date { width: 92px; }
.sk-lic-status { width: 66px; }
.sk-lic-action { width: 92px; height: 28px; border-radius: 12px; }

.sk-u-name { width: 140px; }
.sk-u-email { width: 200px; }
.sk-u-role { width: 110px; }
.sk-u-status { width: 72px; }

.sk-ai-date { width: 92px; }
.sk-ai-tokens { width: 54px; }
.sk-ai-total { width: 54px; }
.sk-ai-bar { width: 12px; height: 86px; border-radius: 10px; }

.ai-skeleton-bars {
  display: grid;
  grid-template-columns: repeat(30, 12px);
  gap: 8px;
  align-items: end;
  padding: 10px 6px;
}

.sk-dom-domain { width: 160px; }
.sk-dom-type { width: 56px; }
.sk-dom-date { width: 92px; }
.sk-dom-method { width: 66px; }
.sk-dom-status { width: 66px; }
.sk-dom-action { width: 72px; height: 28px; border-radius: 12px; }

.sk-cr-lic { width: 160px; }
.sk-cr-run { width: 200px; }
.sk-cr-date { width: 92px; }
.sk-cr-status { width: 66px; }
.sk-cr-action { width: 92px; height: 28px; border-radius: 12px; }

.sk-cap-scope { width: 160px; }
.sk-cap-hosts { width: 220px; }
.sk-cap-date { width: 92px; }
.sk-cap-status { width: 66px; }
.sk-cap-action { width: 92px; height: 28px; border-radius: 12px; }

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0% 0; }
}

.page {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.mode-page-scroll .page {
  overflow: visible;
}

.mode-page-scroll .table-wrap.scroll {
  max-height: none;
  overflow-y: visible;
}

.page.hidden {
  display: none;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.page-header h2 {
  margin: 0;
  font-size: 20px;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page[data-page="wallet"] {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.page[data-page="wallet"] .wallet-stack {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.page[data-page="wallet"] .wallet-top-grid {
  display: grid;
  grid-template-columns: minmax(500px, 40%) 1fr;
  gap: 16px;
  align-items: stretch;
}

@media (max-width: 980px) {
  .page[data-page="wallet"] .wallet-top-grid {
    grid-template-columns: 1fr;
  }
}

.spend-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  overflow: visible;
}

.spend-card .card-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
}

.spend-title {
  margin: 0;
  justify-self: start;
}

.spend-legend-header {
  justify-self: center;
}

.spend-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 6px;
}

.spend-controls {
  gap: 10px;
}

.spend-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: #6b7280;
}

.spend-filter span {
  display: none;
}

.spend-filter select {
  font-size: 15px;
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
}

.spend-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  min-height: 18px;
}

.legend-item {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-size: 13px;
  color: #6b7280;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.spend-plot {
  flex: 1;
  min-height: 160px;
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: stretch;
  gap: 10px;
}

.spend-yaxis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 0 6px;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  text-align: right;
}

.spend-yaxis .y-tick {
  line-height: 1;
}

.spend-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 6px 6px;
  border: 1px solid #eef1f7;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
  overflow: hidden;
}

.spend-bars .spend-bar {
  max-width: none;
}

.spend-tooltip {
  position: absolute;
  z-index: 50;
  max-width: 340px;
  min-width: 240px;
  padding: 12px 12px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.14);
  pointer-events: none;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.spend-tooltip.active {
  opacity: 1;
  transform: translateY(0);
}

.spend-tt-title {
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  margin-bottom: 10px;
  color: #0f172a;
}

.spend-tt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  color: #334155;
}

.spend-tt-table td {
  padding: 6px 0;
  border-bottom: 1px solid #eef1f7;
  vertical-align: middle;
}

.spend-tt-table tr:last-child td {
  border-bottom: none;
}

.spend-tt-name {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.spend-tt-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex: 0 0 auto;
}

.spend-tt-val {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.spend-tt-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-top: 10px;
  font-size: 13px;
  color: #334155;
}

.spend-tt-total strong {
  font-size: 14px;
  color: #0f172a;
}

.spend-xaxis {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 2px 6px 0 60px; /* yaxis(44) + gap(10) + bars padding-left(6) */
}

.spend-xlabel {
  flex: 1 1 0;
  min-width: 0;
  max-width: none;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  white-space: nowrap;
  overflow: visible;
  text-overflow: initial;
}

.spend-bar {
  flex: 1 1 0;
  min-width: 8px;
  max-width: 14px;
  height: 100%;
  display: flex;
  flex-direction: column-reverse;
  gap: 0;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(237, 242, 252, 0.9);
}

.spend-seg {
  width: 100%;
}

.spend-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  font-size: 14px;
  height: 160px;
  border: 1px dashed #e5e7eb;
  border-radius: 12px;
}

.page[data-page="wallet"] .ledger-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.page[data-page="wallet"] .ledger-card .table-wrap.scroll {
  flex: 1;
  min-height: 0;
  max-height: none;
}

.page[data-page="cloudruns"] {
  flex: 1;
  min-height: 0;
}

.page[data-page="cloudruns"] .stack {
  flex: 1;
  min-height: 0;
}

.page[data-page="cloudruns"] .cloudruns-history {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.page[data-page="cloudruns"] .cloudruns-history .table-wrap.scroll {
  flex: 1;
  min-height: 0;
  max-height: none;
}

.page[data-page="cloudruns"] .cloudruns-top-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}

.page[data-page="cloudruns"] .cloudruns-top-grid .cloudrun-active {
  max-width: none;
}

@media (max-width: 980px) {
  .page[data-page="cloudruns"] .cloudruns-top-grid {
    grid-template-columns: 1fr;
  }
}

.page[data-page="ai"] .ai-top-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}

@media (max-width: 980px) {
  .page[data-page="ai"] .ai-top-grid {
    grid-template-columns: 1fr;
  }
}

.ai-usage-brick {
  min-height: 140px;
}

.ai-usage-brick .section-sub {
  margin-top: 8px;
  font-size: 15px;
  color: var(--muted);
  line-height: 1.45;
  max-width: none;
  font-weight: 400;
}

.page[data-page="transactions"] {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.page[data-page="transactions"] .stack {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.page[data-page="transactions"] .transactions-history {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.page[data-page="transactions"] .transactions-history .table-wrap.scroll {
  flex: 1;
  min-height: 0;
  max-height: none;
}

details.card {
  padding: 0;
}

details.card summary {
  list-style: none;
  padding: 16px;
  font-weight: 700;
  font-size: 18px;
  cursor: pointer;
}

details.card summary::-webkit-details-marker {
  display: none;
}

details.card summary {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

details.card summary::after {
  position: absolute;
  right: 16px;
  top: 16px;
}

.summary-sub {
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
  max-width: 80%;
}

details.card summary::after {
  content: "▾";
  float: right;
  color: var(--muted);
}

details.card[open] summary::after {
  content: "▴";
}

.card-body {
  padding: 0 16px 16px;
  color: var(--muted);
}

.section-sub {
  color: var(--muted);
  font-size: 17px;
  margin-top: 6px;
  font-weight: 700;
  max-width: 80%;
}

.body-copy {
  color: var(--text);
  font-size: 15px;
  margin-top: 8px;
  margin-bottom: 0;
  font-weight: 400;
  line-height: 1.35;
  max-width: 80%;
}

.cloudrun-active {
  max-width: calc(30% + 200px);
}

.cloudruns-info .body-copy {
  max-width: none;
}

.active-run-status {
  color: var(--muted);
  font-size: 14px;
}

.ai-budget {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-budget-value {
  font-size: 22px;
  font-weight: 700;
}

.ai-budget-sub {
  color: var(--muted);
  font-size: 14px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.legend {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--muted);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  margin-right: 6px;
}

.dot.neo {
  background: #4f46e5;
}

.dot.trinity {
  background: #22d3ee;
}

.dot.oracle {
  background: #f97316;
}

.dot.keymaker {
  background: #ef4444;
}

.dot.morpheus {
  background: #10b981;
}

.dot.other {
  background: #94a3b8;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(30, minmax(6px, 1fr));
  align-items: end;
  gap: 8px;
  height: 180px;
  margin-top: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.bar {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  position: relative;
}

.bar .stack {
  width: 100%;
  border-radius: 6px 6px 0 0;
}

.bar .stack + .stack {
  margin-top: 0;
}

.bar .stack.neo {
  background: rgba(79, 70, 229, 0.7);
}

.bar .stack.trinity {
  background: rgba(34, 211, 238, 0.7);
}

.bar .stack.oracle {
  background: rgba(249, 115, 22, 0.7);
}

.bar .stack.keymaker {
  background: rgba(239, 68, 68, 0.7);
}

.bar .stack.morpheus {
  background: rgba(16, 185, 129, 0.7);
}

.bar .stack.other {
  background: rgba(148, 163, 184, 0.7);
}

.bar .stack.empty {
  background: #f1f3f9;
  border: 1px dashed #e3e7f2;
  border-radius: 6px;
}

.bar .label {
  position: absolute;
  bottom: -18px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

.expand-row {
  cursor: pointer;
}

.expand-row::after {
  content: "▾";
  color: var(--muted);
  float: right;
}

.expand-row.open::after {
  content: "▴";
}

.expand-details {
  display: none;
}

.expand-details.open {
  display: table-row;
}

.details-body {
  display: grid;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
  padding: 8px 0 4px;
}

.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.tab {
  border: 1px solid var(--border);
  background: #f6f7fb;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 15px;
  cursor: pointer;
}

.tab.active {
  background: #eef1ff;
  color: #2a1b6f;
  border-color: var(--accent);
}

.tab-panels {
  display: block;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.form-stack {
  grid-template-columns: 1fr;
  max-width: 520px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 15px;
  color: var(--muted);
}

.form-grid input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 15px;
}

.form-grid select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 38px 8px 10px;
  font-size: 15px;
  background-color: #fff;
  color: inherit;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px);
  background-size:
    6px 6px,
    6px 6px;
  background-repeat: no-repeat;
}

.form-grid input:focus,
.form-grid select:focus {
  outline: none;
  border-color: rgba(35, 198, 255, 0.55);
  box-shadow: 0 0 0 4px rgba(35, 198, 255, 0.18);
}

.perm-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.perm-row:last-child {
  border-bottom: none;
}

.perm-desc {
  color: var(--muted);
  font-size: 14px;
  margin-top: 4px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch span {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #e4e8f4;
  border-radius: 999px;
  transition: background 0.2s ease;
}

.switch span::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 3px 6px rgba(16, 24, 40, 0.12);
}

.switch input:checked + span {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.switch input:checked + span::before {
  transform: translateX(20px);
}

.security-actions {
  display: flex;
  gap: 10px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px 16px;
}

.detail-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  min-height: 140px;
  box-shadow: 0 12px 24px rgba(16, 24, 40, 0.05);
}

.budget-card {
  max-width: none;
}

.users-card {
  min-height: 520px;
}

.users-card .table-wrap {
  max-height: 60vh;
  overflow-y: auto;
}

.purchase-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(200px, 0.45fr);
  gap: 16px;
}

.purchase-card {
  min-height: 420px;
  max-width: none;
  border-radius: 20px;
}

.purchase-note {
  color: var(--muted);
  font-size: 14px;
  margin-top: 8px;
}

.purchase-summary {
  min-height: 200px;
}

.purchase-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 6px 0;
}

.purchase-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.purchase-section-title {
  font-size: 18px;
  font-weight: 700;
}

.purchase-section-text {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
}

.purchase-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.purchase-qty-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 15px;
  color: var(--muted);
}

.purchase-qty {
  font-size: 26px;
  font-weight: 700;
  max-width: 160px;
}

.purchase-price {
  text-align: right;
  color: var(--muted);
  font-size: 14px;
}

.purchase-price strong {
  display: block;
  font-size: 18px;
  color: var(--text);
}

.purchase-total {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.purchase-total strong {
  font-size: 18px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.summary-row strong {
  font-size: 16px;
}

.summary-row:last-of-type {
  border-bottom: none;
}

.purchase-summary button {
  width: 60%;
  margin-left: auto;
  margin-right: auto;
  margin-top: 16px;
  display: block;
}

.purchase-summary .summary-row strong {
  font-size: 16px;
}

.purchase-status {
  margin-top: 12px;
  font-size: 15px;
  color: var(--muted);
}

.purchase-status.success {
  color: #0f766e;
}

.purchase-status.error {
  color: #b42318;
}

.org-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.org-overlay.active {
  display: flex;
}

.org-overlay.hidden {
  display: none;
}

.org-modal {
  background: #ffffff;
  border-radius: 20px;
  width: min(720px, 92vw);
  padding: 20px 24px;
  box-shadow: 0 20px 50px rgba(16, 24, 40, 0.2);
}

.org-modal .form-grid {
  grid-template-columns: 1fr;
  max-width: 520px;
  width: 100%;
}

#domain-protocol-wrap {
  display: none;
}

.org-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.org-modal-header h3 {
  margin: 0;
}

.org-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

#msg-text {
  white-space: pre-line;
}

#msg-overlay.is-busy .org-modal-actions button {
  opacity: 0.8;
}

#msg-overlay.is-busy .org-modal-actions {
  pointer-events: auto;
}

.cloudrun-live-modal {
  max-width: 860px;
  width: 860px;
}

.cloudrun-live-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.cloudrun-live-sub {
  color: var(--fwl-muted, #6b7a8c);
  font-size: 13px;
}

.cloudrun-live-stage {
  font-size: 18px;
  font-weight: 800;
  margin-top: 2px;
  margin-bottom: 6px;
  color: #0f172a;
}

.cloudrun-live-progress {
  margin: 14px 0;
}

.cloudrun-live-progress-bar {
  height: 16px;
  border-radius: 10px;
  background: rgba(35, 198, 255, 0.14);
  overflow: hidden;
  border: 1px solid rgba(35, 198, 255, 0.25);
}

.cloudrun-live-progress-bar > div {
  height: 100%;
  width: 0%;
  background: linear-gradient(135deg, var(--fwl-primary, #5b3bf5), var(--fwl-accent, #23c6ff));
  transition: width 0.2s ease-in-out;
}

.cloudrun-live-progress-text {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 6px;
}

.cloudrun-live-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.cloudrun-live-kpi {
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
}

.cloudrun-live-kpi strong {
  display: block;
  font-size: 16px;
}

.cloudrun-live-kpi span {
  display: block;
  font-size: 13px;
  color: var(--fwl-muted, #6b7a8c);
}

.cloudrun-live-artifacts {
  margin-top: 14px;
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
}

.cloudrun-live-log {
  margin-top: 14px;
}

.cloudrun-live-log-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--fwl-muted, #6b7a8c);
  margin-bottom: 8px;
}

.cloudrun-live-log-box {
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  height: 150px;
  overflow: auto;
  font-size: 14px;
  line-height: 1.4;
}

.cloudrun-live-log-line {
  margin-bottom: 4px;
}

.cloudrun-live-log-line:last-child {
  margin-bottom: 0;
}

.domain-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

.domain-actions-bottom {
  margin-top: 12px;
}

.domain-instructions {
  margin-top: 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 12px;
  font-size: 15px;
  color: var(--text);
  background: #fbfcff;
}

.domain-instructions code {
  display: block;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  padding: 8px 10px;
  background: #f3f4f8;
  border-radius: 10px;
  color: #1b2a3a;
  margin-top: 6px;
}

.domain-instructions .domain-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.domain-kv {
  display: flex;
  align-items: center;
  gap: 8px;
}

.domain-kv code {
  flex: 1 1 auto;
  margin-top: 6px;
}

.copy-icon {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 2px 4px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: 0.7;
}

.copy-icon:hover {
  opacity: 1;
}

.copy-tooltip {
  display: none;
  font-size: 12px;
  color: var(--muted);
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  padding: 4px 8px;
  border-radius: 8px;
  white-space: nowrap;
}

.copy-tooltip.show {
  display: inline-block;
}

.header-actions.inside-card {
  margin-left: auto;
}

.ledger-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.ai-usage-toolbar {
  margin-left: 16px;
}

.ledger-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

.ledger-filter input[type="date"] {
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
}

.card h3 {
  margin-top: 0;
  font-size: 18px;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
}

.table-wrap.scroll {
  max-height: 260px;
  overflow-y: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.table th,
.table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  text-align: left;
}

.table thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.wallet-budget-row {
  cursor: pointer;
  transition: background 120ms ease;
}

.wallet-tokens-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
}

.wallet-tokens-cell .wallet-release-link {
  visibility: hidden;
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  margin-left: auto;
}

.wallet-budget-row:hover .wallet-tokens-cell .wallet-release-link {
  visibility: visible;
}

.wallet-tokens-cell .wallet-release-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
  color: #475467;
}

.wallet-tokens-cell .wallet-release-link.is-placeholder,
.wallet-budget-row:hover .wallet-tokens-cell .wallet-release-link.is-placeholder {
  visibility: hidden;
  pointer-events: none;
}

.wallet-budget-row:hover {
  background: rgba(35, 198, 255, 0.07);
}

.wallet-budget-row.is-selected {
  background: rgba(91, 59, 245, 0.10);
}

.wallet-release-busy .wallet-tokens-cell .wallet-release-link {
  opacity: 0.6;
  pointer-events: none;
}

.table tfoot th {
  font-weight: 700;
}

button.primary,
button.ghost {
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 15px;
  cursor: pointer;
}

button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}

button.ghost {
  background: #f0f2f8;
  color: #111827;
}

button.ghost.danger {
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
  font-weight: 700;
}

button.ghost.danger:hover {
  background: rgba(220, 38, 38, 0.18);
}

/* Standard close X for dialogs (circle + thin border). */
.modal-x {
  border: 1px solid var(--border);
  background: #ffffff;
  color: #111827;
  border-radius: 999px;
  width: 34px;
  height: 34px;
  padding: 0;
  line-height: 32px;
  font-size: 18px;
  cursor: pointer;
}

.modal-x:hover {
  background: #f2f4f7;
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .rail {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .top-bricks {
    grid-template-columns: 1fr;
  }
  .token-summary {
    grid-template-columns: repeat(2, minmax(80px, 1fr));
  }
}
