/* =========================================================================
   Skyblocks — App styles
   Components + layout + screen-specific bits
   ========================================================================= */

/* ============ App shell ============ */
.app {
  display: grid;
  grid-template-columns: auto 1fr;
  min-height: 100vh;
  background: var(--bg-base);
}

.app[data-sidebar="icons"] { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
.app[data-sidebar="expanded"] { grid-template-columns: var(--sidebar-w) 1fr; }
.app[data-sidebar="floating"] { grid-template-columns: 1fr; }

/* ============ Sidebar ============ */
.sidebar {
  background: var(--bg-canvas);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  width: var(--sidebar-w);
  transition: width var(--dur) var(--ease-out);
  overflow: hidden;
}

.app[data-sidebar="icons"] .sidebar { width: var(--sidebar-w-collapsed); }

.app[data-sidebar="floating"] .sidebar {
  position: fixed;
  top: 12px;
  left: 12px;
  bottom: 12px;
  height: auto;
  width: var(--sidebar-w);
  border-radius: var(--r-xl);
  border: 1px solid var(--border-default);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-drawer);
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.app[data-sidebar="floating"] .sidebar-brand { border-bottom-color: transparent; }
.sidebar-brand-mark { flex-shrink: 0; }
.sidebar-brand-name {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  opacity: 1;
  transition: opacity var(--dur) var(--ease-out);
}
.app[data-sidebar="icons"] .sidebar-brand-name,
.app[data-sidebar="icons"] .sidebar-section-label,
.app[data-sidebar="icons"] .nav-item-label,
.app[data-sidebar="icons"] .nav-item-badge,
.app[data-sidebar="icons"] .nav-item-caret,
.app[data-sidebar="icons"] .sidebar-footer-text {
  opacity: 0; pointer-events: none;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 8px 12px 8px;
  scrollbar-width: thin;
}

.sidebar-section { padding: 4px 0; }
.sidebar-section + .sidebar-section { margin-top: 12px; }

.sidebar-section-label {
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 8px 12px 6px;
  transition: opacity var(--dur);
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 0 10px;
  height: 32px;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
  position: relative;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--row-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--text-primary);
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -8px; top: 50%;
  transform: translateY(-50%);
  width: 2px; height: 16px;
  background: var(--accent);
  border-radius: 2px;
}
.app[data-sidebar="floating"] .nav-item.active::before,
.app[data-sidebar="icons"] .nav-item.active::before { display: none; }

.nav-item-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }
.nav-item.active .nav-item-icon { color: var(--accent); opacity: 1; }
.nav-item-label { flex: 1; transition: opacity var(--dur); }
.nav-item-badge {
  font-size: var(--fs-2xs);
  font-weight: 600;
  background: var(--bg-surface-3);
  color: var(--text-secondary);
  padding: 1px 6px;
  border-radius: var(--r-full);
  transition: opacity var(--dur);
}
.nav-item-badge.danger { background: var(--danger-soft); color: var(--danger); }
.nav-item-badge.accent { background: var(--accent-soft); color: var(--accent); }
.nav-item-caret { width: 14px; height: 14px; opacity: 0.6; transition: transform var(--dur), opacity var(--dur); }
.nav-item.expanded .nav-item-caret { transform: rotate(90deg); }

.nav-subgroup {
  overflow: hidden;
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows var(--dur) var(--ease-out);
}
.nav-subgroup.collapsed { grid-template-rows: 0fr; }
.nav-subgroup-inner { min-height: 0; padding: 2px 0 2px 22px; display: flex; flex-direction: column; gap: 1px; }

