/* ================================================================
   Astrail Design System — CSS Tokens + Global Styles
   Stone & Signal (default) | Aurora | Onyx & Champagne | Dusk
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Onest:wght@400;500;600;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: 'Onest', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  background-color: var(--col-bg);
  color: var(--col-text);
  transition: background-color 220ms ease, color 180ms ease;
}

/* ================================================================
   PALETTE TOKENS — Applied via JS on <html> element style
   Variable names:
   --col-bg, --col-surface, --col-surface-2
   --col-border-s, --col-border, --col-border-str
   --col-text, --col-text-2, --col-text-3, --col-text-dis
   --col-accent, --col-accent-50, --col-accent-100, --col-accent-600
   --col-accent-hover
   --shadow-xs, --shadow-sm, --shadow-md, --shadow-lg
   ================================================================ */

/* Semantic tokens — consistent across all palettes */
/* Light semantics (defaults, overridden by .dark-semantics class) */
:root {
  --col-success:        #16A34A;
  --col-success-bg:     #DCFCE7;
  --col-success-border: #86EFAC;
  --col-warning:        #C2800A;
  --col-warning-bg:     #FEF3C7;
  --col-warning-border: #FCD34D;
  --col-error:          #DC2626;
  --col-error-bg:       #FEE2E2;
  --col-error-border:   #FCA5A5;
  --col-info:           #2563EB;
  --col-info-bg:        #DBEAFE;

  /* Transaction statuses */
  --col-confirmed:      #16A34A;
  --col-confirmed-bg:   #DCFCE7;
  --col-pending:        #C2800A;
  --col-pending-bg:     #FEF3C7;
  --col-processing:     #2563EB;
  --col-processing-bg:  #DBEAFE;
  --col-failed:         #DC2626;
  --col-failed-bg:      #FEE2E2;
  --col-draft:          #706C68;
  --col-draft-bg:       #F2F0EC;

  /* Chain colors (fixed — not palette dependent) */
  --col-chain-evm:      #627EEA;
  --col-chain-evm-bg:   #EEF0FF;
  --col-chain-tron:     #E84142;
  --col-chain-tron-bg:  #FFF0F0;
  --col-chain-sol:      #9945FF;
  --col-chain-sol-bg:   #F5EEFF;
  --col-chain-btc:      #F7931A;
  --col-chain-btc-bg:   #FFF6E8;
  --col-chain-ton:      #0098EA;
  --col-chain-ton-bg:   #E0F4FF;

  /* Density defaults (comfortable) */
  --density-row:       52px;
  --density-card-pad:  24px;
  --density-gap:       16px;
  --density-section:   24px;
  --density-font-sm:   14px;
  --density-font-cap:  12px;
}

/* Dark semantic overrides */
.sem-dark {
  --col-success:        #4ADE80;
  --col-success-bg:     rgba(74,222,128,0.14);
  --col-success-border: rgba(74,222,128,0.30);
  --col-warning:        #FCD34D;
  --col-warning-bg:     rgba(252,211,77,0.14);
  --col-warning-border: rgba(252,211,77,0.30);
  --col-error:          #F87171;
  --col-error-bg:       rgba(248,113,113,0.14);
  --col-error-border:   rgba(248,113,113,0.30);
  --col-info:           #60A5FA;
  --col-info-bg:        rgba(96,165,250,0.14);
  --col-confirmed:      #4ADE80;
  --col-confirmed-bg:   rgba(74,222,128,0.12);
  --col-pending:        #FCD34D;
  --col-pending-bg:     rgba(252,211,77,0.12);
  --col-processing:     #60A5FA;
  --col-processing-bg:  rgba(96,165,250,0.12);
  --col-failed:         #F87171;
  --col-failed-bg:      rgba(248,113,113,0.12);
  --col-draft:          #8A8880;
  --col-draft-bg:       rgba(138,136,128,0.14);
}

/* Compact density overrides */
.density-compact {
  --density-row:       40px;
  --density-card-pad:  16px;
  --density-gap:       12px;
  --density-section:   16px;
  --density-font-sm:   13px;
  --density-font-cap:  11px;
}

/* ================================================================
   APP SHELL LAYOUT
   ================================================================ */
#root { height: 100%; }

.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--col-bg);
}

/* ================================================================
   SIDEBAR
   ================================================================ */
