/* CloudC4 Trading DevX — tokens + chrome + dock
   X language, trading layout. Do not import styles.css / styles-devb / static/x. */

:root, html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --bg-elevated: #0c1118;
  --bg-hover: rgba(59, 130, 246, 0.06);
  --bg-hover-strong: rgba(59, 130, 246, 0.12);
  --border: #1a2330;
  --border-subtle: #111820;
  --text: #f2f5f8;
  --muted: #8b9aab;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --on-accent: #ffffff;
  --good: #3ecf8e;
  --bad: #f07178;
  --warn: #e6b450;
  --header-bg: rgba(0, 0, 0, 0.72);
  --shadow: none;
  --radius-pill: 999px;
  --radius-panel: 12px;
  --header-h: 52px;
  --dock-h: 56px;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
  --card: #0c1118;
  --surface: #0c1118;
  --surface-2: #000000;
  --surface-3: #121a24;
  --table-border: #1a2330;
  --badge-bg: #121a24;
  --nav-active-bg: transparent;
  --user-bubble: var(--accent-soft);
  --user-bubble-border: var(--accent);
  --btn-primary-bg: var(--accent);
  --btn-primary-border: var(--accent);
  --card-grad-top: #0c1118;
  --grade-b: #3ecf8e;
  --pos: var(--good);
  --neg: var(--bad);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --bg-elevated: #f4f6f8;
  --bg-hover: rgba(29, 78, 216, 0.05);
  --bg-hover-strong: rgba(29, 78, 216, 0.10);
  --border: #e2e8f0;
  --border-subtle: #eef2f6;
  --text: #0b1220;
  --muted: #5b6b7c;
  --accent: #1d4ed8;
  --accent-hover: #2563eb;
  --accent-soft: rgba(29, 78, 216, 0.10);
  --on-accent: #ffffff;
  --good: #047857;
  --bad: #b91c1c;
  --warn: #b45309;
  --header-bg: rgba(255, 255, 255, 0.78);
  --card: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f4f6f8;
  --surface-3: #e8edf2;
  --table-border: #e2e8f0;
  --badge-bg: #e8edf2;
  --nav-active-bg: transparent;
  --user-bubble: var(--accent-soft);
  --user-bubble-border: var(--accent);
  --btn-primary-bg: var(--accent);
  --btn-primary-border: var(--accent);
  --card-grad-top: #f4f6f8;
  --grade-b: #047857;
  --pos: var(--good);
  --neg: var(--bad);
}

@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]):not([data-theme="light"]) {
    color-scheme: light;
    --bg: #ffffff;
    --bg-elevated: #f4f6f8;
    --bg-hover: rgba(29, 78, 216, 0.05);
    --bg-hover-strong: rgba(29, 78, 216, 0.10);
    --border: #e2e8f0;
    --border-subtle: #eef2f6;
    --text: #0b1220;
    --muted: #5b6b7c;
    --accent: #1d4ed8;
    --accent-hover: #2563eb;
    --accent-soft: rgba(29, 78, 216, 0.10);
    --on-accent: #ffffff;
    --good: #047857;
    --bad: #b91c1c;
    --warn: #b45309;
    --header-bg: rgba(255, 255, 255, 0.78);
    --card: #f4f6f8;
    --surface: #ffffff;
    --surface-2: #f4f6f8;
    --surface-3: #e8edf2;
    --table-border: #e2e8f0;
    --badge-bg: #e8edf2;
    --btn-primary-bg: var(--accent);
    --btn-primary-border: var(--accent);
    --card-grad-top: #f4f6f8;
    --grade-b: #047857;
    --pos: var(--good);
    --neg: var(--bad);
  }
}

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

html {
  width: 100%;
  max-width: 100%;
  height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  min-height: 100dvh;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.35;
  letter-spacing: -0.011em;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Header 52px ─────────────────────────────────────────── */

.top {
  display: flex;
  align-items: center;
  gap: 0.5rem 0.85rem;
  height: var(--header-h);
  min-height: var(--header-h);
  max-height: none;
  padding: 0 clamp(0.65rem, 1.6vw, 1.25rem);
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 40;
  width: 100%;
  flex-wrap: nowrap;
}

.top-brand {
  flex: 0 0 auto;
  min-width: 0;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}
.brand-link:hover { text-decoration: none; }

.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-elevated);
}

.top-brand h1,
.top h1,
.brand-title {
  margin: 0;
  font-size: 0.98rem;
  letter-spacing: -0.015em;
  font-weight: 650;
  color: var(--text);
  white-space: nowrap;
}