.nav-subitem {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px;
  height: 28px;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.nav-subitem:hover { background: var(--row-hover); color: var(--text-primary); }
.nav-subitem.active { color: var(--accent); background: var(--accent-soft); font-weight: 500; }

.sidebar-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 10px 8px;
  flex-shrink: 0;
}
.app[data-sidebar="floating"] .sidebar-footer { border-top-color: transparent; }
.sidebar-footer-user {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--dur-fast);
}
.sidebar-footer-user:hover { background: var(--row-hover); }
.sidebar-footer-avatar {
  width: 26px; height: 26px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, var(--accent), hsl(calc(var(--accent-h) + 30) 70% 60%));
  color: var(--accent-fg);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  flex-shrink: 0;
}
.sidebar-footer-text { flex: 1; transition: opacity var(--dur); overflow: hidden; }
.sidebar-footer-name { font-size: var(--fs-sm); font-weight: 500; }
.sidebar-footer-role { font-size: var(--fs-xs); color: var(--text-tertiary); }

/* ============ Topbar ============ */
.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
}

.topbar-mobile-toggle {
  display: none;
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  align-items: center; justify-content: center;
  color: var(--text-secondary);
}
.topbar-mobile-toggle:hover { background: var(--row-hover); color: var(--text-primary); }

.breadcrumbs { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-tertiary); }
.breadcrumb-item.current { color: var(--text-primary); font-weight: 500; }
.breadcrumb-sep { opacity: 0.5; }

.topbar-spacer { flex: 1; }

.topbar-actions { display: flex; align-items: center; gap: 4px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  transition: background var(--dur-fast), color var(--dur-fast);
  position: relative;
}
.icon-btn:hover { background: var(--row-hover); color: var(--text-primary); }
.icon-btn.has-dot::after {
  content: "";
  position: absolute;
  top: 6px; right: 6px;
  width: 6px; height: 6px;
  border-radius: var(--r-full);
  background: var(--accent);
  border: 2px solid var(--bg-base);
  box-sizing: content-box;
}

/* Workspace switcher */
.workspace-switcher {
  display: flex; align-items: center; gap: 8px;
  height: 32px;
  padding: 0 8px 0 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast);
  max-width: 220px;
}
.workspace-switcher:hover { background: var(--bg-surface-2); border-color: var(--border-strong); }
.workspace-avatar {
  width: 18px; height: 18px;
  border-radius: var(--r-xs);
  background: linear-gradient(135deg, var(--accent), hsl(calc(var(--accent-h) + 50) 70% 55%));
  color: var(--accent-fg);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
  flex-shrink: 0;
}

/* Global search */
.global-search {
  display: flex; align-items: center; gap: 8px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-tertiary);
  font-size: var(--fs-sm);
  width: 240px;
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.global-search:hover { background: var(--bg-surface-2); border-color: var(--border-strong); }
.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: var(--r-xs);
  border: 1px solid var(--border-default);
  background: var(--bg-surface-2);
  color: var(--text-tertiary);
  font-size: 10px; font-family: var(--font-mono); font-weight: 500;
}

/* ============ Page container ============ */
.page {
  padding: 24px 28px 60px;
  max-width: 1480px;
  margin: 0 auto;
  width: 100%;
}

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.page-title { font-size: var(--fs-h1); font-weight: 600; letter-spacing: -0.02em; margin: 0; line-height: 1.2; }
.page-subtitle { color: var(--text-secondary); font-size: var(--fs-sm); margin-top: 4px; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  height: var(--control-h);
  padding: 0 12px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast), transform var(--dur-fast);
  border: 1px solid transparent;
  user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary {
  background: var(--accent);
  color: var(--accent-fg);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.07), 0 1px 2px rgba(0,0,0,0.12);
}
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.primary:active:not(:disabled) { background: var(--accent-press); }

.btn.secondary {
  background: var(--bg-surface);
  border-color: var(--border-default);
  color: var(--text-primary);
}
.btn.secondary:hover:not(:disabled) { background: var(--bg-surface-2); border-color: var(--border-strong); }

.btn.ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn.ghost:hover:not(:disabled) { background: var(--row-hover); color: var(--text-primary); }

.btn.danger {
  background: var(--danger);
  color: #fff;
}
.btn.danger:hover:not(:disabled) { background: hsl(0 84% 55%); }

.btn.subtle {
  background: var(--bg-surface-2);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}
.btn.subtle:hover:not(:disabled) { background: var(--bg-surface-3); }