.sidebar {
  width: 244px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--col-surface);
  border-right: 1px solid var(--col-border-s);
  transition: background 220ms ease, border-color 180ms ease;
  z-index: 10;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  height: 56px;
  border-bottom: 1px solid var(--col-border-s);
  flex-shrink: 0;
  user-select: none;
}

.sidebar-logo-mark {
  width: 30px;
  height: 30px;
  background: #0A0B0F;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--col-text);
  letter-spacing: -0.01em;
}

.sidebar-workspace {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  margin: 8px 8px 4px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 150ms ease;
  border: 1px solid var(--col-border-s);
}
.sidebar-workspace:hover { background: var(--col-surface-2); }

.sidebar-workspace-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--col-text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-workspace-role {
  font-size: 11px;
  color: var(--col-text-3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  height: 38px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--col-text-2);
  transition: background 120ms ease, color 120ms ease;
  user-select: none;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
}
.nav-item:hover { background: var(--col-accent-hover); color: var(--col-text); }
.nav-item.active {
  background: var(--col-accent-50);
  color: var(--col-accent);
}
.nav-item.active .nav-icon { color: var(--col-accent); }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--col-accent);
  color: white;
  font-size: 11px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}
.nav-icon { color: var(--col-text-3); flex-shrink: 0; }
.nav-item.active .nav-icon { color: var(--col-accent); }

.nav-divider {
  height: 1px;
  background: var(--col-border-s);
  margin: 6px 8px;
}

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--col-border-s);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 120ms ease;
}
.sidebar-user:hover { background: var(--col-accent-hover); }

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--col-accent-50);
  color: var(--col-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 500; color: var(--col-text); }
.user-role { font-size: 11px; color: var(--col-text-3); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 500; }

/* ================================================================
   MAIN CONTENT AREA
   ================================================================ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 56px;
  border-bottom: 1px solid var(--col-border-s);
  background: var(--col-surface);
  flex-shrink: 0;
  gap: 16px;
  transition: background 220ms ease, border-color 180ms ease;
}

.content-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--col-text-2);
}
.breadcrumb-sep { color: var(--col-text-3); }
.breadcrumb-current { color: var(--col-text); font-weight: 500; }
.breadcrumb-link { color: var(--col-text-2); cursor: pointer; }
.breadcrumb-link:hover { color: var(--col-accent); }

.page-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--col-text);
  letter-spacing: -0.01em;
}

.content-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.content-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: var(--density-section);
}

/* ================================================================
   CARD
   ================================================================ */
.card {
  background: var(--col-surface);
  border: 1px solid var(--col-border-s);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  transition: background 220ms ease, border-color 180ms ease, box-shadow 180ms ease;
}
.card-pad { padding: var(--density-card-pad); }
.card:hover { box-shadow: var(--shadow-md); }

.card-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--col-text-3);
  margin-bottom: 16px;
}

/* ================================================================
   STAT CARDS
   ================================================================ */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--density-gap);
}

.stat-card {
  background: var(--col-surface);
  border: 1px solid var(--col-border-s);
  border-radius: 16px;
  padding: 20px var(--density-card-pad);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: default;
  transition: background 220ms ease, border-color 180ms ease, box-shadow 180ms ease;
}
.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-label {
  font-size: var(--density-font-cap);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--col-text-3);
}

