:root {
  color-scheme: dark;
  --sacred-pattern: url("data:image/svg+xml,%3Csvg width='520' height='520' viewBox='0 0 520 520' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23d7b65a' stroke-width='1.3' opacity='.55'%3E%3Ccircle cx='260' cy='260' r='54'/%3E%3Ccircle cx='314' cy='260' r='54'/%3E%3Ccircle cx='206' cy='260' r='54'/%3E%3Ccircle cx='287' cy='213' r='54'/%3E%3Ccircle cx='233' cy='213' r='54'/%3E%3Ccircle cx='287' cy='307' r='54'/%3E%3Ccircle cx='233' cy='307' r='54'/%3E%3Ccircle cx='260' cy='166' r='54'/%3E%3Ccircle cx='260' cy='354' r='54'/%3E%3Ccircle cx='260' cy='260' r='166' stroke-width='1.8'/%3E%3C/g%3E%3C/svg%3E");
  --bg: #050607;
  --bg-soft: #090b0e;
  --surface: rgba(18, 21, 26, 0.94);
  --surface-2: rgba(27, 31, 38, 0.94);
  --surface-3: #0c1015;
  --ink: #f4efe3;
  --ink-strong: #fff9ea;
  --muted: #9aa4b2;
  --line: rgba(215, 182, 90, 0.22);
  --line-soft: rgba(148, 163, 184, 0.16);
  --nav: rgba(6, 7, 10, 0.96);
  --nav-2: rgba(31, 36, 44, 0.88);
  --accent: #d7b65a;
  --accent-2: #37d6c2;
  --blue: #6ea8ff;
  --amber: #d7b65a;
  --red: #ff6b6b;
  --green: #45d483;
  --violet: #a78bfa;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.38);
  --chart-bg: #090b0e;
  --chart-grid: rgba(215, 182, 90, 0.16);
  --chart-fill: rgba(215, 182, 90, 0.08);
  --radius: 8px;
}

:root[data-theme="midnight"] {
  color-scheme: dark;
  --bg: #070b12;
  --bg-soft: #0b1020;
  --surface: rgba(14, 20, 31, 0.95);
  --surface-2: rgba(20, 29, 45, 0.95);
  --surface-3: #0a0f1a;
  --ink: #edf3ff;
  --ink-strong: #ffffff;
  --muted: #94a3b8;
  --line: rgba(110, 168, 255, 0.22);
  --line-soft: rgba(148, 163, 184, 0.17);
  --nav: rgba(7, 11, 18, 0.97);
  --nav-2: rgba(23, 33, 51, 0.92);
  --accent: #6ea8ff;
  --accent-2: #45d483;
  --blue: #6ea8ff;
  --amber: #f6c85f;
  --red: #ff6b6b;
  --green: #45d483;
  --violet: #b695ff;
  --chart-bg: #0b1020;
  --chart-grid: rgba(110, 168, 255, 0.16);
  --chart-fill: rgba(110, 168, 255, 0.08);
}

:root[data-theme="day"] {
  color-scheme: light;
  --bg: #f3f5f8;
  --bg-soft: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --ink: #111827;
  --ink-strong: #020617;
  --muted: #64748b;
  --line: #d7dde6;
  --line-soft: #e5eaf1;
  --nav: #111827;
  --nav-2: #1f2937;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --blue: #2563eb;
  --amber: #a16207;
  --red: #b91c1c;
  --green: #15803d;
  --violet: #7c3aed;
  --shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
  --chart-bg: #ffffff;
  --chart-grid: #d8dee9;
  --chart-fill: rgba(15, 118, 110, 0.07);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(145deg, var(--bg) 0%, var(--bg-soft) 45%, var(--bg) 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: var(--sacred-pattern) center / 520px 520px repeat;
  opacity: 0.36;
}

:root[data-theme="day"] body::before { opacity: 0.08; }

body.security-locked {
  background: #000;
  overflow: hidden;
}

body.security-locked::before {
  opacity: 0;
}

body.security-locked .app-shell,
body.security-locked .toast,
body.security-locked .trada-assistant {
  visibility: hidden;
  pointer-events: none;
}

button,
input,
select { font: inherit; }

button { text-align: center; }

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
}