.btn.sm { height: var(--control-h-sm); padding: 0 10px; font-size: var(--fs-xs); }
.btn.lg { height: var(--control-h-lg); padding: 0 16px; font-size: var(--fs-body); }
.btn.icon-only { width: var(--control-h); padding: 0; }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-top-left-radius: var(--r-sm); border-bottom-left-radius: var(--r-sm); margin-left: 0; }
.btn-group .btn:last-child { border-top-right-radius: var(--r-sm); border-bottom-right-radius: var(--r-sm); }

/* ============ Form controls ============ */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: var(--fs-sm); font-weight: 500; color: var(--text-primary); }
.label .req { color: var(--danger); margin-left: 2px; }
.helper { font-size: var(--fs-xs); color: var(--text-tertiary); }
.helper.error { color: var(--danger); }

.input,
.select,
.textarea {
  height: var(--control-h);
  padding: 0 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: var(--fs-sm);
  transition: border-color var(--dur-fast), background var(--dur-fast), box-shadow var(--dur-fast);
  width: 100%;
}
.textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 80px; font-family: inherit; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.input::placeholder, .textarea::placeholder { color: var(--text-tertiary); }
.input.error, .select.error, .textarea.error { border-color: var(--danger); }
.input.error:focus { box-shadow: 0 0 0 3px var(--danger-soft); }

.input-wrap {
  position: relative;
  display: flex; align-items: center;
}
.input-wrap .input { padding-left: 32px; }
.input-wrap-icon {
  position: absolute; left: 10px;
  color: var(--text-tertiary);
  pointer-events: none;
}
.input-wrap-right {
  position: absolute; right: 8px;
  display: flex; align-items: center; gap: 4px;
}

.checkbox {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: var(--r-xs);
  border: 1.5px solid var(--border-strong);
  background: var(--bg-surface);
  cursor: pointer;
  display: inline-grid; place-content: center;
  transition: background var(--dur-fast), border-color var(--dur-fast);
  flex-shrink: 0;
}
.checkbox:checked { background: var(--accent); border-color: var(--accent); }
.checkbox:checked::after {
  content: ""; width: 9px; height: 5px;
  border: 2px solid #fff; border-top: 0; border-right: 0;
  transform: rotate(-45deg) translate(0px, -1px);
}
.checkbox.indeterminate { background: var(--accent); border-color: var(--accent); }
.checkbox.indeterminate::after {
  content: ""; width: 8px; height: 2px; background: #fff; border-radius: 1px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 32px; height: 18px;
  border-radius: var(--r-full);
  background: var(--border-default);
  cursor: pointer;
  transition: background var(--dur);
  flex-shrink: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: var(--r-full);
  background: #fff;
  transition: transform var(--dur) var(--ease-out);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(14px); }

