@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&family=IBM+Plex+Sans:wght@300;400;500;600;700&display=swap");

:root,
body.theme-dark {
  --bg: #08090b;
  --surface: #0d0f13;
  --surface-2: #12141a;
  --surface-3: #181b23;
  --surface-4: #1e222c;
  --surface-5: #252a36;
  --line: rgba(255, 255, 255, 0.045);
  --line-strong: rgba(255, 255, 255, 0.08);
  --line-max: rgba(255, 255, 255, 0.12);
  --text: #dfe2e9;
  --muted: #878e9f;
  --muted-2: #505766;
  --muted-3: #363c4a;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.1);
  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.1);
  --green-text: #34d399;
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.08);
  --red-text: #f87171;
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.08);
  --cyan: #06b6d4;
  --shadow: none;
  --handle: 5px;
}

body.theme-light {
  --bg: #f4f1eb;
  --surface: #faf9f7;
  --surface-2: #f0eeea;
  --surface-3: #e8e5df;
  --surface-4: #ddd9d2;
  --surface-5: #d0ccc4;
  --line: rgba(0, 0, 0, 0.07);
  --line-strong: rgba(0, 0, 0, 0.12);
  --line-max: rgba(0, 0, 0, 0.18);
  --text: #1a1714;
  --muted: #5c564d;
  --muted-2: #8a847a;
  --muted-3: #b0aaa0;
  --accent: #b45309;
  --accent-soft: rgba(180, 83, 9, 0.08);
  --green: #16a34a;
  --green-soft: rgba(22, 163, 74, 0.08);
  --green-text: #15803d;
  --red: #dc2626;
  --red-soft: rgba(220, 38, 38, 0.06);
  --red-text: #b91c1c;
  --amber: #d97706;
  --amber-soft: rgba(217, 119, 6, 0.06);
  --cyan: #0e7490;
}

body.theme-console {
  --bg: #07110b;
  --surface: #0b1610;
  --surface-2: #0d1a13;
  --surface-3: #12241a;
  --surface-4: #163020;
  --surface-5: #1a3826;
  --line: rgba(82, 135, 106, 0.18);
  --line-strong: rgba(82, 135, 106, 0.28);
  --line-max: rgba(82, 135, 106, 0.4);
  --text: #e8f7eb;
  --muted: #7ca08a;
  --muted-2: #50705c;
  --muted-3: #335041;
  --accent: #49c97d;
  --accent-soft: rgba(73, 201, 125, 0.1);
  --green: #49d98a;
  --green-soft: rgba(73, 217, 138, 0.12);
  --green-text: #80f3ae;
  --red: #ff716f;
  --red-soft: rgba(255, 113, 111, 0.08);
  --red-text: #ff9b99;
  --amber: #d6ac55;
  --amber-soft: rgba(214, 172, 85, 0.1);
  --cyan: #4ddad4;
}

:root {
  --mono: "IBM Plex Mono", monospace;
  --sans: "IBM Plex Sans", sans-serif;
  --radius: 6px;
  --radius-sm: 4px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  display: flex;
  flex-direction: column;
  font-size: 14px;
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-frame {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.login-brand,
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Top-bar login/account button ------------------------------------------------ */
.auth-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.auth-button:hover {
  border-color: rgba(91, 135, 255, 0.55);
  background: rgba(91, 135, 255, 0.08);
}

.auth-button .auth-avatar {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(91, 135, 255, 0.18);
  border: 1px solid rgba(91, 135, 255, 0.35);
  color: #d7e5ff;
}

.auth-button .auth-avatar svg {
  width: 14px;
  height: 14px;
}

.auth-button.is-anonymous {
  border-color: rgba(91, 135, 255, 0.45);
  color: #d7e5ff;
}

.auth-button.is-authed {
  border-color: rgba(39, 208, 143, 0.45);
  color: #c8f5de;
  background: rgba(39, 208, 143, 0.08);
}

.auth-button.is-authed .auth-avatar {
  background: rgba(39, 208, 143, 0.18);
  border-color: rgba(39, 208, 143, 0.45);
  color: #c8f5de;
}

.auth-button.is-authed:hover {
  border-color: rgba(39, 208, 143, 0.7);
  background: rgba(39, 208, 143, 0.12);
}

/* Anonymous visual state — fade controls that require auth -------------------- */
body.auth-anonymous [data-requires-auth] {
  opacity: 0.55;
  pointer-events: none;
}

body.auth-anonymous .bbar .bact,
body.auth-anonymous #matrix-open-button,
body.auth-anonymous #wallet-open-button {
  opacity: 0.6;
}

/* Login modal ----------------------------------------------------------------- */
.login-modal {
  width: min(440px, 92vw);
  max-width: 92vw;
}

.login-modal .login-brand {
  margin-bottom: 12px;
}

.login-error {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--red);
  font-size: 0.85rem;
}

.login-oauth-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.oauth-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--fg);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.oauth-button:hover {
  background: var(--bg3);
  border-color: var(--fg-muted);
}
.oauth-button svg {
  flex-shrink: 0;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--fg-muted);
  font-size: 0.82rem;
}
.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.login-toggle-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--fg-muted);
  margin-top: 4px;
}

.link-button {
  background: none;
  border: none;
  color: var(--blue);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-button:hover {
  color: var(--fg);
}

.login-verify-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(52, 168, 83, 0.1);
  border: 1px solid rgba(52, 168, 83, 0.25);
  color: var(--fg);
  font-size: 0.85rem;
  line-height: 1.45;
  margin-top: 4px;
}
.login-verify-notice svg {
  flex-shrink: 0;
  color: #34a853;
  margin-top: 2px;
}
.login-verify-notice strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.9rem;
}
.login-verify-notice p {
  margin: 0;
  color: var(--fg-muted);
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(91, 135, 255, 0.24), rgba(91, 135, 255, 0.1));
  border: 1px solid rgba(91, 135, 255, 0.24);
  color: #f7fbff;
  font-family: var(--mono);
  font-weight: 700;
}