.stat-value {
  font-size: 26px;
  font-weight: 600;
  color: var(--col-text);
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.stat-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.stat-change {
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat-change.pos { color: var(--col-success); }
.stat-change.neg { color: var(--col-error); }

.stat-sub {
  font-size: 12px;
  color: var(--col-text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-meta { flex-wrap: wrap; row-gap: 3px; }

/* ================================================================
   BUTTONS
   ================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease, box-shadow 120ms ease, opacity 120ms ease, transform 80ms ease;
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:active { transform: none; }

.btn-sm  { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-md  { height: 38px; padding: 0 16px; font-size: 14px; }
.btn-lg  { height: 44px; padding: 0 22px; font-size: 15px; }

.btn-primary {
  background: var(--col-accent);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.14), 0 0 0 0 transparent;
}
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 2px 8px rgba(0,0,0,0.18); }

.btn-secondary {
  background: var(--col-surface);
  color: var(--col-text);
  border: 1px solid var(--col-border);
}
.btn-secondary:hover { background: var(--col-surface-2); }

.btn-ghost {
  background: transparent;
  color: var(--col-text-2);
  border: none;
}
.btn-ghost:hover { background: var(--col-accent-hover); color: var(--col-text); }

.btn-destructive {
  background: var(--col-error-bg);
  color: var(--col-error);
  border: 1px solid var(--col-error-border);
}
.btn-destructive:hover { filter: brightness(0.96); }

.btn-link {
  background: transparent;
  color: var(--col-accent);
  padding: 0;
  height: auto;
  font-size: 13px;
  border-radius: 4px;
}
.btn-link:hover { text-decoration: underline; }

/* ================================================================
   BADGES
   ================================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--density-font-cap);
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge-confirmed  { background: var(--col-confirmed-bg);  color: var(--col-confirmed);  }
.badge-pending    { background: var(--col-pending-bg);    color: var(--col-pending);    }
.badge-processing { background: var(--col-processing-bg); color: var(--col-processing); }
.badge-failed     { background: var(--col-failed-bg);     color: var(--col-failed);     }
.badge-draft      { background: var(--col-draft-bg);      color: var(--col-draft);      }

.badge-dot::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

/* Chain badges */
.chain-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.chain-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.chain-evm  { background: var(--col-chain-evm-bg);  color: var(--col-chain-evm);  }
.chain-tron { background: var(--col-chain-tron-bg); color: var(--col-chain-tron); }
.chain-sol  { background: var(--col-chain-sol-bg);  color: var(--col-chain-sol);  }
.chain-btc  { background: var(--col-chain-btc-bg);  color: var(--col-chain-btc);  }
.chain-ton  { background: var(--col-chain-ton-bg);  color: var(--col-chain-ton);  }

/* ================================================================
   TABLE
   ================================================================ */
.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: var(--density-font-cap);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--col-text-3);
  border-bottom: 1px solid var(--col-border-s);
  white-space: nowrap;
}

.data-table th.right, .data-table td.right { text-align: right; }
.data-table th.center, .data-table td.center { text-align: center; }

.data-table td {
  padding: 0 16px;
  height: var(--density-row);
  font-size: var(--density-font-sm);
  color: var(--col-text);
  border-bottom: 1px solid var(--col-border-s);
  vertical-align: middle;
  transition: background 100ms ease;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover td { background: var(--col-accent-hover); }
.data-table tbody tr.selected td { background: var(--col-accent-50); }

.cell-primary { font-weight: 500; color: var(--col-text); }
.cell-secondary { color: var(--col-text-2); }
.cell-mono { font-variant-numeric: tabular-nums; font-weight: 500; }
.cell-address {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--col-text-2);
}

/* ================================================================
   TABS
   ================================================================ */
.tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--col-surface-2);
  border-radius: 10px;
  width: fit-content;
}
.tab {
  padding: 5px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--col-text-2);
  cursor: pointer;
  transition: all 150ms ease;
  user-select: none;
}
.tab:hover { color: var(--col-text); }
.tab.active {
  background: var(--col-surface);
  color: var(--col-text);
  box-shadow: var(--shadow-xs);
}

/* ================================================================
   MISC UTILITIES
   ================================================================ */
.flex-row { display: flex; align-items: center; }
.flex-col { display: flex; flex-direction: column; }
.gap-4  { gap: 4px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.ml-auto { margin-left: auto; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-2  { color: var(--col-text-2); }
.text-3  { color: var(--col-text-3); }
.text-accent { color: var(--col-accent); }
.text-success { color: var(--col-success); }
.text-error   { color: var(--col-error); }
.text-warning { color: var(--col-warning); }
.fw-5 { font-weight: 500; }
.fw-6 { font-weight: 600; }
.mono { font-variant-numeric: tabular-nums; }

/* Approval progress */
.approval-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--col-text-2);
}
.sig-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}
.sig-dot.signed   { background: var(--col-success-bg); color: var(--col-success); }
.sig-dot.unsigned { background: var(--col-surface-2); border: 1.5px dashed var(--col-border); color: var(--col-text-3); }

/* Validation checks */
.check-list { display: flex; flex-direction: column; gap: 8px; }
.check-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.check-item .check-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 10px;
}
.check-ok   { background: var(--col-success-bg); color: var(--col-success); }
.check-warn { background: var(--col-warning-bg); color: var(--col-warning); }
.check-err  { background: var(--col-error-bg);   color: var(--col-error);   }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 32px;
  gap: 12px;
  text-align: center;
}
.empty-icon { color: var(--col-text-3); opacity: 0.5; margin-bottom: 4px; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--col-text-2); }
.empty-desc  { font-size: 13px; color: var(--col-text-3); max-width: 300px; }