/* ============ Badges ============ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--r-xs);
  font-size: var(--fs-2xs);
  font-weight: 500;
  line-height: 1;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.lg { height: 22px; font-size: var(--fs-xs); padding: 0 8px; }
.badge.dot { padding-left: 4px; }
.badge .dot {
  width: 6px; height: 6px;
  border-radius: var(--r-full);
  background: currentColor;
  flex-shrink: 0;
}
.badge.success { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.badge.warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.badge.danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.badge.info { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }
.badge.neutral { background: var(--bg-surface-3); color: var(--text-secondary); border-color: var(--border-subtle); }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.outline { background: transparent; color: var(--text-secondary); border-color: var(--border-default); }

/* ============ Cards & panels ============ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: var(--fs-h3); font-weight: 600; margin: 0; }
.card-body { padding: 16px; }
.card.flush .card-body { padding: 0; }

/* KPI card */
.kpi {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  display: flex; flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.kpi:hover { border-color: var(--border-default); }
.kpi-label {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  font-weight: 500;
}
.kpi-icon {
  width: 22px; height: 22px;
  border-radius: var(--r-xs);
  background: var(--bg-surface-3);
  color: var(--text-secondary);
  display: inline-flex; align-items: center; justify-content: center;
}
.kpi-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
}
.trend {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 6px;
  border-radius: var(--r-xs);
  font-size: var(--fs-xs);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.trend.up { background: var(--success-bg); color: var(--success); }
.trend.down { background: var(--danger-bg); color: var(--danger); }
.trend.flat { background: var(--bg-surface-3); color: var(--text-secondary); }
.kpi-spark {
  position: absolute;
  right: 12px; bottom: 12px;
  opacity: 0.85;
}

/* ============ Tabs (segmented) ============ */
.tabs {
  display: inline-flex;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 2px;
}
.tab {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px;
  padding: 0 12px;
  border-radius: var(--r-xs);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
  white-space: nowrap;
}
.tab:hover { color: var(--text-primary); }
.tab.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* Underline tabs */
.tabs-line { display: flex; gap: 4px; border-bottom: 1px solid var(--border-subtle); }
.tab-line {
  position: relative;
  padding: 10px 14px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--dur-fast);
  display: inline-flex; align-items: center; gap: 6px;
}
.tab-line:hover { color: var(--text-primary); }
.tab-line.active { color: var(--text-primary); }
.tab-line.active::after {
  content: "";
  position: absolute;
  bottom: -1px; left: 8px; right: 8px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}

/* ============ Filter bar ============ */
.filter-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  flex-wrap: wrap;
}
.filter-bar > .input-wrap { flex: 1; min-width: 220px; }
.filter-bar .spacer { flex: 1; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: var(--control-h);
  padding: 0 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.filter-chip:hover { background: var(--bg-surface-2); border-color: var(--border-strong); }
.filter-chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.filter-chip .value { color: var(--text-secondary); }
.filter-chip.active .value { color: var(--accent); }
.filter-chip .x {
  width: 14px; height: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-full);
  color: var(--text-tertiary);
  margin-left: 2px;
}
.filter-chip .x:hover { background: var(--row-hover); color: var(--text-primary); }

/* ============ Table ============ */
.table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.table-wrap.loading { position: relative; }
.table-wrap.loading::after {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 1.5px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: tableProgress 1s linear infinite;
  z-index: 2;
}
@keyframes tableProgress {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

mark.hl {
  background: hsl(var(--accent-h) var(--accent-s) var(--accent-l) / 0.22);
  color: var(--text-primary);
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
}
.table-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.table-toolbar-left, .table-toolbar-right { display: flex; align-items: center; gap: 8px; }
.table-scroll { overflow-x: auto; }
.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.tbl thead th {
  position: sticky; top: 0;
  background: var(--bg-surface-2);
  color: var(--text-tertiary);
  font-size: var(--fs-xs);
  font-weight: 500;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  user-select: none;
}
.tbl thead th.sortable { cursor: pointer; }
.tbl thead th.sortable:hover { color: var(--text-primary); }
.tbl thead th .sort-ind { display: inline-block; margin-left: 4px; vertical-align: middle; opacity: 0.6; }
.tbl thead th.numeric, .tbl tbody td.numeric { text-align: right; }
.tbl tbody td {
  padding: 0 12px;
  height: var(--row-h);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--row-hover); }
.tbl tbody tr.selected td { background: var(--row-selected); }
.tbl tbody tr.expanded td { background: var(--row-selected); }

.tbl .col-check { width: 36px; padding-right: 0; }
.tbl .col-actions { width: 56px; text-align: right; }

.copy-cell {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}
.copy-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px;
  border-radius: var(--r-xs);
  color: var(--text-tertiary);
  opacity: 0;
  transition: opacity var(--dur-fast), background var(--dur-fast), color var(--dur-fast);
}
.tbl tr:hover .copy-btn,
.copy-btn.copy-success { opacity: 1; }
.copy-btn:hover { background: var(--row-hover); color: var(--text-primary); }
.copy-btn.copy-success { color: var(--success); }

.tbl .expand-row td {
  padding: 0;
  background: var(--bg-surface-2);
}
.expand-row-inner {
  padding: 14px 18px;
  border-top: 1px dashed var(--border-default);
}