.brand-eyebrow,
.summary-label,
.panel-count,
.period-button,
.head-toggle,
.utility-button,
.mobile-tab-button,
.field span,
.control-label,
.runtime-item-label,
.status-text,
.doc-chip,
.link-toggle {
  font-family: var(--mono);
}

.brand-eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.73rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.brand-copy h1,
.panel-head h2,
.modal-head h3,
.login-modal .login-brand h1 {
  margin: 0;
  font-size: 1.36rem;
  letter-spacing: -0.03em;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field input,
.field select,
.command-bar input {
  width: 100%;
  min-height: 46px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  padding: 0 14px;
}

.field input:focus,
.field select:focus,
.command-bar input:focus {
  outline: none;
  border-color: rgba(91, 135, 255, 0.38);
  box-shadow: 0 0 0 3px rgba(91, 135, 255, 0.12);
}

.topbar{display:flex;align-items:center;background:var(--surface);border-bottom:1px solid var(--line);height:56px;flex-shrink:0;padding:0 12px;gap:8px}
.mg{display:flex;align-items:center;gap:6px;min-width:0;flex:1}
.m{padding:6px 14px;display:flex;flex-direction:column;justify-content:center;gap:1px;background:var(--surface-2);border:1px solid var(--line);border-radius:6px;min-width:0;cursor:default;transition:all .15s;flex:0 1 132px}
.m:hover{background:var(--surface-2)}
.m.primary{border-color:var(--line-strong);min-width:160px}
.m.highlight .v{font-size:18px}
.interactive-metric{appearance:none;border:none;text-align:left;color:inherit;cursor:pointer}
.m .l{font-size:11px;font-weight:500;letter-spacing:.4px;color:var(--muted);font-family:var(--mono);white-space:nowrap}
.m .v{font-size:15px;font-weight:600;font-family:var(--mono);color:var(--text);white-space:nowrap;display:flex;align-items:baseline;gap:3px;line-height:1.2}
.m .v.positive{color:var(--green-text)}
.m .v.negative{color:var(--red-text)}
.msub{display:none}
.tools,.theme-switch,.dots,.panel-tools,.dual-actions,.quad-actions,.inline-field{display:flex;align-items:center;gap:10px}
.tools{gap:2px;padding:0 8px;margin-left:auto;flex-shrink:0}
.seg{display:flex;background:var(--surface-4);border-radius:5px;padding:1px;margin:0 3px}
.seg button{height:26px;padding:0 12px;border:none;background:transparent;color:var(--muted-2);font-size:13px;font-family:var(--sans);font-weight:500;cursor:pointer;border-radius:4px;transition:all .1s}
.seg button:hover{color:var(--muted)}
.seg button.active,.seg button.is-active{background:var(--accent);color:#fff}
.seg.lang button.active,.seg.lang button.is-active{background:var(--surface);color:var(--text)}
.ib,.toolbar-button,.toolbar-icon-button,.period-button,.head-toggle,.utility-button,.primary-button,.danger-button,.wbtn{appearance:none;border:none;background:transparent;color:var(--muted);transition:all .1s}
.ib{width:30px;height:30px;border-radius:5px;display:flex;align-items:center;justify-content:center}
.ib:hover{background:var(--surface-4);color:var(--text)}
.ib svg{width:16px;height:16px}
.ib.is-active{
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.28);
}
body.theme-light .ib.is-active{
  background: rgba(180, 83, 9, 0.10);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(180, 83, 9, 0.22);
}
.wbtn{height:30px;padding:0 14px;border-radius:5px;border:1px solid var(--line-strong);background:var(--surface-4);color:var(--text);font-size:13px;font-family:var(--sans);font-weight:500;cursor:pointer;white-space:nowrap;margin-left:3px}
.wbtn:hover{border-color:var(--accent)}
.wbtn.subtle{background:transparent;color:var(--muted);border-color:transparent}
.danger-button{background:var(--red-text);border-color:var(--red-text);color:#fff}
.dots,.theme-switch{display:flex;align-items:center;gap:5px;margin:0 8px}
.dot,.theme-dot{width:14px;height:14px;border-radius:50%;border:2px solid var(--line-max);background:transparent;cursor:pointer;transition:all .15s}
.dot:hover,.theme-dot:hover{transform:scale(1.2)}
.dot.dark-dot,.theme-dot-dark{background:#1a1a2e}
.dot.light-dot,.theme-dot-light{background:#faf9f7;border-color:#ccc}
.dot.active-dot,.theme-dot.active{border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-soft)}
.sound-icon{display:inline-block;width:16px;height:16px;background:currentColor;-webkit-mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M14.857 17.082A23.848 23.848 0 0018 12c0-1.882-.47-3.656-1.143-5.082m-2.953 10.164a23.784 23.784 0 01-3.714 0m3.714 0a3 3 0 11-3.714 0m3.714 0H10.29m4.567 0a24.255 24.255 0 003.472-.504m-11.511.504A24.255 24.255 0 013.472 16.578M6.857 17.082V10a5.143 5.143 0 1110.286 0v7.082M6.857 17.082h10.286'/%3E%3C/svg%3E\") center/contain no-repeat;mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M14.857 17.082A23.848 23.848 0 0018 12c0-1.882-.47-3.656-1.143-5.082m-2.953 10.164a23.784 23.784 0 01-3.714 0m3.714 0a3 3 0 11-3.714 0m3.714 0H10.29m4.567 0a24.255 24.255 0 003.472-.504m-11.511.504A24.255 24.255 0 013.472 16.578M6.857 17.082V10a5.143 5.143 0 1110.286 0v7.082M6.857 17.082h10.286'/%3E%3C/svg%3E\") center/contain no-repeat}
.main{flex:1;display:flex;overflow:hidden;min-height:0}
.center{flex:1;display:flex;flex-direction:column;min-width:0;overflow:hidden}
.row-top{display:flex;min-height:120px;overflow:hidden;flex:1 1 0}
.sidebar{width:320px;min-width:280px;max-width:480px;flex-shrink:0;background:var(--surface);border-left:1px solid var(--line);display:flex;flex-direction:column;overflow:hidden}
.rs-h{padding:10px 14px;border-bottom:1px solid var(--line)}
.rs-t{font-size:15px;font-weight:600}
.rs-d{padding:10px 14px;font-size:13px;line-height:1.6;color:var(--muted);border-bottom:1px solid var(--line)}
.rs-hint{padding:8px 14px 0;font-size:11px;line-height:1.5;color:var(--muted-3);font-family:var(--mono)}
.sm{padding:12px 14px;overflow-x:auto}
.links-grid{min-width:max-content}
.pnl{min-height:0;display:flex;flex-direction:column;background:var(--surface);border:1px solid var(--line);border-radius:6px;overflow:hidden;flex:1}
.p-new{flex:1 1 0;min-width:120px;min-height:0;display:flex;flex-direction:column;padding:6px 0 6px 6px}
.p-hot{flex:0 0 280px;width:280px;min-width:160px;max-width:450px;min-height:0;display:flex;flex-direction:column;padding:6px 0}
.p-exec{flex:0 0 340px;width:340px;min-width:180px;max-width:550px;min-height:0;display:flex;flex-direction:column;padding:6px 6px 6px 0}
.p-cmd{min-height:96px;display:flex;flex-direction:column;padding:0 6px;overflow:hidden;flex:0.5 1 0}
.p-port{min-height:160px;display:flex;flex-direction:column;padding:0 6px 6px;overflow:hidden;flex:0.4 1 0}
.ph{display:flex;align-items:center;padding:8px 12px;gap:6px;border-bottom:1px solid var(--line);flex-shrink:0}
.pt{font-size:14px;font-weight:600}
.bdg{background:var(--accent);color:#fff;font-size:11px;font-weight:600;min-width:18px;height:18px;border-radius:9px;display:inline-flex;align-items:center;justify-content:center;padding:0 5px;font-family:var(--mono);margin-left:auto}
.bdg.g{background:var(--green)}
.ps{flex:1;overflow:auto;min-height:0}
.ps .tb{min-width:max-content}
.ptabs{display:flex;gap:0}
.ptb{height:26px;padding:0 12px;border:none;background:transparent;color:var(--muted-2);font-size:12px;font-family:var(--sans);font-weight:500;cursor:pointer;border-radius:0;transition:all .1s;border-bottom:2px solid transparent}
.ptb:hover{color:var(--muted)}
.ptb.active,.ptb.is-active{color:var(--accent);border-bottom-color:var(--accent);background:var(--accent-soft)}
.ttabs{display:flex;gap:2px;padding:6px 10px 3px}
.tt{height:24px;padding:0 10px;border-radius:4px;border:1px solid var(--line-strong);background:transparent;color:var(--muted-2);font-size:11px;font-family:var(--mono);font-weight:600;cursor:pointer;transition:all .1s}
.tt:hover{border-color:var(--line-max);color:var(--muted)}
.tt.active,.tt.is-active{background:var(--accent);border-color:var(--accent);color:#fff}
.tb{width:100%;border-collapse:collapse}
.tb th{text-align:left;font-size:11px;font-weight:600;color:var(--muted-3);padding:6px 10px;border-bottom:1px solid var(--line);font-family:var(--mono);position:sticky;top:0;background:var(--surface);z-index:1;white-space:nowrap}
.tb td{padding:6px 10px;color:var(--muted);border-bottom:1px solid var(--line);font-family:var(--mono);white-space:nowrap;font-size:13px}
.tb tr:hover td{background:var(--surface-2)}
.data-table tbody tr.is-selected{background:var(--accent-soft)}
.empty-state,
.loading-cell{padding:18px 10px !important;text-align:center;color:var(--muted-2) !important}
.loading-cell .loading-line,
.loading-cell .loading-chip{
  display:block;
  border-radius:6px;
  background:linear-gradient(90deg, var(--surface-2) 0%, var(--surface-4) 50%, var(--surface-2) 100%);
  background-size:220% 100%;
  animation:loading-shimmer 1.2s ease-in-out infinite;
}
.loading-cell .loading-line{height:12px;margin:0 auto 8px;width:min(88%,480px)}
.loading-cell .loading-line.short{width:min(46%,220px)}
.loading-cell .loading-chip{width:84px;height:20px;margin:0 auto}
@keyframes loading-shimmer{
  0%{background-position:200% 0}
  100%{background-position:-20% 0}
}
.h-resize{width:var(--handle);cursor:col-resize;background:transparent;flex-shrink:0;position:relative;z-index:10}
.h-resize:hover,.h-resize.active{background:var(--accent)}
.h-resize::after{content:'';position:absolute;top:0;bottom:0;left:-2px;right:-2px}
.v-resize{height:var(--handle);cursor:row-resize;background:transparent;flex-shrink:0;position:relative;z-index:10}
.v-resize:hover,.v-resize.active{background:var(--accent)}
.v-resize::after{content:'';position:absolute;left:0;right:0;top:-2px;bottom:-2px}
.bbar{display:flex;align-items:center;padding:4px 6px;gap:4px;border-top:1px solid var(--line);background:var(--surface);flex-shrink:0}
.btabs,.brt{display:flex;gap:3px;align-items:center}
.brt{margin-left:auto}
.btab,.bact{height:32px;padding:0 14px;border-radius:5px;border:1px solid var(--line-strong);background:transparent;color:var(--muted);font-size:13px;font-family:var(--sans);font-weight:500;cursor:pointer;transition:all .1s}
.btab:hover,.bact:hover{border-color:var(--line-max);color:var(--text)}
.btab.active,.btab.is-active{background:var(--accent-soft);border-color:var(--accent);color:var(--accent)}
.bact.buy{color:var(--green-text);border-color:rgba(16,185,129,0.2)}
.bact.buy:hover{background:var(--green-soft)}
.bact.danger{color:var(--red-text);border-color:rgba(239,68,68,0.15)}
.bact.danger:hover{background:var(--red-soft)}
.sbar{display:flex;align-items:center;padding:3px 10px;gap:10px;background:var(--bg);border-top:1px solid var(--line);flex-shrink:0;height:24px}
.status-text{font-size:11px;color:var(--muted);font-family:var(--mono);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.status-text{display:flex;align-items:center;gap:10px;width:100%}
.si{font-size:11px;color:var(--muted);font-family:var(--mono);white-space:nowrap;display:flex;align-items:center;gap:3px}
.stag{padding:1px 5px;border-radius:2px;font-weight:600;font-size:11px;font-family:var(--mono)}
.stag.tui{background:rgba(6,182,212,0.12);color:var(--cyan)}
.stag.web{background:var(--green-soft);color:var(--green-text)}
.si.sim{color:var(--amber);background:var(--amber-soft);padding:1px 6px;border-radius:2px;font-weight:600}
body.resizing{cursor:col-resize;user-select:none}
body.resizing-v{cursor:row-resize;user-select:none}
body.resizing *,body.resizing-v *{pointer-events:none}
body.resizing .h-resize,body.resizing-v .v-resize{pointer-events:auto}

.mono {
  font-family: var(--mono);
}

.positive {
  color: var(--green);
  font-weight: 700;
}

.negative {
  color: var(--red);
  font-weight: 700;
}

.neutral {
  color: var(--text);
}

.tb td.positive,
.tb td.mono.positive,
.data-table td.positive,
.data-table td.mono.positive {
  color: var(--green) !important;
  font-weight: 700;
}

.tb td.negative,
.tb td.mono.negative,
.data-table td.negative,
.data-table td.mono.negative {
  color: var(--red) !important;
  font-weight: 700;
}

.tb td.neutral,
.tb td.mono.neutral,
.data-table td.neutral,
.data-table td.mono.neutral {
  color: var(--text) !important;
}

.tb td.positive .text-soft,
.tb td.mono.positive .text-soft,
.data-table td.positive .text-soft,
.data-table td.mono.positive .text-soft {
  color: var(--green) !important;
  opacity: 0.92;
}

.tb td.negative .text-soft,
.tb td.mono.negative .text-soft,
.data-table td.negative .text-soft,
.data-table td.mono.negative .text-soft {
  color: var(--red) !important;
  opacity: 0.92;
}

.tb td.neutral .text-soft,
.tb td.mono.neutral .text-soft,
.data-table td.neutral .text-soft,
.data-table td.mono.neutral .text-soft {
  color: var(--text) !important;
  opacity: 0.92;
}

.text-soft {
  color: var(--muted);
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 28px 18px;
}

.token-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 180px;
}

.token-avatar-shell {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  position: relative;
}

.token-avatar,
.token-badge {
  width: 34px;
  height: 34px;
  border-radius: 11px;
}

.token-avatar {
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.token-badge {
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(91, 135, 255, 0.16), rgba(91, 135, 255, 0.05));
  border: 1px solid rgba(91, 135, 255, 0.22);
  color: #f7fbff;
  font-family: var(--mono);
  font-weight: 700;
}

.token-badge-fallback {
  display: none;
  position: absolute;
  inset: 0;
}

.token-main {
  font-weight: 700;
}

.token-sub {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.78rem;
}

.ca-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ca-copy-button {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  transition: color .12s ease, border-color .12s ease, background .12s ease, transform .12s ease;
}

.ca-copy-button:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.08);
}

.ca-copy-button:active {
  transform: translateY(1px);
}

body.theme-light .ca-copy-button {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.10);
  color: #64748b;
}

body.theme-light .ca-copy-button:hover {
  background: rgba(59, 130, 246, 0.10);
  border-color: rgba(59, 130, 246, 0.22);
  color: #1d4ed8;
}

.doc-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(91, 135, 255, 0.14);
  color: #d9e6ff;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid rgba(91, 135, 255, 0.26);
}

body.theme-light .doc-chip {
  background: rgba(59, 130, 246, 0.10);
  color: #1d4ed8;
  border-color: rgba(59, 130, 246, 0.26);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.quick-sell-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.quick-sell-button {
  min-height: 28px;
  padding: 0 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.quick-sell-button:hover {
  border-color: rgba(91, 135, 255, 0.35);
  background: rgba(91, 135, 255, 0.14);
}

.quick-sell-button-strong {
  border-color: rgba(255, 122, 122, 0.4);
  background: rgba(255, 122, 122, 0.18);
  color: #ffdada;
}

body.theme-light .quick-sell-button {
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(0, 0, 0, 0.12);
  color: #2b241c;
}

body.theme-light .quick-sell-button:hover {
  border-color: rgba(180, 83, 9, 0.28);
  background: rgba(180, 83, 9, 0.08);
}

body.theme-light .quick-sell-button-strong {
  border-color: rgba(220, 38, 38, 0.28);
  background: rgba(220, 38, 38, 0.10);
  color: #991b1b;
}

body.theme-light .quick-sell-button-strong:hover {
  border-color: rgba(220, 38, 38, 0.42);
  background: rgba(220, 38, 38, 0.16);
  color: #7f1d1d;
}

.panel-note {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.83rem;
}

.links-grid {
  display: grid;
  gap: 5px;
}

.sm-h {
  display: grid;
  grid-template-columns: 38px repeat(8, 44px);
  column-gap: 4px;
  align-items: center;
  padding-left: 0;
  margin-bottom: 6px;
}

.sm-h span {
  width: auto;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--mono);
  color: var(--muted-3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sm-h > :first-child {
  width: auto;
}

.sm-h button {
  width: auto;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--mono);
  color: var(--muted-3);
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sm-hb:hover {
  color: var(--text);
}

.sm-r {
  display: grid;
  grid-template-columns: 38px repeat(8, 44px);
  column-gap: 4px;
  align-items: center;
  margin-bottom: 5px;
}

.sm-l {
  width: auto;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--mono);
  color: var(--muted-2);
}

.sm-c {
  width: 44px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 4px;
  margin: 0;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
  background: rgba(255, 255, 255, 0.02);
}

.sm-c:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}

.sm-c.on,
.link-toggle.is-active {
  background: var(--green-soft);
  border-color: rgba(16, 185, 129, 0.25);
  color: var(--green);
}

.link-toggle.is-pending {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.25);
  color: var(--accent);
}

.link-toggle.is-pending span {
  font-size: 16px;
}

.sm-c span {
  font-size: 18px;
  line-height: 1;
}

.links-header,
.links-row,
.links-row-label {
  display: none;
}

.link-toggle {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--muted);
}

.sm-r .link-toggle::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.015);
  pointer-events: none;
}