/* Flag/alert inline */
.inline-flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.flag-new  { background: var(--col-accent-50); color: var(--col-accent); }
.flag-high { background: var(--col-warning-bg); color: var(--col-warning); }

/* Avatar initials */
.avatar {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
  font-size: 12px;
}
.avatar-sm { width: 26px; height: 26px; font-size: 10px; }
.avatar-md { width: 32px; height: 32px; font-size: 12px; }
.avatar-lg { width: 40px; height: 40px; font-size: 15px; }

/* Wallet type badge */
.wallet-type {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 4px;
}
.wallet-multisig { background: var(--col-accent-50); color: var(--col-accent); }
.wallet-eoa      { background: var(--col-surface-2); color: var(--col-text-3); border: 1px solid var(--col-border-s); }

/* SVG chart */
.chart-bar-in  { fill: var(--col-accent); transition: fill 220ms ease; }
.chart-bar-out { fill: var(--col-border-str); transition: fill 220ms ease; }
.chart-bar-in:hover  { fill: var(--col-accent-600); }
.chart-bar-out:hover { filter: brightness(0.9); }

/* ================================================================
   GLASS MODE — Apple-style frosted glass
   ================================================================ */
.glass-mode {
  background: transparent !important;
}
.glass-mode .app-shell { background: transparent !important; }
.glass-mode .main-content { background: transparent !important; }
.glass-mode .content-body { background: transparent; }

.glass-mode .sidebar {
  background: rgba(255,255,255,0.62) !important;
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border-right-color: rgba(255,255,255,0.55) !important;
  box-shadow: 1px 0 0 rgba(255,255,255,0.6) inset;
}
.glass-mode .sidebar-logo,
.glass-mode .sidebar-footer { border-color: rgba(255,255,255,0.4) !important; }
.glass-mode .sidebar-workspace {
  background: rgba(255,255,255,0.5) !important;
  border-color: rgba(255,255,255,0.7) !important;
}
.glass-mode .sidebar-workspace:hover { background: rgba(255,255,255,0.72) !important; }
.glass-mode .nav-item:hover { background: rgba(255,255,255,0.45) !important; }
.glass-mode .nav-item.active { background: rgba(255,255,255,0.70) !important; }

.glass-mode .content-header {
  background: rgba(255,255,255,0.58) !important;
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom-color: rgba(255,255,255,0.5) !important;
}

.glass-mode .card,
.glass-mode .stat-card {
  background: rgba(255,255,255,0.58) !important;
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-color: rgba(255,255,255,0.72) !important;
  box-shadow:
    0 8px 32px rgba(0,0,0,0.07),
    0 2px 8px rgba(0,0,0,0.04),
    0 1px 0 rgba(255,255,255,0.85) inset !important;
}
.glass-mode .card:hover,
.glass-mode .stat-card:hover {
  background: rgba(255,255,255,0.70) !important;
  box-shadow:
    0 12px 40px rgba(0,0,0,0.10),
    0 2px 8px rgba(0,0,0,0.05),
    0 1px 0 rgba(255,255,255,0.90) inset !important;
}
.glass-mode .data-table tbody tr:hover td { background: rgba(255,255,255,0.45) !important; }

.glass-mode .tabs {
  background: rgba(255,255,255,0.40) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.glass-mode .tab.active { background: rgba(255,255,255,0.80) !important; }

.glass-mode .btn-secondary {
  background: rgba(255,255,255,0.62) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-color: rgba(255,255,255,0.8) !important;
}
.glass-mode .btn-secondary:hover { background: rgba(255,255,255,0.82) !important; }

/* Dark glass */
.glass-mode.sem-dark .sidebar {
  background: rgba(18,16,32,0.68) !important;
  border-right-color: rgba(255,255,255,0.08) !important;
}
.glass-mode.sem-dark .content-header {
  background: rgba(18,16,32,0.58) !important;
  border-bottom-color: rgba(255,255,255,0.07) !important;
}
.glass-mode.sem-dark .card,
.glass-mode.sem-dark .stat-card {
  background: rgba(28,24,48,0.62) !important;
  border-color: rgba(255,255,255,0.10) !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.28), 0 1px 0 rgba(255,255,255,0.06) inset !important;
}
.glass-mode.sem-dark .sidebar-workspace {
  background: rgba(255,255,255,0.06) !important;
  border-color: rgba(255,255,255,0.10) !important;
}
.glass-mode.sem-dark .nav-item.active  { background: rgba(255,255,255,0.12) !important; }
.glass-mode.sem-dark .nav-item:hover   { background: rgba(255,255,255,0.07) !important; }
.glass-mode.sem-dark .tabs             { background: rgba(255,255,255,0.06) !important; }
.glass-mode.sem-dark .tab.active       { background: rgba(255,255,255,0.14) !important; }
.glass-mode.sem-dark .btn-secondary    { background: rgba(255,255,255,0.08) !important; border-color: rgba(255,255,255,0.12) !important; }