.table-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--border-subtle);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  flex-wrap: wrap;
  gap: 10px;
}
.pagination { display: inline-flex; align-items: center; gap: 4px; }
.page-btn {
  min-width: 28px; height: 28px;
  border-radius: var(--r-xs);
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 6px;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.page-btn:hover { background: var(--row-hover); color: var(--text-primary); }
.page-btn.active { background: var(--accent); color: var(--accent-fg); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============ Modal ============ */
.modal-overlay {
  position: fixed; inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fadeIn var(--dur) var(--ease-out);
}
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  animation: modalIn var(--dur) var(--ease-out);
}
.modal.lg { max-width: 640px; }
.modal-header {
  padding: 18px 20px 12px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.modal-title { font-size: var(--fs-h2); font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.modal-desc { color: var(--text-secondary); font-size: var(--fs-sm); margin-top: 4px; }
.modal-body { padding: 4px 20px 18px; overflow-y: auto; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ============ Toasts ============ */
.toast-stack {
  position: fixed;
  bottom: 20px; right: 20px;
  display: flex; flex-direction: column-reverse; gap: 8px;
  z-index: var(--z-toast);
  pointer-events: none;
}
.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 12px 14px;
  display: flex; align-items: flex-start; gap: 10px;
  min-width: 280px; max-width: 380px;
  animation: toastIn var(--dur) var(--ease-out);
  pointer-events: auto;
}
.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast.success .toast-icon { color: var(--success); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.danger .toast-icon { color: var(--danger); }
.toast.info .toast-icon { color: var(--info); }
.toast-content { flex: 1; }
.toast-title { font-size: var(--fs-sm); font-weight: 500; }
.toast-desc { font-size: var(--fs-xs); color: var(--text-secondary); margin-top: 2px; }
.toast-action {
  font-size: var(--fs-xs); font-weight: 500;
  color: var(--accent);
  padding: 0 6px;
}
.toast-close {
  color: var(--text-tertiary);
  padding: 2px;
}
.toast-close:hover { color: var(--text-primary); }

@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

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

/* ============ Popover/menu ============ */
.menu {
  position: absolute;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  padding: 4px;
  min-width: 200px;
  z-index: var(--z-modal);
  animation: menuIn 140ms var(--ease-out);
}
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.menu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  border-radius: var(--r-xs);
  font-size: var(--fs-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--dur-fast);
  width: 100%;
  text-align: left;
}
.menu-item:hover { background: var(--row-hover); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-sep { height: 1px; background: var(--border-subtle); margin: 4px 0; }
.menu-label { font-size: var(--fs-2xs); color: var(--text-tertiary); padding: 6px 8px 2px; text-transform: uppercase; letter-spacing: 0.06em; }

/* ============ Stepper ============ */
.stepper {
  display: flex; align-items: center; gap: 0;
}
.stepper-step {
  display: flex; align-items: center; gap: 10px;
  flex: 1;
}
.stepper-circle {
  width: 28px; height: 28px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-tertiary);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--fs-xs); font-weight: 600;
  flex-shrink: 0;
  transition: all var(--dur);
}
.stepper-step.active .stepper-circle {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-fg);
}
.stepper-step.done .stepper-circle {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.stepper-step.done .stepper-circle::after {
  content: "✓";
}
.stepper-step.done .stepper-num { display: none; }
.stepper-label { font-size: var(--fs-sm); color: var(--text-secondary); font-weight: 500; }
.stepper-step.active .stepper-label { color: var(--text-primary); }
.stepper-line {
  flex: 1; height: 1.5px;
  background: var(--border-default);
  margin: 0 6px;
}
.stepper-step.done + .stepper-line, .stepper-step.active + .stepper-line { background: var(--accent); }

/* ============ Auth ============ */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-base);
}
.auth-side {
  position: relative;
  background:
    radial-gradient(circle at 20% 30%, var(--accent-soft) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, hsla(var(--accent-h) 100% 70% / 0.08) 0%, transparent 50%),
    var(--bg-canvas);
  border-right: 1px solid var(--border-subtle);
  padding: 40px;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.auth-side::after {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--chart-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--chart-grid) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse at center, black 0%, transparent 65%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 0%, transparent 65%);
  pointer-events: none;
}
.auth-main {
  display: flex; align-items: center; justify-content: center;
  padding: 32px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
}
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 36px; }
.auth-title { font-size: 28px; font-weight: 600; letter-spacing: -0.025em; margin: 0 0 6px; }
.auth-sub { color: var(--text-secondary); font-size: var(--fs-sm); margin-bottom: 28px; }
.auth-meta {
  position: absolute; bottom: 24px; left: 40px; right: 40px;
  display: flex; justify-content: space-between;
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  z-index: 2;
}