.sidebar {
  background: var(--nav);
  color: var(--ink);
  border-right: 1px solid var(--line);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 2px 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid color-mix(in srgb, var(--accent) 58%, transparent);
  color: var(--accent);
  box-shadow: inset 0 0 18px color-mix(in srgb, var(--accent) 17%, transparent);
  font-weight: 950;
}

.brand-name {
  font-size: 20px;
  font-weight: 950;
  line-height: 1;
  color: var(--ink-strong);
}

.brand-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
}

.nav-section { display: grid; gap: 7px; }

.nav-label,
.theme-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  margin: 0 4px 4px;
  font-weight: 900;
}

.nav-item {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: color-mix(in srgb, var(--ink) 82%, var(--muted));
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
}

.nav-item.active,
.nav-item:hover {
  background: var(--nav-2);
  border-color: var(--line);
  color: var(--ink-strong);
}

.nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
  box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 55%, transparent);
}

.theme-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  display: grid;
  gap: 10px;
}

.theme-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.theme-choice {
  min-height: 34px;
  border-radius: 7px;
  border: 1px solid var(--line-soft);
  background: var(--surface-3);
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
  font-size: 11px;
  padding: 6px;
  position: relative;
  overflow: hidden;
  transition: transform 140ms ease, border-color 160ms ease, background 160ms ease;
}

.theme-choice.active {
  border-color: var(--accent);
  color: var(--ink-strong);
  background: color-mix(in srgb, var(--accent) 16%, var(--surface-3));
}

.operator-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  place-items: center;
  padding: 20px;
  background: #000;
  overflow: hidden;
}

.operator-modal.open { display: grid; }

.operator-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
  display: grid;
  gap: 14px;
}

.operator-title {
  color: var(--ink-strong);
  font-size: 18px;
  font-weight: 950;
}

.security-stack {
  width: min(360px, calc(100vw - 40px));
  display: grid;
  gap: 22px;
  place-items: center stretch;
  position: relative;
  z-index: 1;
  padding-top: clamp(96px, 22vh, 218px);
}

.security-card {
  width: 100%;
  min-height: auto;
  place-items: stretch;
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
  position: relative;
  z-index: 3;
}

.security-riddle {
  color: #ffb7b7;
  text-align: center;
  width: min(1040px, calc(100vw - 40px));
  position: fixed;
  top: clamp(26px, 8vh, 92px);
  left: 50%;
  z-index: 2;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  margin: 0;
  min-height: clamp(54px, 12vw, 112px);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(18px, 5.2vw, 92px);
  line-height: 0.9;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0;
  opacity: 0.98;
  transform: translate(-50%, 0) scaleX(0.74) rotate(-0.4deg);
  animation: securityRiddleDrift 7.8s ease-in-out infinite;
  -webkit-text-stroke: clamp(0.8px, 0.09vw, 1.7px) rgba(255, 235, 235, 0.74);
  text-shadow:
    0 0 6px rgba(255, 238, 238, 0.94),
    0 0 18px rgba(255, 0, 0, 0.9),
    0 0 46px rgba(178, 0, 0, 0.82),
    0 0 96px rgba(96, 0, 0, 0.72);
  user-select: none;
  pointer-events: none;
  filter: saturate(1.36) contrast(1.12);
}

.security-riddle::before,
.security-riddle::after {
  content: attr(aria-label);
  position: absolute;
  inset: auto 50% auto auto;
  width: 100%;
  transform: translateX(50%);
  text-transform: uppercase;
  font: inherit;
  letter-spacing: inherit;
  white-space: nowrap;
  pointer-events: none;
}

.security-riddle::before {
  top: 42%;
  color: rgba(255, 0, 0, 0.2);
  filter: blur(18px);
  text-shadow:
    0 22px 52px rgba(255, 0, 0, 0.52),
    0 64px 86px rgba(96, 0, 0, 0.4);
  animation: securityRiddleSmoke 9.8s ease-in-out infinite;
}

.security-riddle::after {
  top: 64%;
  color: rgba(115, 0, 0, 0.2);
  filter: blur(28px);
  text-shadow:
    0 42px 72px rgba(255, 0, 0, 0.34),
    0 96px 118px rgba(85, 0, 0, 0.32);
  animation: securityRiddleSmoke 12.2s ease-in-out infinite reverse;
}