/* ================================================================
   FOCUS VISIBLE — keyboard navigation (C6 fix)
   ================================================================ */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--col-accent);
  outline-offset: 2px;
  border-radius: inherit;
}
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--col-accent);
  outline-offset: 0;
}
.nav-item:focus-visible      { border-radius: 9px; }
.btn:focus-visible            { border-radius: 10px; }
.tab:focus-visible            { border-radius: 8px; }
.bottom-tab-item:focus-visible{ outline-offset: -3px; }

/* ================================================================
   PREFERS REDUCED MOTION (C7 fix)
   ================================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .modal, .modal-overlay, .toast,
  .notif-panel-inner, .approval-panel-inner {
    animation: none !important;
  }
}

/* ================================================================
   Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--col-border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--col-border-str); }

/* Global keyframes */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Toast */
.toast-area {
  position: fixed;
  top: 16px;
  right: 20px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 380px;
}
.toast {
  background: var(--col-surface);
  border: 1px solid var(--col-border-s);
  border-radius: 14px;
  padding: 13px 14px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,0,0,0.03);
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 14px;
  pointer-events: all;
  min-width: 300px;
  max-width: 380px;
  animation: toastIn 280ms cubic-bezier(0.34, 1.3, 0.64, 1);
  position: relative;
  overflow: hidden;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}
.toast-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.toast-icon-success { background: var(--col-success-bg); color: var(--col-success); }
.toast-icon-error   { background: var(--col-error-bg);   color: var(--col-error);   }
.toast-icon-warning { background: var(--col-warning-bg); color: var(--col-warning); }
.toast-icon-info    { background: var(--col-info-bg);    color: var(--col-info);    }
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  border-radius: 0 0 14px 14px;
  animation: toastProgress linear forwards;
}
.toast-progress-success { background: var(--col-success); }
.toast-progress-error   { background: var(--col-error);   }
.toast-progress-warning { background: var(--col-warning); }
@keyframes toastProgress {
  from { width: 100%; }
  to   { width: 0%; }
}

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 180ms ease;
}
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
.modal {
  background: var(--col-surface);
  border-radius: 20px;
  box-shadow: var(--shadow-xl, 0 20px 60px rgba(0,0,0,0.18), 0 4px 16px rgba(0,0,0,0.08));
  padding: 28px;
  width: 480px;
  max-width: calc(100vw - 32px);
  animation: modalIn 200ms ease;
}
@keyframes modalIn { from { opacity:0; transform: scale(0.96) translateY(-8px); } to { opacity:1; transform: none; } }
.modal-header { margin-bottom: 16px; }
.modal-title  { font-size: 18px; font-weight: 600; color: var(--col-text); }
.modal-body   { color: var(--col-text-2); font-size: 14px; line-height: 1.6; margin-bottom: 24px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; }

/* ================================================================
   LAYOUT GRID UTILITIES
   ================================================================ */
.grid-main-aside      { display: grid; grid-template-columns: 1fr minmax(0,340px); gap: var(--density-gap); }
.grid-aside-main      { display: grid; grid-template-columns: 300px minmax(0,1fr); gap: var(--density-gap); }
.grid-content-sidebar { display: grid; grid-template-columns: minmax(0,1fr) 310px; gap: var(--density-gap); align-items: start; }

/* Table scroll wrapper — prevents broken layouts on narrow screens */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap .data-table { min-width: 540px; }

/* ================================================================
   MOBILE TOP BAR + HAMBURGER + OVERLAY
   ================================================================ */