/* ============ Drawer (mobile sidebar) ============ */
.drawer-overlay {
  position: fixed; inset: 0;
  background: var(--bg-overlay);
  z-index: var(--z-drawer);
  animation: fadeIn var(--dur);
}
.drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 280px;
  background: var(--bg-canvas);
  border-right: 1px solid var(--border-default);
  z-index: calc(var(--z-drawer) + 1);
  display: flex; flex-direction: column;
  animation: drawerIn var(--dur) var(--ease-out);
}
@keyframes drawerIn { from { transform: translateX(-100%); } to { transform: translateX(0); } }

/* ============ Empty state ============ */
.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-secondary);
}
.empty-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px;
  border-radius: var(--r-lg);
  background: var(--bg-surface-2);
  color: var(--text-tertiary);
  margin-bottom: 16px;
}
.empty-title { font-size: var(--fs-h3); color: var(--text-primary); margin: 0 0 6px; font-weight: 600; }
.empty-desc { font-size: var(--fs-sm); margin-bottom: 16px; }

/* ============ Status pill (with dot, for table cells) ============ */
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-xs);
  font-weight: 500;
}
.status-pill .ind {
  width: 6px; height: 6px;
  border-radius: var(--r-full);
  position: relative;
  flex-shrink: 0;
}
.status-pill .ind::after {
  content: "";
  position: absolute; inset: -3px;
  border-radius: inherit;
  background: currentColor;
  opacity: 0.15;
}
.status-pill.success { color: var(--success); }
.status-pill.warning { color: var(--warning); }
.status-pill.danger { color: var(--danger); }
.status-pill.info { color: var(--info); }
.status-pill.neutral { color: var(--text-secondary); }
.status-pill.success .ind, .status-pill.warning .ind,
.status-pill.danger .ind, .status-pill.info .ind { background: currentColor; }
.status-pill.pending .ind {
  background: var(--warning);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ============ Section header ============ */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}
.section-title { font-size: var(--fs-h3); font-weight: 600; margin: 0; }