.link-toggle:disabled {
  cursor: wait;
}

.panel-modal {
  position: fixed;
  top: 84px;
  right: 18px;
  z-index: 42;
  width: min(520px, calc(100vw - 36px));
  max-height: calc(100vh - 120px);
  padding: 16px;
  overflow: auto;
}

/* ── Matrix Popup ──────────────────────────────── */

.matrix-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(1240px, 96vw);
  height: min(88vh, 900px);
  padding: 0;
  overflow: hidden;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255,255,255,.06);
  z-index: 50;
}

/* ── Matrix Popup Header ───────────────────────── */

.matrix-popup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 52px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
  gap: 12px;
  background: rgba(255, 255, 255, 0.025);
}

.matrix-popup-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
}

.matrix-brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: brand-pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes brand-pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

.matrix-nav {
  display: flex;
  gap: 2px;
}

.matrix-nav-btn {
  font-size: 12px;
  color: var(--muted);
  padding: 5px 14px;
  border-radius: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  font-family: var(--mono);
}

.matrix-nav-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.matrix-nav-btn.is-active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.09);
}

.matrix-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.matrix-scope {
  margin-left: auto;
  min-width: 0;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--mono);
}

/* ── Matrix Pages ──────────────────────────────── */

.matrix-page {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.matrix-page[hidden] { display: none; }

.matrix-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(229, 162, 40, 0.12);
  border: 1px solid rgba(229, 162, 40, 0.25);
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 18px;
  line-height: 1.7;
}