.security-riddle-char,
.security-riddle-gap {
  position: relative;
  z-index: 2;
  display: inline-block;
  transform: translate(var(--char-x, 0), var(--char-y, 0)) rotate(var(--char-tilt, 0deg));
  animation: securityRiddleLetterFloat 5.8s ease-in-out infinite;
  animation-delay: var(--char-delay, 0ms);
  will-change: transform;
}

.security-riddle-char {
  margin-inline: calc(var(--char-gap, 5px) * 0.56);
}

.security-riddle-gap {
  width: clamp(8px, 1.8vw, 28px);
  margin-inline: clamp(2px, 0.5vw, 8px);
}

@keyframes securityRiddleDrift {
  0% { transform: translate(-50%, 0) scaleX(0.74) rotate(-0.4deg); }
  24% { transform: translate(-49.5%, -4px) scaleX(0.75) rotate(0.25deg); }
  56% { transform: translate(-50.5%, 3px) scaleX(0.735) rotate(-0.2deg); }
  82% { transform: translate(-49.7%, -5px) scaleX(0.745) rotate(0.45deg); }
  100% { transform: translate(-50%, 0) scaleX(0.74) rotate(-0.4deg); }
}

@keyframes securityRiddleSmoke {
  0% { opacity: 0.44; transform: translateX(50%) translateY(0) scaleX(0.96); }
  42% { opacity: 0.72; transform: translateX(50%) translateY(28px) scaleX(1.04); }
  74% { opacity: 0.38; transform: translateX(50%) translateY(12px) scaleX(1.01); }
  100% { opacity: 0.44; transform: translateX(50%) translateY(0) scaleX(0.96); }
}

@keyframes securityRiddleLetterFloat {
  0%,
  100% {
    transform: translate(var(--char-x, 0), var(--char-y, 0)) rotate(var(--char-tilt, 0deg));
  }
  50% {
    transform: translate(var(--char-float-x, 0), var(--char-float-y, -10px)) rotate(var(--char-float-tilt, 0deg));
  }
}

.security-input {
  width: 100%;
  min-height: 44px;
  border: 1px solid #39ff14;
  border-radius: 7px;
  background: #000;
  color: #39ff14;
  caret-color: #39ff14;
  outline: none;
  padding: 10px 12px;
  box-shadow: 0 0 14px rgba(57, 255, 20, 0.18);
}

.security-input:focus {
  border-color: #8cff72;
  box-shadow: 0 0 0 3px rgba(57, 255, 20, 0.16), 0 0 24px rgba(57, 255, 20, 0.18);
}

.security-actions {
  justify-content: flex-end;
}

.security-submit,
.security-clear {
  border-color: #39ff14;
  background: #000;
  color: #39ff14;
  box-shadow: 0 0 18px rgba(57, 255, 20, 0.14);
}

.security-submit:hover,
.security-clear:hover,
.security-submit:focus-visible,
.security-clear:focus-visible {
  border-color: #8cff72;
  color: #8cff72;
  box-shadow: 0 0 0 3px rgba(57, 255, 20, 0.16), 0 0 24px rgba(57, 255, 20, 0.2);
}

.operator-token-btn {
  min-width: 88px;
}

.side-status {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  display: grid;
  gap: 10px;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 76px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  font-weight: 950;
  color: var(--ink-strong);
}