.env-chip {
  display: inline-block;
  margin-left: 0.3rem;
  padding: 0.08rem 0.38rem;
  border-radius: var(--radius-pill);
  font-size: 0.62rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  vertical-align: 0.12em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
}
.env-chip-opendev {
  color: var(--good);
  background: color-mix(in srgb, var(--good) 16%, transparent);
  border-color: color-mix(in srgb, var(--good) 40%, var(--border));
}
.opendev-strip {
  width: 100%;
  padding: 0.45rem 1rem;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  background: color-mix(in srgb, var(--good) 12%, var(--bg-elevated));
  border-bottom: 1px solid color-mix(in srgb, var(--good) 28%, var(--border));
}

.icon-btn.refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex: 0 0 auto;
}
.icon-btn.refresh-btn:hover {
  color: var(--text);
  background: var(--bg-hover-strong);
  filter: none;
}
.icon-btn.refresh-btn.is-spinning svg {
  animation: spin-refresh 0.8s linear infinite;
}
@keyframes spin-refresh {
  to { transform: rotate(360deg); }
}

.nav {
  display: flex;
  gap: 0.1rem;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: nowrap;
  overflow: hidden;
}
.nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-pill);
  border: 0;
  font-size: 1.02rem;
  letter-spacing: -0.015em;
  white-space: nowrap;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.nav-ico, .devx-dock-ico {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  display: block;
}
.nav-burger {
  display: none;
  appearance: none;
  border: 0;
  background: transparent;
  width: 42px;
  height: 42px;
  padding: 0;
  margin: 0 0.15rem 0 0;
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.nav-burger:hover { background: var(--bg-hover); }
.nav-burger-lines {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 18px;
}
.nav-burger-lines span {
  display: block;
  height: 1.8px;
  width: 100%;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.18s ease, opacity 0.18s ease;
}
body.nav-open .nav-burger-lines span:nth-child(1) { transform: translateY(6.8px) rotate(45deg); }
body.nav-open .nav-burger-lines span:nth-child(2) { opacity: 0; }
body.nav-open .nav-burger-lines span:nth-child(3) { transform: translateY(-6.8px) rotate(-45deg); }
.nav-drawer {
  position: fixed;
  inset: 0;
  z-index: 1400;
  background: rgba(0,0,0,0.45);
}
.nav-drawer[hidden] { display: none !important; }
.nav-drawer-panel {
  width: min(20rem, 86vw);
  height: 100%;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 1rem 0.85rem 1.5rem;
  overflow-y: auto;
  box-shadow: 8px 0 32px rgba(0,0,0,0.18);
}
.nav-drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding: 0 0.35rem;
}
.nav-drawer-close {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 650;
  cursor: pointer;
  min-height: 2.5rem;
}
.nav-drawer-nav { display: flex; flex-direction: column; gap: 0.15rem; }
.nav-drawer-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.7rem;
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  font-size: 1.05rem;
  min-height: 2.75rem;
}
.nav-drawer-nav a .nav-ico { width: 22px; height: 22px; }
.nav-drawer-nav a:hover, .nav-drawer-nav a.nav-active { background: var(--bg-hover-strong); color: var(--text); }
.nav-drawer-nav a.nav-active { box-shadow: inset 3px 0 0 var(--accent); }
.nav a:hover {
  color: var(--text);
  background: var(--bg-hover);
  text-decoration: none;
}
.nav a.nav-active {
  color: var(--text);
  font-weight: 650;
  background: transparent;
}
.nav a.nav-active::after {
  content: "";
  position: absolute;
  left: 0.55rem;
  right: 0.55rem;
  bottom: 0.08rem;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.header-more-btn {
  display: none;
  appearance: none;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 550;
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
}
.header-more-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.top-trailing {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: nowrap;
  margin-left: auto;
  flex: 0 1 auto;
  min-width: 0;
}

.header-updated {
  font-size: 0.72rem;
  white-space: nowrap;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.jump-form {
  display: none;
  position: relative;
  flex: 0 0 auto;
}
.jump-input {
  width: 11.5rem;
  min-width: 0;
  padding: 0.32rem 0.7rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.82rem;
}
.jump-input:focus {
  outline: none;
  border-color: var(--accent);
}
.jump-results {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 16rem;
  max-width: 22rem;
  z-index: 50;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.25rem;
  max-height: 16rem;
  overflow: auto;
}
.jump-hit {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}
.jump-hit:hover { background: var(--bg-hover); }
.jump-hit strong { font-size: 0.88rem; }
.jump-hit span { font-size: 0.75rem; color: var(--muted); }

.top > .c4-header-utils {
  margin-left: 0;
  flex-shrink: 0;
}
.c4-header-utils { display: inline-flex; align-items: center; flex-shrink: 0; }
.c4-theme-picker {
  display: inline-flex;
  align-items: stretch;
  padding: 2px;
  gap: 1px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}
.c4-theme-picker__btn {
  appearance: none;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1;
  padding: 0.32rem 0.5rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
}
.c4-theme-picker__btn:hover { color: var(--text); }
.c4-theme-picker__btn.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
}
.c4-theme-picker__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Banner hairline ─────────────────────────────────────── */

.app-banner-slot {
  width: 100%;
}
#app-banner:empty,
#app-banner:not(:has(*)) {
  display: none;
}