.matrix-notice:empty { display: none; }

/* ── Matrix Table ──────────────────────────────── */

.matrix-wrap {
  overflow-x: auto;
  flex-shrink: 0;
}

.matrix-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 640px;
}

.matrix-table th,
.matrix-table td { padding: 0; }

/* Column group headers */
.matrix-col-group-hd {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  text-transform: uppercase;
  padding: 0 0 8px 0;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.matrix-col-group-hd.left { text-align: left; padding-left: 0; }

/* Column button headers */
.matrix-col-hd {
  padding: 6px 4px 10px;
  text-align: center;
  vertical-align: bottom;
}

.matrix-col-hd-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
  min-width: 64px;
  font-family: var(--mono);
}

.matrix-col-hd-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.09);
}

.matrix-col-hd-btn.is-active {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.13);
}

.matrix-col-hd-btn .col-hd-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  line-height: 1;
}

.matrix-col-hd-btn .col-hd-sub {
  font-size: 10px;
  color: var(--muted-2);
  white-space: nowrap;
}

/* Separator columns */
.matrix-col-sep { width: 10px; }

.matrix-col-sep-line {
  width: 1px;
  background: rgba(255, 255, 255, 0.07);
  padding: 0;
}

/* Strategy rows */
.matrix-strat-row td { padding: 4px 0; }
.matrix-strat-row td:first-child { padding-right: 8px; }
.matrix-strat-row + .matrix-strat-row td { border-top: 1px solid rgba(255, 255, 255, 0.07); }
.matrix-strat-row.dragging { opacity: 0.35; }
.matrix-strat-row.drag-over td { border-top: 2px solid var(--green) !important; }