.mobile-topbar {
  display: none;
  height: 52px;
  background: var(--col-surface);
  border-bottom: 1px solid var(--col-border-s);
  padding: 0 14px 0 16px;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  transition: background 220ms ease, border-color 180ms ease;
}
.mobile-topbar-title {
  font-size: 15px; font-weight: 600; color: var(--col-text);
  flex: 1; letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mobile-topbar-mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--col-accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.mobile-topbar-actions {
  display: flex; align-items: center; gap: 2px; flex-shrink: 0;
}
.mobile-topbar-btn {
  width: 36px; height: 36px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: var(--col-text-2); padding: 0;
  transition: background 120ms ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  flex-shrink: 0;
}
.mobile-topbar-btn:active { background: var(--col-surface-2); }

.hamburger {
  width: 36px; height: 36px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: var(--col-text-2); padding: 0; flex-shrink: 0;
  transition: background 120ms ease;
  -webkit-tap-highlight-color: transparent;
}
.hamburger:hover { background: var(--col-accent-hover); color: var(--col-text); }
.hamburger:active { background: var(--col-surface-2); }

.sidebar-overlay {
  position: fixed; inset: 0; z-index: 9;
  background: rgba(0,0,0,0.48);
  display: none;
}
.sidebar-overlay.is-open { display: block; animation: fadeIn 200ms ease; }

/* ================================================================
   BOTTOM TAB BAR — mobile primary navigation
   ================================================================ */
.bottom-tab-bar {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(56px + env(safe-area-inset-bottom, 0px));
  background: var(--col-surface);
  border-top: 1px solid var(--col-border-s);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 110;
  align-items: flex-start;
  justify-content: space-around;
  box-shadow: 0 -1px 0 var(--col-border-s), 0 -4px 20px rgba(0,0,0,0.04);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  transition: background 220ms ease, border-color 180ms ease;
}
.bottom-tab-item {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; flex: 1; height: 56px;
  cursor: pointer; color: var(--col-text-3);
  transition: color 120ms ease;
  position: relative;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  min-width: 44px;
}
.bottom-tab-item:active { opacity: 0.65; transform: scale(0.93); }
.bottom-tab-item.active { color: var(--col-accent); }
.bottom-tab-icon {
  display: flex; align-items: center; justify-content: center;
  position: relative; width: 24px; height: 24px;
}
.bottom-tab-label {
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.01em; line-height: 1;
}
.bottom-tab-badge {
  position: absolute; top: -4px; right: -6px;
  min-width: 14px; height: 14px; border-radius: 999px;
  background: var(--col-accent);
  border: 1.5px solid var(--col-surface);
  display: flex; align-items: center; justify-content: center;
  font-size: 8px; font-weight: 700; color: white;
  padding: 0 3px; line-height: 1;
}

/* ================================================================
   MORE BOTTOM SHEET — mobile secondary navigation
   ================================================================ */
.more-sheet-row {
  display: flex; align-items: center; gap: 14px;
  padding: 15px 20px; cursor: pointer;
  transition: background 100ms ease;
  border-bottom: 1px solid var(--col-border-s);
  -webkit-tap-highlight-color: transparent;
}
.more-sheet-row:last-of-type { border-bottom: none; }
.more-sheet-row:active { background: var(--col-surface-2); }
.more-sheet-icon {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--col-surface-2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ================================================================
   RESPONSIVE — LARGE DESKTOP  (≥ 1440px)
   ================================================================ */
@media (min-width: 1440px) {
  .content-body { padding: 32px 40px; }
}

/* ================================================================
   RESPONSIVE — TABLET  (768px – 1099px)
   Icon-only sidebar always in flow — no drawer, no hamburger
   ================================================================ */
@media (min-width: 768px) and (max-width: 1099px) {
  /* Narrow icon-only sidebar — in normal flow */
  .sidebar {
    width: 62px !important;
    min-width: 62px !important;
    flex-shrink: 0;
    overflow: visible;
  }
  .sidebar .sidebar-workspace-name,
  .sidebar .sidebar-workspace-role,
  .sidebar .user-name,
  .sidebar .user-role          { display: none !important; }
  .sidebar .sidebar-workspace  { justify-content: center !important; padding: 8px 6px !important; margin: 6px 4px 4px !important; }
  .sidebar .sidebar-footer     { padding: 8px 4px !important; }
  .sidebar .sidebar-user       { justify-content: center !important; padding: 8px 4px !important; }
  .sidebar .nav-item           { justify-content: center !important; padding: 0 !important; height: 44px !important; overflow: hidden !important; }
  .sidebar .nav-item > span    { display: none !important; }
  .sidebar .sidebar-workspace > span { display: none !important; }
  .sidebar .nav-badge          { display: none !important; }
  .sidebar .settings-subnav   { display: none !important; }
  .sidebar .sidebar-nav        { padding: 8px 4px !important; }
  .sidebar .nav-divider        { margin: 4px 6px !important; }
  .sidebar .sidebar-logo       { padding: 0 !important; justify-content: center !important; overflow: hidden !important; }
  .sidebar .sidebar-logo-text  { display: none !important; }
  .sidebar-collapse-btn        { display: none !important; }
  .sidebar                     { overflow: hidden !important; }

  /* Content header visible on tablet — no mobile topbar */
  .mobile-topbar  { display: none !important; }
  .content-header { display: flex !important; }

  /* 2-col stat cards; other grids single-col */
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .grid-main-aside,
  .grid-aside-main,
  .grid-content-sidebar { grid-template-columns: 1fr; }

  .content-body { padding: 20px 24px; }
  .bottom-tab-bar { display: none !important; }
}

/* ================================================================
   RESPONSIVE — MOBILE  (≤ 767px)
   ================================================================ */
@media (max-width: 767px) {
  /* Sidebar as hidden drawer (accessible via MoreSheet if needed) */
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 10;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
  }
  .sidebar.is-open         { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-overlay.is-open { display: block; }

  /* Mobile topbar + hide page content-header */
  .mobile-topbar  { display: flex; }
  .content-header { display: none; }

  /* Single-column grids */
  .stat-cards,
  .grid-main-aside,
  .grid-aside-main,
  .grid-content-sidebar { grid-template-columns: 1fr; }

  /* Spacing — extra bottom padding for tab bar */
  .content-body {
    padding: 14px 16px;
    gap: 12px;
    padding-bottom: calc(14px + 56px + env(safe-area-inset-bottom, 0px));
  }

  /* Typography scale */
  .stat-value { font-size: 22px; }
  .modal      { border-radius: 16px; padding: 22px; }

  /* Show bottom tab bar */
  .bottom-tab-bar { display: flex; }

  /* Touch target minimums per docs (44×44px) */
  .btn-sm  { min-height: 38px; }
  .btn-md  { min-height: 44px; }
  .btn-lg  { min-height: 48px; }
  .nav-item { min-height: 44px; }

  /* Notification panel full-screen on mobile */
  .notif-panel-inner {
    width: 100% !important;
    border-left: none !important;
    border-top: 1px solid var(--col-border-s) !important;
  }
  /* Approval detail panel full-screen on mobile */
  .approval-panel-inner {
    width: 100% !important;
    border-left: none !important;
  }

  /* Toast above bottom tab bar */
  .toast-area {
    top: auto !important;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    right: 12px; left: 12px;
    max-width: none;
  }
  .toast { min-width: 0; max-width: none; width: 100%; }

  /* Table overflow on mobile */
  .table-wrap .data-table { min-width: 480px; }

  /* Mobile card list (used for tx history etc) */
  .mobile-card-list-item {
    display: flex !important; align-items: center;
    padding: 13px 16px; gap: 12px;
    border-bottom: 1px solid var(--col-border-s);
    cursor: pointer; transition: background 100ms ease;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-card-list-item:last-child  { border-bottom: none; }
  .mobile-card-list-item:active      { background: var(--col-surface-2); }
  /* Hide desktop table, show mobile list */
  .desktop-only-table { display: none !important; }
  .mobile-only-list   { display: flex !important; flex-direction: column; }
}

/* ================================================================
   DEVICE SIMULATOR  — classes applied to #root by Tweaks panel
   ================================================================ */

/* Centering shell */
#root.sim-phone,
#root.sim-tablet {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: oklch(from var(--col-bg) calc(l - 0.03) c h);
  min-height: 100vh;
}
/* Critical: transform creates a containing block for position:fixed children
   so fixed overlays/bars are scoped to the simulated device frame */
#root.sim-phone > *, #root.sim-tablet > * {
  flex-shrink: 0;
  min-height: 100vh;
  box-shadow: 0 0 0 1px var(--col-border), 0 24px 80px rgba(0,0,0,0.18);
  overflow: hidden;
  transform: translateZ(0);
}
#root.sim-phone  > * { width: 390px; }
#root.sim-tablet > * { width: 820px; }

/* ── Phone sim ── */
#root.sim-phone .sidebar {
  position: fixed !important; left: 0; top: 0; bottom: 0; z-index: 10;
  width: 280px !important; transform: translateX(-100%) !important;
  transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1); box-shadow: none;
}
#root.sim-phone .sidebar.is-open          { transform: translateX(0) !important; box-shadow: var(--shadow-lg) !important; }
#root.sim-phone .sidebar-overlay.is-open  { display: block !important; }
#root.sim-phone .mobile-topbar            { display: flex !important; }
#root.sim-phone .content-header           { display: none !important; }
#root.sim-phone .stat-cards,
#root.sim-phone .grid-main-aside,
#root.sim-phone .grid-aside-main,
#root.sim-phone .grid-content-sidebar     { grid-template-columns: 1fr !important; }
#root.sim-phone .content-body {
  padding: 14px 16px !important; gap: 12px !important;
  padding-bottom: calc(14px + 56px + env(safe-area-inset-bottom, 0px)) !important;
}
#root.sim-phone .stat-value               { font-size: 22px !important; }
#root.sim-phone .bottom-tab-bar           { display: flex !important; }
#root.sim-phone .notif-panel-inner        { width: 100% !important; border-left: none !important; }
#root.sim-phone .approval-panel-inner     { width: 100% !important; border-left: none !important; }
#root.sim-phone .desktop-only-table       { display: none !important; }
#root.sim-phone .mobile-only-list         { display: flex !important; flex-direction: column !important; }
#root.sim-phone .toast-area {
  top: auto !important;
  bottom: calc(68px + env(safe-area-inset-bottom, 0px)) !important;
  right: 12px !important; left: 12px !important;
  max-width: none !important;
}
#root.sim-phone .toast { min-width: 0 !important; max-width: none !important; width: 100% !important; }
#root.sim-phone .btn-md { min-height: 44px !important; }