.live-banner {
  margin: 0;
  padding: 0.4rem clamp(0.65rem, 1.6vw, 1.25rem);
  border-radius: 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
}
.live-banner.ok { color: var(--good); }
.live-banner.err { color: var(--bad); }
.live-banner.busy,
.live-banner.warn { color: var(--warn); }

/* ── Canvas ──────────────────────────────────────────────── */

#app-root {
  width: 100%;
  max-width: 100%;
  min-height: 50vh;
}

#spa-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  z-index: 100;
  background: var(--accent);
  opacity: 0;
  pointer-events: none;
  transition: width 0.25s ease, opacity 0.2s ease;
}
#spa-progress.is-on {
  opacity: 1;
  width: 70%;
  animation: spa-progress 1.2s ease-in-out infinite;
}
@keyframes spa-progress {
  0% { width: 15%; }
  50% { width: 75%; }
  100% { width: 90%; }
}
body.spa-loading #app-root {
  opacity: 0.72;
  transition: opacity 0.15s ease;
}

.app-footer,
.app-footer:empty,
.app-footer:not(:has(*)) {
  display: none;
}

/* ── Phone dock + More sheet ─────────────────────────────── */

.devx-dock {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  height: calc(var(--dock-h) + env(safe-area-inset-bottom));
  padding: 0 0.25rem env(safe-area-inset-bottom);
  border-top: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  align-items: stretch;
  justify-content: space-around;
}
.devx-dock a,
.devx-dock button {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-decoration: none;
  font: inherit;
  font-size: 0.68rem;
  font-weight: 550;
  padding: 0.25rem 0.15rem;
  cursor: pointer;
  min-width: 0;
}
.devx-dock a:hover,
.devx-dock button:hover {
  color: var(--text);
  text-decoration: none;
  filter: none;
}
.devx-dock a.nav-active {
  color: var(--accent);
  font-weight: 650;
}
.devx-dock-ico {
  width: 22px;
  height: 22px;
  display: block;
}

.devx-sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.48);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.devx-sheet[hidden] { display: none !important; }
.devx-sheet-panel {
  width: 100%;
  max-width: 28rem;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 0.75rem 0.85rem calc(0.85rem + env(safe-area-inset-bottom));
}
.devx-sheet-title {
  margin: 0 0 0.55rem;
  font-size: 0.9375rem;
  font-weight: 650;
}
.devx-sheet-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.devx-sheet-nav a {
  display: block;
  padding: 0.7rem 0.75rem;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 550;
}
.devx-sheet-nav a:hover { background: var(--bg-hover); text-decoration: none; }
.devx-sheet-nav a.nav-active { font-weight: 650; color: var(--accent); }

/* ── Breakpoints ─────────────────────────────────────────── */

@media (min-width: 1100px) {
  .jump-form { display: block; }
}

@media (max-width: 1099px) and (min-width: 768px) {
  .header-more-btn { display: inline-flex; }
  .nav a[data-nav="agents"],
  .nav a[data-nav="strategies"],
  .nav a[data-nav="chat"],
  .nav a[data-nav="workers"],
  .nav a[data-nav="settings"] {
    display: none;
  }
}

@media (max-width: 900px) {
  .nav,
  .header-more-btn,
  .jump-form,
  .header-updated,
  .pills {
    display: none !important;
  }
  .nav-burger { display: inline-flex; }
  .devx-dock { display: none !important; }
  .top {
    height: var(--header-h);
  }
  body, body.charts-body {
    padding-bottom: env(safe-area-inset-bottom);
  }
  .c4-theme-picker__btn { padding: 0.3rem 0.42rem; font-size: 0.68rem; }
}

@media (max-width: 720px) {
  .header-updated {
    font-size: 0.7rem;
    max-width: min(48vw, 14rem);
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