.matrix-row-label-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 100px;
  padding: 8px 0;
}

/* CSS Slide Toggle */
.matrix-strat-toggle {
  width: 30px;
  height: 17px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.13);
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
  flex-shrink: 0;
}

.matrix-strat-toggle::after {
  content: '';
  position: absolute;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--muted-2);
  top: 2px;
  left: 2px;
  transition: all 0.2s;
}

.matrix-strat-toggle.on {
  background: var(--green-soft);
  border-color: rgba(16, 185, 129, 0.5);
}

.matrix-strat-toggle.on::after {
  background: #4ade80;
  transform: translateX(13px);
}

/* Drag handle */
.matrix-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 32px;
  cursor: grab;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
  color: var(--muted-2);
}

.matrix-drag-handle:active { cursor: grabbing; }
.matrix-drag-handle svg { pointer-events: none; }
.matrix-strat-row:hover .matrix-drag-handle { opacity: 1; }

.matrix-strat-name-btn {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 6px;
  transition: background 0.15s;
  text-align: left;
  font-family: var(--mono);
}

.matrix-strat-name-btn:hover { background: rgba(255, 255, 255, 0.06); }

/* Matrix cells */
.matrix-mcell {
  padding: 4px;
  text-align: center;
}

.matrix-mcell-btn {
  width: 56px;
  height: 42px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: all 0.15s;
  margin: 0 auto;
}