/* ============ Grids ============ */
.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* ============ Mobile responsive ============ */
@media (max-width: 1023px) {
  .app { grid-template-columns: 1fr !important; }
  .sidebar { display: none; }
  .topbar-mobile-toggle { display: inline-flex; }
  .global-search { width: 160px; }
  .page { padding: 16px 16px 80px; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
}
@media (max-width: 640px) {
  .global-search { display: none; }
  .workspace-switcher { max-width: 140px; }
  .breadcrumbs .breadcrumb-item:not(.current):not(:last-of-type) { display: none; }
  .breadcrumb-sep:not(:last-of-type) { display: none; }
  .page-header { flex-direction: column; align-items: stretch; }
  .period-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .period-row > * { width: 100%; }
  .period-row .tabs { justify-content: stretch; }
  .period-row .tab { flex: 1; justify-content: center; }
  .filter-bar { padding: 8px; gap: 6px; }
  .filter-bar > .input-wrap { min-width: 100%; }
  .filter-chip { font-size: var(--fs-xs); padding: 0 8px; }
  .modal { max-height: 92vh; border-radius: var(--r-lg) var(--r-lg) 0 0; align-self: flex-end; max-width: 100%; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .toast-stack { right: 12px; left: 12px; bottom: 12px; }
  .toast { min-width: 0; max-width: 100%; }
}

/* ============ Mobile table → card view ============ */
@media (max-width: 768px) {
  .tx-mobile-cards { display: flex; flex-direction: column; gap: 8px; padding: 12px; }
  .tx-mobile-card {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    padding: 12px 14px;
    cursor: pointer;
    transition: border-color 120ms, background 120ms;
  }
  .tx-mobile-card:hover { border-color: var(--border-default); }
  .tx-mobile-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
  .tx-mobile-card-amount { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
  .tx-mobile-card-meta { display: flex; justify-content: space-between; gap: 12px; font-size: var(--fs-xs); color: var(--text-secondary); }
  .tx-mobile-card-hash { font-family: var(--font-mono); }
  .table-scroll.hide-mobile { display: none; }
  .tx-desktop-only { display: none; }
}
@media (min-width: 769px) {
  .tx-mobile-cards { display: none; }
}

/* Filter sheet (mobile) */
.filter-sheet-trigger {
  display: none;
  height: var(--control-h);
  padding: 0 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: var(--fs-sm);
  font-weight: 500;
  align-items: center;
  gap: 6px;
}
.filter-sheet-trigger .count {
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: var(--r-full);
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
}
@media (max-width: 768px) {
  .filter-sheet-trigger { display: inline-flex; }
  .filter-bar-desktop { display: none !important; }
}
@media (min-width: 769px) {
  .mobile-only-row { display: none !important; }
}

/* ============ Sub-header with sticky filters ============ */
.subheader {
  position: sticky;
  top: var(--topbar-h);
  background: var(--bg-base);
  z-index: calc(var(--z-sticky) - 1);
  padding: 14px 0 12px;
}

/* ============ Switcher row (period segmented) ============ */
.period-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px;
}

/* ============ Chart container ============ */
.chart-wrap { position: relative; width: 100%; height: 280px; }
.chart-wrap.sm { height: 180px; }
.chart-svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart-tip {
  position: absolute;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  padding: 6px 8px;
  font-size: var(--fs-xs);
  pointer-events: none;
  box-shadow: var(--shadow-pop);
  transition: opacity var(--dur-fast);
}

/* ============ Form grid ============ */
.form-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px 32px;
  padding: 4px 0;
}
.form-grid .form-section-label {
  font-size: var(--fs-sm);
  font-weight: 600;
}
.form-grid .form-section-desc {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  margin-top: 4px;
}
.form-grid .form-section + .form-section { padding-top: 24px; border-top: 1px solid var(--border-subtle); }
.form-section { display: contents; }
.form-section-fields { display: flex; flex-direction: column; gap: 14px; max-width: 540px; }
@media (max-width: 800px) { .form-grid { grid-template-columns: 1fr; gap: 12px; } }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* ============ Avatar group ============ */
.avatar {
  width: 28px; height: 28px;
  border-radius: var(--r-full);
  background: var(--bg-surface-3);
  color: var(--text-primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--fs-xs); font-weight: 600;
  border: 2px solid var(--bg-surface);
  flex-shrink: 0;
}

/* ============ Tweaks panel positional ============ */
.tweaks-floating { position: fixed; bottom: 20px; right: 20px; z-index: var(--z-tweaks); }

/* ===== Helpers ===== */
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.muted { color: var(--text-secondary); }
.faint { color: var(--text-tertiary); }
.flex-1 { flex: 1; }
.sep-h { height: 1px; background: var(--border-subtle); width: 100%; }
.text-h1 { font-size: var(--fs-h1); font-weight: 600; letter-spacing: -0.02em; margin: 0; }
.text-h2 { font-size: var(--fs-h2); font-weight: 600; letter-spacing: -0.015em; margin: 0; }
.text-h3 { font-size: var(--fs-h3); font-weight: 600; margin: 0; }
.text-xs { font-size: var(--fs-xs); }
.text-sm { font-size: var(--fs-sm); }