/* ── Tablet sim ── */
/* Sidebar in-flow, icon-only — NOT fixed/hidden */
#root.sim-tablet .sidebar {
  position: relative !important;
  left: auto !important; top: auto !important; bottom: auto !important;
  transform: none !important;
  width: 62px !important; min-width: 62px !important;
  flex-shrink: 0 !important;
  height: 100vh;
  overflow: visible !important;
}
#root.sim-tablet .sidebar .sidebar-workspace-name,
#root.sim-tablet .sidebar .sidebar-workspace-role,
#root.sim-tablet .sidebar .user-name,
#root.sim-tablet .sidebar .user-role         { display: none !important; }
#root.sim-tablet .sidebar .sidebar-workspace { justify-content: center !important; padding: 8px 6px !important; margin: 6px 4px 4px !important; }
#root.sim-tablet .sidebar .sidebar-footer    { padding: 8px 4px !important; }
#root.sim-tablet .sidebar .sidebar-user      { justify-content: center !important; padding: 8px 4px !important; }
#root.sim-tablet .sidebar .nav-item          { justify-content: center !important; padding: 0 !important; height: 44px !important; overflow: hidden !important; }
#root.sim-tablet .sidebar .nav-item > span   { display: none !important; }
#root.sim-tablet .sidebar .nav-badge         { display: none !important; }
#root.sim-tablet .sidebar .settings-subnav  { display: none !important; }
#root.sim-tablet .sidebar .sidebar-nav       { padding: 8px 4px !important; }
#root.sim-tablet .sidebar .nav-divider       { margin: 4px 6px !important; }
#root.sim-tablet .sidebar .sidebar-logo      { padding: 0 !important; justify-content: center !important; overflow: hidden !important; }
#root.sim-tablet .sidebar .sidebar-logo-text { display: none !important; }
#root.sim-tablet .sidebar-collapse-btn       { display: none !important; }
#root.sim-tablet .sidebar                    { overflow: hidden !important; }
/* No drawer overlay on tablet */
#root.sim-tablet .sidebar-overlay            { display: none !important; }
/* Content header visible */
#root.sim-tablet .mobile-topbar  { display: none !important; }
#root.sim-tablet .content-header { display: flex !important; }
/* 2-col stat cards; single-col other grids */
#root.sim-tablet .stat-cards { grid-template-columns: 1fr 1fr !important; }
#root.sim-tablet .grid-main-aside,
#root.sim-tablet .grid-aside-main,
#root.sim-tablet .grid-content-sidebar { grid-template-columns: 1fr !important; }
#root.sim-tablet .content-body         { padding: 20px 24px !important; }
#root.sim-tablet .bottom-tab-bar       { display: none !important; }