.matrix-mcell-btn:hover {
  border-color: rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.06);
}

.matrix-mcell-btn.on {
  background: var(--green-soft);
  border-color: rgba(16, 185, 129, 0.5);
}

.matrix-mcell-btn.on:hover { border-color: var(--green); }

.mcell-check {
  font-size: 13px;
  color: var(--muted-2);
  line-height: 1;
}

.matrix-mcell-btn.on .mcell-check { color: #4ade80; }

.mcell-hint {
  font-size: 9px;
  color: #4ade80;
  opacity: 0.75;
  line-height: 1;
}

/* ── Param Panel (below table) ─────────────────── */

.matrix-param-panel {
  margin-top: 20px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 14px;
  overflow: hidden;
  animation: mpanel-in 0.15s ease;
}

@keyframes mpanel-in { from{opacity:0;transform:translateY(-6px)} to{opacity:1;transform:none} }

.matrix-param-panel-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.03);
}

.matrix-param-panel-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.matrix-param-panel-close {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
}

.matrix-param-panel-close:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }

.matrix-param-panel-body {
  padding: 12px 16px;
}

.matrix-param-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

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

.matrix-param-lbl {
  font-size: 12px;
  color: var(--muted);
  min-width: 160px;
  flex-shrink: 0;
}

.matrix-param-ctrl {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.matrix-param-valdisp {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  min-width: 48px;
  text-align: right;
  font-family: var(--mono);
}

.matrix-param-panel input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  cursor: pointer;
}

.matrix-param-panel input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #4ade80;
  border: 2px solid var(--surface);
  cursor: pointer;
}

.matrix-param-panel input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #4ade80;
  border: 2px solid var(--surface);
  cursor: pointer;
}

.matrix-param-panel input[type="number"],
.matrix-param-panel input[type="text"] {
  width: 90px;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}

.matrix-param-panel input[type="number"]:focus,
.matrix-param-panel input[type="text"]:focus {
  outline: none;
  border-color: rgba(91, 135, 255, 0.4);
  box-shadow: 0 0 0 3px rgba(91, 135, 255, 0.12);
}

.matrix-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex: 1;
}

.matrix-tag-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.13);
  color: var(--muted);
}

.matrix-tag-x {
  color: var(--muted-2);
  cursor: pointer;
  font-size: 10px;
  background: none;
  border: none;
  padding: 0;
  line-height: 1;
  transition: color 0.1s;
}

.matrix-tag-x:hover { color: #e24b4a; }

.matrix-priority-note {
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(55, 138, 221, 0.12);
  border: 1px solid rgba(55, 138, 221, 0.2);
  border-radius: 6px;
  font-size: 11px;
  color: var(--muted);
}

.matrix-attach-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.matrix-attach-chip {
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--mono);
}

.matrix-attach-chip:hover {
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--green);
}

.matrix-attach-chip.on {
  background: var(--green-soft);
  border-color: rgba(16, 185, 129, 0.4);
  color: #4ade80;
}

/* ── Library Page ──────────────────────────────── */

.matrix-lib-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.matrix-search-box {
  position: relative;
  flex: 1;
  max-width: 280px;
  color: var(--muted-2);
}

.matrix-search-box svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.matrix-search-box input {
  width: 100%;
  padding: 7px 10px 7px 32px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  font-family: var(--mono);
  outline: none;
  transition: border-color 0.15s;
}

.matrix-search-box input:focus {
  border-color: rgba(255, 255, 255, 0.22);
}

.matrix-search-box input::placeholder { color: var(--muted-2); }

.matrix-filter-pills {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.matrix-fpill {
  font-size: 11px;
  padding: 4px 11px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--mono);
}

.matrix-fpill:hover {
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--text);
}

.matrix-fpill.is-active {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.22);
  color: var(--text);
}

.matrix-lib-section-label {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-bottom: 10px;
  margin-top: 24px;
  flex-shrink: 0;
}

.matrix-lib-section-label:first-of-type { margin-top: 0; }

.matrix-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  flex-shrink: 0;
}

.matrix-strat-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s;
}

.matrix-strat-card:hover { border-color: rgba(255, 255, 255, 0.13); }

.matrix-strat-card.is-installed { border-color: rgba(16, 185, 129, 0.4); }

.matrix-card-hd {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.matrix-card-id {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  font-family: var(--mono);
}

.matrix-card-sub {
  font-size: 11px;
  color: var(--muted-2);
  margin-top: 2px;
}

.matrix-card-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.matrix-card-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}

.matrix-card-params {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.matrix-cparam {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: var(--muted-2);
}

.matrix-card-ft {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 4px;
}

.matrix-card-ver { font-size: 10px; color: var(--muted-2); }

.matrix-add-card-btn {
  font-size: 11px;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--mono);
}

.matrix-add-card-btn:hover {
  border-color: rgba(16, 185, 129, 0.5);
  color: #4ade80;
  background: var(--green-soft);
}

.matrix-add-card-btn.is-done {
  background: var(--green-soft);
  border-color: rgba(16, 185, 129, 0.4);
  color: #4ade80;
  cursor: default;
}

.matrix-add-card-btn.is-done:hover { background: var(--green-soft); }

/* Strategy type badges */
.mbadge {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 20px;
  letter-spacing: 0.03em;
}