.subtitle {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.content {
  padding: 24px 28px 32px;
  display: grid;
  gap: 18px;
}

.page-guide {
  min-height: 52px;
  padding: 10px 28px;
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--surface-2) 78%, transparent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-guide > div {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.page-guide strong {
  color: var(--ink-strong);
  font-size: 12px;
  text-transform: uppercase;
  white-space: nowrap;
}

.page-guide span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.page-guide-action { flex: 0 0 auto; }

.validation-note {
  min-height: 48px;
  padding: 12px 16px;
  border-left: 3px solid var(--blue);
  background: color-mix(in srgb, var(--blue) 8%, var(--surface));
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.validation-note strong {
  color: var(--ink-strong);
  white-space: nowrap;
}

.validation-note span {
  color: var(--muted);
  line-height: 1.5;
}

.validation-progress-body {
  display: grid;
  gap: 16px;
}

.progress-track {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-3);
}

.progress-fill {
  width: 0;
  height: 100%;
  background: var(--green);
  box-shadow: 0 0 18px color-mix(in srgb, var(--green) 48%, transparent);
  transition: width 500ms ease;
}

.trada-assistant {
  position: fixed;
  z-index: 80;
  right: 22px;
  bottom: 22px;
  width: 64px;
  height: 64px;
}

.assistant-orb {
  width: 64px;
  height: 64px;
  border: 1px solid #b8ff9c;
  border-radius: 50%;
  background: #73ff3d;
  color: #041300;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: grab;
  touch-action: none;
  box-shadow:
    0 0 0 5px rgba(115, 255, 61, 0.12),
    0 0 22px rgba(115, 255, 61, 0.82),
    0 0 52px rgba(68, 255, 0, 0.42);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.assistant-orb:active { cursor: grabbing; }

.assistant-orb:hover,
.assistant-orb:focus-visible {
  border-color: #ffffff;
  outline: none;
  box-shadow:
    0 0 0 5px rgba(115, 255, 61, 0.2),
    0 0 30px rgba(115, 255, 61, 0.95),
    0 0 68px rgba(68, 255, 0, 0.58);
}

.assistant-orb-core {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(0, 40, 0, 0.48);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 19px;
  font-weight: 950;
  animation: assistantCorePulse 2.8s ease-in-out infinite;
}

@keyframes assistantCorePulse {
  0%, 100% { transform: translateY(0) scale(1); box-shadow: inset 0 0 12px rgba(0, 40, 0, 0.2); }
  50% { transform: translateY(-2px) scale(1.04); box-shadow: inset 0 0 20px rgba(0, 40, 0, 0.34); }
}

.assistant-panel {
  position: fixed;
  display: none;
  width: min(400px, calc(100vw - 28px));
  height: min(620px, calc(100vh - 28px));
  border: 1px solid rgba(115, 255, 61, 0.58);
  border-radius: var(--radius);
  background: #070b08;
  color: #edf7e9;
  box-shadow: 0 22px 58px rgba(0, 0, 0, 0.62), 0 0 34px rgba(115, 255, 61, 0.16);
  overflow: hidden;
  flex-direction: column;
}

.trada-assistant.open .assistant-panel { display: flex; }

.assistant-header {
  min-height: 58px;
  padding: 11px 12px 11px 15px;
  border-bottom: 1px solid rgba(115, 255, 61, 0.22);
  background: #0b120c;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.assistant-header > div { display: grid; gap: 3px; }
.assistant-header strong { color: #b8ff9c; font-size: 15px; }
.assistant-header span { color: #93a78c; font-size: 11px; }

.assistant-icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(115, 255, 61, 0.28);
  border-radius: 50%;
  background: transparent;
  color: #b8ff9c;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.assistant-page-context {
  min-height: 36px;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(115, 255, 61, 0.14);
  color: #b7c9b1;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 900;
}

.assistant-messages {
  flex: 1 1 auto;
  min-height: 0;
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.assistant-message {
  max-width: 92%;
  padding: 10px 11px;
  border: 1px solid rgba(115, 255, 61, 0.16);
  border-radius: var(--radius);
  background: #101711;
  display: grid;
  gap: 6px;
  font-size: 13px;
  line-height: 1.48;
}

.assistant-message.user {
  align-self: flex-end;
  border-color: rgba(110, 168, 255, 0.28);
  background: #101722;
}

.assistant-message strong {
  color: #b8ff9c;
  font-size: 10px;
  text-transform: uppercase;
}

.assistant-message.user strong { color: #9fc2ff; }
.assistant-message > div:not(.assistant-feedback) { white-space: pre-line; overflow-wrap: anywhere; }

.assistant-feedback {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
}

.assistant-feedback button {
  width: 25px;
  height: 25px;
  border: 1px solid rgba(115, 255, 61, 0.22);
  border-radius: 50%;
  background: transparent;
  color: #b8ff9c;
  cursor: pointer;
}

.assistant-suggestions {
  padding: 0 14px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  overflow: hidden;
}

.assistant-suggestion {
  flex: 1 1 112px;
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid rgba(115, 255, 61, 0.22);
  border-radius: 7px;
  background: #0b120c;
  color: #c7d9c1;
  font-size: 11px;
  line-height: 1.25;
  white-space: normal;
  cursor: pointer;
}

.assistant-form {
  padding: 12px 14px;
  border-top: 1px solid rgba(115, 255, 61, 0.18);
  background: #0b120c;
  display: grid;
  gap: 7px;
}

.assistant-form label { color: #93a78c; }
.assistant-form small { color: #72816e; font-size: 10px; line-height: 1.35; }

.assistant-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
}

.assistant-composer textarea {
  width: 100%;
  min-height: 48px;
  max-height: 120px;
  resize: vertical;
  border: 1px solid rgba(115, 255, 61, 0.28);
  border-radius: var(--radius);
  background: #050805;
  color: #edf7e9;
  padding: 8px 9px;
  font: inherit;
  outline: none;
}

.assistant-composer textarea:focus {
  border-color: #73ff3d;
  box-shadow: 0 0 0 3px rgba(115, 255, 61, 0.12);
}

.assistant-send.btn.primary {
  min-width: 64px;
  background: #73ff3d;
  border-color: #73ff3d;
  color: #041300;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(420px, 1.4fr) minmax(320px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.stack { display: grid; gap: 18px; }

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

.panel-header {
  min-height: 54px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--surface-2) 60%, transparent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-title {
  margin: 0;
  font-size: 13px;
  font-weight: 950;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--ink) 84%, var(--accent));
}

.panel-body { padding: 16px; }

.metric {
  padding: 16px;
  min-height: 112px;
  display: grid;
  align-content: space-between;
  gap: 12px;
}

.metric-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.metric-value {
  font-size: 28px;
  font-weight: 950;
  line-height: 1;
  color: var(--ink-strong);
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.metric-foot {
  color: var(--muted);
  font-size: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.pill.green {
  border-color: color-mix(in srgb, var(--green) 35%, transparent);
  background: color-mix(in srgb, var(--green) 13%, var(--surface-2));
  color: var(--green);
}

.pill.red {
  border-color: color-mix(in srgb, var(--red) 35%, transparent);
  background: color-mix(in srgb, var(--red) 13%, var(--surface-2));
  color: var(--red);
}

.pill.blue {
  border-color: color-mix(in srgb, var(--blue) 35%, transparent);
  background: color-mix(in srgb, var(--blue) 13%, var(--surface-2));
  color: var(--blue);
}

.pill.amber {
  border-color: color-mix(in srgb, var(--amber) 38%, transparent);
  background: color-mix(in srgb, var(--amber) 13%, var(--surface-2));
  color: var(--amber);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

.live-pill .dot {
  box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 45%, transparent);
  animation: liveDotPulse 1.2s ease-out infinite;
}

.live-flash {
  animation: liveValueFlash 620ms ease-out;
}

body.stream-stale .chart-wrap,
body.stream-stale .table-card,
body.stream-stale .metric {
  border-color: color-mix(in srgb, var(--amber) 22%, var(--line));
}

@keyframes liveDotPulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 45%, transparent); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@keyframes liveValueFlash {
  0% {
    filter: brightness(1.55);
    text-shadow: 0 0 12px color-mix(in srgb, currentColor 35%, transparent);
  }
  100% {
    filter: brightness(1);
    text-shadow: none;
  }
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  min-height: 38px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  padding: 8px 12px;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  transition: transform 140ms ease, border-color 160ms ease, background 160ms ease, opacity 160ms ease;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--ink-strong);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-2));
}

.btn.is-clicked,
.theme-choice.is-clicked {
  transform: translateY(1px) scale(0.985);
}

.btn.is-busy {
  cursor: wait;
  opacity: 0.82;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.66;
}

.btn-pulse {
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
  background: color-mix(in srgb, var(--ink-strong) 28%, transparent);
  transform: scale(0);
  animation: button-pulse 520ms ease-out forwards;
}

@keyframes button-pulse {
  to {
    transform: scale(2.4);
    opacity: 0;
  }
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #090b0e;
}

.btn.primary:hover {
  background: color-mix(in srgb, var(--accent) 86%, #ffffff);
}

.btn.blue {
  background: var(--blue);
  border-color: var(--blue);
  color: #06101e;
}

.btn.danger {
  background: var(--red);
  border-color: var(--red);
  color: #190607;
}

.btn.ghost {
  background: transparent;
}

.security-card .btn.primary,
.security-card .btn.ghost {
  border-color: #39ff14;
  background: #000;
  color: #39ff14;
  box-shadow: 0 0 18px rgba(57, 255, 20, 0.14);
}

.security-card .btn:hover,
.security-card .btn:focus-visible {
  border-color: #8cff72;
  background: #000;
  color: #8cff72;
  box-shadow: 0 0 0 3px rgba(57, 255, 20, 0.16), 0 0 24px rgba(57, 255, 20, 0.2);
}

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

.field { display: grid; gap: 6px; }

label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-3);
  color: var(--ink);
  padding: 8px 10px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 950;
  background: var(--surface-2);
}

tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.positive { color: var(--green); }
.negative { color: var(--red); }
.muted { color: var(--muted); }
.mini-status {
  display: inline-flex;
  align-items: center;
  min-width: 46px;
  font-size: 11px;
  line-height: 1;
  font-weight: 900;
  text-transform: uppercase;
}
.scroll-table { overflow-x: auto; }

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

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

.risk-item {
  min-height: 70px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface-2);
  display: grid;
  align-content: space-between;
  gap: 6px;
}

.risk-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 950;
}

.risk-value {
  font-size: 16px;
  font-weight: 950;
  overflow-wrap: anywhere;
}

.signal-result {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 12px;
  min-height: 98px;
  display: grid;
  gap: 8px;
}

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

.signal-action {
  font-weight: 950;
  font-size: 20px;
}

.log-list {
  height: 320px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.log-entry {
  border-left: 3px solid var(--line);
  background: var(--surface-2);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.35;
}

.log-entry.success { border-left-color: var(--green); }
.log-entry.warning { border-left-color: var(--amber); }
.log-entry.error { border-left-color: var(--red); }
.log-entry.info { border-left-color: var(--blue); }

.chart-wrap {
  height: 240px;
  padding: 10px 8px 4px;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 22px 8px;
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  min-width: min(420px, calc(100vw - 36px));
  max-width: 520px;
  display: grid;
  gap: 8px;
}

.toast-item {
  background: var(--surface);
  color: var(--ink-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  font-size: 13px;
}

.mobile-nav {
  display: none;
  background: var(--nav);
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  overflow-x: auto;
  gap: 8px;
}

.mobile-nav a {
  color: var(--ink);
  text-decoration: none;
  background: var(--nav-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 8px 10px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 800;
}

.mobile-theme {
  display: none;
  background: var(--nav);
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
}

.mobile-theme .theme-panel {
  max-width: 420px;
}

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-nav,
  .mobile-theme { display: flex; }
  .grid,
  .grid-3 { grid-template-columns: 1fr; }
  .status-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }
  .top-actions { justify-content: flex-start; }
}

@media (max-width: 680px) {
  .content { padding: 16px; }
  .topbar { padding: 16px; }
  .page-guide {
    padding: 10px 16px;
    align-items: flex-start;
  }
  .page-guide > div { display: grid; gap: 4px; }
  .page-guide-action { min-width: 84px; }
  .validation-note { align-items: flex-start; display: grid; gap: 4px; }
  .status-strip,
  .form-grid,
  .risk-grid,
  .process-grid { grid-template-columns: 1fr; }
  .button-row .btn { flex: 1 1 120px; }
  th,
  td { font-size: 12px; }
  .metric-value { font-size: 24px; }
  .trada-assistant { width: 56px; height: 56px; right: 14px; bottom: 14px; }
  .assistant-orb { width: 56px; height: 56px; }
  .assistant-orb-core { width: 38px; height: 38px; }
  .assistant-panel {
    left: 10px !important;
    right: 10px;
    top: auto !important;
    bottom: 80px;
    width: auto;
    height: min(70vh, 580px);
  }
  .assistant-composer { grid-template-columns: 1fr; }
  .assistant-send.btn { width: 100%; }
}