.mbadge-entry   { background: rgba(16, 185, 129, 0.15); color: #4ade80; border: 1px solid rgba(16, 185, 129, 0.3); }
.mbadge-exit    { background: rgba(55, 138, 221, 0.12);  color: #7eb8f0; border: 1px solid rgba(55, 138, 221, 0.3); }
.mbadge-overlay { background: rgba(127, 119, 221, 0.12); color: #b0aaf5; border: 1px solid rgba(127, 119, 221, 0.3); }

/* ── Legacy compat (used in other panels) ───────── */

.matrix-entry-list,
.matrix-horizontal-list,
.matrix-library-list {
  display: grid;
  gap: 12px;
}

.matrix-entry-card,
.matrix-horizontal-card,
.matrix-library-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.matrix-entry-head,
.matrix-horizontal-head,
.matrix-entry-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.matrix-entry-meta {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.matrix-entry-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.84rem;
}

.matrix-entry-order,
.matrix-chip-actions,
.matrix-library-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.matrix-param-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.matrix-param {
  display: grid;
  gap: 6px;
}

.matrix-param-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
}

.matrix-param-input {
  width: 100%;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  padding: 0 12px;
  font-family: var(--mono);
  font-size: 0.84rem;
}

.matrix-param-input:focus {
  outline: none;
  border-color: rgba(91, 135, 255, 0.4);
  box-shadow: 0 0 0 3px rgba(91, 135, 255, 0.12);
}

.matrix-chip-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
  flex-wrap: wrap;
}

.matrix-chip-card {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.02);
}

.matrix-chip-card.is-active {
  border-color: rgba(16, 185, 129, 0.26);
  background: rgba(16, 185, 129, 0.08);
}

.matrix-chip {
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.matrix-chip:hover {
  border-color: rgba(91, 135, 255, 0.28);
  color: var(--text);
}

.matrix-chip.is-active {
  color: var(--green);
  border-color: rgba(16, 185, 129, 0.28);
  background: var(--green-soft);
}

.matrix-mini,
.matrix-primary {
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.matrix-mini:disabled,
.matrix-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.matrix-primary.is-active {
  border-color: rgba(91, 135, 255, 0.32);
  background: rgba(91, 135, 255, 0.18);
  color: #dfe8ff;
}

.matrix-empty {
  padding: 20px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

body.theme-light .matrix-popup {
  background: #ffffff;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(0,0,0,0.08);
}

body.theme-light .matrix-popup-head {
  background: rgba(0, 0, 0, 0.02);
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

body.theme-light .matrix-scope {
  border-color: rgba(0, 0, 0, 0.08);
  background: rgba(0, 0, 0, 0.035);
  color: #5a6477;
}

body.theme-light .rs-hint {
  color: #7d8798;
}

body.theme-light .sm-c {
  background: rgba(0, 0, 0, 0.018);
}

body.theme-light .sm-c:hover {
  background: rgba(0, 0, 0, 0.045);
  border-color: rgba(0, 0, 0, 0.1);
}

body.theme-light .matrix-col-group-hd { border-bottom-color: rgba(0, 0, 0, 0.08); }
body.theme-light .matrix-col-hd-btn .col-hd-name { color: #1a1d24; }
body.theme-light .matrix-col-hd-btn:hover { background: rgba(0, 0, 0, 0.04); border-color: rgba(0, 0, 0, 0.09); }

body.theme-light .matrix-strat-toggle {
  background: rgba(0, 0, 0, 0.1);
  border-color: rgba(0, 0, 0, 0.18);
}

body.theme-light .matrix-strat-toggle::after { background: #888; }

body.theme-light .matrix-strat-name-btn { color: #1a1d24; }
body.theme-light .matrix-strat-name-btn:hover { background: rgba(0, 0, 0, 0.05); }

body.theme-light .matrix-mcell-btn {
  background: rgba(0, 0, 0, 0.025);
  border-color: rgba(0, 0, 0, 0.1);
}

body.theme-light .matrix-param-panel {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.1);
}

body.theme-light .matrix-entry-card,
body.theme-light .matrix-horizontal-card,
body.theme-light .matrix-library-card,
body.theme-light .matrix-strat-card {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(0, 0, 0, 0.08);
}

body.theme-light .matrix-chip,
body.theme-light .matrix-mini,
body.theme-light .matrix-primary,
body.theme-light .matrix-param-input {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(0, 0, 0, 0.12);
  color: #2b241c;
}

body.theme-light .matrix-primary.is-active {
  color: #1d4ed8;
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(59, 130, 246, 0.24);
}

@media (max-width: 860px) {
  .matrix-popup {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    top: 0;
    left: 0;
    transform: none;
  }
}

#profit-modal {
  width: min(920px, calc(100vw - 36px));
}

#cc10-modal {
  width: min(920px, calc(100vw - 36px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#cc10-scroll {
  flex: 1;
  min-height: 260px;
  max-height: calc(100vh - 220px);
  overflow: auto;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 41;
  background: rgba(2, 6, 12, 0.55);
  backdrop-filter: blur(6px);
}

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

.modal-close {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.form-stack {
  display: grid;
  gap: 14px;
}

.simulation-account-list {
  display: grid;
  gap: 10px;
}

.sim-account-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.sim-account-row.is-active {
  border-color: rgba(91, 135, 255, 0.34);
  box-shadow: inset 0 0 0 1px rgba(91, 135, 255, 0.14);
}

.sim-account-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.sim-account-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sim-account-title-row strong {
  font-size: 0.98rem;
}

.sim-account-stats {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.sim-stat {
  white-space: nowrap;
}

.sim-account-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sim-fund-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sim-fund-input {
  width: 92px;
  min-width: 92px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  padding: 0 10px;
  font-family: var(--mono);
}

.sim-fund-input:focus {
  outline: none;
  border-color: rgba(91, 135, 255, 0.38);
  box-shadow: 0 0 0 3px rgba(91, 135, 255, 0.10);
}

.inline-field {
  align-items: stretch;
}

.inline-field > *:first-child {
  flex: 1;
}

.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wallet-status {
  white-space: pre-line;
  color: var(--muted);
  line-height: 1.6;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.check-row input {
  width: 18px;
  height: 18px;
}

.control-grid,
.runtime-grid,
.profit-metrics {
  display: grid;
  gap: 12px;
}

.control-group,
.metric-block,
.runtime-item {
  padding: 14px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.quad-actions {
  flex-wrap: wrap;
}

.quad-actions .head-toggle,
.dual-actions .head-toggle {
  flex: 1;
}

.runtime-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.runtime-item-label {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.runtime-wallet-block {
  margin-top: 12px;
  padding: 14px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--muted);
  line-height: 1.6;
}

.command-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.command-bar input {
  flex: 1;
}

.console-log {
  min-height: 280px;
  max-height: 420px;
  overflow: auto;
  padding: 14px;
  border-radius: 14px;
  background: rgba(5, 8, 12, 0.56);
  border: 1px solid rgba(255, 255, 255, 0.04);
  font-family: var(--mono);
  font-size: 0.82rem;
  white-space: pre-wrap;
}

.manual-selected-card {
  min-height: 124px;
  margin-bottom: 14px;
  padding: 14px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.manual-card {
  display: flex;
  gap: 14px;
  align-items: center;
}

.manual-card-copy h4 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.manual-card-copy p {
  margin: 0;
  color: var(--muted);
}

.manual-actual {
  min-height: 22px;
  margin-bottom: 14px;
  color: var(--text);
  font-family: var(--mono);
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.profit-range {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.profit-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 18px;
}

.metric-block span,
.metric-block small {
  display: block;
  color: var(--muted);
}

.metric-block strong {
  display: block;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 1.22rem;
}

.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.calendar-head h4 {
  margin: 0;
  font-size: 1.08rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.calendar-cell {
  min-height: 88px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.calendar-cell.is-filler {
  opacity: 0.35;
}

.calendar-day {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.8rem;
}

.calendar-pnl {
  display: block;
  margin-top: 8px;
  font-family: var(--mono);
  font-weight: 700;
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 96px;
  z-index: 60;
  display: grid;
  gap: 10px;
}

.floating-tooltip {
  position: fixed;
  z-index: 95;
  max-width: 360px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: rgba(8, 11, 16, 0.96);
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-line;
  pointer-events: none;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.22);
}

body.theme-light .floating-tooltip {
  background: rgba(250, 249, 247, 0.98);
  border-color: var(--line-max);
}

.toast {
  min-width: 260px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(91, 135, 255, 0.24);
  background: rgba(9, 17, 28, 0.92);
  box-shadow: var(--shadow);
}

.toast strong {
  display: block;
  margin-bottom: 4px;
}

.toast p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.mobile-tabbar {
  display: none;
}

body.profile-pro .workspace-panel,
body.profile-pro .panel-modal,
body.profile-pro .summary-card {
  border-radius: 14px;
}

body.profile-pro .data-table th,
body.profile-pro .data-table td {
  padding-block: 11px;
}

@media (max-width: 1280px) {
  .sidebar {
    width: 280px;
  }

  .p-hot {
    width: 240px;
  }

  .p-exec {
    width: 300px;
  }
}

@media (max-width: 980px) {
  .app-shell {
    margin-bottom: 88px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .mg {
    width: 100%;
    overflow-x: auto;
  }

  .m {
    min-width: 120px;
  }

  .tools {
    width: 100%;
    justify-content: space-between;
    border-left: none;
    border-top: 1px solid var(--line);
  }

  .main {
    display: block;
  }

  .row-top,
  .p-cmd,
  .p-port {
    display: block;
  }

  .sidebar,
  .p-new,
  .p-hot,
  .p-exec,
  .p-cmd,
  .p-port {
    margin-bottom: 10px;
    height: auto !important;
    width: auto;
    max-width: none;
    padding: 0;
  }

  .mobile-pane.hidden-mobile-pane {
    display: none;
  }

  .panel-modal {
    top: auto;
    right: 8px;
    left: 8px;
    bottom: 82px;
    width: auto;
    max-height: calc(100vh - 140px);
  }

  #profit-modal {
    width: auto;
  }

  .profit-metrics,
  .runtime-grid,
  .two-column {
    grid-template-columns: 1fr;
  }

  .calendar-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sim-account-row {
    flex-direction: column;
  }

  .sim-account-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .sim-fund-inline {
    width: 100%;
  }

  .sim-fund-input {
    flex: 1;
    width: auto;
    min-width: 0;
  }

  .mobile-tabbar {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    z-index: 70;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(10, 16, 24, 0.92);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
  }

  .mobile-tab-button {
    min-height: 42px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
  }

  .mobile-tab-button.active {
    color: var(--text);
    background: rgba(91, 135, 255, 0.16);
    border-color: rgba(91, 135, 255, 0.32);
  }

  .h-resize,
  .v-resize,
  .panel-resize-handle {
    display: none;
  }

  .bbar {
    flex-direction: column;
    align-items: stretch;
  }

  .btabs,
  .brt {
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .login-modal {
    padding: 22px;
  }

  .tools,
  .profit-range {
    flex-wrap: wrap;
  }

  .seg {
    flex: 1 1 auto;
  }

  .seg button {
    flex: 1 1 0;
  }

  .data-table {
    min-width: 640px;
  }

  .calendar-grid {
    grid-template-columns: 1fr;
  }
}
